laminarModel.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) 2016-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 "laminarModel.H"
27 #include "Stokes.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class BasicMomentumTransportModel>
33 (
34  const word& type,
35  const alphaField& alpha,
36  const rhoField& rho,
37  const volVectorField& U,
38  const surfaceScalarField& alphaRhoPhi,
39  const surfaceScalarField& phi,
40  const viscosity& viscosity
41 )
42 :
43  BasicMomentumTransportModel
44  (
45  type,
46  alpha,
47  rho,
48  U,
49  alphaRhoPhi,
50  phi,
51  viscosity
52  )
53 {
54  // Force the construction of the mesh deltaCoeffs which may be needed
55  // for the construction of the derived models and BCs
56  this->mesh_.deltaCoeffs();
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
61 
62 template<class BasicMomentumTransportModel>
65 (
66  const alphaField& alpha,
67  const rhoField& rho,
68  const volVectorField& U,
69  const surfaceScalarField& alphaRhoPhi,
70  const surfaceScalarField& phi,
71  const viscosity& viscosity
72 )
73 {
74  const IOdictionary dict
75  (
77  (
78  U.db(),
79  alphaRhoPhi.group()
80  )
81  );
82 
83  if (dict.found("laminar"))
84  {
85  const dictionary& laminarDict(dict.subDict("laminar"));
86 
87  const word modelType = laminarDict.lookupBackwardsCompatible<word>
88  (
89  {"model", "laminarModel"}
90  );
91 
93  << "Selecting laminar stress model " << modelType << endl;
94 
95  libs.open(laminarDict, "libs", dictionaryConstructorTablePtr_);
96 
97  typename dictionaryConstructorTable::iterator cstrIter =
98  dictionaryConstructorTablePtr_->find(modelType);
99 
100  if (cstrIter == dictionaryConstructorTablePtr_->end())
101  {
103  << "Unknown laminarModel type "
104  << modelType << nl << nl
105  << "Valid laminarModel types:" << endl
106  << dictionaryConstructorTablePtr_->sortedToc()
107  << exit(FatalError);
108  }
109 
110  printDictionary print(laminarDict.name());
111  return cstrIter()
112  (
113  alpha,
114  rho,
115  U,
116  alphaRhoPhi,
117  phi,
118  viscosity
119  );
120  }
121  else
122  {
123  Info<< indentOrNl
124  << "Selecting laminar stress model "
126  << endl;
127 
128  printDictionary print(dict.name());
129  return autoPtr<laminarModel>
130  (
132  (
133  alpha,
134  rho,
135  U,
136  alphaRhoPhi,
137  phi,
138  viscosity
139  )
140  );
141  }
142 }
143 
144 
145 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 
147 template<class BasicMomentumTransportModel>
148 const Foam::dictionary&
150 {
151  return this->subDict("laminar");
152 }
153 
154 
155 template<class BasicMomentumTransportModel>
156 const Foam::dictionary&
158 {
159  return typeDict(this->type());
160 }
161 
162 
163 template<class BasicMomentumTransportModel>
164 const Foam::dictionary&
166 (
167  const word& type
168 ) const
169 {
170  return this->laminarDict().optionalTypeDict(type);
171 }
172 
173 
174 template<class BasicMomentumTransportModel>
176 {
178  {
179  return true;
180  }
181  else
182  {
183  return false;
184  }
185 }
186 
187 
188 template<class BasicMomentumTransportModel>
191 {
192  return volScalarField::New
193  (
194  this->groupName("nut"),
195  this->mesh_,
197  );
198 }
199 
200 
201 template<class BasicMomentumTransportModel>
204 (
205  const label patchi
206 ) const
207 {
208  return tmp<scalarField>
209  (
210  new scalarField(this->mesh_.boundary()[patchi].size(), 0.0)
211  );
212 }
213 
214 
215 template<class BasicMomentumTransportModel>
218 {
219  return volScalarField::New
220  (
221  this->groupName("k"),
222  this->mesh_,
224  );
225 }
226 
227 
228 template<class BasicMomentumTransportModel>
231 {
232  return volScalarField::New
233  (
234  this->groupName("epsilon"),
235  this->mesh_,
237  );
238 }
239 
240 
241 template<class BasicMomentumTransportModel>
244 {
245  return volScalarField::New
246  (
247  this->groupName("omega"),
248  this->mesh_,
250  );
251 }
252 
253 
254 template<class BasicMomentumTransportModel>
257 {
259  (
260  this->groupName("sigma"),
261  this->mesh_,
262  dimensionedSymmTensor(sqr(this->U_.dimensions()), Zero)
263  );
264 }
265 
266 
267 template<class BasicMomentumTransportModel>
269 {
270  BasicMomentumTransportModel::predict();
271 }
272 
273 
274 template<class BasicMomentumTransportModel>
276 {
278 }
279 
280 
281 // ************************************************************************* //
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:131
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:111
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:778
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
Definition: dictionary.C:680
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:468
const dictionary & optionalTypeDict(const word &typeName) const
Find and return an optional type sub-dictionary.
Definition: dictionary.C:921
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
BasicMomentumTransportModel::alphaField alphaField
Definition: laminarModel.H:70
virtual tmp< volScalarField > epsilon() const
Return the turbulence kinetic energy dissipation rate,.
Definition: laminarModel.C:230
virtual tmp< volSymmTensorField > R() const
Return the Reynolds stress tensor [m^2/s^2], i.e. 0 for laminar flow.
Definition: laminarModel.C:256
static autoPtr< laminarModel > New(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity)
Return a reference to the selected laminar model.
Definition: laminarModel.C:65
virtual void correct()
Predict the laminar viscosity.
Definition: laminarModel.C:275
virtual tmp< volScalarField > k() const
Return the turbulence kinetic energy, i.e. 0 for laminar flow.
Definition: laminarModel.C:217
const dictionary & laminarDict() const
Const access to the laminar dictionary.
Definition: laminarModel.C:149
virtual void predict()
Predict the laminar viscosity.
Definition: laminarModel.C:268
laminarModel(const word &type, const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity)
Construct from components.
Definition: laminarModel.C:33
const dictionary & typeDict() const
Const access to the coefficients dictionary.
Definition: laminarModel.C:157
virtual tmp< volScalarField > nut() const
Return the turbulence viscosity, i.e. 0 for laminar flow.
Definition: laminarModel.C:190
virtual tmp< volScalarField > omega() const
Return the turbulence specific dissipation rate,.
Definition: laminarModel.C:243
virtual bool read()
Read model coefficients if they have changed.
Definition: laminarModel.C:175
BasicMomentumTransportModel::rhoField rhoField
Definition: laminarModel.H:71
Momentum transport model for Stokes flow.
Definition: Stokes.H:59
static typeIOobject< IOdictionary > readModelDict(const objectRegistry &obr, const word &group, bool registerObject=false)
Enables the printing of a dictionary and subsequently looked-up defaulted entries.
A class for managing temporary objects.
Definition: tmp.H:55
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp)
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dlLibraryTable libs
Table of loaded dynamic libraries.
static const zero Zero
Definition: zero.H:97
const dimensionSet & dimless
Definition: dimensions.C:138
const dimensionSet & dimKinematicViscosity
Definition: dimensions.C:171
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimVelocity
Definition: dimensions.C:154
const dimensionSet & dimTime
Definition: dimensions.C:142
dimensioned< symmTensor > dimensionedSymmTensor
Dimensioned tensor obtained from generic dimensioned type.
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250
error FatalError
static const char nl
Definition: Ostream.H:297
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.name(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Creating face flux\n"<< endl;surfaceScalarField phi(IOobject("phi", runTime.name(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(mesh.Sf().dimensions() *U.dimensions(), 0));autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))