fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / inletOutlet / inletOutletFvPatchField.C
blob46104ec492f244d0a48ea55dd9850a710c77ceb4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 inletOutletFvPatchField<Type>::inletOutletFvPatchField
40     const fvPatch& p,
41     const DimensionedField<Type, volMesh>& iF
44     mixedFvPatchField<Type>(p, iF),
45     phiName_("phi")
47     this->refValue() = pTraits<Type>::zero;
48     this->refGrad() = pTraits<Type>::zero;
49     this->valueFraction() = 0.0;
53 template<class Type>
54 inletOutletFvPatchField<Type>::inletOutletFvPatchField
56     const inletOutletFvPatchField<Type>& ptf,
57     const fvPatch& p,
58     const DimensionedField<Type, volMesh>& iF,
59     const fvPatchFieldMapper& mapper
62     mixedFvPatchField<Type>(ptf, p, iF, mapper),
63     phiName_(ptf.phiName_)
67 template<class Type>
68 inletOutletFvPatchField<Type>::inletOutletFvPatchField
70     const fvPatch& p,
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"))
81     {
82         fvPatchField<Type>::operator=
83         (
84             Field<Type>("value", dict, p.size())
85         );
86     }
87     else
88     {
89         fvPatchField<Type>::operator=(this->refValue());
90     }
92     this->refGrad() = pTraits<Type>::zero;
93     this->valueFraction() = 0.0;
97 template<class Type>
98 inletOutletFvPatchField<Type>::inletOutletFvPatchField
100     const inletOutletFvPatchField<Type>& ptf
103     mixedFvPatchField<Type>(ptf),
104     phiName_(ptf.phiName_)
108 template<class Type>
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  * * * * * * * * * * * * * //
122 template<class Type>
123 void inletOutletFvPatchField<Type>::updateCoeffs()
125     if (this->updated())
126     {
127         return;
128     }
130     const Field<scalar>& phip = this->patch().lookupPatchField
131     (
132         phiName_,
133         reinterpret_cast<const surfaceScalarField*>(0),
134         reinterpret_cast<const scalar*>(0)
135     );
137     this->valueFraction() = 1.0 - pos(phip);
139     mixedFvPatchField<Type>::updateCoeffs();
143 template<class Type>
144 void inletOutletFvPatchField<Type>::write(Ostream& os) const
146     fvPatchField<Type>::write(os);
147     if (phiName_ != "phi")
148     {
149         os.writeKeyword("phi")
150             << phiName_ << token::END_STATEMENT << nl;
151     }
152     this->refValue().writeEntry("inletValue", os);
153     this->writeEntry("value", os);
157 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
159 template<class Type>
160 void inletOutletFvPatchField<Type>::operator=
162     const fvPatchField<Type>& ptf
165     fvPatchField<Type>::operator=
166     (
167         this->valueFraction()*this->refValue()
168         + (1 - this->valueFraction())*ptf
169     );
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 } // End namespace Foam
177 // ************************************************************************* //