initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / inletOutlet / inletOutletFvPatchField.C
blob0cc5d07bcd2fa8d743810be38706ba3efbb39de9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class Type>
37 inletOutletFvPatchField<Type>::inletOutletFvPatchField
39     const fvPatch& p,
40     const DimensionedField<Type, volMesh>& iF
43     mixedFvPatchField<Type>(p, iF),
44     phiName_("phi")
46     this->refValue() = pTraits<Type>::zero;
47     this->refGrad() = pTraits<Type>::zero;
48     this->valueFraction() = 0.0;
52 template<class Type>
53 inletOutletFvPatchField<Type>::inletOutletFvPatchField
55     const inletOutletFvPatchField<Type>& ptf,
56     const fvPatch& p,
57     const DimensionedField<Type, volMesh>& iF,
58     const fvPatchFieldMapper& mapper
61     mixedFvPatchField<Type>(ptf, p, iF, mapper),
62     phiName_(ptf.phiName_)
66 template<class Type>
67 inletOutletFvPatchField<Type>::inletOutletFvPatchField
69     const fvPatch& p,
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"))
80     {
81         fvPatchField<Type>::operator=
82         (
83             Field<Type>("value", dict, p.size())
84         );
85     }
86     else
87     {
88         fvPatchField<Type>::operator=(this->refValue());
89     }
91     this->refGrad() = pTraits<Type>::zero;
92     this->valueFraction() = 0.0;
96 template<class Type>
97 inletOutletFvPatchField<Type>::inletOutletFvPatchField
99     const inletOutletFvPatchField<Type>& ptf
102     mixedFvPatchField<Type>(ptf),
103     phiName_(ptf.phiName_)
107 template<class Type>
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  * * * * * * * * * * * * * //
121 template<class Type>
122 void inletOutletFvPatchField<Type>::updateCoeffs()
124     if (this->updated())
125     {
126         return;
127     }
129     const Field<scalar>& phip = this->patch().lookupPatchField
130     (
131         phiName_,
132         reinterpret_cast<const surfaceScalarField*>(0),
133         reinterpret_cast<const scalar*>(0)
134     );
136     this->valueFraction() = 1.0 - pos(phip);
138     mixedFvPatchField<Type>::updateCoeffs();
142 template<class Type>
143 void inletOutletFvPatchField<Type>::write(Ostream& os) const
145     fvPatchField<Type>::write(os);
146     if (phiName_ != "phi")
147     {
148         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
149     }
150     this->refValue().writeEntry("inletValue", os);
151     this->writeEntry("value", os);
155 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
157 template<class Type>
158 void inletOutletFvPatchField<Type>::operator=
160     const fvPatchField<Type>& ptf
163     fvPatchField<Type>::operator=
164     (
165         this->valueFraction()*this->refValue()
166         + (1 - this->valueFraction())*ptf
167     );
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 } // End namespace Foam
175 // ************************************************************************* //