relativeVelocityModel.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) 2014-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 "relativeVelocityModel.H"
28 #include "slipFvPatchFields.H"
30 #include "fvcGrad.H"
31 #include "fvcDiv.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
39 }
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
43 Foam::wordList Foam::relativeVelocityModel::UdmPatchFieldTypes() const
44 {
45  const volVectorField& U = mixture_.U();
46 
47  wordList UdmTypes
48  (
49  U.boundaryField().size(),
51  );
52 
53  forAll(U.boundaryField(), i)
54  {
55  if
56  (
57  isA<fixedValueFvPatchVectorField>(U.boundaryField()[i])
58  || isA<slipFvPatchVectorField>(U.boundaryField()[i])
59  || isA<partialSlipFvPatchVectorField>(U.boundaryField()[i])
60  )
61  {
63  }
64  }
65 
66  return UdmTypes;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
73 (
74  const dictionary& dict,
76  const uniformDimensionedVectorField& g
77 )
78 :
79  mixture_(mixture),
80  g_(g),
81  Udm_
82  (
83  IOobject
84  (
85  "Udm",
86  mixture_.time().name(),
87  mixture_.mesh(),
88  IOobject::READ_IF_PRESENT,
89  IOobject::AUTO_WRITE
90  ),
91  mixture_.mesh(),
93  UdmPatchFieldTypes()
94  )
95 {}
96 
97 
98 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
99 
101 (
102  const dictionary& dict,
104  const uniformDimensionedVectorField& g
105 )
106 {
107  const word modelType(dict.lookup(typeName));
108 
109  Info<< indentOrNl
110  << "Selecting relative velocity model " << modelType << endl;
111 
112  dictionaryConstructorTable::iterator cstrIter =
113  dictionaryConstructorTablePtr_->find(modelType);
114 
115  if (cstrIter == dictionaryConstructorTablePtr_->end())
116  {
118  << "Unknown time scale model type " << modelType
119  << ", constructor not in hash table" << nl << nl
120  << " Valid time scale model types are:" << nl
121  << dictionaryConstructorTablePtr_->sortedToc()
122  << abort(FatalIOError);
123  }
124 
126 
127  return
129  (
130  cstrIter()
131  (
132  dict.optionalTypeDict(modelType),
133  mixture,
134  g
135  )
136  );
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
141 
143 {}
144 
145 
146 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
147 
150 {
151  // Dispersed phase velocity
152  // const volVectorField Ud(mixture_.U() + Udm_);
153 
154  // Use the mixture rather than the dispersed-phase velocity to approximate
155  // the dispersed-phase acceleration to improve stability as only the mixture
156  // momentum equation is coupled to continuity and pressure
157  //
158  // This approximation is valid only in the limit of small drift-velocity.
159  // For large drift-velocity an Euler-Euler approach should be used in
160  // which both the continuous and dispersed-phase momentum equations are
161  // solved and coupled to the pressure.
162  const volVectorField& Ud = mixture_.U();
163 
164  return g_ - (Ud & fvc::grad(Ud));
165 }
166 
167 
169 {
170  const volScalarField betac(mixture_.alphac()*mixture_.rhoc());
171  const volScalarField betad(mixture_.alphad()*mixture_.rhod());
172 
173  // Calculate the relative velocity of the continuous phase w.r.t the mean
174  const volVectorField Ucm(betad*Udm_/betac);
175 
177  (
178  "tauDm",
179  betad*sqr(Udm_) + betac*sqr(Ucm)
180  );
181 }
182 
183 
185 {
186  return fvc::div(tauDm());
187 }
188 
189 
191 {
192  Udm_ = UdmCoeff()*acceleration();
193 }
194 
195 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
const dictionary & optionalTypeDict(const word &typeName) const
Find and return an optional type sub-dictionary.
Definition: dictionary.C:921
Class to represent a mixture of two constant density phases.
const volVectorField & U() const
Return the mixture velocity field.
Enables the printing of a dictionary and subsequently looked-up defaulted entries.
virtual void correct()
Update the diffusion velocity.
tmp< volSymmTensorField > tauDm() const
Return the stress tensor due to the phase transport.
virtual ~relativeVelocityModel()
Destructor.
tmp< volVectorField > acceleration() const
Return the dispersed phase acceleration.
static autoPtr< relativeVelocityModel > New(const dictionary &dict, const incompressibleDriftFluxMixture &mixture, const uniformDimensionedVectorField &g)
tmp< volVectorField > divDevTau() const
Return the div stress tensor due to the phase transport.
const incompressibleDriftFluxMixture & mixture_
Mixture properties.
relativeVelocityModel(const dictionary &dict, const incompressibleDriftFluxMixture &mixture, const uniformDimensionedVectorField &g)
Construct from components.
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 FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
Calculate the divergence of the given field.
Calculate the gradient of the given field.
U
Definition: pEqn.H:72
const dimensionSet time
const dimensionSet acceleration
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
List< word > wordList
A List of words.
Definition: fileName.H:54
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
messageStream Info
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimVelocity
Definition: dimensions.C:154
defineRunTimeSelectionTable(fvConstraint, dictionary)
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
static const char nl
Definition: Ostream.H:297
dictionary dict