constantCoefficientVirtualMass.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 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 
29 #include "coupledToFluid.H"
30 #include "shaped.H"
31 #include "LagrangianmDdt.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace Lagrangian
38 {
41  (
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
53 Foam::Lagrangian::constantCoefficientVirtualMass::calcVOrMAdd
54 (
55  const LagrangianModelRef& model,
56  const LagrangianSubMesh& subMesh
57 ) const
58 {
59  const LagrangianSubScalarField& v = cloud<clouds::shaped>().v(subMesh);
60 
61  return
62  isCloud<clouds::coupledToIncompressibleFluid>()
63  ? Cvm_*v/cloud<clouds::coupledToIncompressibleFluid>().rhoByRhoc
64  : Cvm_*v*cloud<clouds::coupledToFluid>().rhoc(subMesh);
65 }
66 
67 
68 void Foam::Lagrangian::constantCoefficientVirtualMass::addUSup
69 (
70  const LagrangianSubScalarField& deltaT,
72  LagrangianEqn<vector>& eqn
73 ) const
74 {
75  const LagrangianSubScalarSubField& vOrMAdd = this->vOrMAdd.ref(U.mesh());
76 
77  if (eqn.isPsi(U))
78  {
79  eqn -= Lagrangianm::ddt(deltaT, vOrMAdd, U);
80  }
81  else
82  {
83  eqn -= Lagrangianm::ddt0(deltaT, vOrMAdd, U);
84  }
85 
86  eqn.Su += vOrMAdd*cloud<clouds::coupled>().DUDtc(U.mesh());
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91 
93 (
94  const word& name,
95  const LagrangianMesh& mesh,
96  const dictionary& modelDict,
97  const dictionary& stateDict
98 )
99 :
101  cloudLagrangianModel(static_cast<const LagrangianModel&>(*this)),
102  Cvm_("Cvm", dimless, modelDict),
103  vOrMAdd
104  (
105  cloud().derivedField<scalar>
106  (
107  *this,
108  &constantCoefficientVirtualMass::calcVOrMAdd
109  )
110  )
111 {
112  cloud<clouds::coupled>().DUDtc.psi();
113 }
114 
115 
116 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
117 
120 {
121  return wordList(1, cloud().U.name());
122 }
123 
124 
126 (
127  const LagrangianSubScalarField& deltaT,
130 ) const
131 {
132  assertCloud<clouds::coupledToIncompressibleFluid>();
133 
134  addUSup(deltaT, U, eqn);
135 }
136 
137 
139 (
140  const LagrangianSubScalarField& deltaT,
141  const LagrangianSubScalarSubField& vOrM,
144 ) const
145 {
146  assertCloud<clouds::coupledToIncompressibleFluid, clouds::coupledToFluid>();
147 
148  addUSup(deltaT, U, eqn);
149 }
150 
151 
152 // ************************************************************************* //
Functions for calculating the time derivative for a Lagrangian equation.
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...
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
Class containing Lagrangian geometry and topology.
Base class for Lagrangian models.
virtual wordList addSupFields() const
Return the name of the velocity field.
constantCoefficientVirtualMass(const word &name, const LagrangianMesh &mesh, const dictionary &modelDict, const dictionary &stateDict)
Construct from components.
virtual void addSup(const LagrangianSubScalarField &deltaT, const LagrangianSubVectorSubField &U, LagrangianEqn< vector > &eqn) const
Add a source term to the velocity equation.
Base class for Lagrangian models that refer to a cloud. Not a Lagrangian model in itself....
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:63
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
U
Definition: pEqn.H:72
addToRunTimeSelectionTable(LagrangianModel, constantCoefficientVirtualMass, dictionary)
defineTypeNameAndDebug(constantCoefficientVirtualMass, 0)
tmp< LagrangianEqn< Type > > ddt0(const LagrangianSubScalarField &deltaT, const LagrangianSubSubField< Type > &psi)
tmp< LagrangianEqn< Type > > ddt(const LagrangianSubScalarField &deltaT, const LagrangianSubSubField< Type > &psi)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
const dimensionSet dimless
LagrangianSubSubField< vector > LagrangianSubVectorSubField
LagrangianSubSubField< scalar > LagrangianSubScalarSubField
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
LagrangianSubField< scalar > LagrangianSubScalarField