View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003584 | OpenFOAM | Bug | public | 2020-10-31 17:53 | 2020-11-05 11:11 |
Reporter | diego | Assigned To | henry | ||
Priority | low | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | GNU/Linux | OS | Ubuntu | OS Version | 18.04 |
Fixed in Version | dev | ||||
Summary | 0003584: Setting "system/controlDict" to use USCS unit system fails for perfect gas compressible flow | ||||
Description | Setting "system/controlDict" ("single case controlDict") to use USCS unit system, as mentioned in the end of < https://cfd.direct/openfoam/user-guide/v7-global-settings/ >, fails for perfect gas compressible flow. Although this issue is being reported for OpenFOAM 7.0, by checking the source code, it seems to be reproducible since OpenFOAM 3.0, and also in OpenFOAM 8.0. | ||||
Steps To Reproduce | An example to reproduce the error is shown below. For simplicity for showing the error, the setup of one of the OpenFOAM tutorials is used (although all the setup is performed in SI units, it serves to show the issue). 1) Set up an example that uses "rhoSimpleFoam": $ run $ cp -r $FOAM_TUTORIALS/compressible/rhoSimpleFoam/aerofoilNACA0012 ./ $ cd aerofoilNACA0012 $ blockMesh 2) Write the following in "system/controlDict": DimensionedConstants { unitSet USCS; } 3) Edit "rhoSimpleFoam" solver by including the following prints in the beginning of pEqn.H file: Info << ">> constant::physicoChemical::R = " << constant::physicoChemical::R.value() << endl; Info << ">> constant::standard::Pstd = " << constant::standard::Pstd.value() << endl; Info << ">> constant::standard::Tstd = " << constant::standard::Tstd.value() << endl; Info << ">> constant::thermodynamic::RR = " << constant::thermodynamic::RR << endl; Info << ">> constant::thermodynamic::Pstd = " << constant::thermodynamic::Pstd << endl; Info << ">> constant::thermodynamic::Tstd = " << constant::thermodynamic::Tstd << endl; Recompile "rhoSimpleFoam" (using "wmake"). 3) After compiling the edited "rhoSimpleFoam" solver, running the example with "rhoSimpleFoam" shows that the values defined in "constant::thermodynamic" kept their SI values, and did not change to their USCS counterparts. The prints of "Time = 1" from, for example, OpenFOAM 7.0, are reproduced below: ----------- Time = 1 DILUPBiCGStab: Solving for Ux, Initial residual = 1, Final residual = 0.083305068, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 1, Final residual = 0.070339263, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 0.99999239, Final residual = 0.026874282, No Iterations 2 >> constant::physicoChemical::R.value() = 109.61021 >> constant::standard::Pstd.value() = 2088.6 >> constant::standard::Tstd.value() = 536.67 >> constant::thermodynamic::RR = 8314.4701 >> constant::thermodynamic::Pstd = 100000 >> constant::thermodynamic::Tstd = 298.15 GAMG: Solving for p, Initial residual = 1, Final residual = 0.0079628396, No Iterations 19 time step continuity errors : sum local = 0.026544362, global = 0.0036102344, cumulative = 0.0036102344 pressureControl: p max 2332425.8 pressureControl: p min -241003.58 DILUPBiCGStab: Solving for omega, Initial residual = 0.0040281112, Final residual = 0.00026767745, No Iterations 1 DILUPBiCGStab: Solving for k, Initial residual = 1, Final residual = 0.052874407, No Iterations 1 ExecutionTime = 0.21 s ClockTime = 1 s ----------- As can be seen, R, Pstd and Tstd (from "constant::physicoChemical" and "constant::standard") are in USCS units (according to system/controlDict), while RR (RR = 10**3*R), Pstd and Tstd (from "constant::thermodynamic") are in SI units. | ||||
Additional Information | Idea of the cause of the issue: By looking at < https://github.com/OpenFOAM/OpenFOAM-8/blob/master/src/OpenFOAM/global/constants/thermodynamic/thermodynamicConstants.C >, it can be seen that the values in "constant::thermodynamic" are defined as "const scalar" instead of objects (* The other constants are defined as objects, such as dimensionedScalar). This seems to mean that the variables in "constant::thermodynamic" are only set from the "global controlDict" (etc/controlDict) instead of the "single case controlDict" (system/controlDict), resulting in an inconsistency in measurement units. | ||||
Tags | No tags attached. | ||||
|
Setting DimensionedConstants in system/controlDict is not currently supported, I get a segmentation fault: Overriding DimensionedConstants according to controlDict #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in "/lib64/libc.so.6" #3 Foam::Hasher(void const*, unsigned long, unsigned int) at ??:? #4 Foam::dictionary::lookupEntryPtr(Foam::word const&, bool, bool) at ??:? #5 Foam::dictionary::subDict(Foam::word const&) at ??:? #6 Foam::registerDimensionedConstant::lookup() at ??:? #7 Foam::Time::readDict() at ??:? #8 Foam::Time::setControls() at ??:? #9 Foam::Time::Time(Foam::word const&, Foam::argList const&, Foam::word const&, Foam::word const&) at ??:? #10 ? at ??:? #11 __libc_start_main in "/lib64/libc.so.6" #12 ? at /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122 However if you set unitSet USCS; in etc/controlDict it should work. |
|
commit a121baf047b901a9184183a8eb0295911bde0a7c (HEAD -> master, origin/master, origin/HEAD) Author: Henry Weller <http://cfd.direct> Date: Mon Nov 2 09:26:04 2020 +0000 OpenFOAM::dimensionedConstants: Updated handling of constant specification in system/controlDict Resolves bug-report https://bugs.openfoam.org/view.php?id=3584 |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-10-31 17:53 | diego | New Issue | |
2020-11-01 21:30 | henry | Note Added: 0011649 | |
2020-11-02 09:28 | henry | Note Added: 0011651 | |
2020-11-05 11:11 | henry | Assigned To | => henry |
2020-11-05 11:11 | henry | Status | new => resolved |
2020-11-05 11:11 | henry | Resolution | open => fixed |
2020-11-05 11:11 | henry | Fixed in Version | => dev |