interfaceOxideRate.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) 2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "interfaceOxideRate.H"
29 #include "cutCellIso.H"
30 #include "volPointInterpolation.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Thermo, class OtherThermo>
38 (
39  const dictionary& dict,
40  const phasePair& pair
41 )
42 :
43  InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
44  C_
45  (
47  (
49  dict.getCheck<scalar>("C", scalarMinMax::ge(0))
50  )
51  ),
52  Tliquidus_
53  (
55  (
57  dict.getCheck<scalar>("Tliquidus", scalarMinMax::ge(0))
58  )
59  ),
60  Tsolidus_
61  (
63  (
65  dict.getCheck<scalar>("Tsolidus", scalarMinMax::ge(0))
66  )
67  ),
68  oxideCrit_
69  (
71  (
72  dimDensity,
73  dict.getCheck<scalar>("oxideCrit", scalarMinMax::ge(0))
74  )
75  ),
76  mDotOxide_
77  (
78  IOobject
79  (
80  "mDotOxide",
81  this->mesh_.time().timeName(),
82  this->mesh_,
83  IOobject::NO_READ,
84  IOobject::AUTO_WRITE
85  ),
86  this->mesh_,
88  ),
89  isoAlpha_(dict.getOrDefault<scalar>("isoAlpha", 0.5))
90 {}
91 
92 
93 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
94 
95 template<class Thermo, class OtherThermo>
98 (
99  const volScalarField& T
100 )
101 {
102  const volScalarField& from = this->pair().from();
103  const volScalarField& to = this->pair().to();
104 
105  // (CSC:Eq. 2)
106  const fvMesh& mesh = this->mesh_;
107  scalarField ap
108  (
110  );
111 
112  cutCellIso cutCell(mesh, ap);
113 
114  tmp<volScalarField> tSalpha = scalar(0)*from;
115  volScalarField& Salpha = tSalpha.ref();
116 
117  forAll(Salpha, celli)
118  {
119  const label status = cutCell.calcSubCell(celli, isoAlpha_);
120  if (status == 0) // cell is cut
121  {
122  Salpha[celli] = scalar(1);
123  }
124  }
125 
126  // (CSC:Eq. 5)
127  tmp<volScalarField> tSoxide =
128  max((oxideCrit_.value() - to)/oxideCrit_.value(), scalar(0));
129 
130  // (CSC:Eq. 4)
131  tmp<volScalarField> tST =
132  Foam::exp
133  (
134  scalar(1)
135  - scalar(1)/max((T - Tsolidus_)/(Tliquidus_ - Tsolidus_),scalar(1e-6))
136  );
137 
138  // (CSC:Eq. 6)
139  mDotOxide_ = C_*tSalpha*tSoxide*tST;
140 
141  const volScalarField::Boundary& alphab = to.boundaryField();
142 
143  forAll(alphab, patchi)
144  {
145  if (isA<timeVaryingMassSorptionFvPatchScalarField>(alphab[patchi]))
146  {
147  const auto& pp =
148  refCast<const timeVaryingMassSorptionFvPatchScalarField>
149  (
150  alphab[patchi]
151  );
152  const labelUList& fc = mesh.boundary()[patchi].faceCells();
153  tmp<scalarField> tsb = pp.source();
154 
155  auto tRhoto = tmp<volScalarField>::New
156  (
157  IOobject
158  (
159  "tRhoto",
160  mesh.time().timeName(),
161  mesh
162  ),
163  mesh,
165  );
166  volScalarField& rhoto = tRhoto.ref();
167 
168  rhoto = this->pair().to().rho();
169 
170  forAll(fc, faceI)
171  {
172  const label cellI = fc[faceI];
173  const scalar rhoI = rhoto[cellI];
174  mDotOxide_[cellI] += rhoI*tsb()[faceI];
175  }
176  }
177  }
178 
179  return tmp<volScalarField>::New(mDotOxide_);
180 }
181 
182 
183 template<class Thermo, class OtherThermo>
186 (
187  label variable,
188  const volScalarField& refValue
189 )
190 {
191  return nullptr;
192 }
193 
194 
195 template<class Thermo, class OtherThermo>
198 (
199  label variable,
200  const volScalarField& refValue
201 )
202 {
203  return nullptr;
204 }
205 
206 
207 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
Definition: MeshObject.C:53
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
Class for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with an isosurface defined ...
Definition: cutCellIso.H:72
Base class for interface composition models, templated on the two thermodynamic models either side of...
virtual tmp< volScalarField > Kexp(const volScalarField &field)
Explicit total mass transfer coefficient.
Service routines for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with a surface...
Definition: cutCell.H:55
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
virtual const multiphaseInter::phaseModel & to() const
To phase.
Definition: phasePair.C:52
word timeName
Definition: getTimeIndex.H:3
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
virtual const multiphaseInter::phaseModel & from() const
From phase.
Definition: phasePair.C:42
dynamicFvMesh & mesh
dimensionedScalar exp(const dimensionedScalar &ds)
interfaceOxideRate(const dictionary &dict, const phasePair &pair)
Construct from components.
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:52
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
tmp< volScalarField > rho() const
Return the phase density.
Definition: phaseModel.C:115
const dimensionSet dimDensity
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
virtual tmp< volScalarField > KSp(label modelVariable, const volScalarField &field)
Implicit mass transfer coefficient.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:49
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
virtual tmp< volScalarField > KSu(label modelVariable, const volScalarField &field)
Explicit mass transfer coefficient.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127