solidificationMeltingSource.H
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) 2014-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::fv::solidificationMeltingSource
29
30Group
31 grpFvOptionsSources
32
33Description
34 This source is designed to model the effect of solidification and
35 melting processes, e.g. windhield defrosting, within a specified region.
36 The phase change occurs at the melting temperature, \c Tmelt.
37
38 The presence of the solid phase in the flow field is incorporated into the
39 model as a momentum porosity contribution; the energy associated with the
40 phase change is added as an enthalpy contribution.
41
42 References:
43 \verbatim
44 Voller, V. R., & Prakash, C. (1987).
45 A fixed grid numerical modelling methodology for
46 convection-diffusion mushy region phase-change problems.
47 International Journal of Heat and Mass Transfer, 30(8), 1709-1719.
48 DOI:10.1016/0017-9310(87)90317-6
49
50 Swaminathan, C. R., & Voller, V. R. (1992).
51 A general enthalpy method for modeling solidification processes.
52 Metallurgical transactions B, 23(5), 651-664.
53 DOI:10.1007/BF02649725
54 \endverbatim
55
56 The model generates a field \c <name>:alpha1 which can be visualised to
57 to show the melt distribution as a fraction [0-1].
58
59Usage
60 Minimal example by using \c constant/fvOptions:
61 \verbatim
62 solidificationMeltingSource1
63 {
64 // Mandatory entries (unmodifiable)
65 type solidificationMeltingSource;
66
67 // Mandatory entries (runtime modifiable)
68 Tmelt 273;
69 L 334000;
70 thermoMode <thermoModeName>;
71 rhoRef 800;
72 beta 5e-6;
73
74 // Optional entries (runtime modifiable)
75 relax 0.9;
76 T <Tname>;
77 rho <rhoName>;
78 U <Uname>;
79 phi <phiName>;
80 Cu 1e5;
81 q 1e-2;
82
83 // Conditional optional entries (runtime modifiable)
84
85 // when thermoMode=lookup
86 Cp Cp;
87
88 // Conditional mandatory entries (runtime modifiable)
89
90 // when Cp=CpRef
91 CpRef 1000;
92
93 // Mandatory/Optional (inherited) entries
94 ...
95 }
96 \endverbatim
97
98 where the entries mean:
99 \table
100 Property | Description | Type | Reqd | Dflt
101 type | Type name: solidificationMeltingSource | word | yes | -
102 Tmelt | Melting temperature [K] | scalar | yes | -
103 L | Latent heat of fusion [J/kg] | scalar | yes | -
104 thermoMode | Thermo mode | word | yes | -
105 rhoRef | Reference (solid) density | scalar | yes | -
106 beta | Thermal expansion coefficient [1/K] | scalar | yes | -
107 relax | Relaxation factor [0-1] | scakar | no | 0.9
108 T | Name of operand temperature field | word | no | T
109 rho | Name of operand density field | word | no | rho
110 U | Name of operand velocity field | word | no | U
111 phi | Name of operand flux field | word | no | phi
112 Cu | Mushy region momentum sink coefficient [1/s] <!--
113 --> | scalar | no | 1e5
114 q | Coefficient used in porosity calc | scalar | no | 1e-2
115 Cp | Name of specific heat capacity field | word | cndtnl | Cp
116 CpRef | Specific heat capacity value | scalar | cndtnl | -
117 \endtable
118
119 The inherited entries are elaborated in:
120 - \link fvOption.H \endlink
121 - \link cellSetOption.H \endlink
122
123 Options for the \c thermoMode entry:
124 \verbatim
125 thermo | Access Cp information from database
126 lookup | Access Cp information by looking up from dictionary
127 \endverbatim
128
129SourceFiles
130 solidificationMeltingSource.C
131 solidificationMeltingSourceTemplates.C
132
133\*---------------------------------------------------------------------------*/
134
135#ifndef solidificationMeltingSource_H
136#define solidificationMeltingSource_H
137
138#include "fvMesh.H"
139#include "volFields.H"
140#include "cellSetOption.H"
141#include "Enum.H"
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145namespace Foam
146{
147namespace fv
148{
149
150/*---------------------------------------------------------------------------*\
151 Class solidificationMeltingSource Declaration
152\*---------------------------------------------------------------------------*/
153
154class solidificationMeltingSource
155:
156 public fv::cellSetOption
157{
158public:
159
160 // Public Enumerations
161
162 //- Options for the thermo mode specification
163 enum thermoMode
164 {
165 mdThermo,
167 };
168
169 //- Names for thermoMode
170 static const Enum<thermoMode> thermoModeTypeNames_;
171
172
173private:
174
175 // Private Data
176
177 //- Temperature at which melting occurs [K]
178 scalar Tmelt_;
179
180 //- Latent heat of fusion [J/kg]
181 scalar L_;
182
183 //- Phase fraction under-relaxation coefficient
184 scalar relax_;
185
186 //- Thermodynamics mode
187 thermoMode mode_;
188
189 //- Reference density - typically the solid density
190 scalar rhoRef_;
191
192 //- Name of operand temperature field
193 word TName_;
194
195 //- Name of specific heat capacity field
196 word CpName_;
197
198 //- Name of operand velocity field
199 word UName_;
200
201 //- Name of operand flux field
202 word phiName_;
203
204 //- Mushy region momentum sink coefficient [1/s]
205 scalar Cu_;
206
207 //- Coefficient used in porosity calculation
208 scalar q_;
209
210 //- Thermal expansion coefficient [1/K]
211 scalar beta_;
212
213 //- Phase fraction indicator field
214 volScalarField alpha1_;
215
216 //- Current time index (used for updating)
217 label curTimeIndex_;
218
219 //- Temperature change cached for source calculation when alpha1 updated
220 scalarField deltaT_;
221
222
223 // Private Member Functions
224
225 //- Return the specific heat capacity field
226 tmp<volScalarField> Cp() const;
227
228 //- Update the model
229 void update(const volScalarField& Cp);
230
231 //- Helper function to apply to the energy equation
232 template<class RhoFieldType>
233 void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn);
234
235
236public:
237
238 //- Runtime type information
239 TypeName("solidificationMeltingSource");
240
241
242 // Constructors
243
244 //- Construct from explicit source name and mesh
246 (
247 const word& sourceName,
248 const word& modelType,
249 const dictionary& dict,
250 const fvMesh& mesh
251 );
252
253 //- No copy construct
255 (
257 ) = delete;
258
259 //- No copy assignment
261
263 //- Destructor
265
266
267 // Member Functions
268
269 //- Add explicit contribution to enthalpy equation
270 virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
271
272 //- Add implicit contribution to momentum equation
273 virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
274
275 //- Add explicit contribution to compressible enthalpy equation
276 virtual void addSup
277 (
278 const volScalarField& rho,
279 fvMatrix<scalar>& eqn,
280 const label fieldi
281 );
282
283 //- Add implicit contribution to compressible momentum equation
284 virtual void addSup
285 (
286 const volScalarField& rho,
287 fvMatrix<vector>& eqn,
288 const label fieldi
289 );
290
291
292 //- Read source dictionary
293 virtual bool read(const dictionary& dict);
294};
295
296
297// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298
299} // End namespace fv
300} // End namespace Foam
301
302// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303
304#ifdef NoRepository
306#endif
307
308// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309
310#endif
311
312// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Intermediate abstract class for handling cell-set options for the derived fvOptions.
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
This source is designed to model the effect of solidification and melting processes,...
TypeName("solidificationMeltingSource")
Runtime type information.
solidificationMeltingSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
~solidificationMeltingSource()=default
Destructor.
thermoMode
Options for the thermo mode specification.
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to enthalpy equation.
virtual bool read(const dictionary &dict)
Read source dictionary.
static const Enum< thermoMode > thermoModeTypeNames_
Names for thermoMode.
solidificationMeltingSource(const solidificationMeltingSource &)=delete
No copy construct.
void operator=(const solidificationMeltingSource &)=delete
No copy assignment.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
mesh update()
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
labelList fv(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73