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 -------------------------------------------------------------------------------
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 "solidification.H"
30 #include "thermoSingleLayer.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace regionModels
37 {
38 namespace surfaceFilmModels
39 {
40 
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 
43 defineTypeNameAndDebug(solidification, 0);
44 
46 (
47  phaseChangeModel,
48  solidification,
49  dictionary
50 );
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 solidification::solidification
55 (
57  const dictionary& dict
58 )
59 :
60  phaseChangeModel(typeName, film, dict),
61  T0_(coeffDict_.get<scalar>("T0")),
62  maxSolidificationFrac_
63  (
64  coeffDict_.lookupOrDefault("maxSolidificationFrac", 0.2)
65  ),
66  maxSolidificationRate_
67  (
68  "maxSolidificationRate",
70  GREAT,
71  coeffDict_
72  ),
73  mass_
74  (
75  IOobject
76  (
77  typeName + ":mass",
78  film.regionMesh().time().timeName(),
79  film.regionMesh(),
82  ),
83  film.regionMesh(),
85  zeroGradientFvPatchScalarField::typeName
86  ),
87  thickness_
88  (
89  IOobject
90  (
91  typeName + ":thickness",
92  film.regionMesh().time().timeName(),
93  film.regionMesh(),
96  ),
97  film.regionMesh(),
99  zeroGradientFvPatchScalarField::typeName
100  )
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
105 
107 {}
108 
109 
110 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
111 
113 (
114  const scalar dt,
115  scalarField& availableMass,
116  scalarField& dMass,
117  scalarField& dEnergy
118 )
119 {
120  const thermoSingleLayer& film = filmType<thermoSingleLayer>();
121 
122  const scalarField& T = film.T();
123  const scalarField& alpha = film.alpha();
124 
125  const scalar rateLimiter = min
126  (
127  maxSolidificationFrac_,
128  (
129  maxSolidificationRate_
130  *filmModel_.regionMesh().time().deltaTValue()
131  ).value()
132  );
133 
134  forAll(alpha, celli)
135  {
136  if (alpha[celli] > 0.5)
137  {
138  if (T[celli] < T0_)
139  {
140  const scalar dm = rateLimiter*availableMass[celli];
141 
142  mass_[celli] += dm;
143  dMass[celli] += dm;
144 
145  // Heat is assumed to be removed by heat-transfer to the wall
146  // so the energy remains unchanged by the phase-change.
147  }
148  }
149  }
150 
151  thickness_ = mass_/film.magSf()/film.rho();
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 } // End namespace surfaceFilmModels
158 } // End namespace regionModels
159 } // End namespace Foam
160 
161 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::regionModels::surfaceFilmModels::solidification::~solidification
virtual ~solidification()
Destructor.
Definition: solidification.C:106
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
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:764
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:290
thermoSingleLayer.H
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
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:113
Foam::regionModels::singleLayerRegion::magSf
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
Definition: singleLayerRegion.C:222
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:63
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:122
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:43
Foam::regionModels::surfaceFilmModels::thermoSingleLayer::T
virtual const volScalarField & T() const
Return the film mean temperature [K].
Definition: thermoSingleLayer.C:685
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:121
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:52
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:91
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:246
Foam::regionModels::surfaceFilmModels::kinematicSingleLayer::rho
virtual const volScalarField & rho() const
Return the film density [kg/m3].
Definition: kinematicSingleLayer.C:1011
Foam::IOobject::NO_READ
Definition: IOobject.H:123
solidification.H
Foam::regionModels::surfaceFilmModels::phaseChangeModel
Base class for surface film phase change models.
Definition: phaseChangeModel.H:57