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 "outletMappedUniformInletFvPatchField.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 Foam::outletMappedUniformInletFvPatchField<Type>::
34 outletMappedUniformInletFvPatchField
37 const DimensionedField<Type, volMesh>& iF
40 fixedValueFvPatchField<Type>(p, iF),
47 Foam::outletMappedUniformInletFvPatchField<Type>::
48 outletMappedUniformInletFvPatchField
50 const outletMappedUniformInletFvPatchField<Type>& ptf,
52 const DimensionedField<Type, volMesh>& iF,
53 const fvPatchFieldMapper& mapper
56 fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
57 outletPatchName_(ptf.outletPatchName_),
58 phiName_(ptf.phiName_)
63 Foam::outletMappedUniformInletFvPatchField<Type>::
64 outletMappedUniformInletFvPatchField
67 const DimensionedField<Type, volMesh>& iF,
68 const dictionary& dict
71 fixedValueFvPatchField<Type>(p, iF, dict),
72 outletPatchName_(dict.lookup("outletPatchName")),
73 phiName_(dict.lookupOrDefault<word>("phi", "phi"))
78 Foam::outletMappedUniformInletFvPatchField<Type>::
79 outletMappedUniformInletFvPatchField
81 const outletMappedUniformInletFvPatchField<Type>& ptf
84 fixedValueFvPatchField<Type>(ptf),
85 outletPatchName_(ptf.outletPatchName_),
86 phiName_(ptf.phiName_)
92 Foam::outletMappedUniformInletFvPatchField<Type>::
93 outletMappedUniformInletFvPatchField
95 const outletMappedUniformInletFvPatchField<Type>& ptf,
96 const DimensionedField<Type, volMesh>& iF
99 fixedValueFvPatchField<Type>(ptf, iF),
100 outletPatchName_(ptf.outletPatchName_),
101 phiName_(ptf.phiName_)
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
115 const GeometricField<Type, fvPatchField, volMesh>& f
117 dynamic_cast<const GeometricField<Type, fvPatchField, volMesh>&>
119 this->dimensionedInternalField()
123 const fvPatch& p = this->patch();
124 label outletPatchID =
125 p.patch().boundaryMesh().findPatchID(outletPatchName_);
127 if (outletPatchID < 0)
131 "void outletMappedUniformInletFvPatchField<Type>::updateCoeffs()"
132 ) << "Unable to find outlet patch " << outletPatchName_
133 << abort(FatalError);
136 const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
138 const fvPatchField<Type>& outletPatchField =
139 f.boundaryField()[outletPatchID];
141 const surfaceScalarField& phi =
142 this->db().objectRegistry::template lookupObject<surfaceScalarField>
145 const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
146 scalar sumOutletPatchPhi = gSum(outletPatchPhi);
148 if (sumOutletPatchPhi > SMALL)
150 Type averageOutletField =
151 gSum(outletPatchPhi*outletPatchField)
154 this->operator==(averageOutletField);
158 Type averageOutletField =
159 gSum(outletPatch.magSf()*outletPatchField)
160 /gSum(outletPatch.magSf());
162 this->operator==(averageOutletField);
165 fixedValueFvPatchField<Type>::updateCoeffs();
170 void Foam::outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const
172 fvPatchField<Type>::write(os);
173 os.writeKeyword("outletPatchName")
174 << outletPatchName_ << token::END_STATEMENT << nl;
175 if (phiName_ != "phi")
177 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
179 this->writeEntry("value", os);
183 // ************************************************************************* //