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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenFOAM Foundation
9  Copyright (C) 2022 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::porosityModels::solidification
29 
30 Description
31  Simple solidification porosity model
32 
33  This is a simple approximation to solidification where the solid phase
34  is represented as a porous blockage with the drag-coefficient evaluated from
35 
36  \f[
37  S = - \alpha \rho D(T) U
38  \f]
39 
40  where
41  \vartable
42  \alpha | Optional phase-fraction of solidifying phase
43  D(T) | User-defined drag-coefficient as function of temperature
44  \endvartable
45 
46  Note that the latent heat of solidification is not included and the
47  temperature is unchanged by the modelled change of phase.
48 
49  Example of the solidification model specification:
50  \verbatim
51  type solidification;
52 
53  solidificationCoeffs
54  {
55  // Solidify between 330K and 330.5K
56  D table
57  (
58  (330.0 10000) // Solid below 330K
59  (330.5 0) // Liquid above 330.5K
60  );
61 
62  // Optional phase-fraction of solidifying phase
63  alpha alpha.liquid;
64 
65  // Solidification porosity is isotropic
66  // use the global coordinate system
67  coordinateSystem
68  {
69  origin (0 0 0);
70  e1 (1 0 0);
71  e2 (0 1 0);
72  }
73  }
74  \endverbatim
75 
76 SourceFiles
77  solidification.C
78  solidificationTemplates.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef Foam_porosityModels_solidification_H
83 #define Foam_porosityModels_solidification_H
84 
85 #include "porosityModel.H"
86 #include "Function1.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 namespace porosityModels
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class solidification Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class solidification
100 :
101  public porosityModel
102 {
103  // Private Data
104 
105  //- Name of temperature field, default = "T"
106  word TName_;
107 
108  //- Name of optional phase-fraction field, default = "none"
109  word alphaName_;
110 
111  //- Name of density field, default = "rho"
112  word rhoName_;
113 
114  //- User-defined drag-coefficient as function of temperature
116 
117 
118  // Private Member Functions
119 
120  //- Apply resistance
121  template<class AlphaFieldType, class RhoFieldType>
122  void apply
123  (
124  scalarField& Udiag,
125  const scalarField& V,
126  const AlphaFieldType& alpha,
127  const RhoFieldType& rho,
128  const volVectorField& U
129  ) const;
130 
131  //- Apply resistance
132  template<class AlphaFieldType, class RhoFieldType>
133  void apply
134  (
135  tensorField& AU,
136  const AlphaFieldType& alpha,
137  const RhoFieldType& rho,
138  const volVectorField& U
139  ) const;
140 
141  //- Apply resistance
142  template<class RhoFieldType>
143  void apply
144  (
145  scalarField& Udiag,
146  const scalarField& V,
147  const RhoFieldType& rho,
148  const volVectorField& U
149  ) const;
150 
151  //- Apply resistance
152  template<class RhoFieldType>
153  void apply
154  (
155  tensorField& AU,
156  const RhoFieldType& rho,
157  const volVectorField& U
158  ) const;
159 
160  //- No copy construct
161  solidification(const solidification&) = delete;
162 
163  //- No copy assignment
164  void operator=(const solidification&) = delete;
165 
166 
167 public:
168 
169  //- Runtime type information
170  TypeName("solidification");
171 
172  //- Constructor
174  (
175  const word& name,
176  const word& modelType,
177  const fvMesh& mesh,
178  const dictionary& dict,
179  const wordRe& cellZoneName
180  );
181 
182  //- Destructor
183  virtual ~solidification() = default;
184 
185 
186  // Member Functions
187 
188  //- Transform the model data wrt mesh changes
189  virtual void calcTransformModelData();
190 
191  //- Calculate the porosity force
192  virtual void calcForce
193  (
194  const volVectorField& U,
195  const volScalarField& rho,
196  const volScalarField& mu,
198  ) const;
199 
200  //- Add resistance
201  virtual void correct(fvVectorMatrix& UEqn) const;
202 
203  //- Add resistance
204  virtual void correct
205  (
207  const volScalarField& rho,
208  const volScalarField& mu
209  ) const;
210 
211  //- Add resistance
212  virtual void correct
213  (
214  const fvVectorMatrix& UEqn,
215  volTensorField& AU
216  ) const;
217 
218 
219  // I-O
220 
221  //- Write
222  bool writeData(Ostream& os) const;
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.
Simple solidification porosity model.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
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 Foam::string.
Definition: word.H:63
virtual void calcForce(const volVectorField &U, const volScalarField &rho, const volScalarField &mu, vectorField &force) const
Calculate the porosity force.
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:64
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
TypeName("solidification")
Runtime type information.
const dimensionedScalar mu
Atomic mass unit.
U
Definition: pEqn.H:72
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
bool writeData(Ostream &os) const
Write.
Namespace for OpenFOAM.
virtual ~solidification()=default
Destructor.