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