solidification.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) 2017 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  //- Disallow default bitwise copy construct
164 
165  //- Disallow default bitwise assignment
166  void operator=(const solidification&);
167 
168 
169 public:
170 
171  //- Runtime type information
172  TypeName("solidification");
173 
174  //- Constructor
176  (
177  const word& name,
178  const word& modelType,
179  const fvMesh& mesh,
180  const dictionary& dict,
181  const word& cellZoneName
182  );
183 
184  //- Destructor
185  virtual ~solidification();
186 
187 
188  // Member Functions
189 
190  //- Transform the model data wrt mesh changes
191  virtual void calcTransformModelData();
192 
193  //- Calculate the porosity force
194  virtual void calcForce
195  (
196  const volVectorField& U,
197  const volScalarField& rho,
198  const volScalarField& mu,
200  ) const;
201 
202  //- Add resistance
203  virtual void correct(fvVectorMatrix& UEqn) const;
204 
205  //- Add resistance
206  virtual void correct
207  (
209  const volScalarField& rho,
210  const volScalarField& mu
211  ) const;
212 
213  //- Add resistance
214  virtual void correct
215  (
216  const fvVectorMatrix& UEqn,
217  volTensorField& AU
218  ) const;
219 
220 
221  // I-O
222 
223  //- Write
224  bool writeData(Ostream& os) const;
225 };
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace porosityModels
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #ifdef NoRepository
235  #include "solidificationTemplates.C"
236 #endif
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #endif
241 
242 // ************************************************************************* //
dictionary dict
U
Definition: pEqn.H:83
virtual void calcTransformModelData()
Transform the model data wrt mesh changes.
Simple solidification porosity model.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s)
virtual void correct(fvVectorMatrix &UEqn) const
Add resistance.
dynamicFvMesh & mesh
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.
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
TypeName("solidification")
Runtime type information.
const dimensionedScalar mu
Atomic mass unit.
const word & name() const
Return const access to the porosity model name.
fvVectorMatrix & UEqn
Definition: UEqn.H:13
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
bool writeData(Ostream &os) const
Write.
Namespace for OpenFOAM.