BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / outletMappedUniformInlet / outletMappedUniformInletFvPatchField.C
blob46c021c7f3b18f00fa6d8755a0ae53a6fe48816e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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  * * * * * * * * * * * * * * //
32 template<class Type>
33 Foam::outletMappedUniformInletFvPatchField<Type>::
34 outletMappedUniformInletFvPatchField
36     const fvPatch& p,
37     const DimensionedField<Type, volMesh>& iF
40     fixedValueFvPatchField<Type>(p, iF),
41     outletPatchName_(),
42     phiName_("phi")
46 template<class Type>
47 Foam::outletMappedUniformInletFvPatchField<Type>::
48 outletMappedUniformInletFvPatchField
50     const outletMappedUniformInletFvPatchField<Type>& ptf,
51     const fvPatch& p,
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_)
62 template<class Type>
63 Foam::outletMappedUniformInletFvPatchField<Type>::
64 outletMappedUniformInletFvPatchField
66     const fvPatch& p,
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"))
77 template<class Type>
78 Foam::outletMappedUniformInletFvPatchField<Type>::
79 outletMappedUniformInletFvPatchField
81     const outletMappedUniformInletFvPatchField<Type>& ptf
84     fixedValueFvPatchField<Type>(ptf),
85     outletPatchName_(ptf.outletPatchName_),
86     phiName_(ptf.phiName_)
91 template<class Type>
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  * * * * * * * * * * * * * //
107 template<class Type>
108 void Foam::outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
110     if (this->updated())
111     {
112         return;
113     }
115     const GeometricField<Type, fvPatchField, volMesh>& f
116     (
117         dynamic_cast<const GeometricField<Type, fvPatchField, volMesh>&>
118         (
119             this->dimensionedInternalField()
120         )
121     );
123     const fvPatch& p = this->patch();
124     label outletPatchID =
125         p.patch().boundaryMesh().findPatchID(outletPatchName_);
127     if (outletPatchID < 0)
128     {
129         FatalErrorIn
130         (
131             "void outletMappedUniformInletFvPatchField<Type>::updateCoeffs()"
132         )   << "Unable to find outlet patch " << outletPatchName_
133             << abort(FatalError);
134     }
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>
143         (phiName_);
145     const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
146     scalar sumOutletPatchPhi = gSum(outletPatchPhi);
148     if (sumOutletPatchPhi > SMALL)
149     {
150         Type averageOutletField =
151             gSum(outletPatchPhi*outletPatchField)
152            /sumOutletPatchPhi;
154         this->operator==(averageOutletField);
155     }
156     else
157     {
158         Type averageOutletField =
159             gSum(outletPatch.magSf()*outletPatchField)
160            /gSum(outletPatch.magSf());
162         this->operator==(averageOutletField);
163     }
165     fixedValueFvPatchField<Type>::updateCoeffs();
169 template<class Type>
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")
176     {
177         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
178     }
179     this->writeEntry("value", os);
183 // ************************************************************************* //