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  Copyright (C) 2020-2021 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 \*---------------------------------------------------------------------------*/
28 
30 #include "solidification.H"
31 #include "geometricOneField.H"
32 #include "fvMatrices.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  namespace porosityModels
39  {
40  defineTypeNameAndDebug(solidification, 0);
41  addToRunTimeSelectionTable(porosityModel, solidification, mesh);
42  }
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 Foam::porosityModels::solidification::solidification
49 (
50  const word& name,
51  const word& modelType,
52  const fvMesh& mesh,
53  const dictionary& dict,
54  const word& cellZoneName
55 )
56 :
57  porosityModel(name, modelType, mesh, dict, cellZoneName),
58  TName_(coeffs_.getOrDefault<word>("T", "T")),
59  alphaName_(coeffs_.getOrDefault<word>("alpha", "none")),
60  rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
61  D_(Function1<scalar>::New("D", coeffs_, &mesh))
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
74 {}
75 
76 
78 (
79  const volVectorField& U,
80  const volScalarField& rho,
81  const volScalarField& mu,
82  vectorField& force
83 ) const
84 {
85  scalarField Udiag(U.size(), Zero);
86  const scalarField& V = mesh_.V();
87 
88  apply(Udiag, V, rho, U);
89 
90  force = Udiag*U;
91 }
92 
93 
95 (
97 ) const
98 {
99  const volVectorField& U = UEqn.psi();
100  const scalarField& V = mesh_.V();
101  scalarField& Udiag = UEqn.diag();
102 
103  if (UEqn.dimensions() == dimForce)
104  {
105  const auto& rho = mesh_.lookupObject<volScalarField>
106  (
107  IOobject::groupName(rhoName_, U.group())
108  );
109 
110  apply(Udiag, V, rho, U);
111  }
112  else
113  {
114  apply(Udiag, V, geometricOneField(), U);
115  }
116 }
117 
118 
120 (
122  const volScalarField& rho,
123  const volScalarField& mu
124 ) const
125 {
126  const volVectorField& U = UEqn.psi();
127  const scalarField& V = mesh_.V();
128  scalarField& Udiag = UEqn.diag();
129 
130  apply(Udiag, V, rho, U);
131 }
132 
133 
135 (
136  const fvVectorMatrix& UEqn,
137  volTensorField& AU
138 ) const
139 {
140  const volVectorField& U = UEqn.psi();
141 
142  if (UEqn.dimensions() == dimForce)
143  {
144  const auto& rho = mesh_.lookupObject<volScalarField>
145  (
146  IOobject::groupName(rhoName_, U.group())
147  );
148 
149  apply(AU, rho, U);
150  }
151  else
152  {
153  apply(AU, geometricOneField(), U);
154  }
155 }
156 
157 
159 {
160  dict_.writeEntry(name_, os);
161 
162  return true;
163 }
164 
165 
166 // ************************************************************************* //
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::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::geometricOneField
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Definition: geometricOneField.H:55
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
Foam::dimForce
const dimensionSet dimForce
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::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::Field< vector >
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:123
os
OBJstream os(runTime.globalPath()/outputName)
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:85
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:158
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:67
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
UEqn
fvVectorMatrix & UEqn
Definition: UEqn.H:13
Foam::porosityModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(porosityModel, powerLawLopesdaCosta, mesh)
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
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 >