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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
30 #include "surfaceFields.H"
31 #include "pyrolysisModel.H"
32 #include "surfaceFilmRegionModel.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
38 (
39  const fvPatch& p,
41 )
42 :
43  fixedValueFvPatchVectorField(p, iF),
44  filmRegionName_("surfaceFilmProperties"),
45  pyrolysisRegionName_("pyrolysisProperties"),
46  phiName_("phi"),
47  rhoName_("rho")
48 {}
49 
50 
53 (
55  const fvPatch& p,
57  const fvPatchFieldMapper& mapper
58 )
59 :
60  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
61  filmRegionName_(ptf.filmRegionName_),
62  pyrolysisRegionName_(ptf.pyrolysisRegionName_),
63  phiName_(ptf.phiName_),
64  rhoName_(ptf.rhoName_)
65 {}
66 
67 
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
76  fixedValueFvPatchVectorField(p, iF, dict),
77  filmRegionName_
78  (
79  dict.lookupOrDefault<word>("filmRegion", "surfaceFilmProperties")
80  ),
81  pyrolysisRegionName_
82  (
83  dict.lookupOrDefault<word>("pyrolysisRegion", "pyrolysisProperties")
84  ),
85  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
86  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
87 {}
88 
89 
92 (
94 )
95 :
96  fixedValueFvPatchVectorField(fpvpvf),
97  filmRegionName_(fpvpvf.filmRegionName_),
98  pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_),
99  phiName_(fpvpvf.phiName_),
100  rhoName_(fpvpvf.rhoName_)
101 {}
102 
103 
106 (
109 )
110 :
111  fixedValueFvPatchVectorField(fpvpvf, iF),
112  filmRegionName_(fpvpvf.filmRegionName_),
113  pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_),
114  phiName_(fpvpvf.phiName_),
115  rhoName_(fpvpvf.rhoName_)
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
122 {
123  if (updated())
124  {
125  return;
126  }
127 
128  // Film model
129  const auto* filmModelPtr = db().time().findObject
131  (filmRegionName_);
132 
133  // Pyrolysis model
134  const auto* pyrModelPtr = db().time().findObject
136  (pyrolysisRegionName_);
137 
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  vectorField& Up = *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  vectorField UFilm = filmModel.Us().boundaryField()[filmPatchi];
166  filmModel.toPrimary(filmPatchi, UFilm);
167 
168  // The pyrolysis model
169  const label pyrPatchi = pyrModel.regionPatchID(patchi);
170 
171  scalarField phiPyr = pyrModel.phiGas().boundaryField()[pyrPatchi];
172  pyrModel.toPrimary(pyrPatchi, phiPyr);
173 
174 
175  const surfaceScalarField& phi =
176  db().lookupObject<surfaceScalarField>(phiName_);
177 
178  if (phi.dimensions() == dimVelocity*dimArea)
179  {}
180  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
181  {
182  const fvPatchField<scalar>& rhop =
183  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
184  phiPyr /= rhop;
185  }
186  else
187  {
189  << "Unable to process flux field phi with dimensions "
190  << phi.dimensions() << nl
191  << " on patch " << patch().name()
192  << " of field " << internalField().name()
193  << " in file " << internalField().objectPath()
194  << exit(FatalError);
195  }
196 
197  const scalarField UAvePyr(-phiPyr/patch().magSf());
198  const vectorField& nf = patch().nf();
199 
200 
201  // Evaluate velocity
202  Up = alphaFilm*UFilm + (1.0 - alphaFilm)*UAvePyr*nf;
203 
204  // Restore tag
205  UPstream::msgType() = oldTag;
206 
207  fixedValueFvPatchVectorField::updateCoeffs();
208 }
209 
210 
212 (
213  Ostream& os
214 ) const
215 {
218  (
219  "filmRegion",
220  "surfaceFilmProperties",
221  filmRegionName_
222  );
224  (
225  "pyrolysisRegion",
226  "pyrolysisProperties",
227  pyrolysisRegionName_
228  );
229  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
230  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
231  writeEntry("value", os);
232 }
233 
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 namespace Foam
238 {
240  (
243  );
244 }
245 
246 
247 // ************************************************************************* //
Foam::regionModels::pyrolysisModels::pyrolysisModel
Base class for pyrolysis models.
Definition: pyrolysisModel.H:62
Foam::fvPatchField< scalar >
Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: filmPyrolysisVelocityCoupledFvPatchVectorField.C:212
Foam::fvPatchField< vector >::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:364
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:231
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::dimDensity
const dimensionSet dimDensity
Foam::filmPyrolysisVelocityCoupledFvPatchVectorField
This boundary condition is designed to be used in conjunction with surface film and pyrolysis modelli...
Definition: filmPyrolysisVelocityCoupledFvPatchVectorField.H:69
Foam::regionModels::regionModel::time
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:39
surfaceFields.H
Foam::surfaceFields.
surfaceFilmRegionModel.H
pyrolysisModel.H
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:60
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::filmPyrolysisVelocityCoupledFvPatchVectorField
filmPyrolysisVelocityCoupledFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: filmPyrolysisVelocityCoupledFvPatchVectorField.C:38
Foam::Field< vector >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
filmPyrolysisVelocityCoupledFvPatchVectorField.H
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:491
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
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::nl
constexpr char nl
Definition: Ostream.H:372
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
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::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: filmPyrolysisVelocityCoupledFvPatchVectorField.C:121
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54