LESdelta.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-2015 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "LESdelta.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(LESdelta, 0);
37  defineRunTimeSelectionTable(LESdelta, dictionary);
38 }
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  const word& name,
46 )
47 :
48  turbulenceModel_(turbulence),
49  delta_
50  (
51  IOobject
52  (
53  name,
54  turbulence.mesh().time().timeName(),
55  turbulence.mesh(),
56  IOobject::NO_READ,
57  IOobject::NO_WRITE
58  ),
59  turbulence.mesh(),
61  calculatedFvPatchScalarField::typeName
62  )
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
67 
69 (
70  const word& name,
72  const dictionary& dict,
73  const word& lookupName
74 )
75 {
76  const word deltaType(dict.get<word>(lookupName));
77 
78  Info<< "Selecting LES " << lookupName << " type " << deltaType << endl;
79 
80  auto* ctorPtr = dictionaryConstructorTable(deltaType);
81 
82  if (!ctorPtr)
83  {
85  (
86  dict,
87  "LESdelta",
88  deltaType,
89  *dictionaryConstructorTablePtr_
90  ) << exit(FatalIOError);
91  }
92 
93  return autoPtr<LESdelta>(ctorPtr(name, turbulence, dict));
94 }
95 
96 
98 (
99  const word& name,
101  const dictionary& dict,
102  const dictionaryConstructorTableType& additionalConstructors,
103  const word& lookupName
104 )
105 {
106  const word deltaType(dict.get<word>(lookupName));
107 
108  Info<< "Selecting LES " << lookupName << " type " << deltaType << endl;
109 
110  // First any additional ones
111  {
112  auto ctorIter = additionalConstructors.cfind(deltaType);
113 
114  if (ctorIter.found())
115  {
116  return autoPtr<LESdelta>(ctorIter.val()(name, turbulence, dict));
117  }
118  }
119 
120  auto* ctorPtr = dictionaryConstructorTable(deltaType);
121 
122  if (!ctorPtr)
123  {
125  (
126  dict,
127  "LESdelta",
128  deltaType,
129  *dictionaryConstructorTablePtr_
130  );
131 
132  if (!additionalConstructors.empty())
133  {
135  << " and " << additionalConstructors.sortedToc() << nl;
136  }
137 
139  << exit(FatalIOError);
140  }
141 
142  return autoPtr<LESdelta>(ctorPtr(name, turbulence, dict));
143 }
144 
145 
146 // ************************************************************************* //
Foam::LESdelta::New
static autoPtr< LESdelta > New(const word &name, const turbulenceModel &turbulence, const dictionary &dict, const word &lookupName="delta")
Return a reference to the selected LES delta.
Definition: LESdelta.C:69
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
turbulence
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar("pos", dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar("neg", dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\n"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
calculatedFvPatchFields.H
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::LESdelta::LESdelta
LESdelta(const LESdelta &)=delete
No copy construct.
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:63
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
LESdelta.H
Foam::autoPtr< Foam::LESdelta >
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)