diff --git a/src/regionFaModels/thermalShell/thermalShell.C b/src/regionFaModels/thermalShell/thermalShell.C index 7d625ecfe4..d5fad911dd 100644 --- a/src/regionFaModels/thermalShell/thermalShell.C +++ b/src/regionFaModels/thermalShell/thermalShell.C @@ -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 diff --git a/src/regionFaModels/thermalShellModel/thermalShellModel.H b/src/regionFaModels/thermalShellModel/thermalShellModel.H index a56a48b3af..835633291c 100644 --- a/src/regionFaModels/thermalShellModel/thermalShellModel.H +++ b/src/regionFaModels/thermalShellModel/thermalShellModel.H @@ -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(); }; diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModel.C b/src/regionFaModels/vibrationShellModel/vibrationShellModel.C index 7ce1aaf7ee..cd9bddd821 100644 --- a/src/regionFaModels/vibrationShellModel/vibrationShellModel.C +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModel.C @@ -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("p")), pa_(mesh.lookupObject(pName_)), faOptions_(Foam::fa::options::New(mesh)) diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModel.H b/src/regionFaModels/vibrationShellModel/vibrationShellModel.H index e8053ec526..03dd388eff 100644 --- a/src/regionFaModels/vibrationShellModel/vibrationShellModel.H +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModel.H @@ -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(); }; diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C index 95315348a6..88ca8ed2be 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.C @@ -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) { diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H index 5ff8dda5ea..2e4b7135ec 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H @@ -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 clone() const diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C index c4e2eae0b9..b0089ddef6 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.C @@ -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) { diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H index b8baf048a3..c561b06948 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H @@ -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 clone() const diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C index e6ace63076..bee08309fe 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.C @@ -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) { diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H index 34e759813d..834c9a04e5 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H @@ -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); diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C index 443c4c9197..11d7448aa7 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.C @@ -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("Hf")), emissivity_(dict.get("emissivity")), W_(dict.get("W")), - nu_(dict.getOrDefault("nu", 0.0)), - E_(dict.getOrDefault("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("rho"); + + // Heat of formation, molecular weight + if (category == categories::REGULAR) + { + Hf_ = dict.get("Hf"); + W_ = dict.get("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("Cp"); + kappa_ = dict.getCompat("kappa", {{"K", 1612}}); + + // Also handle emissivity as mandatory + emissivity_ = dict.get("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("nu"); + E_ = dict.get("E"); + } + else + { + dict.readIfPresent("nu", nu_); + dict.readIfPresent("E", E_); + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H index 313f3c37ab..7d13d96787 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H @@ -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 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 diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H index 0f6148bdef..334a3ce471 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidPropertiesI.H @@ -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_; -} - - // ************************************************************************* // diff --git a/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa index aa6b622aef..67f1830fd5 100644 --- a/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa +++ b/tutorials/compressible/acousticFoam/obliqueAirJet/main/0.orig/pa @@ -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 { diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoomWithThermalShell/0/T b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoomWithThermalShell/0/T index 850064d8cc..6a37471aac 100644 --- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoomWithThermalShell/0/T +++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoomWithThermalShell/0/T @@ -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; }