solidification.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2020 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 
29 #include "solidification.H"
31 #include "thermoSingleLayer.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace regionModels
38 {
39 namespace surfaceFilmModels
40 {
41 
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 
44 defineTypeNameAndDebug(solidification, 0);
45 
47 (
48  phaseChangeModel,
49  solidification,
50  dictionary
51 );
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
55 solidification::solidification
56 (
58  const dictionary& dict
59 )
60 :
61  phaseChangeModel(typeName, film, dict),
62  T0_(coeffDict_.get<scalar>("T0")),
63  maxSolidificationFrac_
64  (
65  coeffDict_.getOrDefault<scalar>("maxSolidificationFrac", 0.2)
66  ),
67  maxSolidificationRate_
68  (
69  "maxSolidificationRate",
71  GREAT,
72  coeffDict_
73  ),
74  mass_
75  (
76  IOobject
77  (
78  typeName + ":mass",
79  film.regionMesh().time().timeName(),
80  film.regionMesh(),
83  ),
84  film.regionMesh(),
86  zeroGradientFvPatchScalarField::typeName
87  ),
88  thickness_
89  (
90  IOobject
91  (
92  typeName + ":thickness",
93  film.regionMesh().time().timeName(),
94  film.regionMesh(),
97  ),
98  film.regionMesh(),
100  zeroGradientFvPatchScalarField::typeName
101  )
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
106 
108 {}
109 
110 
111 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
112 
114 (
115  const scalar dt,
116  scalarField& availableMass,
117  scalarField& dMass,
118  scalarField& dEnergy
119 )
120 {
121  const thermoSingleLayer& film = filmType<thermoSingleLayer>();
122 
123  const scalarField& T = film.T();
124  const scalarField& alpha = film.alpha();
125 
126  const scalar rateLimiter = min
127  (
128  maxSolidificationFrac_,
129  (
130  maxSolidificationRate_
131  *filmModel_.regionMesh().time().deltaTValue()
132  ).value()
133  );
134 
135  forAll(alpha, celli)
136  {
137  if (alpha[celli] > 0.5)
138  {
139  if (T[celli] < T0_)
140  {
141  const scalar dm = rateLimiter*availableMass[celli];
142 
143  mass_[celli] += dm;
144  dMass[celli] += dm;
145 
146  // Heat is assumed to be removed by heat-transfer to the wall
147  // so the energy remains unchanged by the phase-change.
148  }
149  }
150  }
151 
152  thickness_ = mass_/film.magSf()/film.rho();
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace surfaceFilmModels
159 } // End namespace regionModels
160 } // End namespace Foam
161 
162 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
Foam::regionModels::surfaceFilmModels::solidification::~solidification
virtual ~solidification()
Destructor.
Definition: solidification.C:107
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::regionModels::surfaceFilmModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(surfaceFilmRegionModel, kinematicSingleLayer, mesh)
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
thermoSingleLayer.H
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::regionModels::surfaceFilmModels::thermoSingleLayer
Thermodynamic form of single-cell layer surface film model.
Definition: thermoSingleLayer.H:67
Foam::Field< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::regionModels::surfaceFilmModels::solidification::correctModel
virtual void correctModel(const scalar dt, scalarField &availableMass, scalarField &dMass, scalarField &dEnergy)
Correct.
Definition: solidification.C:114
Foam::regionModels::singleLayerRegion::magSf
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
Definition: singleLayerRegion.C:223
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:187
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::regionModels::surfaceFilmModels::thermoSingleLayer::T
virtual const volScalarField & T() const
Return the film mean temperature [K].
Definition: thermoSingleLayer.C:662
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::regionModels::surfaceFilmModels::defineTypeNameAndDebug
defineTypeNameAndDebug(kinematicSingleLayer, 0)
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::alpha
const volScalarField & alpha() const
Return the film coverage, 1 = covered, 0 = uncovered [].
Definition: kinematicSingleLayerI.H:92
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::rho
virtual const volScalarField & rho() const
Return the film density [kg/m3].
Definition: kinematicSingleLayer.C:982
Foam::IOobject::NO_READ
Definition: IOobject.H:188
solidification.H
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189
Foam::regionModels::surfaceFilmModels::phaseChangeModel
Base class for surface film phase change models.
Definition: phaseChangeModel.H:57