fixedMultiPhaseHeatFluxFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "fvPatchFieldMapper.H"
29 
30 #include "twoPhaseSystem.H"
34 #include "ThermalDiffusivity.H"
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
41 (
42  const fvPatch& p,
43  const DimensionedField<scalar, volMesh>& iF
44 )
45 :
46  fixedValueFvPatchScalarField(p, iF),
47  q_(p.size(), 0.0),
48  relax_(1.0)
49 {}
50 
51 
54 (
55  const fvPatch& p,
56  const DimensionedField<scalar, volMesh>& iF,
57  const dictionary& dict
58 )
59 :
60  fixedValueFvPatchScalarField(p, iF, dict),
61  q_("q", dict, p.size()),
62  relax_(dict.lookupOrDefault<scalar>("relax", 1.0))
63 {}
64 
65 
68 (
69  const fixedMultiPhaseHeatFluxFvPatchScalarField& psf,
70  const fvPatch& p,
71  const DimensionedField<scalar, volMesh>& iF,
72  const fvPatchFieldMapper& mapper
73 )
74 :
75  fixedValueFvPatchScalarField(psf, p, iF, mapper),
76  q_(psf.q_, mapper),
77  relax_(psf.relax_)
78 {}
79 
80 
83 (
84  const fixedMultiPhaseHeatFluxFvPatchScalarField& psf
85 )
86 :
87  fixedValueFvPatchScalarField(psf),
88  q_(psf.q_),
89  relax_(psf.relax_)
90 {}
91 
92 
95 (
96  const fixedMultiPhaseHeatFluxFvPatchScalarField& psf,
97  const DimensionedField<scalar, volMesh>& iF
98 )
99 :
100  fixedValueFvPatchScalarField(psf, iF),
101  q_(psf.q_),
102  relax_(psf.relax_)
103 {}
104 
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 {
111  if (updated())
112  {
113  return;
114  }
115 
116  // Lookup the fluid model
117  const ThermalPhaseChangePhaseSystem
118  <
119  MomentumTransferPhaseSystem<twoPhaseSystem>
120  >& fluid =
121  refCast
122  <
123  const ThermalPhaseChangePhaseSystem
124  <
125  MomentumTransferPhaseSystem<twoPhaseSystem>
126  >
127  >
128  (
129  db().lookupObject<phaseSystem>("phaseProperties")
130  );
131 
132  const scalarField& Tp = *this;
133 
134  scalarField A(Tp.size(), scalar(0));
135  scalarField B(Tp.size(), scalar(0));
136  scalarField Q(Tp.size(), scalar(0));
137 
138  forAll(fluid.phases(), phasei)
139  {
140  const phaseModel& phase = fluid.phases()[phasei];
141  const fluidThermo& thermo = phase.thermo();
142 
143  const fvPatchScalarField& alpha =
144  phase.boundaryField()[patch().index()];
145 
146  const fvPatchScalarField& T =
147  thermo.T().boundaryField()[patch().index()];
148 
149  const scalarField kappaEff
150  (
151  thermo.kappaEff
152  (
153  phase.turbulence().alphat(patch().index()),
154  patch().index()
155  )
156  );
157 
158  if (debug)
159  {
160  scalarField q0(T.snGrad()*alpha*kappaEff);
161  Q += q0;
162 
163  Info<< patch().name() << " " << phase.name()
164  << ": Heat flux " << gMin(q0) << " - " << gMax(q0) << endl;
165  }
166 
167  A += T.patchInternalField()*alpha*kappaEff*patch().deltaCoeffs();
168  B += alpha*kappaEff*patch().deltaCoeffs();
169  }
170 
171  if (debug)
172  {
173  Info<< patch().name() << " " << ": overall heat flux "
174  << gMin(Q) << " - " << gMax(Q) << endl;
175  }
176 
177  operator==((1 - relax_)*Tp + relax_*(q_ + A)/(B));
178 
179  fixedValueFvPatchScalarField::updateCoeffs();
180 }
181 
182 
184 {
186  os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl;
187  q_.writeEntry("q", os);
188  writeEntry("value", os);
189 }
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 namespace Foam
195 {
197  (
199  fixedMultiPhaseHeatFluxFvPatchScalarField
200  );
201 }
202 
203 
204 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
multiphaseSystem & fluid
Definition: createFields.H:10
label phasei
Definition: pEqn.H:27
Type gMin(const FieldField< Field, Type > &f)
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Macros for easy insertion into run-time selection tables.
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
fixedMultiPhaseHeatFluxFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
fvPatchField< scalar > fvPatchScalarField
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void write(Ostream &) const
Write.
static const char nl
Definition: Ostream.H:262
Type gMax(const FieldField< Field, Type > &f)
messageStream Info
volScalarField & p
Namespace for OpenFOAM.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:363