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 | Copyright (C) 2014-2016 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. The phase change occurs at the
30  melting temperature, \c Tmelt.
31 
32  The presence of the solid phase in the flow field is incorporated into the
33  model as a momentum porosity contribution; the energy associated with the
34  phase change is added as an enthalpy contribution.
35 
36  Based on the references:
37 
38  1. V.R. Voller and C. Prakash, A fixed grid numerical modelling
39  methodology for convection-diffusion mushy phase-change problems,
40  Int. J. Heat Mass Transfer 30(8):17091719, 1987.
41  2. C.R. Swaminathan. and V.R. Voller, A general enthalpy model for
42  modeling solidification processes, Metallurgical Transactions
43  23B:651664, 1992.
44 
45  The model generates a field \c <name>:alpha1 which can be visualised to
46  to show the melt distribution as a fraction [0-1]
47 
48 Usage
49  Example usage:
50  \verbatim
51  solidificationMeltingSource1
52  {
53  type solidificationMeltingSource;
54  active yes;
55 
56  solidificationMeltingSourceCoeffs
57  {
58  selectionMode cellZone;
59  cellZone iceZone;
60 
61  Tmelt 273;
62  L 334000;
63  thermoMode thermo;
64  beta 50e-6;
65  rhoRef 800;
66  }
67  }
68  \endverbatim
69 
70  Where:
71  \table
72  Property | Description | Required | Default value
73  Tmelt | Melting temperature [K] | yes |
74  L | Latent heat of fusion [J/kg] | yes |
75  relax | Relaxation coefficient [0-1] | no | 0.9
76  thermoMode | Thermo mode [thermo|lookup] | yes |
77  rhoRef | Reference (solid) density | yes |
78  rho | Name of density field | no | rho
79  T | Name of temperature field | no | T
80  Cp | Name of specific heat capacity field | no | Cp
81  U | Name of velocity field | no | U
82  phi | Name of flux field | no | phi
83  Cu | Model coefficient | no | 100000
84  q | Model coefficient | no | 0.001
85  beta | Thermal expansion coefficient [1/K] | yes |
86  g | Accelerartion due to gravity | no |
87  \endtable
88 
89 SourceFiles
90  solidificationMeltingSource.C
91  solidificationMeltingSourceIO.C
92 
93 \*---------------------------------------------------------------------------*/
94 
95 #ifndef solidificationMeltingSource_H
96 #define solidificationMeltingSource_H
97 
98 #include "fvMesh.H"
99 #include "volFields.H"
100 #include "cellSetOption.H"
101 #include "NamedEnum.H"
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 namespace Foam
106 {
107 namespace fv
108 {
109 
110 /*---------------------------------------------------------------------------*\
111  Class solidificationMeltingSource Declaration
112 \*---------------------------------------------------------------------------*/
113 
114 class solidificationMeltingSource
115 :
116  public cellSetOption
117 {
118 public:
119 
120  enum thermoMode
121  {
122  mdThermo,
123  mdLookup
124  };
125 
126  static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
127 
128 
129 private:
130 
131  // Private data
132 
133  //- Temperature at which melting occurs [K]
134  scalar Tmelt_;
135 
136  //- Latent heat of fusion [J/kg]
137  scalar L_;
138 
139  //- Phase fraction under-relaxation coefficient
140  scalar relax_;
141 
142  //- Thermodynamics mode
143  thermoMode mode_;
144 
145  //- Reference density - typically the solid density
146  scalar rhoRef_;
147 
148  //- Name of temperature field - default = "T" (optional)
149  word TName_;
150 
151  //- Name of specific heat capacity field - default = "Cp" (optional)
152  word CpName_;
153 
154  //- Name of velocity field - default = "U" (optional)
155  word UName_;
156 
157  //- Name of flux field - default = "phi" (optional)
158  word phiName_;
159 
160  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
161  scalar Cu_;
162 
163  //- Coefficient used in porosity calc - default = 0.001
164  scalar q_;
165 
166  //- Thermal expansion coefficient [1/K]
167  scalar beta_;
168 
169  //- Phase fraction indicator field
170  volScalarField alpha1_;
171 
172  //- Current time index (used for updating)
173  label curTimeIndex_;
174 
175  //- Temperature change cached for source calculation when alpha1 updated
176  scalarField deltaT_;
177 
178 
179  // Private Member Functions
180 
181  //- Return the specific heat capacity field
182  tmp<volScalarField> Cp() const;
183 
184  //- Return the gravity vector
185  vector g() const;
186 
187  //- Update the model
188  void update(const volScalarField& Cp);
190  //- Helper function to apply to the energy equation
191  template<class RhoFieldType>
192  void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn);
193 
194  //- Disallow default bitwise copy construct
196 
197  //- Disallow default bitwise assignment
198  void operator=(const solidificationMeltingSource&);
199 
200 
201 public:
202 
203  //- Runtime type information
204  TypeName("solidificationMeltingSource");
205 
206 
207  // Constructors
208 
209  //- Construct from explicit source name and mesh
211  (
212  const word& sourceName,
213  const word& modelType,
214  const dictionary& dict,
215  const fvMesh& mesh
216  );
217 
218 
219  // Member Functions
220 
221  // Add explicit and implicit contributions
222 
223  //- Add explicit contribution to enthalpy equation
224  virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
225 
226  //- Add implicit contribution to momentum equation
227  virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
228 
229 
230  // Add explicit and implicit contributions to compressible equation
231 
232  //- Add explicit contribution to compressible enthalpy equation
233  virtual void addSup
234  (
235  const volScalarField& rho,
236  fvMatrix<scalar>& eqn,
237  const label fieldi
238  );
239 
240  //- Add implicit contribution to compressible momentum equation
241  virtual void addSup
242  (
243  const volScalarField& rho,
244  fvMatrix<vector>& eqn,
245  const label fieldi
246  );
247 
248 
249  // IO
250 
251  //- Read source dictionary
252  virtual bool read(const dictionary& dict);
253 };
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace fv
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #ifdef NoRepository
265 #endif
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #endif
270 
271 // ************************************************************************* //
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:137
static const NamedEnum< thermoMode, 2 > thermoModeTypeNames_
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
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. The phase change occurs at the melting temperature, Tmelt.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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:71
virtual bool read(const dictionary &dict)
Read source dictionary.
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
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.