Loading...
Searching...
No Matches
filmPyrolysisVelocityCoupledFvPatchVectorField.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-------------------------------------------------------------------------------
11License
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"
34
35// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36
39(
40 const fvPatch& p,
42)
43:
44 fixedValueFvPatchVectorField(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 fixedValueFvPatchVectorField(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 fixedValueFvPatchVectorField(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 fixedValueFvPatchVectorField(fpvpvf),
98 filmRegionName_(fpvpvf.filmRegionName_),
99 pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_),
100 phiName_(fpvpvf.phiName_),
101 rhoName_(fpvpvf.rhoName_)
102{}
103
104
107(
110)
111:
112 fixedValueFvPatchVectorField(fpvpvf, iF),
113 filmRegionName_(fpvpvf.filmRegionName_),
114 pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_),
115 phiName_(fpvpvf.phiName_),
116 rhoName_(fpvpvf.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
131 <regionModels::surfaceFilmModels::surfaceFilmRegionModel>
132 (filmRegionName_);
133
134 // Pyrolysis model
135 const auto* pyrModelPtr = db().time().findObject
136 <regionModels::pyrolysisModels::pyrolysisModel>
137 (pyrolysisRegionName_);
138
139
140 if (!filmModelPtr || !pyrModelPtr)
141 {
142 // Do nothing on construction - film model doesn't exist yet
143 return;
144 }
145
146 const auto& filmModel = *filmModelPtr;
147 const auto& pyrModel = *pyrModelPtr;
148
149
150 // Since we're inside initEvaluate/evaluate there might be processor
151 // comms underway. Change the tag we use.
152 const int oldTag = UPstream::incrMsgType();
153
154 vectorField& Up = *this;
155
156 const label patchi = patch().index();
157
158 // The film model
159 const label filmPatchi = filmModel.regionPatchID(patchi);
160
161 scalarField alphaFilm = filmModel.alpha().boundaryField()[filmPatchi];
162 filmModel.toPrimary(filmPatchi, alphaFilm);
163
164 vectorField UFilm = filmModel.Us().boundaryField()[filmPatchi];
165 filmModel.toPrimary(filmPatchi, UFilm);
166
167 // The pyrolysis model
168 const label pyrPatchi = pyrModel.regionPatchID(patchi);
169
170 scalarField phiPyr = pyrModel.phiGas().boundaryField()[pyrPatchi];
171 pyrModel.toPrimary(pyrPatchi, phiPyr);
172
173
174 const auto& phi = db().lookupObject<surfaceScalarField>(phiName_);
175
176 if (phi.dimensions() == dimVolume/dimTime)
177 {}
178 else if (phi.dimensions() == dimMass/dimTime)
179 {
180 const auto& rhop = patch().lookupPatchField<volScalarField>(rhoName_);
181 phiPyr /= rhop;
182 }
183 else
184 {
186 << "Unable to process flux field phi with dimensions "
187 << phi.dimensions() << nl
188 << " on patch " << patch().name()
189 << " of field " << internalField().name()
190 << " in file " << internalField().objectPath()
191 << exit(FatalError);
192 }
193
194 const scalarField UAvePyr(-phiPyr/patch().magSf());
195 tmp<vectorField> nf(patch().nf());
196
197
198 // Evaluate velocity
199 Up = alphaFilm*UFilm + (1.0 - alphaFilm)*UAvePyr*nf;
201 UPstream::msgType(oldTag); // Restore tag
202
203 fixedValueFvPatchVectorField::updateCoeffs();
204}
205
206
208(
209 Ostream& os
210) const
211{
213 os.writeEntryIfDifferent<word>
214 (
215 "filmRegion",
216 "surfaceFilmProperties",
217 filmRegionName_
218 );
219 os.writeEntryIfDifferent<word>
220 (
221 "pyrolysisRegion",
222 "pyrolysisProperties",
223 pyrolysisRegionName_
224 );
225 os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
226 os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
229
230
231// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232
233namespace Foam
234{
236 (
238 filmPyrolysisVelocityCoupledFvPatchVectorField
239 );
240}
241
242
243// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
static int & msgType() noexcept
Message tag of standard messages.
Definition UPstream.H:1926
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
Definition UPstream.H:1948
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
This boundary condition is designed to be used in conjunction with surface film and pyrolysis modelli...
filmPyrolysisVelocityCoupledFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A FieldMapper for finite-volume patch fields.
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const Time & time() const noexcept
Return the reference to the time database.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
const std::string patch
OpenFOAM patch number as a std::string.
Namespace for OpenFOAM.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
const dimensionSet dimVolume(pow3(dimLength))
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
fvPatchField< vector > fvPatchVectorField
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
Foam::surfaceFields.