Loading...
Searching...
No Matches
solidProperties.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
38}
39
40
41// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42
44:
45 rho_(0),
46 Cp_(0),
47 kappa_(0),
48 Hf_(0),
49 emissivity_(0),
50 W_(0),
51 nu_(0),
52 E_(0)
53{}
54
55
57(
58 scalar rho,
59 scalar Cp,
60 scalar kappa,
61 scalar Hf,
62 scalar emissivity,
63 scalar W,
64 scalar nu,
65 scalar E
67:
68 rho_(rho),
69 Cp_(Cp),
70 kappa_(kappa),
71 Hf_(Hf),
72 emissivity_(emissivity),
73 W_(W),
74 nu_(nu),
75 E_(E)
76{}
77
78
80:
81 rho_(dict.get<scalar>("rho")),
82 Cp_(dict.get<scalar>("Cp")),
83 kappa_(dict.getCompat<scalar>("kappa", {{"K", 1612}})),
84 Hf_(dict.get<scalar>("Hf")),
85 emissivity_(dict.get<scalar>("emissivity")),
86 W_(dict.get<scalar>("W")),
87 nu_(0),
88 E_(0)
90 // Mechanical properties: optional
91 dict.readIfPresent("nu", nu_);
92 dict.readIfPresent("E", E_);
93}
94
95
97(
98 const dictionary& dict,
100)
101:
103{
104 // Everyone gets density
105 rho_ = dict.get<scalar>("rho");
106
107 // Heat of formation, molecular weight
108 if (category == categories::REGULAR)
109 {
110 Hf_ = dict.get<scalar>("Hf");
111 W_ = dict.get<scalar>("W");
112 }
113 else
114 {
115 // Optional if thermal or mechanical only
116 dict.readIfPresent("Hf", Hf_);
117 dict.readIfPresent("W", W_);
118 }
119
120 // Thermal properties
121 if
122 (
123 (category == categories::REGULAR)
124 || (category & categories::THERMAL)
125 )
126 {
127 Cp_ = dict.get<scalar>("Cp");
128 kappa_ = dict.getCompat<scalar>("kappa", {{"K", 1612}});
129
130 // Also handle emissivity as mandatory
131 emissivity_ = dict.get<scalar>("emissivity");
132 }
133 else
134 {
135 // Optional if mechanical only
136 dict.readIfPresent("Cp", Cp_);
137 dict.readIfPresentCompat("kappa", {{"K", 1612}}, kappa_);
138 dict.readIfPresent("emissivity", emissivity_);
139 }
140
141 // Mechanical properties
142 if
143 (
144 (category != categories::REGULAR)
145 && (category & categories::MECHANICAL)
146 )
147 {
148 nu_ = dict.get<scalar>("nu");
149 E_ = dict.get<scalar>("E");
150 }
151 else
152 {
153 dict.readIfPresent("nu", nu_);
154 dict.readIfPresent("E", E_);
155 }
156}
157
158
159// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
160
162{
163 dict.readIfPresent("rho", rho_);
164 dict.readIfPresent("Cp", Cp_);
165 dict.readIfPresentCompat("kappa", {{"K", 1612}}, kappa_);
166 dict.readIfPresent("Hf", Hf_);
167 dict.readIfPresent("emissivity", emissivity_);
168 dict.readIfPresent("W", W_);
169 dict.readIfPresent("nu", nu_);
170 dict.readIfPresent("E", E_);
171}
172
173
175{
176 os << rho_ << token::SPACE
177 << Cp_ << token::SPACE
178 << kappa_ << token::SPACE
179 << Hf_ << token::SPACE
180 << emissivity_ << token::SPACE
181 << W_ << token::SPACE
182 << nu_ << token::SPACE
183 << E_;
184}
185
186
187// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
188
189Foam::Ostream& Foam::operator<<(Ostream& os, const solidProperties& s)
190{
191 s.writeData(os);
192 return os;
193}
194
195
196// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
The thermophysical, mechanical properties of a solid.
solidProperties() noexcept
Default construct.
virtual void writeData(Ostream &os) const
Write the solidProperties properties.
scalar kappa() const noexcept
Thermal conductivity [W/(m.K)].
scalar E() const noexcept
Young modulus [N/m2].
categories
Simple categories of solid properties.
@ MECHANICAL
Needs mechanical only [E, nu].
@ THERMAL
Needs thermal only [Cp, kappa, emissivity?].
@ REGULAR
thermal: mandatory, mechanical: optional
scalar Cp() const
Specific heat capacity [J/(kg.K)].
scalar W() const noexcept
Molar weight [Kg/Kmol].
scalar nu() const noexcept
Poisson ratio.
scalar rho() const noexcept
Density [kg/m3].
scalar emissivity() const noexcept
Emissivity [].
scalar Hf() const noexcept
Heat of formation [J/kg].
void readIfPresent(const dictionary &dict)
Read and set the properties if present in the given dictionary.
@ SPACE
Space [isspace].
Definition token.H:144
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
const volScalarField & Cp
Definition EEqn.H:7
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const direction noexcept
Definition scalarImpl.H:265
volScalarField & nu
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict