diff --git a/src/thermophysicalModels/solidThermo/Make/files b/src/thermophysicalModels/solidThermo/Make/files index ab79d43bd5..858b87cf29 100644 --- a/src/thermophysicalModels/solidThermo/Make/files +++ b/src/thermophysicalModels/solidThermo/Make/files @@ -1,4 +1,5 @@ solidThermo/solidThermo.C solidThermo/solidThermos.C +constSolidThermo/constSolidThermo.C LIB = $(FOAM_LIBBIN)/libsolidThermo diff --git a/src/thermophysicalModels/solidThermo/constSolidThermo/constSolidThermo.C b/src/thermophysicalModels/solidThermo/constSolidThermo/constSolidThermo.C new file mode 100644 index 0000000000..4c878fad7f --- /dev/null +++ b/src/thermophysicalModels/solidThermo/constSolidThermo/constSolidThermo.C @@ -0,0 +1,433 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "constSolidThermo.H" +#include "addToRunTimeSelectionTable.H" + +/* * * * * * * * * * * * * * * Private Static Data * * * * * * * * * * * * * */ + +namespace Foam +{ + defineTypeNameAndDebug(constSolidThermo, 0); + addToRunTimeSelectionTable(basicThermo, constSolidThermo, fvMesh); + addToRunTimeSelectionTable(solidThermo, constSolidThermo, fvMesh); +} + + +/* * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * */ + +Foam::volScalarField Foam::constSolidThermo::readProperty +( + const word& name, + const dimensionSet& dimensions +) const +{ + const dictionary& propDict(subDict(name)); + const word propType(propDict.lookup("type")); + + if (propType == "uniform") + { + return volScalarField + ( + IOobject + ( + phasePropertyName(name), + mesh().time().constant(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensionedScalar(dimensions, propDict.lookup("value")) + ); + } + else if (propType == "file") + { + return volScalarField + ( + IOobject + ( + phasePropertyName(name), + mesh().time().constant(), + mesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensions + ); + } + else + { + FatalErrorInFunction + << "Valid type entries are 'uniform' or 'file' for " << name + << abort(FatalError); + + return volScalarField::null(); + } +} + + +void Foam::constSolidThermo::readProperty +( + const word& name, + volScalarField& prop +) const +{ + const dictionary& propDict(subDict(name)); + const word propType(propDict.lookup("type")); + + if (propType == "uniform") + { + prop == dimensionedScalar + ( + prop.name(), + prop.dimensions(), + propDict.lookup("value") + ); + } + else if (propType == "file") + { + const volScalarField propField + ( + IOobject + ( + prop.name(), + prop.mesh().time().constant(), + prop.mesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + prop.mesh() + ); + prop == propField; + } + else + { + FatalErrorInFunction + << "Valid type entries are 'uniform' or 'file' for " << prop.name() + << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::constSolidThermo::constSolidThermo +( + const fvMesh& mesh, + const word& phaseName +) +: + solidThermo::composite(mesh, phaseName), + Cv_(readProperty("Cv", dimEnergy/dimMass/dimTemperature)), + e_ + ( + IOobject + ( + phasePropertyName("e"), + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + Cv_*T_, + this->heBoundaryTypes(), + this->heBoundaryBaseTypes() + ) +{ + readProperty("rho", rho_); + readProperty("kappa", kappa_); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::constSolidThermo::~constSolidThermo() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::volScalarField& Foam::constSolidThermo::he() +{ + return e_; +} + + +const Foam::volScalarField& Foam::constSolidThermo::he() const +{ + return e_; +} + + +Foam::tmp Foam::constSolidThermo::he +( + const scalarField& T, + const labelList& cells +) const +{ + return scalarField(Cv_, cells)*T; +} + + +Foam::tmp Foam::constSolidThermo::he +( + const volScalarField& p, + const volScalarField& T +) const +{ + return Cv_*T; +} + + +Foam::tmp Foam::constSolidThermo::he +( + const scalarField& T, + const label patchi +) const +{ + return Cv_.boundaryField()[patchi]*T; +} + + +Foam::tmp Foam::constSolidThermo::hs() const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::hs +( + const volScalarField& p, + const volScalarField& T +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::hs +( + const scalarField& T, + const label patchi +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::hs +( + const scalarField& T, + const labelList& cells +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::ha() const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::ha +( + const volScalarField& p, + const volScalarField& T +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::ha +( + const scalarField& T, + const label patchi +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::ha +( + const scalarField& T, + const labelList& cells +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::hc() const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::THE +( + const volScalarField& h, + const volScalarField& p, + const volScalarField& T0 +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::THE +( + const scalarField& he, + const scalarField& T0, + const labelList& cells +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::THE +( + const scalarField& he, + const scalarField& T0, + const label patchi +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +const Foam::volScalarField& Foam::constSolidThermo::Cp() const +{ + return Cv_; +} + + +const Foam::volScalarField& Foam::constSolidThermo::Cv() const +{ + return Cv_; +} + + +Foam::tmp Foam::constSolidThermo::Cp +( + const scalarField& T, + const label patchi +) const +{ + return Cv_.boundaryField()[patchi]; +} + + +Foam::tmp Foam::constSolidThermo::Cv +( + const scalarField& T, + const label patchi +) const +{ + return Cv_.boundaryField()[patchi]; +} + + +Foam::tmp Foam::constSolidThermo::Cpv() const +{ + return Cv_; +} + + +Foam::tmp Foam::constSolidThermo::Cpv +( + const scalarField& T, + const label patchi +) const +{ + return Cv_.boundaryField()[patchi]; +} + + +Foam::tmp Foam::constSolidThermo::alphahe() const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::alphahe +( + const label patchi +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::Kappa() const +{ + NotImplemented; + return tmp(nullptr); +} + + +Foam::tmp Foam::constSolidThermo::Kappa +( + const label patchi +) const +{ + NotImplemented; + return tmp(nullptr); +} + + +void Foam::constSolidThermo::correct() +{ + T_ = e_/Cv_; +} + + +bool Foam::constSolidThermo::read() +{ + return regIOobject::read(); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidThermo/constSolidThermo/constSolidThermo.H b/src/thermophysicalModels/solidThermo/constSolidThermo/constSolidThermo.H new file mode 100644 index 0000000000..ba2901009c --- /dev/null +++ b/src/thermophysicalModels/solidThermo/constSolidThermo/constSolidThermo.H @@ -0,0 +1,349 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::constSolidThermo + +Description + Uniform or non-uniform constant solid thermodynamic properties + + Each physical property can specified as either \c uniform in which case the + value entry is read or \c file in which case the field file in read + from the constant directory. + +Usage + Example of uniform constant solid properties specification: + \verbatim + thermoType constSolidThermo; + + rho + { + type uniform; + value 8940; + } + + Cv + { + type uniform; + value 385; + } + + kappa + { + type uniform; + value 380; + } + \endverbatim + + Example of non-uniform constant solid properties specification: + \verbatim + thermoType constSolidThermo; + + rho + { + type file; + } + + Cv + { + type file; + } + + kappa + { + type file; + } + \endverbatim + where each of the field files are read from the constant directory. + +SourceFiles + constSolidThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constSolidThermo_H +#define constSolidThermo_H + +#include "solidThermo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class constSolidThermo Declaration +\*---------------------------------------------------------------------------*/ + +class constSolidThermo +: + public solidThermo::composite +{ + // Private data + + //- Heat capacity at constant volume [J/kg/K] + volScalarField Cv_; + + //- Internal energy [J/kg] + volScalarField e_; + + +protected: + + // Protected Member Functions + + volScalarField readProperty + ( + const word& name, + const dimensionSet& dimensions + ) const; + + void readProperty(const word& name, volScalarField& prop) const; + + +public: + + //- Runtime type information + TypeName("constSolidThermo"); + + + // Constructors + + //- Construct from mesh and phase name + constSolidThermo + ( + const fvMesh&, + const word& phaseName = word::null + ); + + + //- Destructor + virtual ~constSolidThermo(); + + + // Member Functions + + //- Return the name of the thermo physics + virtual word thermoName() const + { + return type(); + } + + //- Return true if the equation of state is incompressible + // i.e. rho != f(p) + virtual bool incompressible() const + { + return true; + } + + //- Return true if the equation of state is isochoric + // i.e. rho = const + virtual bool isochoric() const + { + return true; + } + + + // Access to thermophysical state variables + + //- Enthalpy/Internal energy [J/kg] + // Non-const access allowed for transport equations + virtual volScalarField& he(); + + //- Enthalpy/Internal energy [J/kg] + virtual const volScalarField& he() const; + + //- Heat capacity at constant pressure [J/kg/K] + virtual const volScalarField& Cp() const; + + //- Heat capacity at constant volume [J/kg/K] + virtual const volScalarField& Cv() const; + + + // Fields derived from thermodynamic state variables + + //- Enthalpy/Internal energy + // for given pressure and temperature [J/kg] + virtual tmp he + ( + const volScalarField& p, + const volScalarField& T + ) const; + + //- Enthalpy/Internal energy for cell-set [J/kg] + virtual tmp he + ( + const scalarField& T, + const labelList& cells + ) const; + + //- Enthalpy/Internal energy for patch [J/kg] + virtual tmp he + ( + const scalarField& T, + const label patchi + ) const; + + //- Sensible enthalpy [J/kg] + virtual tmp hs() const; + + //- Sensible enthalpy + // for given pressure and temperature [J/kg] + virtual tmp hs + ( + const volScalarField& p, + const volScalarField& T + ) const; + + //- Sensible enthalpy for cell-set [J/kg] + virtual tmp hs + ( + const scalarField& T, + const labelList& cells + ) const; + + //- Sensible enthalpy for patch [J/kg] + virtual tmp hs + ( + const scalarField& T, + const label patchi + ) const; + + //- Absolute enthalpy [J/kg/K] + virtual tmp ha() const; + + //- Absolute enthalpy + // for given pressure and temperature [J/kg] + virtual tmp ha + ( + const volScalarField& p, + const volScalarField& T + ) const; + + //- Absolute enthalpy for patch [J/kg/K] + virtual tmp ha + ( + const scalarField& T, + const label patchi + ) const; + + //- Absolute enthalpy for cell-set [J/kg] + virtual tmp ha + ( + const scalarField& T, + const labelList& cells + ) const; + + //- Enthalpy of formation [J/kg] + virtual tmp hc() const; + + //- Temperature from enthalpy/internal energy + virtual tmp THE + ( + const volScalarField& h, + const volScalarField& p, + const volScalarField& T0 // starting temperature + ) const; + + //- Temperature from enthalpy/internal energy for cell-set + virtual tmp THE + ( + const scalarField& he, + const scalarField& T0, // starting temperature + const labelList& cells + ) const; + + //- Temperature from enthalpy/internal energy for patch + virtual tmp THE + ( + const scalarField& he, + const scalarField& T0, // starting temperature + const label patchi + ) const; + + //- Heat capacity at constant pressure for patch [J/kg/K] + virtual tmp Cp + ( + const scalarField& T, + const label patchi + ) const; + + //- Heat capacity at constant volume for patch [J/kg/K] + virtual tmp Cv + ( + const scalarField& T, + const label patchi + ) const; + + //- Heat capacity at constant pressure/volume [J/kg/K] + virtual tmp Cpv() const; + + //- Heat capacity at constant pressure/volume for patch [J/kg/K] + virtual tmp Cpv + ( + const scalarField& T, + const label patchi + ) const; + + + // Fields derived from transport state variables + + //- Thermal diffusivity for energy of mixture [kg/m/s] + virtual tmp alphahe() const; + + //- Thermal diffusivity for energy of mixture for patch [kg/m/s] + virtual tmp alphahe(const label patchi) const; + + //- Return true if thermal conductivity is isotropic + virtual bool isotropic() const + { + return true; + } + + //- Anisotropic thermal conductivity [W/m/K] + virtual tmp Kappa() const; + + //- Anisotropic thermal conductivity [W/m/K] + virtual tmp Kappa(const label patchi) const; + + + //- Update properties + virtual void correct(); + + + // I-O + + //- Read thermophysicalProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/modules/CHT/coolingCylinder2D/constant/solid/physicalProperties b/tutorials/modules/CHT/coolingCylinder2D/constant/solid/physicalProperties index 5b632dd727..3703546636 100644 --- a/tutorials/modules/CHT/coolingCylinder2D/constant/solid/physicalProperties +++ b/tutorials/modules/CHT/coolingCylinder2D/constant/solid/physicalProperties @@ -13,40 +13,25 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -thermoType +thermoType constSolidThermo; + +rho { - type heSolidThermo; - mixture pureMixture; - transport constIsoSolid; - thermo eConst; - equationOfState rhoConst; - specie specie; - energy sensibleInternalEnergy; + type uniform; + value 8940; } -mixture +Cv { - specie - { - nMoles 1; - molWeight 63.5; // [g/mol] - } - - transport - { - kappa 380; // [W/m/K] - } - - thermodynamics - { - Hf 0; - Cv 385; // [J/kg/K] - } - - equationOfState - { - rho 8940; // [kg/m^3] - } + type uniform; + value 385; } +kappa +{ + type uniform; + value 380; +} + + // ************************************************************************* //