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-2019 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. windhield 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  active yes;
83 
84  selectionMode cellZone;
85  cellZone iceZone;
86 
87  Tsol 273;
88  L 334000;
89  thermoMode thermo;
90  beta 50e-6;
91  rhoRef 800;
92  }
93  \endverbatim
94 
95  Where:
96  \table
97  Property | Description | Required | Default value
98  Tsol | Solidus temperature [K] | yes |
99  Tliq | Liquidus temperature [K] | no | Tsol
100  alpha1e | Max eutectic melt fraction [0-1[ | no | 0
101  L | Latent heat of fusion [J/kg] | yes |
102  relax | Relaxation coefficient [0-1] | no | 0.9
103  thermoMode | Thermo mode [thermo|lookup] | yes |
104  rhoRef | Reference (solid) density [kg/m^3] | yes |
105  rho | Name of density field | no | rho
106  T | Name of temperature field | no | T
107  Cp | Name of specific heat field | no | Cp
108  U | Name of velocity field | no | U
109  phi | Name of flux field | no | phi
110  Cu | Model coefficient [1/s] | no | 100000
111  q | Model coefficient | no | 0.001
112  beta | Thermal expansion coefficient [1/K] | yes |
113  g | Accelerartion due to gravity | no |
114  \endtable
115 
116 SourceFiles
117  solidificationMeltingSource.C
118  solidificationMeltingSourceIO.C
119 
120 \*---------------------------------------------------------------------------*/
121 
122 #ifndef solidificationMeltingSource_H
123 #define solidificationMeltingSource_H
124 
125 #include "fvMesh.H"
126 #include "volFields.H"
127 #include "cellSetOption.H"
128 #include "NamedEnum.H"
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 namespace Foam
133 {
134 namespace fv
135 {
136 
137 /*---------------------------------------------------------------------------*\
138  Class solidificationMeltingSource Declaration
139 \*---------------------------------------------------------------------------*/
140 
141 class solidificationMeltingSource
142 :
143  public cellSetOption
144 {
145 public:
146 
147  enum thermoMode
148  {
149  mdThermo,
150  mdLookup
151  };
152 
153  static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
154 
155 
156 private:
157 
158  // Private Data
159 
160  //- Temperature at which isotherm melting occurs
161  // and not isotherm melting starts e.g. eutectic [K]
162  scalar Tsol_;
163 
164  //- Temperature at which not isotherm melting stops (Tliq > Tsol) [K]
165  scalar Tliq_;
166 
167  //- Max eutectic melt fraction [0-1[
168  // where 0 = pure substance is default value,
169  // 1 = eutectic mixture is not permitted
170  scalar alpha1e_;
171 
172  //- Latent heat of fusion [J/kg]
173  scalar L_;
174 
175  //- Phase fraction under-relaxation coefficient
176  scalar relax_;
177 
178  //- Thermodynamics mode
179  thermoMode mode_;
180 
181  //- Reference density - typically the solid density
182  scalar rhoRef_;
183 
184  //- Name of temperature field - default = "T" (optional)
185  word TName_;
186 
187  //- Name of specific heat capacity field - default = "Cp" (optional)
188  word CpName_;
189 
190  //- Name of velocity field - default = "U" (optional)
191  word UName_;
192 
193  //- Name of flux field - default = "phi" (optional)
194  word phiName_;
195 
196  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
197  scalar Cu_;
198 
199  //- Coefficient used in porosity calc - default = 0.001
200  scalar q_;
201 
202  //- Thermal expansion coefficient [1/K]
203  scalar beta_;
204 
205  //- Phase fraction indicator field
206  volScalarField alpha1_;
207 
208  //- Current time index (used for updating)
209  label curTimeIndex_;
210 
211  //- Temperature change cached for source calculation when alpha1 updated
212  scalarField deltaT_;
213 
214 
215  // Private Member Functions
216 
217  //- Return the specific heat capacity field
218  tmp<volScalarField> Cp() const;
219 
220  //- Return the gravity vector
221  vector g() const;
222 
223  //- Update the model
224  void update(const volScalarField& Cp);
225 
226  //- Helper function to apply to the energy equation
227  template<class RhoFieldType>
228  void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn);
229 
230 
231 public:
233  //- Runtime type information
234  TypeName("solidificationMeltingSource");
236 
237  // Constructors
239  //- Construct from explicit source name and mesh
241  (
242  const word& sourceName,
243  const word& modelType,
244  const dictionary& dict,
245  const fvMesh& mesh
246  );
247 
248  //- Disallow default bitwise copy construction
250  (
252  ) = delete;
253 
254 
255  // Member Functions
256 
257  // Add explicit and implicit contributions
258 
259  //- Add explicit contribution to enthalpy equation
260  virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
261 
262  //- Add implicit contribution to momentum equation
263  virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
264 
265 
266  // Add explicit and implicit contributions to compressible equation
267 
268  //- Add explicit contribution to compressible enthalpy equation
269  virtual void addSup
270  (
271  const volScalarField& rho,
272  fvMatrix<scalar>& eqn,
273  const label fieldi
274  );
275 
276  //- Add implicit contribution to compressible momentum equation
277  virtual void addSup
278  (
279  const volScalarField& rho,
280  fvMatrix<vector>& eqn,
281  const label fieldi
282  );
283 
284 
285  // IO
286 
287  //- Read source dictionary
288  virtual bool read(const dictionary& dict);
289 
290 
291  // Member Operators
292 
293  //- Disallow default bitwise assignment
294  void operator=(const solidificationMeltingSource&) = delete;
295 };
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 } // End namespace fv
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #ifdef NoRepository
307 #endif
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #endif
312 
313 // ************************************************************************* //
dictionary dict
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
static const NamedEnum< thermoMode, 2 > thermoModeTypeNames_
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
solidificationMeltingSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
TypeName("solidificationMeltingSource")
Runtime type information.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
This source is designed to model the effect of solidification and melting processes, e.g. windhield defrosting.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void operator=(const solidificationMeltingSource &)=delete
Disallow default bitwise assignment.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to enthalpy equation.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Namespace for OpenFOAM.