solidThermalEquilibrium.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019-2026 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 \*---------------------------------------------------------------------------*/
25 
27 #include "fvmDdt.H"
28 #include "fvmLaplacian.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace fv
36 {
40  (
41  fvModel,
43  dictionary,
44  solidEquilibriumEnergySource,
45  "solidEquilibriumEnergySource"
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 void Foam::fv::solidThermalEquilibrium::readCoeffs(const dictionary& dict)
54 {
55  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
56 
57  solidPhaseName_ = dict.lookup<word>("solidPhase");
58 }
59 
60 
62 Foam::fv::solidThermalEquilibrium::solidAlpha() const
63 {
64  const word alphaName = IOobject::groupName("alpha", solidPhaseName_);
65 
66  if (!mesh().foundObject<volScalarField>(alphaName))
67  {
68  volScalarField* alphaPtr =
69  new volScalarField
70  (
71  IOobject
72  (
73  alphaName,
74  mesh().time().constant(),
75  mesh(),
78  ),
79  mesh(),
80  dimless
81  );
82 
83  alphaPtr->store();
84  }
85 
86  return mesh().lookupObject<volScalarField>(alphaName);
87 }
88 
89 
90 const Foam::solidThermo&
91 Foam::fv::solidThermalEquilibrium::solidThermo() const
92 {
93  const word thermoName =
95 
96  if (!mesh().foundObject<Foam::solidThermo>(thermoName))
97  {
98  Foam::solidThermo* thermoPtr =
99  solidThermo::New(mesh(), solidPhaseName_).ptr();
100 
101  thermoPtr->properties().store();
102  }
103 
104  return mesh().lookupObject<Foam::solidThermo>(thermoName);
105 }
106 
107 
108 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
109 
111 (
112  const word& name,
113  const word& modelType,
114  const fvMesh& mesh,
115  const dictionary& dict
116 )
117 :
118  fvModel(name, modelType, mesh, dict),
119  phaseName_(word::null),
120  solidPhaseName_(word::null)
121 {
122  read(dict);
123  solidAlpha();
124  solidThermo();
125 }
126 
127 
128 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
129 
131 {}
132 
133 
134 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
135 
137 {
138  const basicThermo& thermo =
140  (
142  );
143 
144  return wordList(1, thermo.he().name());
145 }
146 
147 
149 (
150  const volScalarField& rho,
151  const volScalarField& he,
152  fvMatrix<scalar>& eqn
153 ) const
154 {
155  const volScalarField alphahe
156  (
157  "alphahe",
158  solidThermo().kappa()/solidThermo().Cpv()
159  );
160 
161  const volScalarField& A = solidAlpha();
162  const volScalarField B(1 - A);
163 
164  eqn -=
165  A/B*fvm::ddt(solidThermo().rho(), eqn.psi());
166  - 1/B*fvm::laplacian
167  (
168  A*alphahe,
169  eqn.psi(),
170  "laplacian(" + alphahe.name() + "," + eqn.psi().name() + ")"
171  );
172 }
173 
174 
176 (
177  const volScalarField& alpha,
178  const volScalarField& rho,
179  const volScalarField& he,
180  fvMatrix<scalar>& eqn
181 ) const
182 {
183  const volScalarField alphahe
184  (
185  "alphahe",
186  solidThermo().kappa()/solidThermo().Cpv()
187  );
188 
189  const volScalarField& A = solidAlpha();
190  const volScalarField B(1 - A);
191 
192  eqn -=
193  A/B*fvm::ddt(alpha, solidThermo().rho(), eqn.psi());
194  - 1/B*fvm::laplacian
195  (
196  A*alphahe,
197  eqn.psi(),
198  "laplacian(" + alphahe.name() + "," + eqn.psi().name() + ")"
199  );
200 }
201 
202 
204 {
205  return true;
206 }
207 
208 
210 (
211  const polyTopoChangeMap&
212 )
213 {}
214 
215 
217 {}
218 
219 
221 (
222  const polyDistributionMap&
223 )
224 {}
225 
226 
228 {
229  if (fvModel::read(dict))
230  {
231  readCoeffs(coeffs(dict));
232  return true;
233  }
234  else
235  {
236  return false;
237  }
238 }
239 
240 
241 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
const word & name() const
Return name.
Definition: IOobject.H:307
static word groupName(Name name, const word &group)
Base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:78
virtual const IOdictionary & properties() const =0
Properties dictionary.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume model abstract base class.
Definition: fvModel.H:60
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:196
This fvModel adds the thermal inertia of a solid phase into the energy equation. It assumes that the ...
virtual bool movePoints()
Update for mesh motion.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void addSup(const volScalarField &rho, const volScalarField &he, fvMatrix< scalar > &eqn) const
Explicit and implicit sources for compressible equations.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
solidThermalEquilibrium(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void store()
Transfer ownership of this object to its registry.
Definition: regIOobjectI.H:40
Base-class for solid thermodynamic properties.
Definition: solidThermo.H:59
static autoPtr< solidThermo > New(const fvMesh &, const word &phaseName=word::null)
Standard selection based on fvMesh.
Definition: solidThermo.C:65
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the matrix for the first temporal derivative.
Calculate the matrix for the laplacian of the field.
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionSet dimless
const dimensionSet time
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
addBackwardCompatibleToRunTimeSelectionTable(fvConstraint, fixedTemperature, dictionary, fixedTemperatureConstraint, "fixedTemperatureConstraint")
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
static const coefficient B("B", dimless, 18.678)
static const coefficient A("A", dimPressure, 611.21)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
labelList fv(nPoints)
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:15