ENH: simpler mechanical or thermal use of solidProperties

- in some shell models, only the mechanical properties (rho,E,nu) are
  meaningful or just the basic thermal properties
  (rho,Cp,kappa,emissivity).

  Add a distinction when reading the dictionary entries
  if those properties are mandatory and the thermo properties
  (eg, molWt, Cp, etc) are optional or not.

  This simplifies user input for thermal and vibration shell models.
This commit is contained in:
Mark Olesen
2025-10-06 12:58:21 +02:00
parent e46cc77a5b
commit d6081a18f6
15 changed files with 189 additions and 171 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -124,7 +124,8 @@ thermalShell::thermalShell
: :
thermalShellModel(modelType, mesh, dict), thermalShellModel(modelType, mesh, dict),
nNonOrthCorr_(1), nNonOrthCorr_(1),
thermo_(dict.subDict("thermo")), // Only need/want thermal solid properties
thermo_(dict.subDict("thermo"), solidProperties::THERMAL),
qs_ qs_
( (
IOobject IOobject

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -92,7 +92,7 @@ protected:
//- Name of the temperature field //- Name of the temperature field
word TName_; word TName_;
//- Primary region temperature //- Primary (volume) region temperature
const volScalarField& Tp_; const volScalarField& Tp_;
//- Shell temperature //- Shell temperature
@ -157,31 +157,20 @@ public:
// Member Functions // Member Functions
// Access //- Return primary (volume) region temperature
const volScalarField& Tp() const noexcept { return Tp_; }
//- Return primary region temperature //- Return shell temperature
const volScalarField& Tp() const noexcept const areaScalarField& T() const noexcept { return T_; }
{
return Tp_;
}
//- Return shell temperature //- Return faOptions
const areaScalarField& T() const noexcept Foam::fa::options& faOptions() noexcept { return faOptions_; }
{
return T_;
}
//- Return faOptions
Foam::fa::options& faOptions() noexcept
{
return faOptions_;
}
// Evolution // Evolution
//- Pre-evolve region //- Pre-evolve region
virtual void preEvolveRegion(); virtual void preEvolveRegion();
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -74,7 +74,8 @@ vibrationShellModel::vibrationShellModel
regionMesh(), regionMesh(),
dimensionedScalar(dimAcceleration, Zero) dimensionedScalar(dimAcceleration, Zero)
), ),
solid_(dict.subDict("solid")), // Only need/want mechanical solid properties
solid_(dict.subDict("solid"), solidProperties::MECHANICAL),
pName_(dict.get<word>("p")), pName_(dict.get<word>("p")),
pa_(mesh.lookupObject<volScalarField>(pName_)), pa_(mesh.lookupObject<volScalarField>(pName_)),
faOptions_(Foam::fa::options::New(mesh)) faOptions_(Foam::fa::options::New(mesh))

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -167,43 +167,26 @@ public:
// Member Functions // Member Functions
// Access //- Return primary region pa
const volScalarField& pa() const noexcept { return pa_; }
//- Return primary region pa //- Return shell displacement
const volScalarField& pa() const noexcept const areaScalarField& w() const noexcept { return w_; }
{
return pa_;
}
//- Return shell displacement //- Return shell acceleration
const areaScalarField& w() const noexcept const areaScalarField& a() const noexcept { return a_; }
{
return w_;
}
//- Return shell acceleration //- Return faOptions
const areaScalarField& a() const noexcept Foam::fa::options& faOptions() noexcept { return faOptions_; }
{
return a_;
}
//- Return faOptions //- Return solid properties
Foam::fa::options& faOptions() noexcept const solidProperties& solid() const noexcept { return solid_; }
{
return faOptions_;
}
//- Return solid properties
const solidProperties& solid() const noexcept
{
return solid_;
}
// Evolution // Evolution
//- Pre-evolve region //- Pre-evolve region
virtual void preEvolveRegion(); virtual void preEvolveRegion();
}; };

View File

@ -40,7 +40,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::C::C() Foam::C::C() noexcept
: :
solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011, 0.0, 0.0) solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011, 0.0, 0.0)
{ {

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef solid_C_H #ifndef Foam_solid_C_H
#define solid_C_H #define Foam_solid_C_H
#include "solidProperties.H" #include "solidProperties.H"
@ -52,7 +52,6 @@ class C
: :
public solidProperties public solidProperties
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -61,11 +60,11 @@ public:
// Constructors // Constructors
//- Construct null //- Default construct
C(); C() noexcept;
//- Construct from dictionary //- Construct from dictionary
C(const dictionary& dict); explicit C(const dictionary& dict);
//- Return a clone //- Return a clone
virtual autoPtr<solidProperties> clone() const virtual autoPtr<solidProperties> clone() const

View File

@ -40,7 +40,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::CaCO3::CaCO3() Foam::CaCO3::CaCO3() noexcept
: :
solidProperties(2710, 850, 1.3, 0.0, 1.0, 100.086, 0.0, 0.0) solidProperties(2710, 850, 1.3, 0.0, 1.0, 100.086, 0.0, 0.0)
{ {

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef solid_CaCO3_H #ifndef Foam_solid_CaCO3_H
#define solid_CaCO3_H #define Foam_solid_CaCO3_H
#include "solidProperties.H" #include "solidProperties.H"
@ -52,7 +52,6 @@ class CaCO3
: :
public solidProperties public solidProperties
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -61,11 +60,11 @@ public:
// Constructors // Constructors
//- Construct null //- Default construct
CaCO3(); CaCO3() noexcept;
//- Construct from dictionary //- Construct from dictionary
CaCO3(const dictionary& dict); explicit CaCO3(const dictionary& dict);
//- Return a clone //- Return a clone
virtual autoPtr<solidProperties> clone() const virtual autoPtr<solidProperties> clone() const

View File

@ -40,7 +40,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ash::ash() Foam::ash::ash() noexcept
: :
solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011, 0.0, 0.0) solidProperties(2010, 710, 0.04, 0.0, 1.0, 12.011, 0.0, 0.0)
{ {

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef solid_ash_H #ifndef Foam_solid_ash_H
#define solid_ash_H #define Foam_solid_ash_H
#include "solidProperties.H" #include "solidProperties.H"
@ -52,7 +52,6 @@ class ash
: :
public solidProperties public solidProperties
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -61,8 +60,8 @@ public:
// Constructors // Constructors
//- Construct null //- Default construct
ash(); ash() noexcept;
//- Construct from dictionary //- Construct from dictionary
ash(const dictionary& dict); ash(const dictionary& dict);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,6 +40,19 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidProperties::solidProperties() noexcept
:
rho_(0),
Cp_(0),
kappa_(0),
Hf_(0),
emissivity_(0),
W_(0),
nu_(0),
E_(0)
{}
Foam::solidProperties::solidProperties Foam::solidProperties::solidProperties
( (
scalar rho, scalar rho,
@ -50,7 +63,7 @@ Foam::solidProperties::solidProperties
scalar W, scalar W,
scalar nu, scalar nu,
scalar E scalar E
) ) noexcept
: :
rho_(rho), rho_(rho),
Cp_(Cp), Cp_(Cp),
@ -71,9 +84,76 @@ Foam::solidProperties::solidProperties(const dictionary& dict)
Hf_(dict.get<scalar>("Hf")), Hf_(dict.get<scalar>("Hf")),
emissivity_(dict.get<scalar>("emissivity")), emissivity_(dict.get<scalar>("emissivity")),
W_(dict.get<scalar>("W")), W_(dict.get<scalar>("W")),
nu_(dict.getOrDefault<scalar>("nu", 0.0)), nu_(0),
E_(dict.getOrDefault<scalar>("E", 0.0)) E_(0)
{} {
// Mechanical properties: optional
dict.readIfPresent("nu", nu_);
dict.readIfPresent("E", E_);
}
Foam::solidProperties::solidProperties
(
const dictionary& dict,
solidProperties::categories category
)
:
solidProperties()
{
// Everyone gets density
rho_ = dict.get<scalar>("rho");
// Heat of formation, molecular weight
if (category == categories::REGULAR)
{
Hf_ = dict.get<scalar>("Hf");
W_ = dict.get<scalar>("W");
}
else
{
// Optional if thermal or mechanical only
dict.readIfPresent("Hf", Hf_);
dict.readIfPresent("W", W_);
}
// Thermal properties
if
(
(category == categories::REGULAR)
|| (category & categories::THERMAL)
)
{
Cp_ = dict.get<scalar>("Cp");
kappa_ = dict.getCompat<scalar>("kappa", {{"K", 1612}});
// Also handle emissivity as mandatory
emissivity_ = dict.get<scalar>("emissivity");
}
else
{
// Optional if mechanical only
dict.readIfPresent("Cp", Cp_);
dict.readIfPresentCompat("kappa", {{"K", 1612}}, kappa_);
dict.readIfPresent("emissivity", emissivity_);
}
// Mechanical properties
if
(
(category != categories::REGULAR)
&& (category & categories::MECHANICAL)
)
{
nu_ = dict.get<scalar>("nu");
E_ = dict.get<scalar>("E");
}
else
{
dict.readIfPresent("nu", nu_);
dict.readIfPresent("E", E_);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd. Copyright (C) 2018-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +28,7 @@ Class
Foam::solidProperties Foam::solidProperties
Description Description
The thermophysical properties of a solid The thermophysical, mechanical properties of a solid
SourceFiles SourceFiles
solidProperties.C solidProperties.C
@ -74,7 +74,7 @@ class solidProperties
//- Molar weight [Kg/Kmol] //- Molar weight [Kg/Kmol]
scalar W_; scalar W_;
//- Poisson ration //- Poisson ratio
scalar nu_; scalar nu_;
//- Young Modulus [N/m2] //- Young Modulus [N/m2]
@ -83,6 +83,21 @@ class solidProperties
public: public:
// Public Data Types
//- Simple categories of solid properties.
// Can be leveraged eg, for mechanical-only vs thermal-only etc
enum categories
{
//! Needs mechanical only [E, nu]
MECHANICAL = (1),
//! Needs thermal only [Cp, kappa, emissivity?]
THERMAL = (2),
//! thermal: mandatory, mechanical: optional
REGULAR = 0xFF
};
//- Runtime type information //- Runtime type information
TypeName("solid"); TypeName("solid");
@ -110,6 +125,9 @@ public:
// Constructors // Constructors
//- Default construct
solidProperties() noexcept;
//- Construct from components //- Construct from components
solidProperties solidProperties
( (
@ -121,10 +139,14 @@ public:
scalar W, scalar W,
scalar nu, scalar nu,
scalar E scalar E
); ) noexcept;
//- Construct from dictionary //- Construct from dictionary
solidProperties(const dictionary& dict); explicit solidProperties(const dictionary& dict);
//- Construct from dictionary with category-specific handling
solidProperties(const dictionary& dict, categories category);
//- Construct and return clone //- Construct and return clone
virtual autoPtr<solidProperties> clone() const virtual autoPtr<solidProperties> clone() const
@ -157,32 +179,32 @@ public:
// Physical constants which define the solidProperties // Physical constants which define the solidProperties
//- Density [kg/m3] //- Density [kg/m3]
inline scalar rho() const; scalar rho() const noexcept { return rho_; }
//- Specific heat capacity [J/(kg.K)] //- Specific heat capacity [J/(kg.K)]
inline scalar Cp() const; scalar Cp() const { return Cp_; }
//- Thermal conductivity [W/(m.K)] //- Thermal conductivity [W/(m.K)]
inline scalar kappa() const; scalar kappa() const noexcept { return kappa_; }
//- Heat of formation [J/kg] //- Heat of formation [J/kg]
inline scalar Hf() const; scalar Hf() const noexcept { return Hf_; }
//- Sensible enthalpy - reference to Tstd [J/kg] //- Sensible enthalpy - reference to Tstd [J/kg]
inline scalar Hs(const scalar T) const; inline scalar Hs(const scalar T) const;
//- Emissivity [] //- Emissivity []
inline scalar emissivity() const; scalar emissivity() const noexcept { return emissivity_;}
//- Molar weight [Kg/Kmol] //- Molar weight [Kg/Kmol]
inline scalar W() const; scalar W() const noexcept { return W_; }
//- Poissons //- Poisson ratio
inline scalar nu() const; scalar nu() const noexcept { return nu_; }
//- Young modulus [N/m2] //- Young modulus [N/m2]
inline scalar E() const; scalar E() const noexcept { return E_; }
// I-O // I-O

View File

@ -30,58 +30,10 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline Foam::scalar Foam::solidProperties::rho() const
{
return rho_;
}
inline Foam::scalar Foam::solidProperties::Cp() const
{
return Cp_;
}
inline Foam::scalar Foam::solidProperties::kappa() const
{
return kappa_;
}
inline Foam::scalar Foam::solidProperties::Hf() const
{
return Hf_;
}
inline Foam::scalar Foam::solidProperties::Hs(const scalar T) const inline Foam::scalar Foam::solidProperties::Hs(const scalar T) const
{ {
return Cp_*(T - Tstd); return Cp_*(T - Tstd);
} }
inline Foam::scalar Foam::solidProperties::emissivity() const
{
return emissivity_;
}
inline Foam::scalar Foam::solidProperties::W() const
{
return W_;
}
inline Foam::scalar Foam::solidProperties::nu() const
{
return nu_;
}
inline Foam::scalar Foam::solidProperties::E() const
{
return E_;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 | | \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -29,22 +29,16 @@ boundaryField
window window
{ {
type vibrationShell; type vibrationShell;
active true; active true;
p pa; p pa;
solid solid
{ {
W 20; //Not used // Mechanical properties
rho 2500; rho 2500;
E 7e10;
kappa 200; nu 0.22;
Cp 600;
Hf 0;
emissivity 0;
E 7e10;
nu 0.22;
} }
region vibrationShell; region vibrationShell;
@ -55,7 +49,7 @@ boundaryField
f2 0; f2 0;
value $internalField; value $internalField;
} }
wall wall
{ {

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 | | \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -34,11 +34,10 @@ boundaryField
thermo thermo
{ {
W 50; // Thermal properties
rho 1000; rho 1000;
kappa 200; kappa 200;
Cp 600; Cp 600;
Hf 0;
emissivity 0; emissivity 0;
} }