fluidLagrangianThermo.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) 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 "fluidLagrangianThermo.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
38 }
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  const dictionary& dict,
45  const LagrangianMesh& mesh,
46  const word& phaseName,
48 )
49 :
50  p_
51  (
52  IOobject
53  (
54  IOobject::groupName("p", phaseName),
55  mesh.time().name(),
56  mesh,
57  IOobject::READ_IF_PRESENT,
58  IOobject::AUTO_WRITE
59  ),
60  mesh,
61  dimensionedScalar("NaN", dimPressure, NaN),
62  wordList
63  (
64  mesh.boundary().size(),
65  calculatedLagrangianPatchScalarField::typeName
66  ),
67  wordList::null(),
69  T.sources().errorLocation()
70  ),
71  pSourcePtr_
72  (
73  LagrangianScalarFieldSource::New
74  (
75  p_,
76  dict.subDict("pressure")
77  )
78  ),
79  psi_
80  (
81  IOobject
82  (
83  IOobject::groupName("psi", phaseName),
84  mesh.time().name(),
85  mesh,
86  IOobject::NO_READ,
87  IOobject::NO_WRITE
88  ),
89  mesh,
91  wordList
92  (
93  mesh.boundary().size(),
94  calculatedLagrangianPatchScalarField::typeName
95  ),
96  wordList::null(),
98  T.sources().errorLocation()
99  ),
100  mu_
101  (
102  IOobject
103  (
104  IOobject::groupName("mu", phaseName),
105  mesh.time().name(),
106  mesh,
107  IOobject::NO_READ,
108  IOobject::NO_WRITE
109  ),
110  mesh,
112  wordList
113  (
114  mesh.boundary().size(),
115  calculatedLagrangianPatchScalarField::typeName
116  ),
117  wordList::null(),
119  T.sources().errorLocation()
120  )
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
125 
128 (
129  const LagrangianMesh& mesh,
130  const word& phaseName
131 )
132 {
133  return basicLagrangianThermo::New<fluidLagrangianThermo>(mesh, phaseName);
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
140 {}
141 
142 
144 {}
145 
146 
147 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
148 
150 {
151  // Initialise the pressure if it was not read in
152  if (!p_.headerOk()) correctPressure(mesh().subAll());
153 
154  correct(mesh().subAll());
155 }
156 
157 
159 (
160  const LagrangianSubMesh& subMesh
161 )
162 {
163  if (debug) InfoInFunction << endl;
164 
165  SubField<scalar> p = subMesh.sub(this->p_.primitiveFieldRef());
166 
167  // Use the source model to update the pressure on this sub-mesh
168  p = pSourcePtr_->value(subMesh)().primitiveField();
169 
170  if (debug) Info<< " Finished" << endl;
171 }
172 
173 
176 {
177  return p_;
178 }
179 
180 
183 {
184  return p_;
185 }
186 
187 
190 (
191  const LagrangianSubMesh& subMesh
192 ) const
193 {
194  return subMesh.sub(p_);
195 }
196 
197 
200 (
201  const LagrangianInjection& injection,
202  const LagrangianSubMesh& subMesh
203 ) const
204 {
205  return pSourcePtr_->value(injection, subMesh);
206 }
207 
208 
211 {
212  return psi_;
213 }
214 
215 
218 {
219  return mu_;
220 }
221 
222 
223 // ************************************************************************* //
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Class containing Lagrangian geometry and topology.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
word sub(const word &fieldName) const
Return the name of a field corresponding to this sub-mesh.
Pre-declare related SubField type.
Definition: SubField.H:63
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
virtual const LagrangianMesh & mesh() const =0
Access the mesh.
virtual void correctPressure(const LagrangianSubMesh &)=0
Update the pressure.
virtual void correct(const LagrangianSubMesh &)=0
Update state.
virtual const word & phaseName() const =0
Access the phase name.
Source condition for compressibility. Applied to the compressibility field automatically by the Lagra...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Source condition for dynamic viscosity. Applied to the dynamic viscosity field automatically by the L...
virtual const LagrangianScalarDynamicField & psi() const
Compressibility [s^2/m^2].
virtual const LagrangianScalarDynamicField & mu() const
Dynamic viscosity [kg/m/s].
virtual void correctPressure(const LagrangianSubMesh &)
Update the pressure.
implementation(const dictionary &, const LagrangianMesh &, const word &, const LagrangianScalarDynamicField &T)
Construct from dictionary, mesh and phase name.
virtual const LagrangianScalarDynamicField & p() const
Pressure [Pa].
Base-class for fluid Lagrangian thermodynamic models.
static autoPtr< fluidLagrangianThermo > New(const LagrangianMesh &mesh, const word &phaseName=word::null)
Select a fluid thermo.
virtual const LagrangianScalarDynamicField & p() const =0
Pressure [Pa].
virtual ~fluidLagrangianThermo()
Destructor.
Source condition for pressure. Applied to the pressure field automatically by the Lagrangian thermody...
A class for managing temporary objects.
Definition: tmp.H:55
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define InfoInFunction
Report an information message using Foam::Info.
const dimensionSet time
Namespace for OpenFOAM.
const dimensionSet & dimDynamicViscosity
Definition: dimensions.C:173
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
defineRunTimeSelectionTable(fvConstraint, dictionary)
const dimensionSet & dimDensity
Definition: dimensions.C:158
const dimensionSet & dimPressure
Definition: dimensions.C:163
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
faceListList boundary(nPatches)
dictionary dict