From 06adb182997870c71efa7411a58df3bb45f0f690 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 14 Apr 2018 11:04:12 +0100 Subject: [PATCH] thermophysicalModels::liquidProperties: Added initial write-to-dict functionality Needs further work to make read and write of dictionary consistent. --- .../absoluteEnthalpy/absoluteEnthalpy.H | 4 ++-- .../absoluteInternalEnergy.H | 4 ++-- .../sensibleEnthalpy/sensibleEnthalpy.H | 4 ++-- .../sensibleInternalEnergy.H | 4 ++-- .../specie/thermo/thermo/thermoI.H | 2 +- .../liquidProperties/liquidProperties.C | 21 ++++++++++++++++++- .../liquidProperties/liquidProperties.H | 7 +++++-- .../thermophysicalProperties.C | 10 ++++++++- .../thermophysicalProperties.H | 5 ++++- .../thermophysicalPropertiesSelector.C | 14 ++++++++++++- .../thermophysicalPropertiesSelector.H | 10 +++++++-- 11 files changed, 68 insertions(+), 17 deletions(-) diff --git a/src/thermophysicalModels/specie/thermo/absoluteEnthalpy/absoluteEnthalpy.H b/src/thermophysicalModels/specie/thermo/absoluteEnthalpy/absoluteEnthalpy.H index 2130d60bc6..a7d02ed377 100644 --- a/src/thermophysicalModels/specie/thermo/absoluteEnthalpy/absoluteEnthalpy.H +++ b/src/thermophysicalModels/specie/thermo/absoluteEnthalpy/absoluteEnthalpy.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,7 +64,7 @@ public: // Fundamental properties - static word name() + static word energyName() { return "ha"; } diff --git a/src/thermophysicalModels/specie/thermo/absoluteInternalEnergy/absoluteInternalEnergy.H b/src/thermophysicalModels/specie/thermo/absoluteInternalEnergy/absoluteInternalEnergy.H index c78b61d50e..9f5be192f2 100644 --- a/src/thermophysicalModels/specie/thermo/absoluteInternalEnergy/absoluteInternalEnergy.H +++ b/src/thermophysicalModels/specie/thermo/absoluteInternalEnergy/absoluteInternalEnergy.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,7 +65,7 @@ public: // Fundamental properties - static word name() + static word energyName() { return "ea"; } diff --git a/src/thermophysicalModels/specie/thermo/sensibleEnthalpy/sensibleEnthalpy.H b/src/thermophysicalModels/specie/thermo/sensibleEnthalpy/sensibleEnthalpy.H index 1b77cd40a6..7f058c1307 100644 --- a/src/thermophysicalModels/specie/thermo/sensibleEnthalpy/sensibleEnthalpy.H +++ b/src/thermophysicalModels/specie/thermo/sensibleEnthalpy/sensibleEnthalpy.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,7 +64,7 @@ public: // Fundamental properties - static word name() + static word energyName() { return "h"; } diff --git a/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H b/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H index 0922569c7d..0263faae08 100644 --- a/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H +++ b/src/thermophysicalModels/specie/thermo/sensibleInternalEnergy/sensibleInternalEnergy.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,7 +65,7 @@ public: // Fundamental properties - static word name() + static word energyName() { return "e"; } diff --git a/src/thermophysicalModels/specie/thermo/thermo/thermoI.H b/src/thermophysicalModels/specie/thermo/thermo/thermoI.H index fcd1671f26..791042fe75 100644 --- a/src/thermophysicalModels/specie/thermo/thermo/thermoI.H +++ b/src/thermophysicalModels/specie/thermo/thermo/thermoI.H @@ -100,7 +100,7 @@ template class Type> inline Foam::word Foam::species::thermo::heName() { - return Type>::name(); + return Type>::energyName(); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.C b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.C index 5f88b7a3e6..574fe5f5e7 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.C +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -260,6 +260,25 @@ void Foam::liquidProperties::writeData(Ostream& os) const } +void Foam::liquidProperties::write(Ostream& os) const +{ + thermophysicalProperties::write(os); + + dictionary dict("liquidProperties"); + dict.add("Tc", Tc_); + dict.add("Pc", Pc_); + dict.add("Vc", Vc_); + dict.add("Zc", Zc_); + dict.add("Tt", Tt_); + dict.add("Pt", Pt_); + dict.add("Tb", Tb_); + dict.add("dipm", dipm_); + dict.add("omega", omega_); + dict.add("delta", delta_); + os << indent << dict.dictName() << dict; +} + + // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // Foam::Ostream& Foam::operator<<(Ostream& os, const liquidProperties& l) diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H index 7df742adca..e36c8479e9 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -291,7 +291,10 @@ public: inline void readIfPresent(Liquid& l, const dictionary& dict); //- Write the function coefficients - virtual void writeData(Ostream& os) const = 0;; + virtual void writeData(Ostream& os) const = 0; + + //- Write dictionary to Ostream + void write(Ostream& os) const; //- Write the data for each of the property functions template diff --git a/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.C b/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.C index e5613a98bc..3f4e939725 100644 --- a/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.C +++ b/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -121,6 +121,14 @@ void Foam::thermophysicalProperties::writeData(Ostream& os) const } +void Foam::thermophysicalProperties::write(Ostream& os) const +{ + dictionary dict("thermophysicalProperties"); + dict.add("W", W_); + os << indent << dict.dictName() << dict; +} + + // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // Foam::Ostream& Foam::operator<<(Ostream& os, const thermophysicalProperties& l) diff --git a/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.H b/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.H index f44237ed70..f50c64290a 100644 --- a/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.H +++ b/src/thermophysicalModels/thermophysicalProperties/thermophysicalProperties/thermophysicalProperties.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -172,6 +172,9 @@ public: //- Write the function coefficients virtual void writeData(Ostream& os) const = 0; + //- Write dictionary to Ostream + void write(Ostream& os) const; + //- Ostream Operator friend Ostream& operator<< ( diff --git a/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.C b/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.C index 59607a8160..5bbf5e9b8f 100644 --- a/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.C +++ b/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,4 +58,16 @@ thermophysicalPropertiesSelector } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::thermophysicalPropertiesSelector::write +( + Ostream& os +) const +{ + propertiesPtr_->write(os); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.H b/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.H index 9f4c228d96..c7ac49d694 100644 --- a/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.H +++ b/src/thermophysicalModels/thermophysicalProperties/thermophysicalPropertiesSelector/thermophysicalPropertiesSelector.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class thermophysicalPropertiesSelector Declaration + Class thermophysicalPropertiesSelector Declaration \*---------------------------------------------------------------------------*/ template @@ -135,6 +135,12 @@ public: inline scalar S(const scalar p, const scalar T) const; + // I-O + + //- Write to Ostream + void write(Ostream& os) const; + + // Physical properties //- Liquid viscosity [Pa s]