SchaefferFrictionalStress.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2018 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "unitConversion.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace kineticTheoryModels
38 {
39 namespace frictionalStressModels
40 {
41  defineTypeNameAndDebug(Schaeffer, 0);
42 
44  (
45  frictionalStressModel,
46  Schaeffer,
47  dictionary
48  );
49 }
50 }
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
57 (
58  const dictionary& dict
59 )
60 :
62  coeffDict_(dict.optionalSubDict(typeName + "Coeffs")),
63  phi_("phi", dimless, coeffDict_)
64 {
65  phi_ *= degToRad();
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
70 
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
80 (
81  const phaseModel& phase,
82  const dimensionedScalar& alphaMinFriction,
84 ) const
85 {
86  const volScalarField& alpha = phase;
87 
88  return
89  dimensionedScalar("", dimensionSet(1, -1, -2, 0, 0), 1e24)
90  *pow(Foam::max(alpha - alphaMinFriction, scalar(0)), 10.0);
91 }
92 
93 
97 (
98  const phaseModel& phase,
99  const dimensionedScalar& alphaMinFriction,
101 ) const
102 {
103  const volScalarField& alpha = phase;
104 
105  return
106  dimensionedScalar("", dimensionSet(1, -1, -2, 0, 0), 1e25)
107  *pow(Foam::max(alpha - alphaMinFriction, scalar(0)), 9.0);
108 }
109 
110 
113 (
114  const phaseModel& phase,
115  const dimensionedScalar& alphaMinFriction,
117  const volScalarField& pf,
118  const volSymmTensorField& D
119 ) const
120 {
121  const volScalarField& alpha = phase;
122 
124  (
125  new volScalarField
126  (
127  IOobject
128  (
129  "Schaeffer:nu",
130  phase.mesh().time().timeName(),
131  phase.mesh(),
135  ),
136  phase.mesh(),
137  dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero)
138  )
139  );
140 
141  volScalarField& nuf = tnu.ref();
142 
143  forAll(D, celli)
144  {
145  if (alpha[celli] > alphaMinFriction.value())
146  {
147  nuf[celli] =
148  0.5*pf[celli]*sin(phi_.value())
149  /(
150  sqrt((1.0/3.0)*sqr(tr(D[celli])) - invariantII(D[celli]))
151  + SMALL
152  );
153  }
154  }
155 
156  const fvPatchList& patches = phase.mesh().boundary();
157  const volVectorField& U = phase.U();
158 
160 
161  forAll(patches, patchi)
162  {
163  if (!patches[patchi].coupled())
164  {
165  nufBf[patchi] =
166  (
167  pf.boundaryField()[patchi]*sin(phi_.value())
168  /(
169  mag(U.boundaryField()[patchi].snGrad())
170  + SMALL
171  )
172  );
173  }
174  }
175 
176  // Correct coupled BCs
178 
179  return tnu;
180 }
181 
182 
184 {
185  coeffDict_ <<= dict_.optionalSubDict(typeName + "Coeffs");
186 
187  phi_.read(coeffDict_);
188  phi_ *= degToRad();
189 
190  return true;
191 }
192 
193 
194 // ************************************************************************* //
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a SymmTensor.
Definition: SymmTensorI.H:581
const Type & value() const noexcept
Return const reference to value.
dictionary dict
Schaeffer(const dictionary &dict)
Construct from components.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Unit conversion functions.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
addToRunTimeSelectionTable(frictionalStressModel, JohnsonJackson, dictionary)
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
dimensionedScalar alphaMax("alphaMax", dimless/dimTime, laminarTransport)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
virtual tmp< volScalarField > frictionalPressure(const phaseModel &phase, const dimensionedScalar &alphaMinFriction, const dimensionedScalar &alphaMax) const
const Mesh & mesh() const noexcept
Return mesh.
dimensionedScalar sin(const dimensionedScalar &ds)
virtual tmp< volScalarField > nu(const phaseModel &phase, const dimensionedScalar &alphaMinFriction, const dimensionedScalar &alphaMax, const volScalarField &pf, const volSymmTensorField &D) const
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
U
Definition: pEqn.H:72
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
const polyBoundaryMesh & patches
Nothing to be read.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
virtual tmp< volScalarField > frictionalPressurePrime(const phaseModel &phase, const dimensionedScalar &alphaMinFriction, const dimensionedScalar &alphaMax) const
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phase.H:50
void correctBoundaryConditions()
Correct boundary field.
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
const dimensionedScalar & D
A class for managing temporary objects.
Definition: HashPtrTable.H:50
bool coupled
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:53
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Do not request registration (bool: false)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127