SchaefferFrictionalStress.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-2020 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 
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace kineticTheoryModels
34 {
35 namespace frictionalStressModels
36 {
37  defineTypeNameAndDebug(Schaeffer, 0);
38 
40  (
41  frictionalStressModel,
42  Schaeffer,
43  dictionary
44  );
45 }
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
53 (
54  const dictionary& dict
55 )
56 :
57  frictionalStressModel(dict),
58  coeffDict_(dict.optionalSubDict(typeName + "Coeffs")),
59  phi_("phi", dimless, coeffDict_)
60 {
61  phi_ *= constant::mathematical::pi/180.0;
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
76 (
77  const phaseModel& phase,
78  const dimensionedScalar& alphaMinFriction,
79  const dimensionedScalar& alphaMax
80 ) const
81 {
82  const volScalarField& alpha = phase;
83 
84  return
85  dimensionedScalar(dimensionSet(1, -1, -2, 0, 0), 1e24)
86  *pow(Foam::max(alpha - alphaMinFriction, scalar(0)), 10.0);
87 }
88 
89 
93 (
94  const phaseModel& phase,
95  const dimensionedScalar& alphaMinFriction,
96  const dimensionedScalar& alphaMax
97 ) const
98 {
99  const volScalarField& alpha = phase;
100 
101  return
102  dimensionedScalar(dimensionSet(1, -1, -2, 0, 0), 1e25)
103  *pow(Foam::max(alpha - alphaMinFriction, scalar(0)), 9.0);
104 }
105 
106 
109 (
110  const phaseModel& phase,
111  const dimensionedScalar& alphaMinFriction,
112  const dimensionedScalar& alphaMax,
113  const volScalarField& pf,
114  const volSymmTensorField& D
115 ) const
116 {
117  const volScalarField& alpha = phase;
118 
119  tmp<volScalarField> tnu
120  (
122  (
124  (
125  IOobject::modelName("nu", frictionalStressModel::typeName),
126  phase.group()
127  ),
128  phase.mesh(),
129  dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), 0)
130  )
131  );
132 
133  volScalarField& nuf = tnu.ref();
134 
135  forAll(D, celli)
136  {
137  if (alpha[celli] > alphaMinFriction.value())
138  {
139  nuf[celli] =
140  0.5*pf[celli]*sin(phi_.value())
141  /(
142  sqrt((1.0/3.0)*sqr(tr(D[celli])) - invariantII(D[celli]))
143  + small
144  );
145  }
146  }
147 
148  const fvPatchList& patches = phase.mesh().boundary();
149  const volVectorField& U = phase.U();
150 
151  volScalarField::Boundary& nufBf = nuf.boundaryFieldRef();
152 
153  forAll(patches, patchi)
154  {
155  if (!patches[patchi].coupled())
156  {
157  nufBf[patchi] =
158  (
159  pf.boundaryField()[patchi]*sin(phi_.value())
160  /(
161  mag(U.boundaryField()[patchi].snGrad())
162  + small
163  )
164  );
165  }
166  }
167 
168  // Correct coupled BCs
169  nuf.correctBoundaryConditions();
170 
171  return tnu;
172 }
173 
174 
176 {
177  coeffDict_ <<= dict_.optionalSubDict(typeName + "Coeffs");
178 
179  phi_.read(coeffDict_);
180  phi_ *= constant::mathematical::pi/180.0;
181 
182  return true;
183 }
184 
185 
186 // ************************************************************************* //
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a symmetric tensor.
Definition: SymmTensorI.H:403
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:61
virtual tmp< volScalarField > frictionalPressurePrime(const phaseModel &phase, const dimensionedScalar &alphaMinFriction, const dimensionedScalar &alphaMax) const
dictionary dict
Schaeffer(const dictionary &dict)
Construct from components.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Internal &, const PtrList< fvPatchField< scalar >> &)
Return a temporary field constructed from name,.
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionSet dimless
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
void read(const dictionary &)
Update the value of dimensioned<Type>
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1040
static word groupName(Name name, const word &group)
const Type & value() const
Return const reference to value.
virtual tmp< volScalarField > nu(const phaseModel &phase, const dimensionedScalar &alphaMinFriction, const dimensionedScalar &alphaMax, const volScalarField &pf, const volSymmTensorField &D) const
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
dimensionedScalar sin(const dimensionedScalar &ds)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
const dictionary & dict_
Reference to higher-level dictionary for re-read.
virtual tmp< volScalarField > frictionalPressure(const phaseModel &phase, const dimensionedScalar &alphaMinFriction, const dimensionedScalar &alphaMax) const
defineTypeNameAndDebug(combustionModel, 0)
Internal & ref()
Return a reference to the dimensioned internal field.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:45
label patchi
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensioned< scalar > mag(const dimensioned< Type > &)
static word modelName(Name name, const word &model)
Return the name of the object within the given model.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.