dynamicLagrangian.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) 2011-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 "dynamicLagrangian.H"
27 #include "fvModels.H"
28 #include "fvConstraints.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace LESModels
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class BasicMomentumTransportModel>
41 (
42  const tmp<volTensorField>& gradU
43 )
44 {
45  this->nut_ = (flm_/fmm_)*sqr(this->delta())*mag(dev(symm(gradU)));
46  this->nut_.correctBoundaryConditions();
47  fvConstraints::New(this->mesh_).constrain(this->nut_);
48 }
49 
50 
51 template<class BasicMomentumTransportModel>
53 {
54  correctNut(fvc::grad(this->U_));
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
60 template<class BasicMomentumTransportModel>
62 (
63  const alphaField& alpha,
64  const rhoField& rho,
65  const volVectorField& U,
66  const surfaceScalarField& alphaRhoPhi,
67  const surfaceScalarField& phi,
68  const viscosity& viscosity,
69  const word& type
70 )
71 :
72  LESeddyViscosity<BasicMomentumTransportModel>
73  (
74  type,
75  alpha,
76  rho,
77  U,
78  alphaRhoPhi,
79  phi,
80  viscosity
81  ),
82 
83  flm_
84  (
85  IOobject
86  (
87  this->groupName("flm"),
88  this->runTime_.name(),
89  this->mesh_,
90  IOobject::MUST_READ,
91  IOobject::AUTO_WRITE
92  ),
93  this->mesh_,
94  dimless
95  ),
96  fmm_
97  (
98  IOobject
99  (
100  this->groupName("fmm"),
101  this->runTime_.name(),
102  this->mesh_,
103  IOobject::MUST_READ,
104  IOobject::AUTO_WRITE
105  ),
106  this->mesh_,
107  dimless
108  ),
109  theta_("theta", this->typeDict(type), 1.5),
110 
111  simpleFilter_(U.mesh()),
112  filterPtr_(LESfilter::New(U.mesh(), this->typeDict(type))),
113  filter_(filterPtr_()),
114 
115  flm0_("flm0", flm_.dimensions(), 0.0),
116  fmm0_("fmm0", fmm_.dimensions(), vSmall)
117 {}
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
122 template<class BasicMomentumTransportModel>
124 {
126  {
127  filter_.read(this->typeDict());
128  theta_.readIfPresent(this->typeDict());
129 
130  return true;
131  }
132  else
133  {
134  return false;
135  }
136 }
137 
138 
139 template<class BasicMomentumTransportModel>
141 {
142  if (!this->turbulence_)
143  {
144  return;
145  }
146 
147  // Local references
148  const alphaField& alpha = this->alpha_;
149  const rhoField& rho = this->rho_;
150  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
151  const volVectorField& U = this->U_;
152  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
154  (
155  Foam::fvConstraints::New(this->mesh_)
156  );
157 
159 
161  const volTensorField& gradU = tgradU();
162 
163  volSymmTensorField S(dev(symm(gradU)));
164  volScalarField magS(mag(S));
165 
166  volVectorField Uf(filter_(U));
168  volScalarField magSf(mag(Sf));
169 
170  volSymmTensorField L(dev(filter_(sqr(U)) - (sqr(filter_(U)))));
172  (
173  2.0*sqr(this->delta())*(filter_(magS*S) - 4.0*magSf*Sf)
174  );
175 
176  volScalarField invT
177  (
178  alpha*rho*(1.0/(theta_.value()*this->delta()))*pow(flm_*fmm_, 1.0/8.0)
179  );
180 
181  volScalarField LM(L && M);
182 
183  fvScalarMatrix flmEqn
184  (
185  fvm::ddt(alpha, rho, flm_)
186  + fvm::div(alphaRhoPhi, flm_)
187  ==
188  invT*LM
189  - fvm::Sp(invT, flm_)
190  + fvModels.source(alpha, rho, flm_)
191  );
192 
193  flmEqn.relax();
194  fvConstraints.constrain(flmEqn);
195  flmEqn.solve();
196  fvConstraints.constrain(flm_);
197  bound(flm_, flm0_);
198 
199  volScalarField MM(M && M);
200 
201  fvScalarMatrix fmmEqn
202  (
203  fvm::ddt(alpha, rho, fmm_)
204  + fvm::div(alphaRhoPhi, fmm_)
205  ==
206  invT*MM
207  - fvm::Sp(invT, fmm_)
208  + fvModels.source(alpha, rho, fmm_)
209  );
210 
211  fmmEqn.relax();
212  fvConstraints.constrain(fmmEqn);
213  fmmEqn.solve();
214  fvConstraints.constrain(fmm_);
215  bound(fmm_, fmm0_);
216 
217  correctNut(gradU);
218 }
219 
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 } // End namespace LESModels
224 } // End namespace Foam
225 
226 // ************************************************************************* //
scalar delta
#define M(I)
static fvConstraints & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Eddy viscosity LES SGS model base class.
BasicMomentumTransportModel::alphaField alphaField
virtual void correct()
Correct Eddy-Viscosity and related properties.
dynamicLagrangian(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity, const word &type=typeName)
Construct from components.
virtual bool read()
Read model coefficients if they have changed.
BasicMomentumTransportModel::rhoField rhoField
Abstract class for LES filters.
Definition: LESfilter.H:55
virtual void correct()=0
Solve the turbulence equations and correct the turbulence viscosity.
Finite volume constraints.
Definition: fvConstraints.H:68
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
Definition: fvMatrix.C:602
SolverPerformance< Type > solve(const dictionary &)
Solve segregated or coupled returning the solution statistics.
Definition: fvMatrixSolve.C:58
Finite volume models.
Definition: fvModels.H:69
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
A class for managing temporary objects.
Definition: tmp.H:55
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
U
Definition: pEqn.H:72
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 dimless
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
Namespace for OpenFOAM.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void dev(pointPatchField< tensor > &, const pointPatchField< tensor > &)
void symm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
bool bound(volScalarField &, const dimensionedScalar &min)
Bound the given scalar field where it is below the specified min value.
Definition: bound.C:31
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488