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  fixedValueFvPatchScalarField(p, iF),
45  filmRegionName_("surfaceFilmProperties"),
46  pyrolysisRegionName_("pyrolysisProperties"),
47  phiName_("phi"),
48  rhoName_("rho")
49 {}
50 
51 
54 (
56  const fvPatch& p,
58  const fvPatchFieldMapper& mapper
59 )
60 :
61  fixedValueFvPatchScalarField(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  fixedValueFvPatchScalarField(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 (
95 )
96 :
97  fixedValueFvPatchScalarField(fptpsf),
98  filmRegionName_(fptpsf.filmRegionName_),
99  pyrolysisRegionName_(fptpsf.pyrolysisRegionName_),
100  phiName_(fptpsf.phiName_),
101  rhoName_(fptpsf.rhoName_)
102 {}
103 
104 
107 (
110 )
111 :
112  fixedValueFvPatchScalarField(fptpsf, iF),
113  filmRegionName_(fptpsf.filmRegionName_),
114  pyrolysisRegionName_(fptpsf.pyrolysisRegionName_),
115  phiName_(fptpsf.phiName_),
116  rhoName_(fptpsf.rhoName_)
117 {}
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
123 {
124  if (updated())
125  {
126  return;
127  }
128 
129  // Film model
130  const auto* filmModelPtr = db().time().findObject
132  (filmRegionName_);
133 
134  // Pyrolysis model
135  const auto* pyrModelPtr = db().time().findObject
137  (pyrolysisRegionName_);
138 
139  if (!filmModelPtr || !pyrModelPtr)
140  {
141  // Do nothing on construction - film model doesn't exist yet
142  return;
143  }
144 
145  const auto& filmModel = *filmModelPtr;
146  const auto& pyrModel = *pyrModelPtr;
147 
148 
149  // Since we're inside initEvaluate/evaluate there might be processor
150  // comms underway. Change the tag we use.
151  int oldTag = UPstream::msgType();
152  UPstream::msgType() = oldTag+1;
153 
154 
155  scalarField& Tp = *this;
156 
157  const label patchi = patch().index();
158 
159  // The film model
160  const label filmPatchi = filmModel.regionPatchID(patchi);
161 
162  scalarField alphaFilm = filmModel.alpha().boundaryField()[filmPatchi];
163  filmModel.toPrimary(filmPatchi, alphaFilm);
164 
165  scalarField TFilm = filmModel.Ts().boundaryField()[filmPatchi];
166  filmModel.toPrimary(filmPatchi, TFilm);
167 
168  // The pyrolysis model
169  const label pyrPatchi = pyrModel.regionPatchID(patchi);
170 
171  scalarField TPyr = pyrModel.T().boundaryField()[pyrPatchi];
172  pyrModel.toPrimary(pyrPatchi, TPyr);
173 
174 
175  // Evaluate temperature
176  Tp = alphaFilm*TFilm + (1.0 - alphaFilm)*TPyr;
177 
178  // Restore tag
179  UPstream::msgType() = oldTag;
180 
181  fixedValueFvPatchScalarField::updateCoeffs();
182 }
183 
184 
186 (
187  Ostream& os
188 ) const
189 {
192  (
193  "filmRegion",
194  "surfaceFilmProperties",
195  filmRegionName_
196  );
198  (
199  "pyrolysisRegion",
200  "pyrolysisProperties",
201  pyrolysisRegionName_
202  );
203  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
204  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
205  writeEntry("value", os);
206 }
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 namespace Foam
212 {
214  (
217  );
218 }
219 
220 
221 // ************************************************************************* //
Foam::regionModels::pyrolysisModels::pyrolysisModel
Base class for pyrolysis models.
Definition: pyrolysisModel.H:61
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::fvPatchField< scalar >::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:384
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:248
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: filmPyrolysisTemperatureCoupledFvPatchScalarField.C:186
Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::filmPyrolysisTemperatureCoupledFvPatchScalarField
filmPyrolysisTemperatureCoupledFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: filmPyrolysisTemperatureCoupledFvPatchScalarField.C:39
Foam::regionModels::regionModel::time
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:40
surfaceFields.H
Foam::surfaceFields.
surfaceFilmRegionModel.H
pyrolysisModel.H
Foam::Field< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::Field::T
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: Field.C:599
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: filmPyrolysisTemperatureCoupledFvPatchScalarField.C:122
Foam::UPstream::msgType
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:540
Foam::objectRegistry::findObject
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Definition: objectRegistryTemplates.C:401
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField
This boundary condition is designed to be used in conjunction with surface film and pyrolysis modelli...
Definition: filmPyrolysisTemperatureCoupledFvPatchScalarField.H:68
filmPyrolysisTemperatureCoupledFvPatchScalarField.H
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54