solidificationMeltingSource.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-2023 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::solidificationMeltingSource
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  solidificationMeltingSource1
80  {
81  type solidificationMeltingSource;
82 
83  select cellZone;
84  cellZone iceZone;
85 
86  Tsol 273;
87  L 334000;
88  thermoMode thermo;
89  beta 50e-6;
90  rhoRef 800;
91  }
92  \endverbatim
93 
94  Where:
95  \table
96  Property | Description | Required | Default value
97  Tsol | Solidus temperature [K] | yes |
98  Tliq | Liquidus temperature [K] | no | Tsol
99  alpha1e | Max eutectic melt fraction [0-1[ | no | 0
100  L | Latent heat of fusion [J/kg] | yes |
101  relax | Relaxation coefficient [0-1] | no | 0.9
102  thermoMode | Thermo mode [thermo or lookup] | yes |
103  rhoRef | Reference (solid) density [kg/m^3] | yes |
104  rho | Name of density field | no | rho
105  T | Name of temperature field | no | T
106  Cp | Name of specific heat field | no | Cp
107  U | Name of velocity field | no | U
108  phi | Name of flux field | no | phi
109  Cu | Model coefficient [1/s] | no | 100000
110  q | Model coefficient | no | 0.001
111  beta | Thermal expansion coefficient [1/K] | yes |
112  g | Acceleration due to gravity | no |
113  \endtable
114 
115 SourceFiles
116  solidificationMeltingSource.C
117 
118 \*---------------------------------------------------------------------------*/
119 
120 #ifndef solidificationMeltingSource_H
121 #define solidificationMeltingSource_H
122 
123 #include "fvModel.H"
124 #include "fvCellSet.H"
125 #include "fvMesh.H"
126 #include "volFields.H"
127 #include "NamedEnum.H"
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 namespace Foam
132 {
133 namespace fv
134 {
135 
136 /*---------------------------------------------------------------------------*\
137  Class solidificationMeltingSource Declaration
138 \*---------------------------------------------------------------------------*/
139 
140 class solidificationMeltingSource
141 :
142  public fvModel
143 {
144 public:
145 
146  enum class thermoMode
147  {
148  thermo,
149  lookup
150  };
151 
152  static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
153 
154 
155 private:
156 
157  // Private Data
158 
159  //- The set of cells the fvConstraint applies to
160  fvCellSet set_;
161 
162  //- Temperature at which isotherm melting occurs
163  // and not isotherm melting starts e.g. eutectic [K]
164  scalar Tsol_;
165 
166  //- Temperature at which not isotherm melting stops (Tliq > Tsol) [K]
167  scalar Tliq_;
168 
169  //- Max eutectic melt fraction [0-1[
170  // where 0 = pure substance is default value,
171  // 1 = eutectic mixture is not permitted
172  scalar alpha1e_;
173 
174  //- Latent heat of fusion [J/kg]
175  scalar L_;
176 
177  //- Phase fraction under-relaxation coefficient
178  scalar relax_;
179 
180  //- Thermodynamics mode
181  thermoMode mode_;
182 
183  //- Reference density - typically the solid density
184  scalar rhoRef_;
185 
186  //- Name of temperature field - default = "T" (optional)
187  word TName_;
188 
189  //- Name of specific heat capacity field - default = "Cp" (optional)
190  word CpName_;
191 
192  //- Name of velocity field - default = "U" (optional)
193  word UName_;
194 
195  //- Name of flux field - default = "phi" (optional)
196  word phiName_;
197 
198  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
199  scalar Cu_;
200 
201  //- Coefficient used in porosity calc - default = 0.001
202  scalar q_;
203 
204  //- Thermal expansion coefficient [1/K]
205  scalar beta_;
206 
207  //- Phase fraction indicator field
208  mutable volScalarField alpha1_;
209 
210  //- Current time index (used for updating)
211  mutable label curTimeIndex_;
212 
213  //- Temperature change cached for source calculation when alpha1 updated
214  mutable scalarField deltaT_;
215 
216 
217  // Private Member Functions
218 
219  //- Non-virtual read
220  void readCoeffs();
221 
222  //- Return the specific heat capacity field
223  tmp<volScalarField> Cp() const;
224 
225  //- Return the gravity vector
226  vector g() const;
227 
228  //- Update the model
229  void update(const volScalarField& Cp) const;
230 
231  //- Helper function to apply to the energy equation
232  template<class RhoFieldType>
233  void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn) const;
234 
235 
236 public:
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& name,
248  const word& modelType,
249  const fvMesh& mesh,
250  const dictionary& dict
251  );
252 
253  //- Disallow default bitwise copy construction
255  (
257  ) = delete;
258 
259 
260  // Member Functions
261 
262  // Checks
263 
264  //- Return the list of fields for which the fvModel adds source term
265  // to the transport equation
266  virtual wordList addSupFields() const;
267 
268 
269  // Add explicit and implicit contributions
270 
271  //- Add explicit contribution to enthalpy equation
272  virtual void addSup
273  (
274  fvMatrix<scalar>& eqn,
275  const word& fieldName
276  ) const;
277 
278  //- Add implicit contribution to momentum equation
279  virtual void addSup
280  (
281  fvMatrix<vector>& eqn,
282  const word& fieldName
283  ) const;
284 
285 
286  // Add explicit and implicit contributions to compressible equation
287 
288  //- Add explicit contribution to compressible enthalpy equation
289  virtual void addSup
290  (
291  const volScalarField& rho,
292  fvMatrix<scalar>& eqn,
293  const word& fieldName
294  ) const;
295 
296  //- Add implicit contribution to compressible momentum equation
297  virtual void addSup
298  (
299  const volScalarField& rho,
300  fvMatrix<vector>& eqn,
301  const word& fieldName
302  ) const;
303 
304 
305  // Mesh changes
306 
307  //- Update for mesh motion
308  virtual bool movePoints();
309 
310  //- Update topology using the given map
311  virtual void topoChange(const polyTopoChangeMap&);
312 
313  //- Update from another mesh using the given map
314  virtual void mapMesh(const polyMeshMap&);
315 
316  //- Redistribute or update using the given distribution map
317  virtual void distribute(const polyDistributionMap&);
318 
319 
320  // IO
321 
322  //- Read source dictionary
323  virtual bool read(const dictionary& dict);
324 
325 
326  // Member Operators
327 
328  //- Disallow default bitwise assignment
329  void operator=(const solidificationMeltingSource&) = delete;
330 };
331 
332 
333 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 
335 } // End namespace fv
336 } // End namespace Foam
337 
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
339 
340 #ifdef NoRepository
342 #endif
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 #endif
347 
348 // ************************************************************************* //
Generic GeometricField class.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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:101
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:28
This source is designed to model the effect of solidification and melting processes,...
virtual bool movePoints()
Update for mesh motion.
TypeName("solidificationMeltingSource")
Runtime type information.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
virtual void addSup(fvMatrix< scalar > &eqn, const word &fieldName) 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.
solidificationMeltingSource(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
void operator=(const solidificationMeltingSource &)=delete
Disallow default bitwise assignment.
static const NamedEnum< thermoMode, 2 > thermoModeTypeNames_
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 handling words, derived from string.
Definition: word.H:62
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.
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
labelList fv(nPoints)
dictionary dict