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-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 Class
25  Foam::clouds::coupled
26 
27 Description
28  Base class for clouds which are coupled to a carrier
29 
30 SourceFiles
31  coupled.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef coupled_H
36 #define coupled_H
37 
38 #include "carried.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 template<class Type>
46 class CarrierEqn;
47 
48 namespace clouds
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class coupled Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class coupled
56 {
57 private:
58 
59  // Private Data
60 
61  //- Reference to the cloud
62  const cloud& cloud_;
63 
64  //- Reference to the carried cloud
65  const carried& carriedCloud_;
66 
67  //- Are any carrier equations cached?
68  mutable bool hasCarrierEqns_;
69 
70  //- Cached carrier kinematic viscosity field
71  tmp<volScalarField> tnucVf_;
72 
73  //- Carrier equations
74  #define DECLARE_CARRIER_EQNS(Type, nullArg) \
75  mutable HashPtrTable<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  //- Get the carrier kinematic viscosity field
87  tmp<volScalarField> getNucVf() const;
88 
89  //- Calculate the carrier kinematic viscosity
90  virtual tmp<LagrangianSubScalarField> calcNuc
91  (
92  const LagrangianModelRef& model,
93  const LagrangianSubMesh& subMesh
94  ) const;
95 
96  //- Access the carrier equations. Only specialisations are defined.
97  template<class Type>
98  HashPtrTable<CarrierEqn<Type>>& carrierEqns() const;
99 
100 
101 protected:
102 
103  // Protected Member Functions
104 
105  //- Update the cached carrier fields
106  void updateCarrier();
107 
108  //- Add/get a carrier equation to/from the cache
109  template<class Type>
111 
112  //- Add/get a carrier equation to/from the cache
113  template<class Type>
115 
116  //- Clear the carrier equations
117  void clearCarrierEqns();
118 
119  //- Do we need to re-calculate particles that are modified?
120  template<class Type>
121  bool initPsicDdt
122  (
123  const LagrangianSubScalarSubField& vOrM,
124  const CloudDerivedField<Type>& psic
125  ) const;
126 
127  //- Return the basic models-only equation for a carrier field
129  (
130  const LagrangianSubScalarField& deltaT,
131  const LagrangianSubScalarSubField& vOrM,
132  const CloudDerivedField<scalar>& oneOrRhoc
133  ) const;
134 
135  //- Return the basic models-only equation for a carrier field
136  template<class Type>
138  (
139  const LagrangianSubScalarField& deltaT,
140  const LagrangianSubScalarSubField& vOrM,
142  const CloudDerivedField<Type>& psic
143  ) const;
144 
145 
146 public:
147 
148  // Public Static Data
149 
150  //- Run-time type information
151  TypeName("coupled");
152 
153 
154  // Public Data
155 
156  //- Carrier kinematic viscosity
158 
159 
160  // Constructors
161 
162  //- Construct from a reference to the cloud
163  coupled(const cloud& c, const carried&);
164 
165 
166  //- Destructor
167  virtual ~coupled();
168 
169 
170  // Member Functions
171 
172  // Equations
173 
174  //- Return if any carrier equations are cached
175  bool hasCarrierEqns() const;
176 
177  //- Return if a carrier equation is in the cache
178  template<class Type>
179  bool hasCarrierEqn(const word&) const;
180 
181  //- Get a carrier equation from the cache
182  template<class Type>
183  const CarrierEqn<Type>& carrierEqn(const word&) const;
184 
185  //- Get multiple phase carrier equations from the cache
186  template<class Type>
187  const HashTable<const CarrierEqn<Type>*> carrierEqns
188  (
189  const word&
190  ) const;
191 
192  //- Return if a carrier equation is in the cache
193  template<class Type>
194  bool hasCarrierEqn(const VolField<Type>&) const;
195 
196  //- Get a carrier equation from the cache
197  template<class Type>
198  const CarrierEqn<Type>& carrierEqn(const VolField<Type>&) const;
199 
200  //- Get multiple phase carrier equations from the cache
201  template<class Type>
202  const HashTable<const CarrierEqn<Type>*> carrierEqns
203  (
204  const VolField<Type>&
205  ) const;
206 };
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace clouds
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #ifdef NoRepository
216  #include "coupledTemplates.C"
217 #endif
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
Class to store the coefficients of a term in a carrier equation.
Definition: CarrierEqn.H:55
A field interpolated from the carrier to the cloud. Uses CloudDerivedField to provide flexible access...
Definition: CarrierField.H:207
A field derived from other state fields of the cloud. Stores and virtualises a function or a method w...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
An STL-conforming hash table.
Definition: HashTable.H:127
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 which are coupled to a carrier.
Definition: coupled.H:55
bool hasCarrierEqns() const
Return if any carrier equations are cached.
Definition: coupled.C:171
bool hasCarrierEqn(const word &) const
Return if a carrier equation is in the cache.
CarrierEqn< Type > & carrierEqn(const CloudDerivedField< Type > &)
Add/get a carrier equation to/from the cache.
tmp< LagrangianEqn< scalar > > psicEqn(const LagrangianSubScalarField &deltaT, const LagrangianSubScalarSubField &vOrM, const CloudDerivedField< scalar > &oneOrRhoc) const
Return the basic models-only equation for a carrier field.
Definition: coupled.C:130
coupled(const cloud &c, const carried &)
Construct from a reference to the cloud.
Definition: coupled.C:148
TypeName("coupled")
Run-time type information.
bool initPsicDdt(const LagrangianSubScalarSubField &vOrM, const CloudDerivedField< Type > &psic) const
Do we need to re-calculate particles that are modified?
void clearCarrierEqns()
Clear the carrier equations.
Definition: coupled.C:110
const CloudDerivedField< scalar > & nuc
Carrier kinematic viscosity.
Definition: coupled.H:156
void updateCarrier()
Update the cached carrier fields.
Definition: coupled.C:101
virtual ~coupled()
Destructor.
Definition: coupled.C:165
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
#define DECLARE_CARRIER_EQNS(Type, nullArg)
Carrier equations.
Definition: coupled.H:73
const volScalarField & psi
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.