coupled.H
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 Class
25  Foam::clouds::coupled
26 
27 Description
28  Base class for clouds which are coupled to a fluid
29 
30 SourceFiles
31  coupled.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef coupled_H
36 #define coupled_H
37 
38 #include "cloud.H"
39 #include "PtrDictionary.H"
40 #include "volFieldsFwd.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 template<class Type>
48 class CarrierField;
49 
50 template<class Type>
51 class CarrierEqn;
52 
53 namespace clouds
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class coupled Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class coupled
61 {
62 private:
63 
64  // Private Data
65 
66  //- Carrier fields
67  #define DECLARE_CARRIER_FIELDS(Type, nullArg) \
68  mutable PtrDictionary<CarrierField<Type>> \
69  CAT3(carrier, CAPITALIZE(Type), Fields_);
70  FOR_ALL_FIELD_TYPES(DECLARE_CARRIER_FIELDS);
71  #undef DECLARE_CARRIER_FIELDS
72 
73  //- Carrier equations
74  #define DECLARE_CARRIER_EQNS(Type, nullArg) \
75  mutable PtrDictionary<CarrierEqn<Type>> \
76  CAT3(carrier, CAPITALIZE(Type), Eqns_);
77  FOR_ALL_FIELD_TYPES(DECLARE_CARRIER_EQNS);
78  #undef DECLARE_CARRIER_EQNS
79 
80  //- Carrier velocity time derivative
81  mutable autoPtr<volVectorField> dUdtcPtr_;
82 
83 
84  // Private Member Functions
85 
86  //- Calculate the carrier kinematic viscosity
87  virtual tmp<LagrangianSubScalarField> calcNuc
88  (
89  const LagrangianModelRef& model,
90  const LagrangianSubMesh& subMesh
91  ) const = 0;
92 
93  //- Access the carrier fields. Only specialisations are defined.
94  template<class Type>
95  PtrDictionary<CarrierField<Type>>& carrierFields() const;
96 
97  //- Clear the carrier fields
98  void clearCarrierFields();
99 
100  //- Reset the carrier fields
101  void resetCarrierFields(const bool predict);
102 
103  //- Access the carrier equations. Only specialisations are defined.
104  template<class Type>
105  PtrDictionary<CarrierEqn<Type>>& carrierEqns() const;
106 
107  //- Read the carrier velocity time derivative
108  autoPtr<volVectorField> readDUdtc(const cloud& c) const;
109 
110  //- Access the carrier velocity time derivative
111  const volVectorField& dUdtc() const;
112 
113 
114 protected:
115 
116  // Protected Member Functions
117 
118  //- Clear the carrier equations
119  void clearCarrierEqns();
120 
121  //- Initialisation hook
122  void initialise(const bool predict);
123 
124  //- Partition hook
125  void partition();
126 
127 
128 public:
129 
130  // Public Static Data
131 
132  //- Run-time type information
133  TypeName("coupled");
134 
135 
136  // Public Data
137 
138  //- Carrier velocity
139  const CarrierField<vector>& Uc;
140 
141  //- Carrier velocity curl
143 
144  //- Carrier advective derivative
146 
147  //- Carrier kinematic viscosity
149 
150 
151  // Constructors
152 
153  //- Construct from a reference to the cloud
154  coupled(const cloud& c);
155 
156 
157  //- Destructor
158  virtual ~coupled();
159 
160 
161  // Member Functions
162 
163  //- Modify a name to disambiguate it as relating to the carrier
164  static word carrierName(const word& name);
165 
166 
167  // Fields
168 
169  //- Add/get a carrier field to/from the cache
170  template<class Type>
171  const CarrierField<Type>& carrierField(const VolField<Type>&) const;
172 
173  //- Add/get a carrier field to/from the cache
174  template<class Type, class ... Args>
175  const CarrierField<Type>& carrierField(const Args& ... args) const;
176 
177  //- Add/get a carrier equation to/from the cache
178  template<class Type>
180 
181  //- Add/get a carrier equation to/from the cache
182  template<class Type>
183  const CarrierEqn<Type>& carrierEqn(const VolField<Type>&) const;
184 
185  //- Add/get a carrier equation to/from the cache
186  template<class Type>
188 
189  //- Add/get a carrier equation to/from the cache
190  template<class Type>
191  const CarrierEqn<Type>& carrierEqn(const CarrierField<Type>&) const;
192 };
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace clouds
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #ifdef NoRepository
202  #include "coupledTemplates.C"
203 #endif
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
Class to store the coefficients of a term in a carrier equation.
Definition: CarrierEqn.H:52
A field interpolated from the carrier to the cloud. Uses CloudDerivedField to provide flexible access...
Definition: CarrierField.H:57
Generic GeometricField class.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:63
Base class for clouds which are coupled to a fluid.
Definition: coupled.H:60
CarrierEqn< Type > & carrierEqn(const VolField< Type > &)
Add/get a carrier equation to/from the cache.
void initialise(const bool predict)
Initialisation hook.
Definition: coupled.C:188
const CarrierField< Type > & carrierField(const VolField< Type > &) const
Add/get a carrier field to/from the cache.
const CarrierField< vector > & DUDtc
Carrier advective derivative.
Definition: coupled.H:144
TypeName("coupled")
Run-time type information.
static word carrierName(const word &name)
Modify a name to disambiguate it as relating to the carrier.
Definition: coupled.C:246
coupled(const cloud &c)
Construct from a reference to the cloud.
Definition: coupled.C:202
void clearCarrierEqns()
Clear the carrier equations.
Definition: coupled.C:171
const CloudDerivedField< scalar > & nuc
Carrier kinematic viscosity.
Definition: coupled.H:147
const CarrierField< vector > & Uc
Carrier velocity.
Definition: coupled.H:138
void partition()
Partition hook.
Definition: coupled.C:194
virtual ~coupled()
Destructor.
Definition: coupled.C:240
const CarrierField< vector > & curlUc
Carrier velocity curl.
Definition: coupled.H:141
A class for handling words, derived from string.
Definition: word.H:62
#define DECLARE_CARRIER_EQNS(Type, nullArg)
Carrier equations.
Definition: coupled.H:73
#define DECLARE_CARRIER_FIELDS(Type, nullArg)
Carrier fields.
Definition: coupled.H:66
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Foam::argList args(argc, argv)