diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C index f9576198d..1760a340a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C @@ -41,7 +41,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField : fixedValueFvPatchScalarField(p, iF), rho_(0.0), - pRefValue_(0.0), + pRef_(0.0), + pRefPointSpecified_(false), pRefPoint_(Zero) {} @@ -54,11 +55,24 @@ uniformDensityHydrostaticPressureFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict), - rho_(readScalar(dict.lookup("rho"))), - pRefValue_(readScalar(dict.lookup("pRefValue"))), - pRefPoint_(dict.lookup("pRefPoint")) -{} + fixedValueFvPatchScalarField(p, iF, dict, false), + rho_(readScalar(dict.lookup("rhoRef"))), + pRef_(readScalar(dict.lookup("pRef"))), + pRefPointSpecified_(dict.found("pRefPoint")), + pRefPoint_(dict.lookupOrDefault("pRefPoint", Zero)) +{ + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchField::operator=(pRef_); + } +} Foam::uniformDensityHydrostaticPressureFvPatchScalarField:: @@ -72,7 +86,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField : fixedValueFvPatchScalarField(ptf, p, iF, mapper), rho_(ptf.rho_), - pRefValue_(ptf.pRefValue_), + pRef_(ptf.pRef_), + pRefPointSpecified_(ptf.pRefPointSpecified_), pRefPoint_(ptf.pRefPoint_) {} @@ -85,7 +100,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField : fixedValueFvPatchScalarField(ptf), rho_(ptf.rho_), - pRefValue_(ptf.pRefValue_), + pRef_(ptf.pRef_), + pRefPointSpecified_(ptf.pRefPointSpecified_), pRefPoint_(ptf.pRefPoint_) {} @@ -99,7 +115,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField : fixedValueFvPatchScalarField(ptf, iF), rho_(ptf.rho_), - pRefValue_(ptf.pRefValue_), + pRef_(ptf.pRef_), + pRefPointSpecified_(ptf.pRefPointSpecified_), pRefPoint_(ptf.pRefPoint_) {} @@ -116,10 +133,25 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs() const uniformDimensionedVectorField& g = db().lookupObject("g"); + scalar ghRef = g.value() & pRefPoint_; + + if (!pRefPointSpecified_) + { + const uniformDimensionedScalarField& hRef = + db().lookupObject("hRef"); + + ghRef = + ( + mag(g.value()) > small + ? (g & (cmptMag(g.value())/mag(g.value()))*hRef).value() + : 0 + ); + } + operator== ( - pRefValue_ - + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_)) + pRef_ + + rho_*((g.value() & patch().Cf()) - ghRef) ); fixedValueFvPatchScalarField::updateCoeffs(); @@ -132,9 +164,13 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write ) const { fvPatchScalarField::write(os); - os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl; - os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl; - os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl; + os.writeKeyword("rhoRef") << rho_ << token::END_STATEMENT << nl; + os.writeKeyword("pRef") << pRef_ << token::END_STATEMENT << nl; + if (pRefPointSpecified_) + { + os.writeKeyword("pRefPoint") + << pRefPoint_ << token::END_STATEMENT << nl; + } writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H index 3466d80a5..92ca39248 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.H @@ -32,25 +32,25 @@ Description calculated as: \f[ - p_{hyd} = p_{ref} + \rho g (x - x_{ref}) + p_{hyd} = p_{ref} + \rho_{ref} g (x - x_{ref}) \f] where \vartable - p_{hyd} | Hydrostatic pressure [Pa] - p_{ref} | Reference pressure [Pa] - x_{ref} | Reference point in Cartesian co-ordinates - \rho | Density (assumed uniform) - g | Acceleration due to gravity [m/s2] + p_{hyd} | Hydrostatic pressure [Pa] + p_{ref} | Reference pressure [Pa] + x_{ref} | Reference point in Cartesian co-ordinates + \rho_{ref} | Density (assumed uniform) + g | Acceleration due to gravity [m/s2] \endtable Usage \table Property | Description | Required | Default value - rho | Uniform density [kg/m3] | yes | - pRefValue | Reference pressure [Pa] | yes | - pRefPoint | Reference pressure location | yes | - value | Initial value | yes | + rhoRef | Uniform density [kg/m3] | yes | + pRef | Reference pressure [Pa] | yes | + pRefPoint | Reference pressure location | no | hRef + value | Initial value | no | pRef \endtable Example of the boundary condition specification: @@ -58,10 +58,9 @@ Usage { type uniformDensityHydrostaticPressure; - rho rho; - pRefValue 1e5; + rhoRef 1000; + pRef 1e5; pRefPoint (0 0 0); - value uniform 0; // Required initial value } \endverbatim @@ -94,9 +93,12 @@ class uniformDensityHydrostaticPressureFvPatchScalarField scalar rho_; //- Reference pressure - scalar pRefValue_; + scalar pRef_; - //- Reference pressure location + //- True if the reference pressure location is specified + bool pRefPointSpecified_; + + //- Optional reference pressure location vector pRefPoint_; @@ -190,15 +192,15 @@ public: } //- Return the reference pressure - scalar pRefValue() const + scalar pRef() const { - return pRefValue_; + return pRef_; } //- Return reference to the reference pressure to allow adjustment - scalar& pRefValue() + scalar& pRef() { - return pRefValue_; + return pRef_; } //- Return the pressure reference location