momentumTransportModelTemplates.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) 2021-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 "momentumTransportModel.H"
27 #include "printDictionary.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 template<class MomentumTransportModel>
33 (
34  const typename MomentumTransportModel::alphaField& alpha,
35  const typename MomentumTransportModel::rhoField& rho,
36  const volVectorField& U,
37  const surfaceScalarField& alphaRhoPhi,
38  const surfaceScalarField& phi,
39  const viscosity& viscosity
40 )
41 {
42  IOobject modelDictIO =
44  (
45  U.db(),
47  );
48 
49  const word modelType =
50  IOdictionary(modelDictIO).lookup<word>("simulationType");
51 
52  Info<< indentOrNl << "Selecting momentum transport model type "
53  << modelType << endl;
54 
55  typename MomentumTransportModel::dictionaryConstructorTable::iterator
56  cstrIter =
57  MomentumTransportModel::dictionaryConstructorTablePtr_->find(modelType);
58 
59  if
60  (
61  cstrIter
62  == MomentumTransportModel::dictionaryConstructorTablePtr_->end()
63  )
64  {
66  << "Unknown " << MomentumTransportModel::typeName << " type "
67  << modelType << nl << nl
68  << "Valid " << MomentumTransportModel::typeName << " types:" << endl
69  << MomentumTransportModel::dictionaryConstructorTablePtr_
70  ->sortedToc()
71  << exit(FatalError);
72  }
73 
74  printDictionary print(modelDictIO.objectPath(true));
75 
76  return cstrIter()(alpha, rho, U, alphaRhoPhi, phi, viscosity);
77 }
78 
79 
80 // ************************************************************************* //
Generic GeometricField class.
IOdictionary(const IOobject &io, const word &wantedType)
Construct given an IOobject, supply wanted typeName.
Definition: IOdictionary.C:47
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:309
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:131
fileName objectPath(const bool global) const
Return complete path + object name including the processor.
Definition: IOobject.H:411
const iterator & end()
Definition: UILList.H:223
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 volVectorField & U() const
Access function to velocity field.
static typeIOobject< IOdictionary > readModelDict(const objectRegistry &obr, const word &group, bool registerObject=false)
static autoPtr< MomentumTransportModel > New(const typename MomentumTransportModel::alphaField &alpha, const typename MomentumTransportModel::rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity)
virtual tmp< surfaceScalarField > phi() const
Return the volumetric flux field.
const surfaceScalarField & alphaRhoPhi() const
Access function to phase flux field.
Enables the printing of a dictionary and subsequently looked-up defaulted entries.
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
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))
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
messageStream Info
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
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))