CloudLagrangianFieldSource.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 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 Type>
34 template<class Derived>
36 (
37  const Derived& field
38 )
39 :
40  field_(static_cast<const LagrangianFieldSource<Type>&>(field)),
41  cloud_(field_.db().template lookupType<Foam::cloud>())
42 {}
43 
44 
45 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
46 
47 template<class Type>
48 template<class Cloud, class ... Clouds>
50 {
52 }
53 
54 
55 template<class Type>
56 template<class Cloud, class ... Clouds>
58 (
59  const LagrangianModel& model,
60  const LagrangianSubMesh& subMesh
61 ) const
62 {
63  if (!isCloud<Cloud, Clouds ...>())
64  {
66  << "The '" << field_.type() << "' source of field '"
67  << (field_.db().dbDir()/field_.internalField().name()).c_str()
68  << "' for the '" << model.type() << "' Lagrangian model '"
69  << model.name() << "' of cloud '" << cloud_.mesh().name()
70  << "' requires a cloud of type "
72  << " (or a derivation thereof), rather than '" << cloud_.type()
73  << "'" << exit(FatalError);
74  }
75 }
76 
77 
78 template<class LagrangianFieldSource>
79 template<class Cloud>
81 (
82  const LagrangianModel& model,
83  const LagrangianSubMesh& subMesh
84 ) const
85 {
86  assertCloud<Cloud>(model, subMesh);
87  return refCast<const Cloud>(cloud_);
88 }
89 
90 
91 // ************************************************************************* //
Struct to aid casting of the cloud to a derived type.
const Cloud & cloud(const LagrangianModel &model, const LagrangianSubMesh &subMesh) const
Get a reference to the cloud.
bool isCloud() const
Determine whether the cloud is one of the given types.
void assertCloud(const LagrangianModel &model, const LagrangianSubMesh &subMesh) 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.
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.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:63
#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:171
error FatalError