cloudLagrangianFieldSourceTemplates.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) 2025-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 
27 #include "LagrangianModel.H"
28 #include "cloud.H"
29 #include "CloudTypes.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Derived>
35 (
36  const Derived& field
37 )
38 :
39  field_(static_cast<const LagrangianFieldSourceBase&>(field)),
40  cloud_
41  (
42  field_.db().template foundType<Foam::cloud>()
43  ? field_.db().template lookupType<Foam::cloud>()
45  )
46 {}
47 
48 
49 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
50 
51 template<class Cloud, class ... Clouds>
53 {
54  if (isNull(cloud_))
55  {
56  return false;
57  }
58  else
59  {
61  }
62 }
63 
64 
65 template<class Cloud, class ... Clouds>
67 {
68  if (!isCloud<Cloud, Clouds ...>())
69  {
71  << "The '" << field_.type() << "' source of field '"
72  << (field_.db().dbDir()/field_.internalName()).c_str()
73  << "' of cloud '" << cloud_.mesh().name()
74  << "' requires a cloud of type "
76  << " (or a derivation thereof), rather than '" << cloud_.type()
77  << "'" << exit(FatalError);
78  }
79 }
80 
81 
82 template<class Cloud, class ... Clouds>
84 (
85  const LagrangianModel& model
86 ) const
87 {
88  if (!isCloud<Cloud, Clouds ...>())
89  {
91  << "The '" << field_.type() << "' source of field '"
92  << (field_.db().dbDir()/field_.internalName()).c_str()
93  << "' for the '" << model.type() << "' Lagrangian model '"
94  << model.name() << "' of cloud '" << cloud_.mesh().name()
95  << "' requires a cloud of type "
97  << " (or a derivation thereof), rather than '" << cloud_.type()
98  << "'" << exit(FatalError);
99  }
100 }
101 
102 
103 template<class Cloud>
105 {
106  assertCloud<Cloud>();
107 
108  return refCast<const Cloud>(cloud_);
109 }
110 
111 
112 template<class Cloud>
114 (
115  const LagrangianModel& model
116 ) const
117 {
118  assertCloud<Cloud>(model);
119 
120  return refCast<const Cloud>(cloud_);
121 }
122 
123 
124 // ************************************************************************* //
Struct to aid casting of the cloud to a derived type.
Base cloud calls templated on particle type.
Base class for Lagrangian source conditions.
Base class for Lagrangian models.
const word & name() const
The source name.
void assertCloud() const
Generate an error if the cloud is not one of the given types.
cloudLagrangianFieldSource(const Derived &)
Construct with reference to the derived field source.
bool isCloud() const
Determine whether the cloud is one of the given types.
const Cloud & cloud() const
Get a reference to the cloud.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
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
const T & NullObjectRef()
Return const reference to the nullObject of type T.
Definition: nullObjectI.H:27
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:58
error FatalError