solidificationMelting.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2014-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::solidificationMelting
26 
27 Description
28  This source is designed to model the effect of solidification and melting
29  processes, e.g. windshield defrosting.
30 
31  The isotherm phase change occurs at the melting temperature, \c Tsol (= \c
32  Tliq). The not isotherm phase change occurs between solidus and liquidus
33  temperature, \c Tsol < \c Tliq respectively, as long as the melt fraction is
34  greater than the max eutectic melt fraction, \c alpha1e (0 = pure_substance,
35  1 = eutectic_mixture is not permitted), where a linear eutectic melt
36  fraction to temperature relation is considered; e.g. given a specific
37  quantity of a binary system, \c alpha1 is its melt fraction and \c alpha0 is
38  its solid fraction, such that \c alpha0 = 1 - \c alpha1 therefore, assuming
39  infinite solute diffusion, the quantity of a component in solid phase is
40  (1 - \c alpha1) * \c CS where \c CS is the solid concentration of the
41  considered component and the quantity of a component in liquid phase is \c
42  alpha1 * \c CL where \c CL is the melt concentration of the considered
43  component; considering that the total quantity of a component must be equal
44  to the sum of the quantities of the considered component in the liquid and
45  solid phases, if \c C0 is the initial concentration of the considered
46  component before the phase change, then:
47  \c C0 = (1 - \c alpha1) * \c CS + \c alpha1 * \c CL (lever rule)
48  from which: \c alpha1 = (\c C0 - \c CS) / (\c CL - \c CS)
49  and thus:
50  - for a miscible binary system \c alpha1e = 0;
51  - for a binary system not miscible at solid state
52  \c alpha1e = \c C0 / \c CLE where \c CLE is eutectic melt concentration;
53  - for a binary system partially-miscible at solid state
54  \c alpha1e = (\c C0 - \c CSE) / (\c CLE - \c CSE) where \c CSE is eutectic
55  solid concentration of the relative solid solution.
56 
57  The presence of the solid phase in the flow field is incorporated into the
58  model as a momentum porosity contribution; the energy associated with the
59  phase change is added as an enthalpy contribution.
60 
61  References:
62  \verbatim
63  Voller, V. R., & Prakash, C. (1987).
64  A fixed grid numerical modelling methodology for convection-diffusion
65  mushy region phase-change problems.
66  International Journal of Heat and Mass Transfer, 30(8), 1709-1719.
67 
68  Swaminathan, C. R., & Voller, V. R. (1992).
69  A general enthalpy method for modeling solidification processes.
70  Metallurgical transactions B, 23(5), 651-664.
71  \endverbatim
72 
73  The model generates the field \c <name>:alpha1 which can be visualised to
74  to show the melt distribution as a fraction [0-1].
75 
76 Usage
77  Example usage:
78  \verbatim
79  solidificationMelting1
80  {
81  type solidificationMelting;
82 
83  cellZone iceZone;
84 
85  Tsol 273;
86  L 334000;
87  thermoMode thermo;
88  beta 50e-6;
89  rhoRef 800;
90  }
91  \endverbatim
92 
93  Where:
94  \table
95  Property | Description | Required | Default value
96  Tsol | Solidus temperature [K] | yes |
97  Tliq | Liquidus temperature [K] | no | Tsol
98  alpha1e | Max eutectic melt fraction [0-1[ | no | 0
99  L | Latent heat of fusion [J/kg] | yes |
100  relax | Relaxation coefficient [0-1] | no | 0.9
101  thermoMode | Thermo mode [thermo or lookup] | yes |
102  rhoRef | Reference (solid) density [kg/m^3] | yes |
103  rho | Name of density field | no | rho
104  T | Name of temperature field | no | T
105  Cp | Name of specific heat field | no | Cp
106  U | Name of velocity field | no | U
107  phi | Name of flux field | no | phi
108  Cu | Model coefficient [1/s] | no | 100000
109  q | Model coefficient | no | 0.001
110  beta | Thermal expansion coefficient [1/K] | yes |
111  g | Acceleration due to gravity | no |
112  \endtable
113 
114 SourceFiles
115  solidificationMelting.C
116 
117 \*---------------------------------------------------------------------------*/
118 
119 #ifndef solidificationMelting_H
120 #define solidificationMelting_H
121 
122 #include "fvModel.H"
123 #include "fvCellZone.H"
124 #include "fvMesh.H"
125 #include "volFields.H"
126 #include "NamedEnum.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 namespace Foam
131 {
132 namespace fv
133 {
134 
135 /*---------------------------------------------------------------------------*\
136  Class solidificationMelting Declaration
137 \*---------------------------------------------------------------------------*/
138 
139 class solidificationMelting
140 :
141  public fvModel
142 {
143 public:
144 
145  enum class thermoMode
146  {
147  thermo,
148  lookup
149  };
150 
151  static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
152 
153 
154 private:
155 
156  // Private Data
157 
158  //- The cellZone the fvConstraint applies to
159  fvCellZone zone_;
160 
161  //- Temperature at which isotherm melting occurs
162  // and not isotherm melting starts e.g. eutectic [K]
163  scalar Tsol_;
164 
165  //- Temperature at which not isotherm melting stops (Tliq > Tsol) [K]
166  scalar Tliq_;
167 
168  //- Max eutectic melt fraction [0-1[
169  // where 0 = pure substance is default value,
170  // 1 = eutectic mixture is not permitted
171  scalar alpha1e_;
172 
173  //- Latent heat of fusion [J/kg]
174  scalar L_;
175 
176  //- Phase fraction under-relaxation coefficient
177  scalar relax_;
178 
179  //- Thermodynamics mode
180  thermoMode mode_;
181 
182  //- Reference density - typically the solid density
183  scalar rhoRef_;
184 
185  //- Name of temperature field - default = "T" (optional)
186  word TName_;
187 
188  //- Name of specific heat capacity field - default = "Cp" (optional)
189  word CpName_;
190 
191  //- Name of velocity field - default = "U" (optional)
192  word UName_;
193 
194  //- Name of flux field - default = "phi" (optional)
195  word phiName_;
196 
197  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
198  scalar Cu_;
199 
200  //- Coefficient used in porosity calc - default = 0.001
201  scalar q_;
202 
203  //- Thermal expansion coefficient [1/K]
204  scalar beta_;
205 
206  //- Reference heat capacity for thermoMode::lookup
207  scalar CpRef_;
208 
209  //- Gravitational acceleration
210  vector g_;
211 
212  //- Phase fraction indicator field
213  mutable volScalarField alpha1_;
214 
215  //- Current time index (used for updating)
216  mutable label curTimeIndex_;
217 
218  //- Temperature change cached for source calculation when alpha1 updated
219  mutable scalarField deltaT_;
220 
221 
222  // Private Member Functions
223 
224  //- Non-virtual read
225  void readCoeffs(const dictionary& dict);
226 
227  //- Return the specific heat capacity field
228  tmp<volScalarField> Cp() const;
229 
230  //- Return the gravity vector
231  vector g() const;
232 
233  //- Update the model
234  void update(const volScalarField& Cp) const;
235 
236  //- Helper function to apply to the energy equation
237  template<class RhoFieldType>
238  inline void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn) const;
239 
240 
241 public:
242 
243  //- Runtime type information
244  TypeName("solidificationMelting");
245 
246 
247  // Constructors
248 
249  //- Construct from explicit source name and mesh
251  (
252  const word& name,
253  const word& modelType,
254  const fvMesh& mesh,
255  const dictionary& dict
256  );
257 
258  //- Disallow default bitwise copy construction
260  (
261  const solidificationMelting&
262  ) = delete;
263 
264 
265  // Member Functions
266 
267  // Checks
268 
269  //- Return the list of fields for which the fvModel adds source term
270  // to the transport equation
271  virtual wordList addSupFields() const;
272 
273 
274  // Evaluation
275 
276  //- Add explicit contribution to enthalpy equation
277  virtual void addSup
278  (
279  const volScalarField& he,
280  fvMatrix<scalar>& eqn
281  ) const;
282 
283  //- Add implicit contribution to momentum equation
284  virtual void addSup
285  (
286  const volVectorField& U,
287  fvMatrix<vector>& eqn
288  ) const;
289 
290  //- Add explicit contribution to compressible enthalpy equation
291  virtual void addSup
292  (
293  const volScalarField& rho,
294  const volScalarField& he,
295  fvMatrix<scalar>& eqn
296  ) const;
297 
298  //- Add implicit contribution to compressible momentum equation
299  virtual void addSup
300  (
301  const volScalarField& rho,
302  const volVectorField& U,
303  fvMatrix<vector>& eqn
304  ) const;
305 
306 
307  // Mesh changes
308 
309  //- Update for mesh motion
310  virtual bool movePoints();
311 
312  //- Update topology using the given map
313  virtual void topoChange(const polyTopoChangeMap&);
314 
315  //- Update from another mesh using the given map
316  virtual void mapMesh(const polyMeshMap&);
317 
318  //- Redistribute or update using the given distribution map
319  virtual void distribute(const polyDistributionMap&);
320 
321 
322  // IO
323 
324  //- Read source dictionary
325  virtual bool read(const dictionary& dict);
326 
327 
328  // Member Operators
329 
330  //- Disallow default bitwise assignment
331  void operator=(const solidificationMelting&) = delete;
332 };
333 
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 } // End namespace fv
338 } // End namespace Foam
339 
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 
342 #endif
343 
344 // ************************************************************************* //
Generic GeometricField class.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
This source is designed to model the effect of solidification and melting processes,...
virtual bool movePoints()
Update for mesh motion.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
TypeName("solidificationMelting")
Runtime type information.
void operator=(const solidificationMelting &)=delete
Disallow default bitwise assignment.
virtual void addSup(const volScalarField &he, fvMatrix< scalar > &eqn) const
Add explicit contribution to enthalpy equation.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read source dictionary.
static const NamedEnum< thermoMode, 2 > thermoModeTypeNames_
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
solidificationMelting(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
U
Definition: pEqn.H:72
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
thermo he()
labelList fv(nPoints)
dictionary dict