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-2017 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  selectionMode cellZone;
57  cellZone iceZone;
58 
59  Tmelt 273;
60  L 334000;
61  thermoMode thermo;
62  beta 50e-6;
63  rhoRef 800;
64  }
65  \endverbatim
66 
67  Where:
68  \table
69  Property | Description | Required | Default value
70  Tmelt | Melting temperature [K] | yes |
71  L | Latent heat of fusion [J/kg] | yes |
72  relax | Relaxation coefficient [0-1] | no | 0.9
73  thermoMode | Thermo mode [thermo|lookup] | yes |
74  rhoRef | Reference (solid) density | yes |
75  rho | Name of density field | no | rho
76  T | Name of temperature field | no | T
77  Cp | Name of specific heat capacity field | no | Cp
78  U | Name of velocity field | no | U
79  phi | Name of flux field | no | phi
80  Cu | Model coefficient | no | 100000
81  q | Model coefficient | no | 0.001
82  beta | Thermal expansion coefficient [1/K] | yes |
83  g | Accelerartion due to gravity | no |
84  \endtable
85 
86 SourceFiles
87  solidificationMeltingSource.C
88  solidificationMeltingSourceIO.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef solidificationMeltingSource_H
93 #define solidificationMeltingSource_H
94 
95 #include "fvMesh.H"
96 #include "volFields.H"
97 #include "cellSetOption.H"
98 #include "NamedEnum.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 namespace fv
105 {
106 
107 /*---------------------------------------------------------------------------*\
108  Class solidificationMeltingSource Declaration
109 \*---------------------------------------------------------------------------*/
110 
111 class solidificationMeltingSource
112 :
113  public cellSetOption
114 {
115 public:
116 
117  enum thermoMode
118  {
119  mdThermo,
120  mdLookup
121  };
122 
123  static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
124 
125 
126 private:
127 
128  // Private data
129 
130  //- Temperature at which melting occurs [K]
131  scalar Tmelt_;
132 
133  //- Latent heat of fusion [J/kg]
134  scalar L_;
135 
136  //- Phase fraction under-relaxation coefficient
137  scalar relax_;
138 
139  //- Thermodynamics mode
140  thermoMode mode_;
141 
142  //- Reference density - typically the solid density
143  scalar rhoRef_;
144 
145  //- Name of temperature field - default = "T" (optional)
146  word TName_;
147 
148  //- Name of specific heat capacity field - default = "Cp" (optional)
149  word CpName_;
150 
151  //- Name of velocity field - default = "U" (optional)
152  word UName_;
153 
154  //- Name of flux field - default = "phi" (optional)
155  word phiName_;
156 
157  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
158  scalar Cu_;
159 
160  //- Coefficient used in porosity calc - default = 0.001
161  scalar q_;
162 
163  //- Thermal expansion coefficient [1/K]
164  scalar beta_;
165 
166  //- Phase fraction indicator field
167  volScalarField alpha1_;
168 
169  //- Current time index (used for updating)
170  label curTimeIndex_;
171 
172  //- Temperature change cached for source calculation when alpha1 updated
173  scalarField deltaT_;
174 
175 
176  // Private Member Functions
177 
178  //- Return the specific heat capacity field
179  tmp<volScalarField> Cp() const;
180 
181  //- Return the gravity vector
182  vector g() const;
183 
184  //- Update the model
185  void update(const volScalarField& Cp);
187  //- Helper function to apply to the energy equation
188  template<class RhoFieldType>
189  void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn);
190 
191  //- Disallow default bitwise copy construct
193 
194  //- Disallow default bitwise assignment
195  void operator=(const solidificationMeltingSource&);
196 
197 
198 public:
199 
200  //- Runtime type information
201  TypeName("solidificationMeltingSource");
202 
203 
204  // Constructors
205 
206  //- Construct from explicit source name and mesh
208  (
209  const word& sourceName,
210  const word& modelType,
211  const dictionary& dict,
212  const fvMesh& mesh
213  );
214 
215 
216  // Member Functions
217 
218  // Add explicit and implicit contributions
219 
220  //- Add explicit contribution to enthalpy equation
221  virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
222 
223  //- Add implicit contribution to momentum equation
224  virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
225 
226 
227  // Add explicit and implicit contributions to compressible equation
228 
229  //- Add explicit contribution to compressible enthalpy equation
230  virtual void addSup
231  (
232  const volScalarField& rho,
233  fvMatrix<scalar>& eqn,
234  const label fieldi
235  );
236 
237  //- Add implicit contribution to compressible momentum equation
238  virtual void addSup
239  (
240  const volScalarField& rho,
241  fvMatrix<vector>& eqn,
242  const label fieldi
243  );
244 
245 
246  // IO
247 
248  //- Read source dictionary
249  virtual bool read(const dictionary& dict);
250 };
251 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 } // End namespace fv
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #ifdef NoRepository
262 #endif
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************************************************************* //
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
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
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: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.