coupled.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 
26 #include "coupled.H"
27 #include "physicalProperties.H"
28 #include "viscosity.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace clouds
35 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
43 Foam::tmp<Foam::volScalarField> Foam::clouds::coupled::getNucVf() const
44 {
45  const word nucName =
46  IOobject::groupName("nu", carriedCloud_.carrierPhaseName());
47 
48  if (cloud_.mesh().poly().foundObject<volScalarField>(nucName))
49  {
50  return cloud_.mesh().poly().lookupObject<volScalarField>(nucName);
51  }
52 
53  const word viscosityName =
55  (
57  carriedCloud_.carrierPhaseName()
58  );
59 
60  if (cloud_.mesh().poly().foundObject<viscosity>(viscosityName))
61  {
62  return cloud_.mesh().poly().lookupObject<viscosity>(viscosityName).nu();
63  }
64 
65  return tmp<volScalarField>(nullptr);
66 }
67 
68 
69 Foam::tmp<Foam::LagrangianSubScalarField> Foam::clouds::coupled::calcNuc
70 (
71  const LagrangianModelRef& model,
72  const LagrangianSubMesh& subMesh
73 ) const
74 {
76  << "Could not determine the carrier viscosity"
77  << exit(FatalError);
78 
79  return tmp<LagrangianSubScalarField>(nullptr);
80 }
81 
82 
83 #define ACCESS_CARRIER_EQNS(Type, nullArg) \
84 namespace Foam \
85 { \
86  namespace clouds \
87  { \
88  template<> \
89  HashPtrTable<CarrierEqn<Type>>& coupled::carrierEqns() const \
90  { \
91  return CAT3(carrier, CAPITALIZE(Type), Eqns_); \
92  } \
93  } \
94 }
96 #undef ACCESS_CARRIER_EQNS
97 
98 
99 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
100 
102 {
103  if (tnucVf_.isTmp())
104  {
105  tnucVf_.ref() = getNucVf();
106  }
107 }
108 
109 
111 {
112  #define CLEAR_TYPE_CARRIER_EQNS(Type, nullArg) \
113  forAllIter \
114  ( \
115  HashPtrTable<CarrierEqn<Type>>, \
116  carrierEqns<Type>(), \
117  iter \
118  ) \
119  { \
120  iter()->clear(); \
121  }
123  #undef CLEAR_TYPE_CARRIER_EQNS
124 
125  hasCarrierEqns_ = false;
126 }
127 
128 
130 (
131  const LagrangianSubScalarField& deltaT,
132  const LagrangianSubScalarSubField& vOrM,
133  const CloudDerivedField<scalar>& oneOrRhoc
134 ) const
135 {
136  const LagrangianModels& models = cloud_.LagrangianModels();
137  const LagrangianSubMesh& subMesh = deltaT.mesh();
138 
139  return
140  Lagrangianm::noDdt(deltaT, vOrM.dimensions(), oneOrRhoc(subMesh))
141  ==
142  models.sourceProxy(deltaT, vOrM, oneOrRhoc(subMesh));
143 }
144 
145 
146 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
147 
148 Foam::clouds::coupled::coupled(const cloud& c, const carried& carriedCloud)
149 :
150  cloud_(c),
151  carriedCloud_(carriedCloud),
152  hasCarrierEqns_(false),
153  tnucVf_(getNucVf()),
154  nuc
155  (
156  tnucVf_.valid()
157  ? carriedCloud_.carrierField<scalar>(tnucVf_())
158  : c.derivedField<scalar>(*this, &coupled::calcNuc)
159  )
160 {}
161 
162 
163 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
164 
166 {}
167 
168 
169 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
170 
172 {
173  return hasCarrierEqns_;
174 }
175 
176 
177 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
const GeoMesh & mesh() const
Return mesh.
static word groupName(Name name, const word &group)
const polyMesh & poly() const
Access the poly mesh.
List of Lagrangian models, constructed as a (Lagrangian) mesh object. Provides similar functions to t...
tmp< LagrangianEqn< Type > > sourceProxy(const LagrangianSubScalarField &deltaT, const LagrangianSubField< Type, PrimitiveField > &field, const LagrangianSubField< Type, PrimitiveEqnField > &eqnField) const
Return source for an equation.
LagrangianModels(const LagrangianMesh &mesh)
Construct for a mesh.
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:61
Base class for clouds which are carried by a fluid.
Definition: carried.H:57
const word & carrierPhaseName() const
Return the name of the carrier phase.
Definition: carried.C:242
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
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
void clearCarrierEqns()
Clear the carrier equations.
Definition: coupled.C:110
void updateCarrier()
Update the cached carrier fields.
Definition: coupled.C:101
virtual ~coupled()
Destructor.
Definition: coupled.C:165
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
bool foundObject(const word &name) const
Is the named Type in registry.
A class for managing temporary objects.
Definition: tmp.H:55
#define ACCESS_CARRIER_EQNS(Type, nullArg)
Definition: coupled.C:83
#define CLEAR_TYPE_CARRIER_EQNS(Type, nullArg)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
tmp< LagrangianEqn< Type > > noDdt(const LagrangianSubScalarField &deltaT, const dimensionSet &mDims, const LagrangianSubSubField< Type > &psi)
Return the no-time-derivative matrix containing higher-order.
bool valid(const PtrList< ModelType > &l)
defineTypeNameAndDebug(carried, 0)
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
error FatalError
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.name(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Creating face flux\n"<< endl;surfaceScalarField phi(IOobject("phi", runTime.name(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(mesh.Sf().dimensions() *U.dimensions(), 0));autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))