coupledToConstantDensityFluid.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 "dimensionedScalar.H"
28 #include "physicalProperties.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace clouds
36 {
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 
45 Foam::clouds::coupledToConstantDensityFluid::physicalProperties() const
46 {
47  if (!physicalPropertiesPtr_.valid())
48  {
49  physicalPropertiesPtr_.set
50  (
52  );
53  }
54 
55  return physicalPropertiesPtr_();
56 }
57 
58 
60 Foam::clouds::coupledToConstantDensityFluid::one
61 (
62  const LagrangianSubMesh& subMesh
63 )
64 {
65  return
67  (
68  subMesh.sub("1"),
69  subMesh,
70  dimensionedScalar(dimless, scalar(1))
71  );
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
78 (
79  const cloud& c,
80  const carried& carriedCloud
81 )
82 :
83  coupled(c, carriedCloud),
84  mesh_(c.mesh()),
85  physicalPropertiesPtr_(nullptr),
86  rho_
87  (
88  !carriedCloud.hasPhase()
90  : mesh_.poly().lookupObject<uniformDimensionedScalarField>
91  (
92  IOobject::groupName("rho", carriedCloud.phaseName())
93  )
94  ),
95  rhoc_
96  (
97  carriedCloud.carrierPhaseName() == word::null
99  : mesh_.poly().lookupObject<uniformDimensionedScalarField>
100  (
101  IOobject::groupName("rho", carriedCloud.carrierPhaseName())
102  )
103  ),
104  onec
105  (
106  c.derivedField<scalar>
107  (
108  carried::nameToCarrierName("1", carriedCloud.carrierPhaseName()),
109  [&](const LagrangianModelRef&, const LagrangianSubMesh& subMesh)
110  {
111  return one(subMesh);
112  }
113  )
114  ),
115  onecPhase
116  (
117  c.derivedField<scalar>
118  (
119  carried::nameToCarrierName("1", carriedCloud.phaseName(false)),
120  [&](const LagrangianModelRef&, const LagrangianSubMesh& subMesh)
121  {
122  return one(subMesh);
123  }
124  )
125  ),
126  rhoByRhoc
127  (
128  isNull(rho_) || isNull(rhoc_)
129  ? dimensionedScalar("rhoByRhoc", dimless, physicalProperties())
130  : rho_/rhoc_
131  )
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
136 
138 {}
139 
140 
141 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
142 
145 {
146  if (isNull(rho_))
147  {
149  << "Constant cloud density (rho) requested for cloud "
150  << mesh_.name() << ", but only the density ratio (rhoByRhoc) is "
151  << "defined. Constant cloud density is only available when the "
152  << "Eulerian system is multiphase" << exit(FatalError);
153  }
154 
155  return rho_;
156 }
157 
158 
161 {
162  if (isNull(rhoc_))
163  {
165  << "Constant carrier density (rhoc) requested for cloud "
166  << mesh_.name() << ", but only the density ratio (rhoByRhoc) is "
167  << "defined. Constant carrier density is only available when the "
168  << "Eulerian system is multiphase" << exit(FatalError);
169  }
170 
171  return rhoc_;
172 }
173 
174 
177 {
178  if (isNull(rho_))
179  {
181  << "Constant corresponding Eulerian phase density (rhocPhase) "
182  << "requested for cloud " << mesh_.name() << ", but only the "
183  << "density ratio (rhoByRhoc) is defined. Constant corresponding "
184  << "Eulerian phase density is only available when the Eulerian "
185  << "system is multiphase" << exit(FatalError);
186  }
187 
188  return rho_;
189 }
190 
191 
192 // ************************************************************************* //
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Simple wrapper to provide an optional reference to a Lagrangian model.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
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
static word nameToCarrierName(const word &name)
Convert a name to its disambiguated carrier equivalent name. I.e.,.
Definition: carried.C:273
Base class for clouds which are coupled to a constant density fluid.
const dimensionedScalar & rhoc() const
Carrier density.
coupledToConstantDensityFluid(const cloud &c, const carried &)
Construct from a reference to the cloud.
const dimensionedScalar & rho() const
Cloud density.
const dimensionedScalar & rhocPhase() const
Corresponding Eulerian phase density.
Base class for clouds which are coupled to a carrier.
Definition: coupled.H:55
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Definition: one.H:51
A base class for physical properties.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
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
const dimensionSet & dimless
Definition: dimensions.C:138
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
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Typedefs for UniformDimensionedField.