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 :
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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::phasePair
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:53
Foam::InterfaceCompositionModel
Base class for interface composition models, templated on the two thermodynamic models either side of...
Definition: InterfaceCompositionModel.H:58
Foam::meltingEvaporationModels::interfaceOxideRate::KSu
virtual tmp< volScalarField > KSu(label modelVariable, const volScalarField &field)
Explicit mass transfer coefficient.
Definition: interfaceOxideRate.C:198
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dimDensity
const dimensionSet dimDensity
interfaceOxideRate.H
Foam::phasePair::to
virtual const phaseModel & to() const
To phase.
Definition: phasePair.C:59
Foam::meltingEvaporationModels::interfaceOxideRate::interfaceOxideRate
interfaceOxideRate(const dictionary &dict, const phasePair &pair)
Construct from components.
Definition: interfaceOxideRate.C:38
Foam::exp
dimensionedScalar exp(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:261
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
cutCellIso.H
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::Field< scalar >
Foam::meltingEvaporationModels::interfaceOxideRate::Kexp
virtual tmp< volScalarField > Kexp(const volScalarField &field)
Explicit total mass transfer coefficient.
Definition: interfaceOxideRate.C:98
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::cutCell
Service routines for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with a surface.
Definition: cutCell.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned< scalar >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
T
const volScalarField & T
Definition: createFieldRefs.H:2
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
volPointInterpolation.H
Foam::cutCellIso
Class for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with an isosurface defined ...
Definition: cutCellIso.H:76
timeVaryingMassSorptionFvPatchScalarField.H
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::phasePair::from
virtual const phaseModel & from() const
From phase.
Definition: phasePair.C:49
Foam::UList< label >
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::meltingEvaporationModels::interfaceOxideRate::KSp
virtual tmp< volScalarField > KSp(label modelVariable, const volScalarField &field)
Implicit mass transfer coefficient.
Definition: interfaceOxideRate.C:186
Foam::phaseModel::rho
const dimensionedScalar & rho() const
Definition: phaseModel.H:167
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62