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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2014-2017 OpenFOAM Foundation
9  Copyright (C) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fv::solidificationMeltingSource
29 
30 Group
31  grpFvOptionsSources
32 
33 Description
34  This source is designed to model the effect of solidification and melting
35  processes, e.g. windhield defrosting. The phase change occurs at the
36  melting temperature, \c Tmelt.
37 
38  The presence of the solid phase in the flow field is incorporated into the
39  model as a momentum porosity contribution; the energy associated with the
40  phase change is added as an enthalpy contribution.
41 
42  Based on the references:
43  -# V.R. Voller and C. Prakash, A fixed grid numerical modelling
44  methodology for convection-diffusion mushy phase-change problems,
45  Int. J. Heat Mass Transfer 30(8):17091719, 1987.
46  -# C.R. Swaminathan. and V.R. Voller, A general enthalpy model for
47  modeling solidification processes, Metallurgical Transactions
48  23B:651664, 1992.
49 
50  The model generates a field \c <name>:alpha1 which can be visualised to
51  to show the melt distribution as a fraction [0-1]
52 
53 Usage
54  Example usage:
55  \verbatim
56  solidificationMeltingSource1
57  {
58  type solidificationMeltingSource;
59  active yes;
60 
61  selectionMode cellZone;
62  cellZone iceZone;
63 
64  Tmelt 273;
65  L 334000;
66  thermoMode thermo;
67  beta 50e-6;
68  rhoRef 800;
69  }
70  \endverbatim
71 
72  Where:
73  \table
74  Property | Description | Required | Default value
75  Tmelt | Melting temperature [K] | yes |
76  L | Latent heat of fusion [J/kg] | yes |
77  relax | Relaxation coefficient [0-1] | no | 0.9
78  thermoMode | Thermo mode [thermo|lookup] | yes |
79  rhoRef | Reference (solid) density | yes |
80  rho | Name of density field | no | rho
81  T | Name of temperature field | no | T
82  Cp | Name of specific heat capacity field | no | Cp
83  U | Name of velocity field | no | U
84  phi | Name of flux field | no | phi
85  Cu | Model coefficient | no | 100000
86  q | Model coefficient | no | 0.001
87  beta | Thermal expansion coefficient [1/K] | yes |
88  g | Accelerartion due to gravity | no |
89  \endtable
90 
91 SourceFiles
92  solidificationMeltingSource.C
93  solidificationMeltingSourceIO.C
94 
95 \*---------------------------------------------------------------------------*/
96 
97 #ifndef solidificationMeltingSource_H
98 #define solidificationMeltingSource_H
99 
100 #include "fvMesh.H"
101 #include "volFields.H"
102 #include "cellSetOption.H"
103 #include "Enum.H"
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 namespace fv
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class solidificationMeltingSource Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class solidificationMeltingSource
117 :
118  public cellSetOption
119 {
120 public:
121 
122  enum thermoMode
123  {
124  mdThermo,
125  mdLookup
126  };
127 
128  static const Enum<thermoMode> thermoModeTypeNames_;
129 
130 
131 private:
132 
133  // Private data
134 
135  //- Temperature at which melting occurs [K]
136  scalar Tmelt_;
137 
138  //- Latent heat of fusion [J/kg]
139  scalar L_;
140 
141  //- Phase fraction under-relaxation coefficient
142  scalar relax_;
143 
144  //- Thermodynamics mode
145  thermoMode mode_;
146 
147  //- Reference density - typically the solid density
148  scalar rhoRef_;
149 
150  //- Name of temperature field - default = "T" (optional)
151  word TName_;
152 
153  //- Name of specific heat capacity field - default = "Cp" (optional)
154  word CpName_;
155 
156  //- Name of velocity field - default = "U" (optional)
157  word UName_;
158 
159  //- Name of flux field - default = "phi" (optional)
160  word phiName_;
161 
162  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
163  scalar Cu_;
164 
165  //- Coefficient used in porosity calc - default = 0.001
166  scalar q_;
167 
168  //- Thermal expansion coefficient [1/K]
169  scalar beta_;
170 
171  //- Phase fraction indicator field
172  volScalarField alpha1_;
173 
174  //- Current time index (used for updating)
175  label curTimeIndex_;
176 
177  //- Temperature change cached for source calculation when alpha1 updated
178  scalarField deltaT_;
179 
180 
181  // Private Member Functions
182 
183  //- Return the specific heat capacity field
184  tmp<volScalarField> Cp() 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  //- No copy construct
195  (
197  ) = delete;
198 
199  //- No copy assignment
200  void operator=(const solidificationMeltingSource&) = delete;
201 
202 
203 public:
204 
205  //- Runtime type information
206  TypeName("solidificationMeltingSource");
207 
208 
209  // Constructors
210 
211  //- Construct from explicit source name and mesh
213  (
214  const word& sourceName,
215  const word& modelType,
216  const dictionary& dict,
217  const fvMesh& mesh
218  );
219 
220 
221  //- Destructor
222  ~solidificationMeltingSource() = default;
223 
224 
225  // Member Functions
226 
227  //- Add explicit contribution to enthalpy equation
228  virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
229 
230  //- Add implicit contribution to momentum equation
231  virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
232 
233 
234  //- Add explicit contribution to compressible enthalpy equation
235  virtual void addSup
236  (
237  const volScalarField& rho,
238  fvMatrix<scalar>& eqn,
239  const label fieldi
240  );
241 
242  //- Add implicit contribution to compressible momentum equation
243  virtual void addSup
244  (
245  const volScalarField& rho,
246  fvMatrix<vector>& eqn,
247  const label fieldi
248  );
249 
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 // ************************************************************************* //
volFields.H
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::Enum< thermoMode >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:72
Foam::tmp< volScalarField >
Foam::fv::solidificationMeltingSource::~solidificationMeltingSource
~solidificationMeltingSource()=default
Destructor.
rho
rho
Definition: readInitialConditions.H:96
cellSetOption.H
Foam::fv::solidificationMeltingSource::thermoMode
thermoMode
Definition: solidificationMeltingSource.H:197
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:62
Foam::Field< scalar >
solidificationMeltingSourceTemplates.C
Foam::fv::solidificationMeltingSource::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to enthalpy equation.
Definition: solidificationMeltingSource.C:234
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fv::solidificationMeltingSource::thermoModeTypeNames_
static const Enum< thermoMode > thermoModeTypeNames_
Definition: solidificationMeltingSource.H:203
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::solidificationMeltingSource::TypeName
TypeName("solidificationMeltingSource")
Runtime type information.
fv
labelList fv(nPoints)
Foam::fv::solidificationMeltingSource::mdThermo
Definition: solidificationMeltingSource.H:199
Foam::fv::solidificationMeltingSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: solidificationMeltingSource.C:303
Foam::fv::solidificationMeltingSource::mdLookup
Definition: solidificationMeltingSource.H:200
Foam::fv::option::mesh
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:36
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fv::solidificationMeltingSource
This source is designed to model the effect of solidification and melting processes,...
Definition: solidificationMeltingSource.H:191
Enum.H