interfaceTurbulenceDamping.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) 2022-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 
27 #include "surfaceInterpolate.H"
28 #include "fvcGrad.H"
30 
31 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  namespace fv
36  {
38 
40  (
41  fvModel,
44  );
45  }
46 }
47 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
52 Foam::fv::interfaceTurbulenceDamping::interfaceFraction
53 (
54  const volScalarField& alpha
55 ) const
56 {
57  const fvMesh& mesh = this->mesh();
58 
59  tmp<volScalarField::Internal> tA
60  (
62  (
63  "A",
64  mesh,
66  )
67  );
68  volScalarField::Internal& A = tA.ref();
69 
70  const surfaceVectorField& Sf = mesh.Sf();
71  const labelUList& own = mesh.owner();
72  const labelUList& nei = mesh.neighbour();
73 
75 
76  const volVectorField gradAlpha(fvc::grad(alpha));
78  (
79  gradAlpha()/(mag(gradAlpha()) + phase_.fluid().deltaN())
80  );
81 
82  const scalarField& ialpha = alpha;
83  const scalarField& ialphaf = alphaf;
84  scalarField sumnSf(mesh.nCells(), 0);
85 
86  forAll(own, facei)
87  {
88  {
89  const scalar nSf(mag(n[own[facei]] & Sf[facei]));
90  A[own[facei]] += nSf*(ialphaf[facei] - ialpha[own[facei]]);
91  sumnSf[own[facei]] += nSf;
92  }
93  {
94  const scalar nSf(mag(n[nei[facei]] & Sf[facei]));
95  A[nei[facei]] += nSf*(ialphaf[facei] - ialpha[nei[facei]]);
96  sumnSf[nei[facei]] += nSf;
97  }
98  }
99 
101  {
102  const labelUList& own = mesh.boundary()[patchi].faceCells();
103  const fvsPatchVectorField& pSf = Sf.boundaryField()[patchi];
104  const fvsPatchScalarField& palphaf = alphaf.boundaryField()[patchi];
105 
106  forAll(mesh.boundary()[patchi], facei)
107  {
108  const scalar nSf(mag(n[own[facei]] & pSf[facei]));
109  A[own[facei]] += nSf*(palphaf[facei] - ialpha[own[facei]]);
110  sumnSf[own[facei]] += nSf;
111  }
112  }
113 
114  scalarField& a = A.primitiveFieldRef();
115  forAll(a, i)
116  {
117  if (sumnSf[i] > small)
118  {
119  a[i] = 2*mag(a[i])/sumnSf[i];
120  }
121  else
122  {
123  a[i] = 0;
124  }
125  }
126 
127  return tA;
128 }
129 
130 
131 template<class RhoType>
132 void Foam::fv::interfaceTurbulenceDamping::addRhoSup
133 (
134  const RhoType& rho,
135  const volScalarField& field,
136  fvMatrix<scalar>& eqn
137 ) const
138 {
139  if (debug)
140  {
141  Info<< type() << ": applying source to " << eqn.psi().name() << endl;
142  }
143 
144  const phaseSystem::phaseModelPartialList& movingPhases =
145  phase_.fluid().movingPhases();
146 
148  (
149  movingPhases[0]*sqr(movingPhases[0].fluidThermo().nu()()())
150  );
151 
152  for (label phasei=1; phasei<movingPhases.size(); phasei++)
153  {
154  aSqrnu +=
155  movingPhases[phasei]
156  *sqr(movingPhases[phasei].fluidThermo().nu()()());
157  }
158 
159  if (field.name() == "epsilon")
160  {
161  eqn += rho*interfaceFraction(phase_)*C2_*aSqrnu*turbulence_.k()()
162  /pow4(delta_);
163  }
164  else if (field.name() == "omega")
165  {
166  eqn += rho*interfaceFraction(phase_)*beta_*aSqrnu
167  /(sqr(betaStar_)*pow4(delta_));
168  }
169  else
170  {
172  << "Support for field " << field.name() << " is not implemented"
173  << exit(FatalError);
174  }
175 }
176 
177 
178 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
179 
181 (
182  const word& sourceName,
183  const word& modelType,
184  const fvMesh& mesh,
185  const dictionary& dict
186 )
187 :
188  fvModel(sourceName, modelType, mesh, dict),
189  phaseName_(dict.lookup("phase")),
190  delta_("delta", dimLength, dict),
191  phase_
192  (
193  mesh.lookupObject<phaseModel>(IOobject::groupName("alpha", phaseName_))
194  ),
195  turbulence_
196  (
197  mesh.lookupType<phaseCompressible::momentumTransportModel>(phaseName_)
198  ),
199  C2_("C2", dimless, dict, 1.92),
200  betaStar_("betaStar", dimless, dict, 0.09),
201  beta_("beta", dimless, dict, 0.072)
202 {
203  const word epsilonName(IOobject::groupName("epsilon", phaseName_));
204  const word omegaName(IOobject::groupName("omega", phaseName_));
205 
206  if (mesh.foundObject<volScalarField>(epsilonName))
207  {
208  fieldName_ = epsilonName;
209  }
210  else if (mesh.foundObject<volScalarField>(omegaName))
211  {
212  fieldName_ = omegaName;
213  }
214  else
215  {
217  << "Cannot find either " << epsilonName << " or " << omegaName
218  << " field for fvModel " << typeName << exit(FatalIOError);
219  }
220 }
221 
222 
223 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
224 
226 {
227  return wordList(1, fieldName_);
228 }
229 
230 
232 (
233  const volScalarField& field,
234  fvMatrix<scalar>& eqn
235 ) const
236 {
237  addRhoSup(one(), field, eqn);
238 }
239 
240 
242 (
243  const volScalarField& rho,
244  const volScalarField& field,
245  fvMatrix<scalar>& eqn
246 ) const
247 {
248  addRhoSup(rho(), field, eqn);
249 }
250 
251 
253 (
254  const volScalarField& alpha,
255  const volScalarField& rho,
256  const volScalarField& field,
257  fvMatrix<scalar>& eqn
258 ) const
259 {
260  if (debug)
261  {
262  Info<< type() << ": applying source to " << eqn.psi().name() << endl;
263  }
264 
265  const volScalarField::Internal aSqrnu
266  (
267  alpha*sqr(phase_.fluidThermo().nu()()())
268  );
269 
270  if (field.name() == IOobject::groupName("epsilon", phaseName_))
271  {
272  eqn += rho()*interfaceFraction(alpha)
273  *C2_*aSqrnu*turbulence_.k()()/pow4(delta_);
274  }
275  else if (field.name() == IOobject::groupName("omega", phaseName_))
276  {
277  eqn += rho()*interfaceFraction(alpha)
278  *beta_*aSqrnu/(sqr(betaStar_)*pow4(delta_));
279  }
280  else
281  {
283  << "Support for field " << field.name() << " is not implemented"
284  << exit(FatalError);
285  }
286 }
287 
288 
290 {}
291 
292 
294 {}
295 
296 
298 (
299  const polyDistributionMap&
300 )
301 {}
302 
303 
305 {
306  return true;
307 }
308 
309 
310 // ************************************************************************* //
label n
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
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...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Generic GeometricField class.
DimensionedField< Type, GeoMesh, PrimitiveField > Internal
Type of the internal field from which this GeometricField is derived.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:307
static word groupName(Name name, const word &group)
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:490
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:932
const surfaceVectorField & Sf() const
Return cell face area vectors.
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:496
Finite volume model abstract base class.
Definition: fvModel.H:60
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
Free-surface phase turbulence damping function.
virtual bool movePoints()
Update for mesh motion.
virtual wordList addSupFields() const
Return the list of fields for which the option adds source term.
virtual void addSup(const volScalarField &field, fvMatrix< scalar > &eqn) const
Add source to mixture epsilon or omega equation.
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 void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
interfaceTurbulenceDamping(const word &sourceName, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Abstract base class for momentum transport models (RAS, LES and laminar).
bool foundObject(const word &name) const
Is the named Type in registry.
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Definition: one.H:51
const phaseSystem & fluid() const
Return the system to which this phase belongs.
Definition: phaseModel.C:110
const dimensionedScalar & deltaN() const
Stabilisation for normalisation of the interface normal.
Definition: phaseSystemI.H:250
UPtrList< phaseModel > phaseModelPartialList
Partial list of phase models.
Definition: phaseSystem.H:125
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.
label nCells() const
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
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Calculate the gradient of the given field.
label patchi
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
static const coefficient A("A", dimPressure, 611.21)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
List< word > wordList
A List of words.
Definition: fileName.H:54
const dimensionSet & dimless
Definition: dimensions.C:138
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
const dimensionSet & dimLength
Definition: dimensions.C:141
SurfaceField< scalar > surfaceScalarField
messageStream Info
void pow4(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
IOerror FatalIOError
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
error FatalError
SurfaceField< vector > surfaceVectorField
UList< label > labelUList
Definition: UList.H:65
fvsPatchField< vector > fvsPatchVectorField
fvsPatchField< scalar > fvsPatchScalarField
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
labelList fv(nPoints)
dictionary dict