lambdaThixotropic.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) 2020-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 "lambdaThixotropic.H"
27 #include "fvmDiv.H"
28 #include "fvmSup.H"
29 #include "fvModels.H"
30 #include "fvConstraints.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace laminarModels
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
44 (
45  const alphaField& alpha,
46  const rhoField& rho,
47  const volVectorField& U,
48  const surfaceScalarField& alphaRhoPhi,
49  const surfaceScalarField& phi,
50  const viscosity& viscosity,
51  const word& type
52 )
53 :
54  ViscousStress<laminarModel<BasicMomentumTransportModel>>
55  (
56  typeName,
57  alpha,
58  rho,
59  U,
60  alphaRhoPhi,
61  phi,
62  viscosity
63  ),
64 
65  a_("a", dimless/dimTime, this->typeDict(type)),
66  b_("b", dimless, this->typeDict(type)),
67  d_("d", dimless, this->typeDict(type)),
68  c_("c", pow(dimTime, d_.value() - scalar(1)), this->typeDict(type)),
69  nu0_("nu0", dimKinematicViscosity, this->typeDict(type)),
70  nuInf_("nuInf", dimKinematicViscosity, this->typeDict(type)),
71  K_(1 - sqrt(nuInf_/nu0_)),
72  BinghamPlastic_(this->typeDict(type).found("sigmay")),
73  sigmay_
74  (
75  BinghamPlastic_
77  (
78  "sigmay",
80  this->typeDict(type)
81  )
83  (
84  "sigmay",
86  0
87  )
88  ),
89  residualAlpha_("residualAlpha", dimless, this->typeDict(type), 1e-6),
90  lambda_
91  (
92  IOobject
93  (
94  this->groupName(typedName("lambda")),
95  this->runTime_.name(),
96  this->mesh_,
97  IOobject::MUST_READ,
98  IOobject::AUTO_WRITE
99  ),
100  this->mesh_
101  ),
102 
103  nu_
104  (
105  IOobject
106  (
107  this->groupName(typedName("nu")),
108  this->runTime_.name(),
109  this->mesh_,
110  IOobject::NO_READ,
111  IOobject::AUTO_WRITE
112  ),
113  calcNu(this->strainRate())
114  )
115 {}
116 
117 
118 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
119 
120 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
123 (
124  const volScalarField& strainRate
125 ) const
126 {
128  (
129  nuInf_/(sqr(1 - K_*lambda_) + rootVSmall)
130  );
131 
132  // Add optional yield stress contribution to the viscosity
133  if (BinghamPlastic_)
134  {
135  dimensionedScalar sigmaySmall
136  (
137  "sigmaySmall",
138  sigmay_.dimensions(),
139  small
140  );
141 
142  // Limit the Bingham viscosity to 100x the thixotropic viscosity
143  // for numerical stability
144  dimensionedScalar nuMax_("nuMax", 100*nu0_);
145 
146  nu.ref() = min
147  (
148  sigmay_/(strainRate + 1e-4*(sigmay_ + sigmaySmall)/nu0_) + nu(),
149  nuMax_
150  );
151  }
152 
153  return nu;
154 }
155 
156 
157 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
158 tmp<volScalarField>
159 lambdaThixotropic<BasicMomentumTransportModel, ViscousStress>::
160 strainRate() const
161 {
162  return sqrt(2.0)*mag(symm(fvc::grad(this->U())));
163 }
164 
165 
166 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
167 
168 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
170 {
172  {
173  a_.read(this->typeDict());
174  b_.read(this->typeDict());
175  d_.read(this->typeDict());
176 
177  c_ = dimensionedScalar
178  (
179  "c",
180  pow(dimTime, d_.value() - scalar(1)),
181  this->typeDict()
182  );
183 
184  nu0_.read(this->typeDict());
185  nuInf_.read(this->typeDict());
186 
187  K_ = (1 - sqrt(nuInf_/nu0_));
188 
189  return true;
190  }
191  else
192  {
193  return false;
194  }
195 }
196 
197 
198 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
201 {
202  return volScalarField::New
203  (
204  this->groupName("nuEff"),
205  nu_
206  );
207 }
208 
209 
210 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
213 (
214  const label patchi
215 ) const
216 {
217  return nu_.boundaryField()[patchi];
218 }
219 
220 
221 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
223 {
224  // Local references
225  const alphaField& alpha = this->alpha_;
226  const rhoField& rho = this->rho_;
227  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
228  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
230  (
231  Foam::fvConstraints::New(this->mesh_)
232  );
233 
234  const volScalarField strainRate(this->strainRate());
235 
236  tmp<fvScalarMatrix> lambdaEqn
237  (
238  fvm::ddt(alpha, rho, lambda_)
239  + fvm::div(alphaRhoPhi, lambda_)
240  ==
241  alpha()*rho()*a_*pow(1 - lambda_(), b_)
242  - fvm::Sp
243  (
244  rho()
245  *(
246  alpha()*c_*pow(strainRate(), d_)
247  + max(residualAlpha_ - alpha(), dimensionedScalar(dimless, 0))*a_
248  ),
249  lambda_
250  )
251  + fvModels.source(alpha, rho, lambda_)
252  );
253 
254  lambdaEqn.ref().relax();
255  fvConstraints.constrain(lambdaEqn.ref());
256  solve(lambdaEqn);
257  fvConstraints.constrain(lambda_);
258 
259  lambda_.maxMin(scalar(0), scalar(1));
260 
261  nu_ = calcNu(strainRate);
262 
264 }
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace laminarModels
270 } // End namespace Foam
271 
272 // ************************************************************************* //
bool found
static fvModels & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
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
Finite volume constraints.
Definition: fvConstraints.H:68
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
Finite volume models.
Definition: fvModels.H:69
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
Templated abstract base class for laminar transport models.
Definition: laminarModel.H:52
virtual void correct()
Predict the laminar viscosity.
Definition: laminarModel.C:275
Thixotropic viscosity momentum transport model based on the evolution of the structural parameter :
BasicMomentumTransportModel::alphaField alphaField
virtual void correct()
Correct the lambdaThixotropic viscosity.
lambdaThixotropic(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 tmp< volScalarField > nuEff() const
Return the effective viscosity.
virtual bool read()
Read momentumTransport dictionary.
BasicMomentumTransportModel::rhoField rhoField
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
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))
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for implicit and explicit sources.
label patchi
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))
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
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.
const doubleScalar e
Definition: doubleScalar.H:106
const dimensionSet & dimless
Definition: dimensions.C:138
const dimensionSet & dimKinematicViscosity
Definition: dimensions.C:171
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
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimTime
Definition: dimensions.C:142
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimDensity
Definition: dimensions.C:158
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:188
const dimensionSet & dimPressure
Definition: dimensions.C:163
void symm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
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)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
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
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
Typedefs for UniformDimensionedField.