fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / flux / fluxFvPatchField.C
blobae7185d07a3bacad090bd176c56158b3f4582b91
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 "fluxFvPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class Type>
37 fluxFvPatchField<Type>::fluxFvPatchField
39     const fvPatch& p,
40     const DimensionedField<Type, volMesh>& iF
43     fixedGradientFvPatchField<Type>(p, iF),
44     reactivity_(0),
45     gammaName_("gamma")
47     this->gradient() = pTraits<Type>::zero;
51 template<class Type>
52 fluxFvPatchField<Type>::fluxFvPatchField
54     const fluxFvPatchField<Type>& ptf,
55     const fvPatch& p,
56     const DimensionedField<Type, volMesh>& iF,
57     const fvPatchFieldMapper& mapper
60     fixedGradientFvPatchField<Type>(ptf, p, iF, mapper),
61     reactivity_(ptf.reactivity_),
62     gammaName_(ptf.gammaName_)
66 template<class Type>
67 fluxFvPatchField<Type>::fluxFvPatchField
69     const fvPatch& p,
70     const DimensionedField<Type, volMesh>& iF,
71     const dictionary& dict
74     fixedGradientFvPatchField<Type>(p, iF),
75     reactivity_(readScalar(dict.lookup("reactivity"))),
76     gammaName_(dict.lookup("gamma"))
78     // Set dummy gradient
79     this->gradient() = pTraits<Type>::zero;
81     // Read the value entry from the dictionary
82     if (dict.found("value"))
83     {
84         fvPatchField<Type>::operator=
85         (
86             Field<Type>("value", dict, p.size())
87         );
88     }
89     else
90     {
91         FatalIOErrorIn
92         (
93             "fluxFvPatchField<Type>::fluxFvPatchField"
94             "("
95             "const fvPatch& p,"
96             "const DimensionedField<Type, volMesh>& iF,"
97             "const dictionary& dict,"
98             "const bool valueRequired"
99             ")",
100             dict
101         )   << "Essential entry 'value' missing"
102             << exit(FatalIOError);
103     }
107 template<class Type>
108 fluxFvPatchField<Type>::fluxFvPatchField
110     const fluxFvPatchField<Type>& ptf
113     fixedGradientFvPatchField<Type>(ptf),
114     reactivity_(ptf.reactivity_),
115     gammaName_(ptf.gammaName_)
119 template<class Type>
120 fluxFvPatchField<Type>::fluxFvPatchField
122     const fluxFvPatchField<Type>& ptf,
123     const DimensionedField<Type, volMesh>& iF
126     fixedGradientFvPatchField<Type>(ptf, iF),
127     reactivity_(ptf.reactivity_),
128     gammaName_(ptf.gammaName_)
132 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
134 template<class Type>
135 void fluxFvPatchField<Type>::updateCoeffs()
137     if (this->updated())
138     {
139         return;
140     }
142     const Field<Type>& C = *this;
144     const fvPatchField<scalar>& gammap =
145         this->patch().lookupPatchField
146         (
147             gammaName_,
148             reinterpret_cast<const volScalarField*>(NULL),
149             reinterpret_cast<const scalar*>(NULL)
150         );
152     this->gradient() = reactivity_*C/gammap;
154     fixedGradientFvPatchField<Type>::updateCoeffs();
158 template<class Type>
159 void fluxFvPatchField<Type>::write(Ostream& os) const
161     fixedGradientFvPatchField<Type>::write(os);
162     os.writeKeyword("reactivity")
163         << reactivity_ << token::END_STATEMENT << nl;
164     os.writeKeyword("gamma")
165         << gammaName_ << token::END_STATEMENT << nl;
166     this->writeEntry("value", os);
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // ************************************************************************* //