All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VoFSolidificationMeltingSource.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2021 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::VoFSolidificationMeltingSource
26 
27 Description
28  Solidification and melting model for VoF simulations.
29 
30  The presence of the solid phase in the flow field is incorporated into the
31  model as a momentum porosity contribution; the energy associated with the
32  phase change is added as an enthalpy contribution. The solid fraction as a
33  function of temperature \c alphaSolidT is specified as a Foam::Function1.
34 
35  The model writes the field \c alpha[01].solid which can be visualised to to
36  show the solid distribution.
37 
38 Usage
39  Example usage:
40  \verbatim
41  VoFSolidificationMeltingSource1
42  {
43  type VoFSolidificationMeltingSource;
44 
45  selectionMode cellZone;
46  cellZone solidZone;
47 
48  alphaSolidT table
49  (
50  (330 1)
51  (335 0)
52  );
53 
54  L 334000;
55  }
56  \endverbatim
57 
58  Where:
59  \table
60  Property | Description | Required | Default value
61  alphaSolidT | Solid fraction as function of temperature | yes |
62  L | Latent heat of fusion [J/kg] | yes |
63  relax | Relaxation coefficient [0-1] | no | 0.9
64  Cu | Model coefficient | no | 100000
65  q | Model coefficient | no | 0.001
66  \endtable
67 
68 See also
69  Foam::fv::solidificationMeltingSource
70  Foam::Function1
71 
72 SourceFiles
73  VoFSolidificationMeltingSource.C
74  VoFSolidificationMeltingSourceIO.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef VoFSolidificationMeltingSource_H
79 #define VoFSolidificationMeltingSource_H
80 
81 #include "fvModel.H"
82 #include "fvCellSet.H"
83 #include "fvMesh.H"
84 #include "volFields.H"
85 #include "Function1.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 namespace fv
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class VoFSolidificationMeltingSource Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 class VoFSolidificationMeltingSource
99 :
100  public fvModel
101 {
102  // Private Data
103 
104  //- The set of cells the fvConstraint applies to
105  fvCellSet set_;
106 
107  //- Solid fraction as a function of temperature
108  autoPtr<Function1<scalar>> alphaSolidT_;
109 
110  //- Latent heat of fusion [J/kg]
112 
113  //- Phase fraction under-relaxation coefficient
114  scalar relax_;
115 
116  //- Mushy region momentum sink coefficient [1/s]; default = 10^5
117  scalar Cu_;
118 
119  //- Coefficient used in porosity calc - default = 0.001
120  scalar q_;
121 
122  //- Solid phase fraction
123  mutable volScalarField alphaSolid_;
124 
125  //- Current time index (used for updating)
126  mutable label curTimeIndex_;
128 
129  // Private Member Functions
130 
131  //- Non-virtual read
132  void readCoeffs();
133 
134  //- Return the name of the solid phase fraction
135  word alphaSolidName() const;
136 
137  //- Update the model
138  void update() const;
139 
140  //- Helper function to apply to the energy equation
141  template<class RhoFieldType>
142  void apply(const RhoFieldType& rho, fvMatrix<scalar>& eqn) const;
143 
144 
145 public:
146 
147  //- Runtime type information
148  TypeName("VoFSolidificationMeltingSource");
149 
150 
151  // Constructors
152 
153  //- Construct from explicit source name and mesh
155  (
156  const word& name,
157  const word& modelType,
158  const dictionary& dict,
159  const fvMesh& mesh
160  );
161 
162  //- Disallow default bitwise copy construction
164  (
166  ) = delete;
167 
168 
169  // Member Functions
170 
171  // Checks
172 
173  //- Return the list of fields for which the option adds source term
174  // to the transport equation
175  virtual wordList addSupFields() const;
176 
177 
178  // Add explicit and implicit contributions to compressible equation
179 
180  //- Add explicit contribution to compressible enthalpy equation
181  virtual void addSup
182  (
183  const volScalarField& rho,
184  fvMatrix<scalar>& eqn,
185  const word& fieldName
186  ) const;
187 
188  //- Add implicit contribution to compressible momentum equation
189  virtual void addSup
190  (
191  const volScalarField& rho,
192  fvMatrix<vector>& eqn,
193  const word& fieldName
194  ) const;
195 
196 
197  // Mesh motion
198 
199  //- Update for mesh changes
200  virtual void updateMesh(const mapPolyMesh&);
201 
202 
203  // IO
204 
205  //- Read source dictionary
206  virtual bool read(const dictionary& dict);
207 
208 
209  // Member Operators
210 
211  //- Disallow default bitwise assignment
212  void operator=(const VoFSolidificationMeltingSource&) = delete;
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace fv
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #endif
224 
225 // ************************************************************************* //
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
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:28
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
VoFSolidificationMeltingSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
Solidification and melting model for VoF simulations.
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
TypeName("VoFSolidificationMeltingSource")
Runtime type information.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void operator=(const VoFSolidificationMeltingSource &)=delete
Disallow default bitwise assignment.
virtual void addSup(const volScalarField &rho, fvMatrix< scalar > &eqn, const word &fieldName) const
Add explicit contribution to compressible enthalpy equation.
virtual wordList addSupFields() const
Return the list of fields for which the option adds source term.
Namespace for OpenFOAM.