volumeBlockage.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019-2026 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 
26 #include "volumeBlockage.H"
27 #include "fvmDiv.H"
28 #include "fvmLaplacian.H"
29 #include "fvcDiv.H"
30 #include "surfaceInterpolate.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace fv
39 {
43  (
44  fvModel,
46  dictionary,
47  volumeFractionSource,
48  "volumeFractionSource"
49  );
50 }
51 }
52 
53 
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 
56 void Foam::fv::volumeBlockage::readCoeffs(const dictionary& dict)
57 {
58  phiName_ = dict.lookupOrDefault<word>("phi", "phi");
59  rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
60  UName_ = dict.lookupOrDefault<word>("U", "U");
61 
62  volumePhaseName_ = dict.lookup<word>("volumePhase");
63 }
64 
65 
66 const Foam::volScalarField& Foam::fv::volumeBlockage::volumeAlpha() const
67 {
68  const word alphaName = IOobject::groupName("alpha", volumePhaseName_);
69 
70  if (!mesh().foundObject<volScalarField>(alphaName))
71  {
72  volScalarField* alphaPtr =
73  new volScalarField
74  (
75  IOobject
76  (
77  alphaName,
78  mesh().time().constant(),
79  mesh(),
82  ),
83  mesh(),
84  dimless
85  );
86 
87  alphaPtr->store();
88  }
89 
90  return mesh().lookupObject<volScalarField>(alphaName);
91 }
92 
93 
94 Foam::tmp<Foam::volScalarField> Foam::fv::volumeBlockage::D
95 (
96  const word& fieldName
97 ) const
98 {
99  const word phiName =
100  IOobject::groupName(phiName_, IOobject::group(fieldName));
101  const surfaceScalarField& phi =
103 
104  if (phi.dimensions() == dimVolume/dimTime)
105  {
108 
109  return turbulence.nuEff();
110  }
111  else if (phi.dimensions() == dimMass/dimTime)
112  {
113  const fluidThermophysicalTransportModel& ttm =
114  mesh().lookupType<fluidThermophysicalTransportModel>();
115 
116  return
117  fieldName == ttm.thermo().T().name()
118  ? ttm.kappaEff()
119  : fieldName == ttm.thermo().he().name()
120  ? ttm.kappaEff()/ttm.thermo().Cpv()
121  : ttm.momentumTransport().rho()*ttm.momentumTransport().nuEff();
122  }
123  else
124  {
126  << "Dimensions of " << phi.name() << " not recognised"
127  << exit(FatalError);
128 
129  return tmp<volScalarField>(nullptr);
130  }
131 }
132 
133 
134 template <class Type, class AlphaFieldType>
135 void Foam::fv::volumeBlockage::addGeneralSupType
136 (
137  const AlphaFieldType& alpha,
138  fvMatrix<Type>& eqn
139 ) const
140 {
141  const word phiName =
142  IOobject::groupName(phiName_, IOobject::group(eqn.psi().name()));
143  const surfaceScalarField& phi =
145 
146  const volScalarField B(1 - volumeAlpha());
147  const volScalarField AByB(volumeAlpha()/B);
148  const volScalarField D(this->D(eqn.psi().name()));
149 
150  // Divergence term
151  const word divScheme = "div(" + phiName + "," + eqn.psi().name() + ")";
152  eqn -= AByB*fvm::div(phi, eqn.psi(), divScheme);
153 
154  // Laplacian term
155  const word laplacianScheme =
156  "laplacian(" + D.name() + "," + eqn.psi().name() + ")";
157  eqn +=
158  fvm::laplacian(D, eqn.psi())
159  - 1/B*fvm::laplacian(B*D, eqn.psi(), laplacianScheme);
160 }
161 
162 
163 template<class Type, class AlphaFieldType>
164 void Foam::fv::volumeBlockage::addAlphaSupType
165 (
166  const AlphaFieldType& alpha,
167  const VolField<Type>& field,
168  fvMatrix<Type>& eqn
169 ) const
170 {
171  addGeneralSupType(alpha, eqn);
172 }
173 
174 
175 template<class AlphaFieldType>
176 void Foam::fv::volumeBlockage::addAlphaSupType
177 (
178  const AlphaFieldType& alpha,
179  const volScalarField& field,
180  fvMatrix<scalar>& eqn
181 ) const
182 {
183  if (IOobject::member(field.name()) == rhoName_)
184  {
185  const word phiName =
186  IOobject::groupName(phiName_, IOobject::group(field.name()));
187  const surfaceScalarField& phi =
189 
190  const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha()));
191 
192  eqn -= AByB*fvc::div(phi);
193  }
194  else
195  {
196  addGeneralSupType(alpha, eqn);
197  }
198 }
199 
200 
201 template<class AlphaFieldType>
202 void Foam::fv::volumeBlockage::addAlphaSupType
203 (
204  const AlphaFieldType& alpha,
205  const volVectorField& field,
206  fvMatrix<vector>& eqn
207 ) const
208 {
209  if (IOobject::member(field.name()) == UName_)
210  {
211  const word phiName =
212  IOobject::groupName(phiName_, IOobject::group(field.name()));
213  const surfaceScalarField& phi =
215 
216  const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha()));
217 
218  const word scheme("div(" + phiName + "," + eqn.psi().name() + ")");
219 
220  eqn -= fvm::div(fvc::interpolate(AByB)*phi, eqn.psi(), scheme);
221  }
222  else
223  {
224  addGeneralSupType(alpha, eqn);
225  }
226 }
227 
228 
229 template<class Type>
230 void Foam::fv::volumeBlockage::addSupType
231 (
232  const VolField<Type>& field,
233  fvMatrix<Type>& eqn
234 ) const
235 {
236  addAlphaSupType(geometricOneField(), field, eqn);
237 }
238 
239 
240 template<class Type>
241 void Foam::fv::volumeBlockage::addSupType
242 (
243  const volScalarField& rho,
244  const VolField<Type>& field,
245  fvMatrix<Type>& eqn
246 ) const
247 {
248  addAlphaSupType(geometricOneField(), field, eqn);
249 }
250 
251 
252 template<class Type>
253 void Foam::fv::volumeBlockage::addSupType
254 (
255  const volScalarField& alpha,
256  const volScalarField& rho,
257  const VolField<Type>& field,
258  fvMatrix<Type>& eqn
259 ) const
260 {
261  addAlphaSupType(alpha, field, eqn);
262 }
263 
264 
265 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
266 
268 (
269  const word& name,
270  const word& modelType,
271  const fvMesh& mesh,
272  const dictionary& dict
273 )
274 :
275  fvModel(name, modelType, mesh, dict),
276  phiName_(word::null),
277  rhoName_(word::null),
278  UName_(word::null),
279  volumePhaseName_(word::null)
280 {
281  readCoeffs(coeffs(dict));
282  volumeAlpha();
283 }
284 
285 
286 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
287 
289 {}
290 
291 
292 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
293 
294 bool Foam::fv::volumeBlockage::addsSupToField(const word& fieldName) const
295 {
296  return true;
297 }
298 
299 
301 {
302  return wordList();
303 }
304 
305 
307 
308 
310 
311 
313 (
315  fv::volumeBlockage
316 )
317 
318 
319 bool Foam::fv::volumeBlockage::movePoints()
320 {
321  return true;
322 }
323 
324 
326 {}
327 
328 
330 {}
331 
332 
334 {}
335 
336 
338 {
339  if (fvModel::read(dict))
340  {
341  readCoeffs(coeffs(dict));
342  return true;
343  }
344  else
345  {
346  return false;
347  }
348 }
349 
350 
351 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
word group() const
Return group (extension part of name)
Definition: IOobject.C:321
word member() const
Return member (name without the extension)
Definition: IOobject.C:327
static word groupName(Name name, const word &group)
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:196
This fvModel adds transport terms into the equations to account for the presence of a constant volume...
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
volumeBlockage(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
virtual ~volumeBlockage()
Destructor.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
const Type & lookupType(const word &group=word::null) const
Lookup and return the object of the given Type.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
#define IMPLEMENT_FV_MODEL_ADD_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:33
#define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:71
#define IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:51
Calculate the divergence of the given field.
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for the laplacian of the field.
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
compressibleMomentumTransportModel momentumTransportModel
const dimensionSet dimless
const dimensionSet time
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
addBackwardCompatibleToRunTimeSelectionTable(fvConstraint, fixedTemperature, dictionary, fixedTemperatureConstraint, "fixedTemperatureConstraint")
static tmp< surfaceInterpolationScheme< Type > > scheme(const surfaceScalarField &faceFlux, Istream &schemeData)
Return weighting factors for scheme given from Istream.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
static const coefficient D("D", dimTemperature, 257.14)
static const coefficient B("B", dimless, 18.678)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
List< word > wordList
A List of words.
Definition: fileName.H:54
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
const dimensionSet & dimMass
Definition: dimensions.C:275
SurfaceField< scalar > surfaceScalarField
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
const dimensionSet & dimVolume
Definition: dimensions.C:282
const dimensionSet & dimTime
Definition: dimensions.C:277
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
labelList fv(nPoints)
dictionary dict
autoPtr< incompressible::momentumTransportModel > turbulence(incompressible::momentumTransportModel::New(U, phi, viscosity))