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 "inletOutletFvPatchField.H"
28 #include "surfaceFields.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 inletOutletFvPatchField<Type>::inletOutletFvPatchField
41 const DimensionedField<Type, volMesh>& iF
44 mixedFvPatchField<Type>(p, iF),
47 this->refValue() = pTraits<Type>::zero;
48 this->refGrad() = pTraits<Type>::zero;
49 this->valueFraction() = 0.0;
54 inletOutletFvPatchField<Type>::inletOutletFvPatchField
56 const inletOutletFvPatchField<Type>& ptf,
58 const DimensionedField<Type, volMesh>& iF,
59 const fvPatchFieldMapper& mapper
62 mixedFvPatchField<Type>(ptf, p, iF, mapper),
63 phiName_(ptf.phiName_)
68 inletOutletFvPatchField<Type>::inletOutletFvPatchField
71 const DimensionedField<Type, volMesh>& iF,
72 const dictionary& dict
75 mixedFvPatchField<Type>(p, iF),
76 phiName_(dict.lookupOrDefault<word>("phi", "phi"))
78 this->refValue() = Field<Type>("inletValue", dict, p.size());
80 if (dict.found("value"))
82 fvPatchField<Type>::operator=
84 Field<Type>("value", dict, p.size())
89 fvPatchField<Type>::operator=(this->refValue());
92 this->refGrad() = pTraits<Type>::zero;
93 this->valueFraction() = 0.0;
98 inletOutletFvPatchField<Type>::inletOutletFvPatchField
100 const inletOutletFvPatchField<Type>& ptf
103 mixedFvPatchField<Type>(ptf),
104 phiName_(ptf.phiName_)
109 inletOutletFvPatchField<Type>::inletOutletFvPatchField
111 const inletOutletFvPatchField<Type>& ptf,
112 const DimensionedField<Type, volMesh>& iF
115 mixedFvPatchField<Type>(ptf, iF),
116 phiName_(ptf.phiName_)
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 void inletOutletFvPatchField<Type>::updateCoeffs()
130 const Field<scalar>& phip = this->patch().lookupPatchField
133 reinterpret_cast<const surfaceScalarField*>(0),
134 reinterpret_cast<const scalar*>(0)
137 this->valueFraction() = 1.0 - pos(phip);
139 mixedFvPatchField<Type>::updateCoeffs();
144 void inletOutletFvPatchField<Type>::write(Ostream& os) const
146 fvPatchField<Type>::write(os);
147 if (phiName_ != "phi")
149 os.writeKeyword("phi")
150 << phiName_ << token::END_STATEMENT << nl;
152 this->refValue().writeEntry("inletValue", os);
153 this->writeEntry("value", os);
157 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
160 void inletOutletFvPatchField<Type>::operator=
162 const fvPatchField<Type>& ptf
165 fvPatchField<Type>::operator=
167 this->valueFraction()*this->refValue()
168 + (1 - this->valueFraction())*ptf
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 } // End namespace Foam
177 // ************************************************************************* //