solidification.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::porosityModels::solidification
26 
27 Description
28  Simple solidification porosity model
29 
30  This is a simple approximation to solidification where the solid phase
31  is represented as a porous blockage with the drag-coefficient evaluated from
32 
33  \f[
34  S = - \alpha \rho D(T) U
35  \f]
36 
37  where
38  \vartable
39  \alpha | Optional phase-fraction of solidifying phase
40  D(T) | User-defined drag-coefficient as function of temperature
41  \endvartable
42 
43  Note that the latent heat of solidification is not included and the
44  temperature is unchanged by the modelled change of phase.
45 
46  Example of the solidification model specification:
47  \verbatim
48  type solidification;
49 
50  solidificationCoeffs
51  {
52  // Solidify between 330K and 330.5K
53  D table
54  (
55  (330.0 10000) // Solid below 330K
56  (330.5 0) // Liquid above 330.5K
57  );
58 
59  // Optional phase-fraction of solidifying phase
60  alpha alpha.liquid;
61 
62  // Solidification porosity is isotropic
63  // use the global coordinate system
64  coordinateSystem
65  {
66  type cartesian;
67  origin (0 0 0);
68  coordinateRotation
69  {
70  type axesRotation;
71  e1 (1 0 0);
72  e2 (0 1 0);
73  }
74  }
75  }
76  \endverbatim
77 
78 SourceFiles
79  solidification.C
80  solidificationTemplates.C
81 
82 \*---------------------------------------------------------------------------*/
83 
84 #ifndef solidification_H
85 #define solidification_H
86 
87 #include "porosityModel.H"
88 #include "Function1.H"
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 namespace Foam
93 {
94 namespace porosityModels
95 {
96 
97 /*---------------------------------------------------------------------------*\
98  Class solidification Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class solidification
102 :
103  public porosityModel
104 {
105  // Private Data
106 
107  //- Name of temperature field, default = "T"
108  word TName_;
109 
110  //- Name of optional phase-fraction field, default = "none"
111  word alphaName_;
112 
113  //- Name of density field, default = "rho"
114  word rhoName_;
115 
116  //- User-defined drag-coefficient as function of temperature
118 
119 
120  // Private Member Functions
121 
122  //- Apply resistance
123  template<class AlphaFieldType, class RhoFieldType>
124  void apply
125  (
126  scalarField& Udiag,
127  const scalarField& V,
128  const AlphaFieldType& alpha,
129  const RhoFieldType& rho,
130  const volVectorField& U
131  ) const;
132 
133  //- Apply resistance
134  template<class AlphaFieldType, class RhoFieldType>
135  void apply
136  (
137  tensorField& AU,
138  const AlphaFieldType& alpha,
139  const RhoFieldType& rho,
140  const volVectorField& U
141  ) const;
142 
143  //- Apply resistance
144  template<class RhoFieldType>
145  void apply
146  (
147  scalarField& Udiag,
148  const scalarField& V,
149  const RhoFieldType& rho,
150  const volVectorField& U
151  ) const;
152 
153  //- Apply resistance
154  template<class RhoFieldType>
155  void apply
156  (
157  tensorField& AU,
158  const RhoFieldType& rho,
159  const volVectorField& U
160  ) const;
161 
162 
163 public:
164 
165  //- Runtime type information
166  TypeName("solidification");
167 
168  // Constructors
169 
171  (
172  const word& name,
173  const word& modelType,
174  const fvMesh& mesh,
175  const dictionary& dict,
176  const word& cellZoneName
177  );
178 
179  //- Disallow default bitwise copy construction
180  solidification(const solidification&) = delete;
181 
182 
183  //- Destructor
184  virtual ~solidification();
185 
186 
187  // Member Functions
188 
189  //- Transform the model data wrt mesh changes
190  virtual void calcTransformModelData();
191 
192  //- Calculate the porosity force
193  virtual void calcForce
194  (
195  const volVectorField& U,
196  const volScalarField& rho,
197  const volScalarField& mu,
199  ) const;
200 
201  //- Add resistance
202  virtual void correct(fvVectorMatrix& UEqn) const;
203 
204  //- Add resistance
205  virtual void correct
206  (
207  const fvVectorMatrix& UEqn,
208  volTensorField& AU
209  ) const;
210 
211 
212  // I-O
213 
214  //- Write
215  bool writeData(Ostream& os) const;
216 
217 
218  // Member Operators
219 
220  //- Disallow default bitwise assignment
221  void operator=(const solidification&) = delete;
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace porosityModels
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #ifdef NoRepository
233  #include "solidificationTemplates.C"
234 #endif
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
virtual void calcTransformModelData()
Transform the model data wrt mesh changes.
const dictionary & dict() const
Return dictionary used for model construction.
U
Definition: pEqn.H:72
Simple solidification porosity model.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
fvMesh & mesh
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu) const
Return the force over the cell zone(s)
virtual void correct(fvVectorMatrix &UEqn) const
Add resistance.
A class for handling words, derived from string.
Definition: word.H:59
virtual void calcForce(const volVectorField &U, const volScalarField &rho, const volScalarField &mu, vectorField &force) const
Calculate the porosity force.
virtual ~solidification()
Destructor.
solidification(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName)
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
void operator=(const solidification &)=delete
Disallow default bitwise assignment.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const dimensionedScalar mu
Atomic mass unit.
TypeName("solidification")
Runtime type information.
const word & name() const
Return const access to the porosity model name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
bool writeData(Ostream &os) const
Write.
Namespace for OpenFOAM.
fvVectorMatrix & UEqn
Definition: UEqn.H:13