interfaceHeatResistance.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) 2020 Henning Scheufler
9  Copyright (C) 2020-2021 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 
30 #include "constants.H"
31 #include "cutCellIso.H"
32 #include "volPointInterpolation.H"
33 #include "wallPolyPatch.H"
34 #include "fvcSmooth.H"
35 
36 using namespace Foam::constant;
37 
38 
39 // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
40 
41 template<class Thermo, class OtherThermo>
45 {
46  const fvMesh& mesh = this->mesh_;
47 
48  const volScalarField& alpha = this->pair().from();
49 
50  scalarField ap
51  (
53  );
54 
55  cutCellIso cutCell(mesh, ap);
56 
57  forAll(interfaceArea_, celli)
58  {
59  label status = cutCell.calcSubCell(celli, isoAlpha_);
60  interfaceArea_[celli] = 0;
61  if (status == 0) // cell is cut
62  {
63  interfaceArea_[celli] =
64  mag(cutCell.faceArea())/mesh.V()[celli];
65  }
66  }
67 
68  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
69 
70  forAll(pbm, patchi)
71  {
72  if (isA<wallPolyPatch>(pbm[patchi]))
73  {
74  const polyPatch& pp = pbm[patchi];
75  forAll(pp.faceCells(), faceI)
76  {
77  const label pCelli = pp.faceCells()[faceI];
78  bool interface(false);
79  if
80  (
81  sign(R_.value()) > 0
82  && (T[pCelli] - Tactivate_.value()) > 0
83  )
84  {
85  interface = true;
86  }
87 
88  if
89  (
90  sign(R_.value()) < 0
91  && (T[pCelli] - Tactivate_.value()) < 0
92  )
93  {
94  interface = true;
95  }
96 
97  if
98  (
99  interface
100  &&
101  (
102  alpha[pCelli] < 2*isoAlpha_
103  && alpha[pCelli] > 0.5*isoAlpha_
104  )
105  )
106  {
107  interfaceArea_[pCelli] =
108  mag(pp.faceAreas()[faceI])/mesh.V()[pCelli];
109  }
110  }
111  }
112  }
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
118 template<class Thermo, class OtherThermo>
121 (
122  const dictionary& dict,
123  const phasePair& pair
124 )
125 :
128  Tactivate_("Tactivate", dimTemperature, dict),
129  interfaceArea_
130  (
131  IOobject
132  (
133  "interfaceArea",
134  this->mesh_.time().timeName(),
135  this->mesh_,
138  ),
139  this->mesh_,
141  ),
142  mDotc_
143  (
144  IOobject
145  (
146  "mDotc",
147  this->mesh_.time().timeName(),
148  this->mesh_,
151  ),
152  this->mesh_,
154  ),
155  mDotcSpread_
156  (
157  IOobject
158  (
159  "mDotcSpread",
160  this->mesh_.time().timeName(),
161  this->mesh_,
164  ),
165  this->mesh_,
167  ),
168  htc_
169  (
170  IOobject
171  (
172  "htc",
173  this->mesh_.time().timeName(),
174  this->mesh_,
177  ),
178  this->mesh_,
180  ),
181  isoAlpha_(dict.getOrDefault<scalar>("isoAlpha", 0.5)),
182  spread_(dict.getOrDefault<scalar>("spread", 3))
183 {}
184 
185 
186 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
187 
188 template<class Thermo, class OtherThermo>
192 {
193 
194  const fvMesh& mesh = this->mesh_;
195 
196  updateInterface(T);
197 
198  auto tdeltaT = tmp<volScalarField>::New
199  (
200  IOobject
201  (
202  "tdeltaT",
203  mesh.time().timeName(),
204  mesh
205  ),
206  mesh,
208  );
209  auto& deltaT = tdeltaT.ref();
210 
212 
213  if (sign(R_.value()) > 0)
214  {
215  deltaT = max(T - Tactivate_, T0);
216  }
217  else
218  {
219  deltaT = max(Tactivate_ - T, T0);
220  }
221 
222  word fullSpeciesName = this->transferSpecie();
223  auto tempOpen = fullSpeciesName.find('.');
224  const word speciesName(fullSpeciesName.substr(0, tempOpen));
225 
226  tmp<volScalarField> L = this->L(speciesName, T);
227 
228  htc_ = R_/L();
229 
230  const volScalarField& to = this->pair().to();
231  const volScalarField& from = this->pair().from();
232 
234  (
235  "D",
236  dimArea,
237  spread_/sqr(gAverage(this->mesh_.nonOrthDeltaCoeffs()))
238  );
239 
240  const dimensionedScalar MdotMin("MdotMin", mDotc_.dimensions(), 1e-3);
241 
242  if (max(mDotc_) > MdotMin)
243  {
245  (
246  mDotcSpread_,
247  mDotc_,
248  from,
249  to,
250  D,
251  1e-3
252  );
253  }
254 
255  mDotc_ = interfaceArea_*htc_*deltaT;
256 
257  return tmp<volScalarField>::New(mDotc_);
258 }
259 
260 
261 template<class Thermo, class OtherThermo>
264 ::KSp
265 (
266  label variable,
267  const volScalarField& refValue
268 )
269 {
270  if (this->modelVariable_ == variable)
271  {
272  const volScalarField coeff(htc_*interfaceArea_);
273 
274  if (sign(R_.value()) > 0)
275  {
276  return(coeff*pos(refValue - Tactivate_));
277  }
278  else
279  {
280  return(coeff*pos(Tactivate_ - refValue));
281  }
282  }
283 
284  return nullptr;
285 }
286 
287 
288 template<class Thermo, class OtherThermo>
291 ::KSu
292 (
293  label variable,
294  const volScalarField& refValue
295 )
296 {
297  if (this->modelVariable_ == variable)
298  {
299  const volScalarField coeff(htc_*interfaceArea_*Tactivate_);
300 
301  if (sign(R_.value()) > 0)
302  {
303  return(-coeff*pos(refValue - Tactivate_));
304  }
305  else
306  {
307  return(coeff*pos(Tactivate_ - refValue));
308  }
309  }
310  else if (interfaceCompositionModel::P == variable)
311  {
312  return tmp<volScalarField>::New(mDotcSpread_);
313  }
314 
315  return nullptr;
316 }
317 
318 
319 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
L
const vector L(dict.get< vector >("L"))
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::IOobject::AUTO_WRITE
Definition: IOobject.H:194
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
interfaceHeatResistance.H
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
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
Foam::constant
Different types of constants.
Definition: atomicConstants.C:38
interface
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::MeshObject< fvMesh, UpdateableMeshObject, volPointInterpolation >::New
static const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
Foam::phasePair::to
virtual const phaseModel & to() const
To phase.
Definition: phasePair.C:59
wallPolyPatch.H
Foam::interfaceCompositionModel::P
Definition: interfaceCompositionModel.H:69
Foam::fvc::spreadSource
void spreadSource(volScalarField &mDotOut, const volScalarField &mDotIn, const volScalarField &alpha1, const volScalarField &alpha2, const dimensionedScalar &D, const scalar cutoff)
Definition: fvcSmooth.C:325
Foam::sign
dimensionedScalar sign(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:166
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
cutCellIso.H
Foam::meltingEvaporationModels::interfaceHeatResistance::KSp
virtual tmp< volScalarField > KSp(label modelVariable, const volScalarField &field)
Implicit mass transfer coefficient.
Definition: interfaceHeatResistance.C:265
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::meltingEvaporationModels::interfaceHeatResistance::KSu
virtual tmp< volScalarField > KSu(label modelVariable, const volScalarField &field)
Explicit mass transfer coefficient.
Definition: interfaceHeatResistance.C:292
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
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::dimPower
const dimensionSet dimPower
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::meltingEvaporationModels::interfaceHeatResistance::interfaceHeatResistance
interfaceHeatResistance(const dictionary &dict, const phasePair &pair)
Construct from components.
Definition: interfaceHeatResistance.C:121
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:51
constants.H
volPointInterpolation.H
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::phasePair::from
virtual const phaseModel & from() const
From phase.
Definition: phasePair.C:49
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
D
const dimensionedScalar & D
Definition: solveBulkSurfactant.H:4
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::meltingEvaporationModels::interfaceHeatResistance
Interface Heat Resistance type of condensation/saturation model using spread source distribution foll...
Definition: interfaceHeatResistance.H:127
Foam::meltingEvaporationModels::interfaceHeatResistance::Kexp
virtual tmp< volScalarField > Kexp(const volScalarField &field)
Explicit total mass transfer coefficient.
Definition: interfaceHeatResistance.C:191
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
T0
scalar T0
Definition: createFields.H:22
fvcSmooth.H
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177