solidification.C
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 \*---------------------------------------------------------------------------*/
27 
29 #include "solidification.H"
30 #include "geometricOneField.H"
31 #include "fvMatrices.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  namespace porosityModels
38  {
39  defineTypeNameAndDebug(solidification, 0);
40  addToRunTimeSelectionTable(porosityModel, solidification, mesh);
41  }
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 Foam::porosityModels::solidification::solidification
48 (
49  const word& name,
50  const word& modelType,
51  const fvMesh& mesh,
52  const dictionary& dict,
53  const word& cellZoneName
54 )
55 :
56  porosityModel(name, modelType, mesh, dict, cellZoneName),
57  TName_(coeffs_.lookupOrDefault<word>("T", "T")),
58  alphaName_(coeffs_.lookupOrDefault<word>("alpha", "none")),
59  rhoName_(coeffs_.lookupOrDefault<word>("rho", "rho")),
60  D_(Function1<scalar>::New("D", coeffs_))
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 
67 {}
68 
69 
70 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 
73 {}
74 
75 
77 (
78  const volVectorField& U,
79  const volScalarField& rho,
80  const volScalarField& mu,
81  vectorField& force
82 ) const
83 {
84  scalarField Udiag(U.size(), Zero);
85  const scalarField& V = mesh_.V();
86 
87  apply(Udiag, V, rho, U);
88 
89  force = Udiag*U;
90 }
91 
92 
94 (
96 ) const
97 {
98  const volVectorField& U = UEqn.psi();
99  const scalarField& V = mesh_.V();
100  scalarField& Udiag = UEqn.diag();
101 
102  if (UEqn.dimensions() == dimForce)
103  {
104  const auto& rho = mesh_.lookupObject<volScalarField>
105  (
106  IOobject::groupName(rhoName_, U.group())
107  );
108 
109  apply(Udiag, V, rho, U);
110  }
111  else
112  {
113  apply(Udiag, V, geometricOneField(), U);
114  }
115 }
116 
117 
119 (
121  const volScalarField& rho,
122  const volScalarField& mu
123 ) const
124 {
125  const volVectorField& U = UEqn.psi();
126  const scalarField& V = mesh_.V();
127  scalarField& Udiag = UEqn.diag();
128 
129  apply(Udiag, V, rho, U);
130 }
131 
132 
134 (
135  const fvVectorMatrix& UEqn,
136  volTensorField& AU
137 ) const
138 {
139  const volVectorField& U = UEqn.psi();
140 
141  if (UEqn.dimensions() == dimForce)
142  {
143  const auto& rho = mesh_.lookupObject<volScalarField>
144  (
145  IOobject::groupName(rhoName_, U.group())
146  );
147 
148  apply(AU, rho, U);
149  }
150  else
151  {
152  apply(AU, geometricOneField(), U);
153  }
154 }
155 
156 
158 {
159  dict_.writeEntry(name_, os);
160 
161  return true;
162 }
163 
164 
165 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::constant::physicoChemical::mu
const dimensionedScalar mu
Atomic mass unit.
Definition: createFieldRefs.H:4
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::geometricOneField
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Definition: geometricOneField.H:54
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:77
Foam::dimForce
const dimensionSet dimForce
rho
rho
Definition: readInitialConditions.H:96
Foam::porosityModels::solidification::calcTransformModelData
virtual void calcTransformModelData()
Transform the model data wrt mesh changes.
Definition: solidification.C:72
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:56
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::Field< vector >
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::porosityModels::defineTypeNameAndDebug
defineTypeNameAndDebug(powerLawLopesdaCosta, 0)
dict
dictionary dict
Definition: searchingEngine.H:14
solidification.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
U
U
Definition: pEqn.H:72
Foam::porosityModel
Top level model for porosity models.
Definition: porosityModel.H:57
Foam::porosityModels::solidification::writeData
bool writeData(Ostream &os) const
Write.
Definition: solidification.C:157
geometricOneField.H
Foam::apply
static void apply(bitSet &selection, const Detail::parcelSelection::actionType action, const Predicate &accept, const UList< Type > &list, const AccessOp &aop)
Definition: parcelSelectionDetail.C:82
Foam::porosityModels::solidification::~solidification
virtual ~solidification()
Destructor.
Definition: solidification.C:66
Foam::IOobject::groupName
static word groupName(StringType name, const word &group)
Create dot-delimited name.group.
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
UEqn
fvVectorMatrix & UEqn
Definition: UEqn.H:13
Foam::porosityModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(porosityModel, powerLawLopesdaCosta, mesh)
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:94
Foam::GeometricField< vector, fvPatchField, volMesh >