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 | Copyright (C) 2011-2017 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 
28 #include "surfaceFields.H"
29 #include "pyrolysisModel.H"
30 #include "surfaceFilmModel.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  fixedValueFvPatchVectorField(p, iF),
42  filmRegionName_("surfaceFilmProperties"),
43  pyrolysisRegionName_("pyrolysisProperties"),
44  phiName_("phi"),
45  rhoName_("rho")
46 {}
47 
48 
51 (
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
59  filmRegionName_(ptf.filmRegionName_),
60  pyrolysisRegionName_(ptf.pyrolysisRegionName_),
61  phiName_(ptf.phiName_),
62  rhoName_(ptf.rhoName_)
63 {}
64 
65 
68 (
69  const fvPatch& p,
71  const dictionary& dict
72 )
73 :
74  fixedValueFvPatchVectorField(p, iF, dict),
75  filmRegionName_
76  (
77  dict.lookupOrDefault<word>("filmRegion", "surfaceFilmProperties")
78  ),
79  pyrolysisRegionName_
80  (
81  dict.lookupOrDefault<word>("pyrolysisRegion", "pyrolysisProperties")
82  ),
83  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
84  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
85 {}
86 
87 
90 (
92 )
93 :
94  fixedValueFvPatchVectorField(fpvpvf),
95  filmRegionName_(fpvpvf.filmRegionName_),
96  pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_),
97  phiName_(fpvpvf.phiName_),
98  rhoName_(fpvpvf.rhoName_)
99 {}
100 
101 
104 (
107 )
108 :
109  fixedValueFvPatchVectorField(fpvpvf, iF),
110  filmRegionName_(fpvpvf.filmRegionName_),
111  pyrolysisRegionName_(fpvpvf.pyrolysisRegionName_),
112  phiName_(fpvpvf.phiName_),
113  rhoName_(fpvpvf.rhoName_)
114 {}
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 
120 {
121  if (updated())
122  {
123  return;
124  }
125 
128 
129  // Since we're inside initEvaluate/evaluate there might be processor
130  // comms underway. Change the tag we use.
131  int oldTag = UPstream::msgType();
132  UPstream::msgType() = oldTag+1;
133 
134  bool foundFilm = db().time().foundObject<filmModelType>(filmRegionName_);
135 
136  bool foundPyrolysis =
137  db().time().foundObject<pyrModelType>(pyrolysisRegionName_);
138 
139  if (!foundFilm || !foundPyrolysis)
140  {
141  // Do nothing on construction - film model doesn't exist yet
142  return;
143  }
144 
145  vectorField& Up = *this;
146 
147  const label patchi = patch().index();
148 
149  // Retrieve film model
150  const filmModelType& filmModel =
151  db().time().lookupObject<filmModelType>(filmRegionName_);
152 
153  const label filmPatchi = filmModel.regionPatchID(patchi);
154 
155  scalarField alphaFilm = filmModel.alpha().boundaryField()[filmPatchi];
156  filmModel.toPrimary(filmPatchi, alphaFilm);
157 
158  vectorField UFilm = filmModel.Us().boundaryField()[filmPatchi];
159  filmModel.toPrimary(filmPatchi, UFilm);
160 
161  // Retrieve pyrolysis model
162  const pyrModelType& pyrModel =
163  db().time().lookupObject<pyrModelType>(pyrolysisRegionName_);
164 
165  const label pyrPatchi = pyrModel.regionPatchID(patchi);
166 
167  scalarField phiPyr = pyrModel.phiGas().boundaryField()[pyrPatchi];
168  pyrModel.toPrimary(pyrPatchi, phiPyr);
169 
170 
171  const surfaceScalarField& phi =
172  db().lookupObject<surfaceScalarField>(phiName_);
173 
174  if (phi.dimensions() == dimVelocity*dimArea)
175  {}
176  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
177  {
178  const fvPatchField<scalar>& rhop =
179  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
180  phiPyr /= rhop;
181  }
182  else
183  {
185  << "Unable to process flux field phi with dimensions "
186  << phi.dimensions() << nl
187  << " on patch " << patch().name()
188  << " of field " << internalField().name()
189  << " in file " << internalField().objectPath()
190  << exit(FatalError);
191  }
192 
193  const scalarField UAvePyr(-phiPyr/patch().magSf());
194  const vectorField& nf = patch().nf();
195 
196 
197  // Evaluate velocity
198  Up = alphaFilm*UFilm + (1.0 - alphaFilm)*UAvePyr*nf;
199 
200  // Restore tag
201  UPstream::msgType() = oldTag;
202 
203  fixedValueFvPatchVectorField::updateCoeffs();
204 }
205 
206 
208 (
209  Ostream& os
210 ) const
211 {
213  writeEntryIfDifferent<word>
214  (
215  os,
216  "filmRegion",
217  "surfaceFilmProperties",
218  filmRegionName_
219  );
220  writeEntryIfDifferent<word>
221  (
222  os,
223  "pyrolysisRegion",
224  "pyrolysisProperties",
225  pyrolysisRegionName_
226  );
227  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
228  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
229  writeEntry("value", os);
230 }
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 namespace Foam
236 {
238  (
241  );
242 }
243 
244 
245 // ************************************************************************* //
Foam::surfaceFields.
surfaceScalarField & phi
This boundary condition is designed to be used in conjunction with surface film and pyrolysis modelli...
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:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:465
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:362
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
const dimensionSet & dimensions() const
Return dimensions.
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
filmPyrolysisVelocityCoupledFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
const dimensionSet dimDensity
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
label patchi
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Namespace for OpenFOAM.
const dimensionSet dimVelocity