thermalTemplates.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) 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 "thermal.H"
27 #include "CloudTypes.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Thermo>
33 (
34  const cloud& c,
35  const shaped& shapedCloud,
36  const carried& carriedCloud
37 )
38 :
39  thermal(c, shapedCloud, Thermo::New(c.mesh()).ptr())
40 {}
41 
42 
43 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
44 
45 template<class Thermo, class ... Thermos>
47 {
48  return CloudTypes<Thermo, Thermos ...>::isA(autoPtr::operator()());
49 }
50 
51 
52 template<class Thermo, class ... Thermos>
54 {
55  if (!isThermo<Thermo, Thermos ...>())
56  {
58  << "The cloud '"
59  << cloud_.mesh().name() << "' requires a thermodynamic model "
60  << "derived from "
62  << ", rather than '" << autoPtr::operator()().type()
63  << "'" << exit(FatalError);
64  }
65 }
66 
67 
68 template<class Thermo, class ... Thermos>
70 {
71  if (!isThermo<Thermo, Thermos ...>())
72  {
74  << "The Lagrangian model '" << model.name() << "' of cloud '"
75  << cloud_.mesh().name() << "' requires a thermodynamic model "
76  << "derived from "
78  << ", rather than '" << autoPtr::operator()().type()
79  << "'" << exit(FatalError);
80  }
81 }
82 
83 
84 template<class Thermo, class ... Args>
85 const Thermo& Foam::clouds::thermal::thermo(const Args& ... args) const
86 {
87  assertThermo<Thermo>(args ...);
88  return refCast<const Thermo>(autoPtr::operator()());
89 }
90 
91 
92 template<class Thermo, class ... Args>
93 Thermo& Foam::clouds::thermal::thermo(const Args& ... args)
94 {
95  assertThermo<Thermo>(args ...);
96  return refCast<Thermo>(autoPtr::operator()());
97 }
98 
99 
100 // ************************************************************************* //
Struct to aid casting of the cloud to a derived type.
Base class for Lagrangian models.
const word & name() const
The source name.
T & operator()()
Return reference to the object data.
Definition: autoPtrI.H:151
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
Base class for clouds which are carried by a fluid.
Definition: carried.H:57
Base class for clouds with particles with mass.
Definition: shaped.H:51
Base class for clouds with thermodynamic modelling.
Definition: thermal.H:56
friend class Thermal
Declare friendship with templated derivation.
Definition: thermal.H:76
bool isThermo() const
Determine whether the thermo model is one of the given types.
const Thermo & thermo(const Args &... args) const
Get a reference to the thermodynamic model of a given type.
void assertThermo() const
Generate an error if the thermo model is not one of the given types.
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
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:178
error FatalError
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
Foam::argList args(argc, argv)