pressureWork.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 "pressureWork.H"
28 #include "coupledToThermalFluid.H"
29 #include "fluidLagrangianThermo.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace Lagrangian
36 {
39 }
40 }
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
46  const word& name,
47  const LagrangianMesh& mesh,
48  const dictionary& modelDict,
49  const dictionary& stateDict
50 )
51 :
53  cloudLagrangianModel(static_cast<const LagrangianModel&>(*this)),
54  thermalCloud_(cloud<clouds::thermal>()),
55  pPrevPtr_(nullptr)
56 {}
57 
58 
59 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
60 
62 {
63  return wordList({thermalCloud_.e.name()});
64 }
65 
66 
68 (
69  const word& fieldName,
70  const word& eqnFieldName
71 ) const
72 {
73  return
74  fieldName == thermalCloud_.e.name()
75  && (
76  eqnFieldName == thermalCloud_.e.name()
77  || eqnFieldName == cloud<clouds::coupledToThermalFluid>().hec.name()
78  );
79 }
80 
81 
83 (
84  const LagrangianSubScalarField& deltaT,
85  const bool final
86 )
87 {
88  const LagrangianSubMesh& subMesh = deltaT.mesh();
89 
91  thermalCloud_.thermo<fluidLagrangianThermo>(*this);
92  const LagrangianSubScalarSubField p(subMesh.sub(fluidThermo.p()));
93 
94  pPrevPtr_.set(new LagrangianSubScalarField(p));
95 }
96 
97 
99 (
100  const LagrangianSubScalarField& deltaT,
101  const LagrangianSubScalarSubField& vOrM,
104 ) const
105 {
106  const LagrangianSubMesh& subMesh = deltaT.mesh();
107 
108  const LagrangianSubScalarField& m = thermalCloud_.m(subMesh);
109  const LagrangianSubScalarSubField& rho = thermalCloud_.rho(subMesh);
110 
112  thermalCloud_.thermo<fluidLagrangianThermo>(*this);
113  const LagrangianSubScalarSubField p(subMesh.sub(fluidThermo.p()));
114 
115  // Evaluate the time derivative of the specific volume
116  tmp<LagrangianEqn<scalar>> dOneByRhoDt =
117  - Lagrangianm::ddt0(rho)/(rho*rho.oldTime());
118 
119  // If this is the particle energy equation, then construct corrections to
120  // the above time derivative. If not then just apply it directly.
121  if (eqn.isPsi(e))
122  {
123  tmp<LagrangianEqn<scalar>> dOneByRhoDtCorr =
125  (
126  new LagrangianEqn<scalar>(subMesh)
127  );
128 
129  // Correct for changes in pressure
131  dOneByRhoDtCorr.ref().deltaTSu -=
132  psi*(p - pPrevPtr_())/(rho*rho.oldTime());
133 
134  // Correct for changes in energy
135  const LagrangianSubScalarSubField Cv(subMesh.sub(fluidThermo.Cv()));
136  tmp<LagrangianSubScalarField> alphavByRhoCv =
137  fluidThermo.alphav(subMesh)/(rho*Cv);
138  dOneByRhoDtCorr.ref().deltaTSp += alphavByRhoCv();
139  dOneByRhoDtCorr.ref().deltaTSu -= alphavByRhoCv()*e;
140 
141  // Correct for non-ideal thermodynamic modelling
143  dOneByRhoDtCorr.ref() /= gamma - p*alphavByRhoCv;
144 
145  eqn -= m*p*(dOneByRhoDt + dOneByRhoDtCorr);
146  }
147  else
148  {
149  const LagrangianSubScalarField& pc =
151 
152  eqn -= m*pc*dOneByRhoDt;
153  }
154 }
155 
156 
158 (
159  const LagrangianSubScalarField& deltaT,
160  const bool final
161 )
162 {
163  pPrevPtr_.clear();
164 }
165 
166 
167 // ************************************************************************* //
scalar Cv(const scalar p, const scalar T) const
Definition: HtoEthermo.H:2
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const GeoMesh & mesh() const
Return mesh.
const word & name() const
Return name.
Definition: IOobject.H:307
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
bool isPsi(const LagrangianSubField< Type, PrimitiveField > &) const
Return whether the given field is that of the equation.
Class containing Lagrangian geometry and topology.
Base class for Lagrangian models.
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.
Model for pressure work. Subtracts the pressure-volume work associated with particle expansion from t...
Definition: pressureWork.H:67
virtual wordList addSupFields() const
Return the name of the energy field.
Definition: pressureWork.C:61
virtual bool addsSupToField(const word &fieldName, const word &eqnFieldName) const
Return true for the energy or carrier energy field.
Definition: pressureWork.C:68
virtual void addSup(const LagrangianSubScalarField &deltaT, const LagrangianSubScalarSubField &vOrM, const LagrangianSubScalarSubField &e, LagrangianEqn< scalar > &eqn) const
Add a source term to the energy equation.
Definition: pressureWork.C:99
virtual void preAddSup(const LagrangianSubScalarField &deltaT, const bool final)
Hook before source evaluation.
Definition: pressureWork.C:83
virtual void postAddSup(const LagrangianSubScalarField &deltaT, const bool final)
Hook after source evaluation.
Definition: pressureWork.C:158
pressureWork(const word &name, const LagrangianMesh &mesh, const dictionary &modelDict, const dictionary &stateDict)
Construct from components.
Definition: pressureWork.C:45
virtual const volScalarField & Cv() const =0
Heat capacity at constant volume [J/kg/K].
virtual const volScalarField & Cp() const =0
Heat capacity at constant pressure [J/kg/K].
Mix-in for Lagrangian models that refer to a cloud.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base-class for fluid Lagrangian thermodynamic models.
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:56
virtual const volScalarField & p() const =0
Pressure [Pa].
virtual const volScalarField & psi() const =0
Compressibility [s^2/m^2].
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
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)
const volScalarField & psi
rho
Definition: pEqn.H:1
defineTypeNameAndDebug(collisionPhaseTransfer, 0)
addToRunTimeSelectionTable(LagrangianModel, collisionPhaseTransfer, dictionary)
tmp< LagrangianEqn< Type > > ddt0(const LagrangianSubSubField< Type > &psi)
Return a Euler explicit/forward time derivative matrix.
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
const doubleScalar e
Definition: doubleScalar.H:106
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
LagrangianSubField< scalar > LagrangianSubScalarField
volScalarField & p