filmPyrolysisTemperatureCoupledFvPatchScalarField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "surfaceFields.H"
32 #include "pyrolysisModel.H"
33 #include "surfaceFilmRegionModel.H"
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
39 (
40  const fvPatch& p,
42 )
43 :
44  parent_bctype(p, iF),
45  filmRegionName_("surfaceFilmProperties"),
46  pyrolysisRegionName_("pyrolysisProperties"),
47  phiName_("phi"),
48  rhoName_("rho")
49 {}
50 
51 
54 (
55  const this_bctype& ptf,
56  const fvPatch& p,
58  const fvPatchFieldMapper& mapper
59 )
60 :
61  parent_bctype(ptf, p, iF, mapper),
62  filmRegionName_(ptf.filmRegionName_),
63  pyrolysisRegionName_(ptf.pyrolysisRegionName_),
64  phiName_(ptf.phiName_),
65  rhoName_(ptf.rhoName_)
66 {}
67 
68 
71 (
72  const fvPatch& p,
74  const dictionary& dict
75 )
76 :
77  parent_bctype(p, iF, dict),
78  filmRegionName_
79  (
80  dict.getOrDefault<word>("filmRegion", "surfaceFilmProperties")
81  ),
82  pyrolysisRegionName_
83  (
84  dict.getOrDefault<word>("pyrolysisRegion", "pyrolysisProperties")
85  ),
86  phiName_(dict.getOrDefault<word>("phi", "phi")),
87  rhoName_(dict.getOrDefault<word>("rho", "rho"))
88 {}
89 
90 
93 (
94  const this_bctype& fptpsf,
96 )
97 :
98  parent_bctype(fptpsf, iF),
99  filmRegionName_(fptpsf.filmRegionName_),
100  pyrolysisRegionName_(fptpsf.pyrolysisRegionName_),
101  phiName_(fptpsf.phiName_),
102  rhoName_(fptpsf.rhoName_)
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 {
110  if (updated())
111  {
112  return;
113  }
114 
115  // Film model
116  const auto* filmModelPtr = db().time().findObject
117  <regionModels::surfaceFilmModels::surfaceFilmRegionModel>
118  (filmRegionName_);
119 
120  // Pyrolysis model
121  const auto* pyrModelPtr = db().time().findObject
122  <regionModels::pyrolysisModels::pyrolysisModel>
123  (pyrolysisRegionName_);
124 
125  if (!filmModelPtr || !pyrModelPtr)
126  {
127  // Do nothing on construction - film model doesn't exist yet
128  return;
129  }
130 
131  const auto& filmModel = *filmModelPtr;
132  const auto& pyrModel = *pyrModelPtr;
133 
134 
135  // Since we're inside initEvaluate/evaluate there might be processor
136  // comms underway. Change the tag we use.
137  const int oldTag = UPstream::incrMsgType();
138 
139  scalarField& Tp = *this;
140 
141  const label patchi = patch().index();
142 
143  // The film model
144  const label filmPatchi = filmModel.regionPatchID(patchi);
145 
146  scalarField alphaFilm = filmModel.alpha().boundaryField()[filmPatchi];
147  filmModel.toPrimary(filmPatchi, alphaFilm);
148 
149  scalarField TFilm = filmModel.Ts().boundaryField()[filmPatchi];
150  filmModel.toPrimary(filmPatchi, TFilm);
151 
152  // The pyrolysis model
153  const label pyrPatchi = pyrModel.regionPatchID(patchi);
154 
155  scalarField TPyr = pyrModel.T().boundaryField()[pyrPatchi];
156  pyrModel.toPrimary(pyrPatchi, TPyr);
157 
158 
159  // Evaluate temperature
160  Tp = alphaFilm*TFilm + (1.0 - alphaFilm)*TPyr;
161 
162  UPstream::msgType(oldTag); // Restore tag
163 
164  this->parent_bctype::updateCoeffs();
165 }
166 
167 
169 (
170  Ostream& os
171 ) const
172 {
175  (
176  "filmRegion",
177  "surfaceFilmProperties",
178  filmRegionName_
179  );
181  (
182  "pyrolysisRegion",
183  "pyrolysisProperties",
184  pyrolysisRegionName_
185  );
186  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
187  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
189 }
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 namespace Foam
195 {
197  (
199  filmPyrolysisTemperatureCoupledFvPatchScalarField
200  );
201 }
202 
203 
204 // ************************************************************************* //
Foam::surfaceFields.
dictionary dict
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
Definition: UPstream.H:2041
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
filmPyrolysisTemperatureCoupledFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) const
Write.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:2019
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: fvPatchField.H:425
Ostream & writeEntryIfDifferent(const word &key, const T &refValue, const T &value)
Write a keyword/value entry only if the value differs from the reference value.
Definition: Ostream.H:346
Macros for easy insertion into run-time selection tables.
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: Field.C:745
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
volScalarField & p
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.