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",
79  dimensions::kinematicPressure,
80  this->typeDict(type)
81  )
83  (
84  "sigmay",
85  dimensions::kinematicPressure,
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  dimless
102  ),
103 
104  nu_
105  (
106  IOobject
107  (
108  this->groupName(typedName("nu")),
109  this->runTime_.name(),
110  this->mesh_,
111  IOobject::NO_READ,
112  IOobject::AUTO_WRITE
113  ),
114  calcNu(this->strainRate())
115  )
116 {}
117 
118 
119 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
120 
121 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
124 (
125  const volScalarField& strainRate
126 ) const
127 {
129  (
130  nuInf_/(sqr(1 - K_*lambda_) + rootVSmall)
131  );
132 
133  // Add optional yield stress contribution to the viscosity
134  if (BinghamPlastic_)
135  {
136  dimensionedScalar sigmaySmall
137  (
138  "sigmaySmall",
139  sigmay_.dimensions(),
140  small
141  );
142 
143  // Limit the Bingham viscosity to 100x the thixotropic viscosity
144  // for numerical stability
145  dimensionedScalar nuMax_("nuMax", 100*nu0_);
146 
147  nu.ref() = min
148  (
149  sigmay_/(strainRate + 1e-4*(sigmay_ + sigmaySmall)/nu0_) + nu(),
150  nuMax_
151  );
152  }
153 
154  return nu;
155 }
156 
157 
158 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
159 tmp<volScalarField>
160 lambdaThixotropic<BasicMomentumTransportModel, ViscousStress>::
161 strainRate() const
162 {
163  return sqrt(2.0)*mag(symm(fvc::grad(this->U())));
164 }
165 
166 
167 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
168 
169 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
171 {
173  {
174  a_.read(this->typeDict());
175  b_.read(this->typeDict());
176  d_.read(this->typeDict());
177 
178  c_ = dimensionedScalar
179  (
180  "c",
181  pow(dimTime, d_.value() - scalar(1)),
182  this->typeDict()
183  );
184 
185  nu0_.read(this->typeDict());
186  nuInf_.read(this->typeDict());
187 
188  K_ = (1 - sqrt(nuInf_/nu0_));
189 
190  return true;
191  }
192  else
193  {
194  return false;
195  }
196 }
197 
198 
199 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
202 {
203  return volScalarField::New
204  (
205  this->groupName("nuEff"),
206  nu_
207  );
208 }
209 
210 
211 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
214 (
215  const label patchi
216 ) const
217 {
218  return nu_.boundaryField()[patchi];
219 }
220 
221 
222 template<class BasicMomentumTransportModel, template<class> class ViscousStress>
224 {
225  // Local references
226  const alphaField& alpha = this->alpha_;
227  const rhoField& rho = this->rho_;
228  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
229  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
231  (
232  Foam::fvConstraints::New(this->mesh_)
233  );
234 
235  const volScalarField strainRate(this->strainRate());
236 
237  tmp<fvScalarMatrix> lambdaEqn
238  (
239  fvm::ddt(alpha, rho, lambda_)
240  + fvm::div(alphaRhoPhi, lambda_)
241  ==
242  alpha()*rho()*a_*pow(1 - lambda_(), b_)
243  - fvm::Sp
244  (
245  rho()
246  *(
247  alpha()*c_*pow(strainRate(), d_)
248  + max(residualAlpha_ - alpha(), dimensionedScalar(dimless, 0))*a_
249  ),
250  lambda_
251  )
252  + fvModels.source(alpha, rho, lambda_)
253  );
254 
255  lambdaEqn.ref().relax();
256  fvConstraints.constrain(lambdaEqn.ref());
257  solve(lambdaEqn);
258  fvConstraints.constrain(lambda_);
259 
260  lambda_.maxMin(scalar(0), scalar(1));
261 
262  nu_ = calcNu(strainRate);
263 
265 }
266 
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 } // End namespace laminarModels
271 } // End namespace Foam
272 
273 // ************************************************************************* //
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))
const dimensionSet dimless
const dimensionSet kinematicPressure
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 & dimKinematicViscosity
Definition: dimensions.C:297
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:277
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:188
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.