drag.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 "drag.H"
29 #include "coupledToFluid.H"
30 #include "LagrangianmSp.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace Lagrangian
37 {
39 }
40 }
41 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 void Foam::Lagrangian::drag::addUSup
46 (
48  LagrangianEqn<vector>& eqn
49 ) const
50 {
51  const LagrangianSubScalarField& D = this->D(U.mesh());
52 
53  const LagrangianSubVectorField& Uc =
54  cloud<clouds::carried>().Uc(U.mesh());
55 
56  if (eqn.isPsi(U))
57  {
58  eqn.Su += D*Uc;
59  eqn -= Lagrangianm::Sp(D, U);
60  }
61  else
62  {
63  eqn += Lagrangianm::Sp(D, Uc);
64  eqn.Su -= D*U;
65  }
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 
72 (
73  const word& name,
74  const LagrangianMesh& mesh,
75  const dictionary& modelDict,
76  const dictionary& stateDict
77 )
78 :
80  cloudLagrangianModel(static_cast<const LagrangianModel&>(*this)),
81  D
82  (
83  cloud().derivedField<scalar>
84  (
85  "D",
86  *this,
87  &drag::calcD
88  )
89  )
90 {}
91 
92 
93 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
94 
96 {
97  return wordList({cloud().U.name()});
98 }
99 
100 
102 (
103  const word& fieldName,
104  const word& eqnFieldName
105 ) const
106 {
107  return
108  fieldName == cloud().U.name()
109  && (
110  eqnFieldName == cloud().U.name()
111  || eqnFieldName == cloud<clouds::carried>().Uc.name()
112  );
113 }
114 
115 
117 (
118  const LagrangianSubScalarField& deltaT,
121 ) const
122 {
123  assertCloud<clouds::coupledToConstantDensityFluid>();
124 
125  addUSup(U, eqn);
126 }
127 
128 
130 (
131  const LagrangianSubScalarField& deltaT,
132  const LagrangianSubScalarSubField& vOrM,
135 ) const
136 {
137  assertCloud
138  <
141  >();
142 
143  addUSup(U, eqn);
144 }
145 
146 
147 // ************************************************************************* //
Functions for calculating sources in 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...
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
Class containing Lagrangian geometry and topology.
Base class for Lagrangian models.
Base class for Lagrangian drag models.
Definition: drag.H:55
virtual wordList addSupFields() const
Return the name of the velocity field.
Definition: drag.C:95
virtual bool addsSupToField(const word &fieldName, const word &eqnFieldName) const
Return true for the velocity or carrier velocity field.
Definition: drag.C:102
drag(const word &name, const LagrangianMesh &mesh, const dictionary &modelDict, const dictionary &stateDict)
Construct from components.
Definition: drag.C:72
virtual void addSup(const LagrangianSubScalarField &deltaT, const LagrangianSubVectorSubField &U, LagrangianEqn< vector > &eqn) const
Add a source term to the velocity equation.
Definition: drag.C:117
const CloudDerivedField< scalar > & D
Drag coefficient.
Definition: drag.H:84
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
CloudStateField< vector > U
Velocity.
Definition: cloud.H:209
Base class for clouds which are coupled to a constant density fluid.
Base class for clouds which are coupled to a variable density fluid.
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 handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
U
Definition: pEqn.H:72
defineTypeNameAndDebug(collisionPhaseTransfer, 0)
tmp< LagrangianEqn< Type > > Sp(const LagrangianSubField< SpType > &Sp, const LagrangianSubSubField< Type > &psi)
Return a source matrix.
static const coefficient D("D", dimTemperature, 257.14)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
LagrangianSubSubField< vector > LagrangianSubVectorSubField
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
LagrangianSubField< scalar > LagrangianSubScalarField
LagrangianSubField< vector > LagrangianSubVectorField