VoFSolidificationMeltingSource.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) 2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fv::VoFSolidificationMeltingSource
28 
29 Description
30  Solidification and melting model for VoF simulations.
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. The solid fraction as a
35  function of temperature \c alphaSolidT is specified as a Foam::Function1.
36 
37  The model writes the field \c alpha[01].solid which can be visualised to to
38  show the solid distribution.
39 
40 Usage
41  Example usage:
42  \verbatim
43  VoFSolidificationMeltingSource1
44  {
45  type VoFSolidificationMeltingSource;
46  active yes;
47 
48  selectionMode cellZone;
49  cellZone solidZone;
50 
51  alphaSolidT table
52  (
53  (330 1)
54  (335 0)
55  );
56 
57  L 334000;
58  }
59  \endverbatim
60 
61  Where:
62  \table
63  Property | Description | Required | Default value
64  alphaSolidT | Solid fraction as function of temperature | yes |
65  L | Latent heat of fusion [J/kg] | yes |
66  relax | Relaxation coefficient [0-1] | no | 0.9
67  Cu | Model coefficient | no | 100000
68  q | Model coefficient | no | 0.001
69  \endtable
70 
71 See also
72  Foam::fv::solidificationMeltingSource
73  Foam::Function1
74 
75 SourceFiles
76  VoFSolidificationMeltingSource.C
77  VoFSolidificationMeltingSourceIO.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef VoFSolidificationMeltingSource_H
82 #define VoFSolidificationMeltingSource_H
83 
84 #include "fvMesh.H"
85 #include "volFields.H"
86 #include "cellSetOption.H"
87 #include "Function1.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 namespace Foam
92 {
93 namespace fv
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class VoFSolidificationMeltingSource Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class VoFSolidificationMeltingSource
101 :
102  public fv::cellSetOption
103 {
104  // Private data
105 
106  //- Solid fraction as a function of temperature
107  autoPtr<Function1<scalar>> alphaSolidT_;
108 
109  //- Latent heat of fusion [J/kg]
111 
112  //- Phase fraction under-relaxation coefficient
113  scalar relax_;
114 
115  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
116  scalar Cu_;
117 
118  //- Coefficient used in porosity calc - default = 0.001
119  scalar q_;
120 
121  //- Solid phase fraction
122  volScalarField alphaSolid_;
123 
124  //- Current time index (used for updating)
125  label curTimeIndex_;
126 
127 
128  // Private Member Functions
129 
130  //- Return the name of the solid phase fraction
131  word alphaSolidName() const;
132 
133  //- Update the model
134  void update();
135 
136  //- Helper function to apply to the energy equation
137  template<class RhoFieldType>
138  void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn);
139 
140  //- No copy construct
142  (
144  ) = delete;
145 
146  //- No copy assignment
147  void operator=(const VoFSolidificationMeltingSource&) = delete;
148 
149 
150 public:
151 
152  //- Runtime type information
153  TypeName("VoFSolidificationMeltingSource");
154 
155 
156  // Constructors
157 
158  //- Construct from explicit source name and mesh
160  (
161  const word& sourceName,
162  const word& modelType,
163  const dictionary& dict,
164  const fvMesh& mesh
165  );
166 
167 
168  // Member Functions
169 
170  // Add explicit and implicit contributions
171 
172  //- Add explicit contribution to enthalpy equation
173  virtual void addSup(fvMatrix<scalar>& eqn, const label fieldi);
174 
175  //- Add implicit contribution to momentum equation
176  virtual void addSup(fvMatrix<vector>& eqn, const label fieldi);
177 
178 
179  // Add explicit and implicit contributions to compressible equation
180 
181  //- Add explicit contribution to compressible enthalpy equation
182  virtual void addSup
183  (
184  const volScalarField& rho,
185  fvMatrix<scalar>& eqn,
186  const label fieldi
187  );
188 
189  //- Add implicit contribution to compressible momentum equation
190  virtual void addSup
191  (
192  const volScalarField& rho,
193  fvMatrix<vector>& eqn,
194  const label fieldi
195  );
196 
197 
198  // IO
199 
200  //- Read source dictionary
201  virtual bool read(const dictionary& dict);
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace fv
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #ifdef NoRepository
214 #endif
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
volFields.H
Foam::fv::VoFSolidificationMeltingSource::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to enthalpy equation.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
Function1.H
Foam::fv::VoFSolidificationMeltingSource::TypeName
TypeName("VoFSolidificationMeltingSource")
Runtime type information.
Foam::fv::VoFSolidificationMeltingSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
rho
rho
Definition: readInitialConditions.H:88
cellSetOption.H
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fv::VoFSolidificationMeltingSource
Solidification and melting model for VoF simulations.
Definition: VoFSolidificationMeltingSource.H:129
Foam::dimensioned< scalar >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
VoFSolidificationMeltingSourceTemplates.C
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fv
labelList fv(nPoints)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::fv::option::mesh
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::GeometricField< scalar, fvPatchField, volMesh >