1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 inletOutletFvPatchField<Type>::inletOutletFvPatchField
40 const DimensionedField<Type, volMesh>& iF
43 mixedFvPatchField<Type>(p, iF),
46 this->refValue() = pTraits<Type>::zero;
47 this->refGrad() = pTraits<Type>::zero;
48 this->valueFraction() = 0.0;
53 inletOutletFvPatchField<Type>::inletOutletFvPatchField
55 const inletOutletFvPatchField<Type>& ptf,
57 const DimensionedField<Type, volMesh>& iF,
58 const fvPatchFieldMapper& mapper
61 mixedFvPatchField<Type>(ptf, p, iF, mapper),
62 phiName_(ptf.phiName_)
67 inletOutletFvPatchField<Type>::inletOutletFvPatchField
70 const DimensionedField<Type, volMesh>& iF,
71 const dictionary& dict
74 mixedFvPatchField<Type>(p, iF),
75 phiName_(dict.lookupOrDefault<word>("phi", "phi"))
77 this->refValue() = Field<Type>("inletValue", dict, p.size());
79 if (dict.found("value"))
81 fvPatchField<Type>::operator=
83 Field<Type>("value", dict, p.size())
88 fvPatchField<Type>::operator=(this->refValue());
91 this->refGrad() = pTraits<Type>::zero;
92 this->valueFraction() = 0.0;
97 inletOutletFvPatchField<Type>::inletOutletFvPatchField
99 const inletOutletFvPatchField<Type>& ptf
102 mixedFvPatchField<Type>(ptf),
103 phiName_(ptf.phiName_)
108 inletOutletFvPatchField<Type>::inletOutletFvPatchField
110 const inletOutletFvPatchField<Type>& ptf,
111 const DimensionedField<Type, volMesh>& iF
114 mixedFvPatchField<Type>(ptf, iF),
115 phiName_(ptf.phiName_)
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 void inletOutletFvPatchField<Type>::updateCoeffs()
129 const Field<scalar>& phip = this->patch().lookupPatchField
132 reinterpret_cast<const surfaceScalarField*>(0),
133 reinterpret_cast<const scalar*>(0)
136 this->valueFraction() = 1.0 - pos(phip);
138 mixedFvPatchField<Type>::updateCoeffs();
143 void inletOutletFvPatchField<Type>::write(Ostream& os) const
145 fvPatchField<Type>::write(os);
146 if (phiName_ != "phi")
148 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
150 this->refValue().writeEntry("inletValue", os);
151 this->writeEntry("value", os);
155 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
158 void inletOutletFvPatchField<Type>::operator=
160 const fvPatchField<Type>& ptf
163 fvPatchField<Type>::operator=
165 this->valueFraction()*this->refValue()
166 + (1 - this->valueFraction())*ptf
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 } // End namespace Foam
175 // ************************************************************************* //