1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "uniformDensityHydrostaticPressureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 #include "uniformDimensionedFields.H"
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
37 uniformDensityHydrostaticPressureFvPatchScalarField
40 const DimensionedField<scalar, volMesh>& iF
43 fixedValueFvPatchScalarField(p, iF),
46 pRefPoint_(vector::zero)
50 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
51 uniformDensityHydrostaticPressureFvPatchScalarField
54 const DimensionedField<scalar, volMesh>& iF,
55 const dictionary& dict
58 fixedValueFvPatchScalarField(p, iF),
59 rho_(readScalar(dict.lookup("rho"))),
60 pRefValue_(readScalar(dict.lookup("pRefValue"))),
61 pRefPoint_(dict.lookup("pRefPoint"))
63 if (dict.found("value"))
65 fvPatchField<scalar>::operator=
67 scalarField("value", dict, p.size())
77 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
78 uniformDensityHydrostaticPressureFvPatchScalarField
80 const uniformDensityHydrostaticPressureFvPatchScalarField& ptf,
82 const DimensionedField<scalar, volMesh>& iF,
83 const fvPatchFieldMapper& mapper
86 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
88 pRefValue_(ptf.pRefValue_),
89 pRefPoint_(ptf.pRefPoint_)
93 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
94 uniformDensityHydrostaticPressureFvPatchScalarField
96 const uniformDensityHydrostaticPressureFvPatchScalarField& ptf
99 fixedValueFvPatchScalarField(ptf),
101 pRefValue_(ptf.pRefValue_),
102 pRefPoint_(ptf.pRefPoint_)
106 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
107 uniformDensityHydrostaticPressureFvPatchScalarField
109 const uniformDensityHydrostaticPressureFvPatchScalarField& ptf,
110 const DimensionedField<scalar, volMesh>& iF
113 fixedValueFvPatchScalarField(ptf, iF),
115 pRefValue_(ptf.pRefValue_),
116 pRefPoint_(ptf.pRefPoint_)
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs()
129 const uniformDimensionedVectorField& g =
130 db().lookupObject<uniformDimensionedVectorField>("g");
135 + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_))
138 fixedValueFvPatchScalarField::updateCoeffs();
142 void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write
147 fvPatchScalarField::write(os);
148 os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
149 os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
150 os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
151 writeEntry("value", os);
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 uniformDensityHydrostaticPressureFvPatchScalarField
166 // ************************************************************************* //