Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / flux / fluxFvPatchField.C
blobf351978a060f1c1bf68e24285140205f03dbe1d3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fluxFvPatchField.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
33 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
35 template<class Type>
36 fluxFvPatchField<Type>::fluxFvPatchField
38     const fvPatch& p,
39     const DimensionedField<Type, volMesh>& iF
42     fixedGradientFvPatchField<Type>(p, iF),
43     flux_(p.size(), pTraits<Type>::zero),
44     reactivity_(p.size(), 0),
45     gammaName_("gamma")
47     this->gradient() = pTraits<Type>::zero;
51 template<class Type>
52 fluxFvPatchField<Type>::fluxFvPatchField
54     const fvPatch& p,
55     const DimensionedField<Type, volMesh>& iF,
56     const dictionary& dict
59     fixedGradientFvPatchField<Type>(p, iF),
60     flux_("flux", dict, p.size()),
61     reactivity_("reactivity", dict, p.size()),
62     gammaName_(dict.lookup("gamma"))
64     // Set dummy gradient
65     this->gradient() = pTraits<Type>::zero;
67     // Read the value entry from the dictionary
68     if (dict.found("value"))
69     {
70         fvPatchField<Type>::operator=
71         (
72             Field<Type>("value", dict, p.size())
73         );
74     }
75     else
76     {
77         FatalIOErrorIn
78         (
79             "fluxFvPatchField<Type>::fluxFvPatchField"
80             "("
81             "const fvPatch& p,"
82             "const DimensionedField<Type, volMesh>& iF,"
83             "const dictionary& dict,"
84             "const bool valueRequired"
85             ")",
86             dict
87         )   << "Essential entry 'value' missing"
88             << exit(FatalIOError);
89     }
93 template<class Type>
94 fluxFvPatchField<Type>::fluxFvPatchField
96     const fluxFvPatchField<Type>& ptf,
97     const fvPatch& p,
98     const DimensionedField<Type, volMesh>& iF,
99     const fvPatchFieldMapper& mapper
102     fixedGradientFvPatchField<Type>(ptf, p, iF, mapper),
103     flux_(ptf.flux_),
104     reactivity_(ptf.reactivity_),
105     gammaName_(ptf.gammaName_)
109 template<class Type>
110 fluxFvPatchField<Type>::fluxFvPatchField
112     const fluxFvPatchField<Type>& ptf
115     fixedGradientFvPatchField<Type>(ptf),
116     flux_(ptf.flux_),
117     reactivity_(ptf.reactivity_),
118     gammaName_(ptf.gammaName_)
122 template<class Type>
123 fluxFvPatchField<Type>::fluxFvPatchField
125     const fluxFvPatchField<Type>& ptf,
126     const DimensionedField<Type, volMesh>& iF
129     fixedGradientFvPatchField<Type>(ptf, iF),
130     flux_(ptf.flux_),
131     reactivity_(ptf.reactivity_),
132     gammaName_(ptf.gammaName_)
136 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
138 template<class Type>
139 void fluxFvPatchField<Type>::updateCoeffs()
141     if (this->updated())
142     {
143         return;
144     }
146     const fvPatchField<scalar>& gammap =
147         this->lookupPatchField
148         (
149             gammaName_,
150             reinterpret_cast<const volScalarField*>(NULL),
151             reinterpret_cast<const scalar*>(NULL)
152         );
154     this->gradient() = reactivity_*flux_/gammap;
156     fixedGradientFvPatchField<Type>::updateCoeffs();
160 template<class Type>
161 void fluxFvPatchField<Type>::write(Ostream& os) const
163     fixedGradientFvPatchField<Type>::write(os);
164     flux_.writeEntry("flux", os);
165     reactivity_.writeEntry("reactivity", os);
166     this->writeEntry("value", os);
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // ************************************************************************* //