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