phaseLimitStabilisation.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) 2017-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 
27 #include "fvMatrices.H"
28 #include "fvmSup.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
39 
41  (
42  fvModel,
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 void Foam::fv::phaseLimitStabilisation::readCoeffs(const dictionary& dict)
53 {
54  fieldName_ = dict.lookup<word>("field");
55  rateName_ = dict.lookup<word>("rate");
56  residualAlpha_ = dict.lookup<scalar>("residualAlpha");
57 }
58 
59 
60 template<class Type, class RhoRateFieldType>
61 void Foam::fv::phaseLimitStabilisation::addStabilisation
62 (
63  const volScalarField& alpha,
64  const RhoRateFieldType& rhoRate,
65  fvMatrix<Type>& eqn
66 ) const
67 {
68  eqn -= fvm::Sp(max(residualAlpha_ - alpha(), scalar(0))*rhoRate, eqn.psi());
69 }
70 
71 
72 template<class Type>
73 void Foam::fv::phaseLimitStabilisation::addSupType
74 (
75  const volScalarField& alpha,
76  const VolField<Type>& field,
77  fvMatrix<Type>& eqn
78 ) const
79 {
80  addSupType(alpha, geometricOneField(), field, eqn);
81 }
82 
83 
84 template<class Type, class RhoFieldType>
85 void Foam::fv::phaseLimitStabilisation::addSupType
86 (
87  const volScalarField& alpha,
88  const RhoFieldType& rho,
89  const VolField<Type>& field,
90  fvMatrix<Type>& eqn
91 ) const
92 {
93  if (mesh().foundObject<volScalarField::Internal>(rateName_))
94  {
97 
98  addStabilisation(alpha, rho.internalField()*rate, eqn);
99  }
100  else if (mesh().foundObject<uniformDimensionedScalarField>(rateName_))
101  {
102  const uniformDimensionedScalarField& rate =
103  mesh().lookupObjectRef<uniformDimensionedScalarField>(rateName_);
104 
105  addStabilisation(alpha, rho.internalField()*rate, eqn);
106  }
107  else
108  {
110  << nl
111  << " request for " << volScalarField::Internal::typeName
113  << " " << rateName_ << " from objectRegistry " << this->name()
114  << " failed\n available objects of type "
115  << volScalarField::Internal::typeName << " are" << nl
117  << "\n available objects of type "
119  << mesh().toc<uniformDimensionedScalarField>()
120  << abort(FatalError);
121  }
122 }
123 
124 
125 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
126 
128 (
129  const word& name,
130  const word& modelType,
131  const fvMesh& mesh,
132  const dictionary& dict
133 )
134 :
135  fvModel(name, modelType, mesh, dict),
136  fieldName_(word::null),
137  rateName_(word::null),
138  residualAlpha_(NaN)
139 {
140  readCoeffs(coeffs(dict));
141 }
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
147 {
148  return wordList(1, fieldName_);
149 }
150 
151 
153 (
155  fv::phaseLimitStabilisation
156 )
157 
158 
160 (
162  fv::phaseLimitStabilisation
163 )
164 
165 
167 {
168  return true;
169 }
170 
171 
173 {}
174 
175 
177 {}
178 
179 
181 (
182  const polyDistributionMap&
183 )
184 {}
185 
186 
188 {
189  if (fvModel::read(dict))
190  {
191  readCoeffs(coeffs(dict));
192  return true;
193  }
194  else
195  {
196  return false;
197  }
198 }
199 
200 
201 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
DimensionedField< Type, GeoMesh, PrimitiveField > Internal
Type of the internal field from which this GeometricField is derived.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:196
Stabilisation source for phase transport equations.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool movePoints()
Add a source term to an incompressible phase equation.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
phaseLimitStabilisation(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Type & lookupObjectRef(const word &name) const
Lookup and return the object reference of the given Type.
wordList toc(const word &className) const
Return the list of names of IOobjects of given class name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
A special matrix type and solver, designed for finite volume solutions of scalar equations.
#define IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:71
#define IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP(Type, modelType)
Definition: fvModelM.H:51
Calculate the matrix for implicit and explicit sources.
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionSet rate
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
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
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
static const char nl
Definition: Ostream.H:297
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
labelList fv(nPoints)
dictionary dict
Typedefs for UniformDimensionedField.