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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,7 +40,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ash::ash()
Foam::ash::ash() noexcept
:
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
#define solid_ash_H
#ifndef Foam_solid_ash_H
#define Foam_solid_ash_H
#include "solidProperties.H"
@ -52,7 +52,6 @@ class ash
:
public solidProperties
{
public:
//- Runtime type information
@ -61,8 +60,8 @@ public:
// Constructors
//- Construct null
ash();
//- Default construct
ash() noexcept;
//- Construct from dictionary
ash(const dictionary& dict);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,6 +40,19 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidProperties::solidProperties() noexcept
:
rho_(0),
Cp_(0),
kappa_(0),
Hf_(0),
emissivity_(0),
W_(0),
nu_(0),
E_(0)
{}
Foam::solidProperties::solidProperties
(
scalar rho,
@ -50,7 +63,7 @@ Foam::solidProperties::solidProperties
scalar W,
scalar nu,
scalar E
)
) noexcept
:
rho_(rho),
Cp_(Cp),
@ -71,9 +84,76 @@ Foam::solidProperties::solidProperties(const dictionary& dict)
Hf_(dict.get<scalar>("Hf")),
emissivity_(dict.get<scalar>("emissivity")),
W_(dict.get<scalar>("W")),
nu_(dict.getOrDefault<scalar>("nu", 0.0)),
E_(dict.getOrDefault<scalar>("E", 0.0))
{}
nu_(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 * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,7 +28,7 @@ Class
Foam::solidProperties
Description
The thermophysical properties of a solid
The thermophysical, mechanical properties of a solid
SourceFiles
solidProperties.C
@ -74,7 +74,7 @@ class solidProperties
//- Molar weight [Kg/Kmol]
scalar W_;
//- Poisson ration
//- Poisson ratio
scalar nu_;
//- Young Modulus [N/m2]
@ -83,6 +83,21 @@ class solidProperties
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
TypeName("solid");
@ -110,6 +125,9 @@ public:
// Constructors
//- Default construct
solidProperties() noexcept;
//- Construct from components
solidProperties
(
@ -121,10 +139,14 @@ public:
scalar W,
scalar nu,
scalar E
);
) noexcept;
//- 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
virtual autoPtr<solidProperties> clone() const
@ -157,32 +179,32 @@ public:
// Physical constants which define the solidProperties
//- Density [kg/m3]
inline scalar rho() const;
//- Density [kg/m3]
scalar rho() const noexcept { return rho_; }
//- Specific heat capacity [J/(kg.K)]
inline scalar Cp() const;
//- Specific heat capacity [J/(kg.K)]
scalar Cp() const { return Cp_; }
//- Thermal conductivity [W/(m.K)]
inline scalar kappa() const;
//- Thermal conductivity [W/(m.K)]
scalar kappa() const noexcept { return kappa_; }
//- Heat of formation [J/kg]
inline scalar Hf() const;
//- Heat of formation [J/kg]
scalar Hf() const noexcept { return Hf_; }
//- Sensible enthalpy - reference to Tstd [J/kg]
inline scalar Hs(const scalar T) const;
//- Sensible enthalpy - reference to Tstd [J/kg]
inline scalar Hs(const scalar T) const;
//- Emissivity []
inline scalar emissivity() const;
//- Emissivity []
scalar emissivity() const noexcept { return emissivity_;}
//- Molar weight [Kg/Kmol]
inline scalar W() const;
//- Molar weight [Kg/Kmol]
scalar W() const noexcept { return W_; }
//- Poissons
inline scalar nu() const;
//- Poisson ratio
scalar nu() const noexcept { return nu_; }
//- Young modulus [N/m2]
inline scalar E() const;
//- Young modulus [N/m2]
scalar E() const noexcept { return E_; }
// 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
{
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++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2512 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -29,22 +29,16 @@ boundaryField
window
{
type vibrationShell;
active true;
p pa;
type vibrationShell;
active true;
p pa;
solid
{
W 20; //Not used
rho 2500;
kappa 200;
Cp 600;
Hf 0;
emissivity 0;
E 7e10;
nu 0.22;
// Mechanical properties
rho 2500;
E 7e10;
nu 0.22;
}
region vibrationShell;
@ -55,7 +49,7 @@ boundaryField
f2 0;
value $internalField;
}
}
wall
{

View File

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