pressure function object v1912
Summary
The v1912 pressure function object fails if hydrostatic pressures are applied for incompressible cases. The reason is that the pressure field created in calcPressure and that is the only parameter to function addHydrostaticContribution always has dimensions dimPressure and can never be kinematic pressure. Function rhoScale is called from addHydrostaticContribution and checks the dimensions of the pressure field to decide whether to multiply a second field by the volScalarField rho (if dimPressure) or the by the scalar rhoInf. It can never multiply by rhoInf as the pressure always has dimensions dimPressure. It tries to retrieve a volScalarField called rhoInf and crashes as the field does not exist.
It would also help to list g and hRef in the documentation as optional parameters for the function object when hydrostaticMode applies.
Steps to reproduce
Example case
What is the current bug behaviour?
The software crashes when a volScalarField called rhoInf is not found.
What is the expected correct behavior?
It should not crash!
Relevant logs and/or images
Environment information
- OpenFOAM version : v1912
- Operating system : Centos 7
- Hardware info :
- Compiler : gcc 8.3
Possible fixes
- In the 2-parameter rhoScale function check whether rhoInfInitialised_ is true. If so, use rhoInf, otherwise use rho. Or, more in keeping with the current code:
- Have 2 input parameters to addHydrostaticContribution(p,result) where p is the unmodified input pressure field and result is the pressure field created in calcPressure. In addHydrostaticContribution use p as the first parameter to rhoScale while rgh is added or subtracted from result and returned.