1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pressureNormalInletOutletVelocityFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
36 pressureNormalInletOutletVelocityFvPatchVectorField
39 const DimensionedField<vector, volMesh>& iF
42 mixedFvPatchVectorField(p, iF),
47 refGrad() = vector::zero;
48 valueFraction() = 0.0;
52 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
53 pressureNormalInletOutletVelocityFvPatchVectorField
55 const pressureNormalInletOutletVelocityFvPatchVectorField& ptf,
57 const DimensionedField<vector, volMesh>& iF,
58 const fvPatchFieldMapper& mapper
61 mixedFvPatchVectorField(ptf, p, iF, mapper),
62 phiName_(ptf.phiName_),
63 rhoName_(ptf.rhoName_)
67 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
68 pressureNormalInletOutletVelocityFvPatchVectorField
71 const DimensionedField<vector, volMesh>& iF,
72 const dictionary& dict
75 mixedFvPatchVectorField(p, iF),
76 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
77 rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
79 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
81 refGrad() = vector::zero;
82 valueFraction() = 0.0;
86 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
87 pressureNormalInletOutletVelocityFvPatchVectorField
89 const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf
92 mixedFvPatchVectorField(pivpvf),
93 phiName_(pivpvf.phiName_),
94 rhoName_(pivpvf.rhoName_)
98 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
99 pressureNormalInletOutletVelocityFvPatchVectorField
101 const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf,
102 const DimensionedField<vector, volMesh>& iF
105 mixedFvPatchVectorField(pivpvf, iF),
106 phiName_(pivpvf.phiName_),
107 rhoName_(pivpvf.rhoName_)
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs()
120 const surfaceScalarField& phi =
121 db().lookupObject<surfaceScalarField>(phiName_);
123 const fvsPatchField<scalar>& phip =
124 patch().patchField<surfaceScalarField, scalar>(phi);
126 tmp<vectorField> n = patch().nf();
127 const Field<scalar>& magS = patch().magSf();
129 if (phi.dimensions() == dimVelocity*dimArea)
131 refValue() = n*phip/magS;
133 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
135 const fvPatchField<scalar>& rhop =
136 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
138 refValue() = n*phip/(rhop*magS);
144 "pressureNormalInletOutletVelocityFvPatchVectorField::"
146 ) << "dimensions of phi are not correct"
147 << "\n on patch " << this->patch().name()
148 << " of field " << this->dimensionedInternalField().name()
149 << " in file " << this->dimensionedInternalField().objectPath()
153 valueFraction() = 1.0 - pos(phip);
155 mixedFvPatchVectorField::updateCoeffs();
159 void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::write
164 fvPatchVectorField::write(os);
165 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
166 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
167 writeEntry("value", os);
171 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
173 void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::operator=
175 const fvPatchField<vector>& pvf
178 fvPatchField<vector>::operator=
180 valueFraction()*(patch().nf()*(patch().nf() & pvf))
181 + (1 - valueFraction())*pvf
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 pressureNormalInletOutletVelocityFvPatchVectorField
197 // ************************************************************************* //