1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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 "inletOutletFvPatchField.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
34 const DimensionedField<Type, volMesh>& iF
37 mixedFvPatchField<Type>(p, iF),
40 this->refValue() = pTraits<Type>::zero;
41 this->refGrad() = pTraits<Type>::zero;
42 this->valueFraction() = 0.0;
47 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
49 const inletOutletFvPatchField<Type>& ptf,
51 const DimensionedField<Type, volMesh>& iF,
52 const fvPatchFieldMapper& mapper
55 mixedFvPatchField<Type>(ptf, p, iF, mapper),
56 phiName_(ptf.phiName_)
61 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
64 const DimensionedField<Type, volMesh>& iF,
65 const dictionary& dict
68 mixedFvPatchField<Type>(p, iF),
69 phiName_(dict.lookupOrDefault<word>("phi", "phi"))
71 this->refValue() = Field<Type>("inletValue", dict, p.size());
73 if (dict.found("value"))
75 fvPatchField<Type>::operator=
77 Field<Type>("value", dict, p.size())
82 fvPatchField<Type>::operator=(this->refValue());
85 this->refGrad() = pTraits<Type>::zero;
86 this->valueFraction() = 0.0;
91 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
93 const inletOutletFvPatchField<Type>& ptf
96 mixedFvPatchField<Type>(ptf),
97 phiName_(ptf.phiName_)
102 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
104 const inletOutletFvPatchField<Type>& ptf,
105 const DimensionedField<Type, volMesh>& iF
108 mixedFvPatchField<Type>(ptf, iF),
109 phiName_(ptf.phiName_)
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 void Foam::inletOutletFvPatchField<Type>::updateCoeffs()
123 const Field<scalar>& phip =
124 this->patch().template lookupPatchField<surfaceScalarField, scalar>
129 this->valueFraction() = 1.0 - pos(phip);
131 mixedFvPatchField<Type>::updateCoeffs();
136 void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const
138 fvPatchField<Type>::write(os);
139 if (phiName_ != "phi")
141 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
143 this->refValue().writeEntry("inletValue", os);
144 this->writeEntry("value", os);
148 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
151 void Foam::inletOutletFvPatchField<Type>::operator=
153 const fvPatchField<Type>& ptf
156 fvPatchField<Type>::operator=
158 this->valueFraction()*this->refValue()
159 + (1 - this->valueFraction())*ptf
164 // ************************************************************************* //