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 "pressureNormalInletOutletVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 pressureNormalInletOutletVelocityFvPatchVectorField::
41 pressureNormalInletOutletVelocityFvPatchVectorField
44 const DimensionedField<vector, volMesh>& iF
47 mixedFvPatchVectorField(p, iF),
52 refGrad() = vector::zero;
53 valueFraction() = 0.0;
57 pressureNormalInletOutletVelocityFvPatchVectorField::
58 pressureNormalInletOutletVelocityFvPatchVectorField
60 const pressureNormalInletOutletVelocityFvPatchVectorField& ptf,
62 const DimensionedField<vector, volMesh>& iF,
63 const fvPatchFieldMapper& mapper
66 mixedFvPatchVectorField(ptf, p, iF, mapper),
67 phiName_(ptf.phiName_),
68 rhoName_(ptf.rhoName_)
72 pressureNormalInletOutletVelocityFvPatchVectorField::
73 pressureNormalInletOutletVelocityFvPatchVectorField
76 const DimensionedField<vector, volMesh>& iF,
77 const dictionary& dict
80 mixedFvPatchVectorField(p, iF),
81 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
82 rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
84 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
86 refGrad() = vector::zero;
87 valueFraction() = 0.0;
91 pressureNormalInletOutletVelocityFvPatchVectorField::
92 pressureNormalInletOutletVelocityFvPatchVectorField
94 const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf
97 mixedFvPatchVectorField(pivpvf),
98 phiName_(pivpvf.phiName_),
99 rhoName_(pivpvf.rhoName_)
103 pressureNormalInletOutletVelocityFvPatchVectorField::
104 pressureNormalInletOutletVelocityFvPatchVectorField
106 const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf,
107 const DimensionedField<vector, volMesh>& iF
110 mixedFvPatchVectorField(pivpvf, iF),
111 phiName_(pivpvf.phiName_),
112 rhoName_(pivpvf.rhoName_)
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 void pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs()
125 const surfaceScalarField& phi =
126 db().lookupObject<surfaceScalarField>(phiName_);
128 const fvsPatchField<scalar>& phip =
129 patch().patchField<surfaceScalarField, scalar>(phi);
131 vectorField n = patch().nf();
132 const Field<scalar>& magS = patch().magSf();
134 if (phi.dimensions() == dimVelocity*dimArea)
136 refValue() = n*phip/magS;
138 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
140 const fvPatchField<scalar>& rhop =
141 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
143 refValue() = n*phip/(rhop*magS);
149 "pressureNormalInletOutletVelocityFvPatchVectorField::"
151 ) << "dimensions of phi are not correct"
152 << "\n on patch " << this->patch().name()
153 << " of field " << this->dimensionedInternalField().name()
154 << " in file " << this->dimensionedInternalField().objectPath()
158 valueFraction() = 1.0 - pos(phip);
160 mixedFvPatchVectorField::updateCoeffs();
164 void pressureNormalInletOutletVelocityFvPatchVectorField::
165 write(Ostream& os) const
167 fvPatchVectorField::write(os);
168 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
169 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
170 writeEntry("value", os);
174 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
176 void pressureNormalInletOutletVelocityFvPatchVectorField::operator=
178 const fvPatchField<vector>& pvf
181 fvPatchField<vector>::operator=
183 valueFraction()*(patch().nf()*(patch().nf() & pvf))
184 + (1 - valueFraction())*pvf
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 pressureNormalInletOutletVelocityFvPatchVectorField
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // ************************************************************************* //