Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / inletOutlet / inletOutletFvPatchField.C
blobe081d6570d0b78072333572741cea21f0a347306
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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 "inletOutletFvPatchField.H"
28 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
30 template<class Type>
31 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
33     const fvPatch& p,
34     const DimensionedField<Type, volMesh>& iF
37     mixedFvPatchField<Type>(p, iF),
38     phiName_("phi")
40     this->refValue() = pTraits<Type>::zero;
41     this->refGrad() = pTraits<Type>::zero;
42     this->valueFraction() = 0.0;
46 template<class Type>
47 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
49     const inletOutletFvPatchField<Type>& ptf,
50     const fvPatch& p,
51     const DimensionedField<Type, volMesh>& iF,
52     const fvPatchFieldMapper& mapper
55     mixedFvPatchField<Type>(ptf, p, iF, mapper),
56     phiName_(ptf.phiName_)
60 template<class Type>
61 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
63     const fvPatch& p,
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"))
74     {
75         fvPatchField<Type>::operator=
76         (
77             Field<Type>("value", dict, p.size())
78         );
79     }
80     else
81     {
82         fvPatchField<Type>::operator=(this->refValue());
83     }
85     this->refGrad() = pTraits<Type>::zero;
86     this->valueFraction() = 0.0;
90 template<class Type>
91 Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
93     const inletOutletFvPatchField<Type>& ptf
96     mixedFvPatchField<Type>(ptf),
97     phiName_(ptf.phiName_)
101 template<class Type>
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  * * * * * * * * * * * * * //
115 template<class Type>
116 void Foam::inletOutletFvPatchField<Type>::updateCoeffs()
118     if (this->updated())
119     {
120         return;
121     }
123     const Field<scalar>& phip =
124         this->patch().template lookupPatchField<surfaceScalarField, scalar>
125         (
126             phiName_
127         );
129     this->valueFraction() = 1.0 - pos(phip);
131     mixedFvPatchField<Type>::updateCoeffs();
135 template<class Type>
136 void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const
138     fvPatchField<Type>::write(os);
139     if (phiName_ != "phi")
140     {
141         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
142     }
143     this->refValue().writeEntry("inletValue", os);
144     this->writeEntry("value", os);
148 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
150 template<class Type>
151 void Foam::inletOutletFvPatchField<Type>::operator=
153     const fvPatchField<Type>& ptf
156     fvPatchField<Type>::operator=
157     (
158         this->valueFraction()*this->refValue()
159         + (1 - this->valueFraction())*ptf
160     );
164 // ************************************************************************* //