From e1daa5391f8238e4c90ff98e7328f8cb8aab15e3 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 25 Nov 2019 14:43:22 +0000 Subject: [PATCH] liquidProperties: Added support for multiple entries is mixture each of specified type If the optional "type" entry is provided for the liquid specie that type is looked-up rather than the entry name, e.g. mixture { H2O { type liquid; W 18.015; Tc 647.13; Pc 2.2055e+7; Vc 0.05595; Zc 0.229; Tt 273.16; Pt 6.113e+2; Tb 373.15; dipm 6.1709e-30; omega 0.3449; delta 4.7813e+4; rho { type NSRDSfunc5; a 98.343885; b 0.30542; c 647.13; d 0.081; } . . . } ethanol { type liquid; W 46.07; . . . } } --- .../liquidProperties/liquidProperties.C | 65 +++++-------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.C b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.C index ed921f6e6a..99ce8b1a3f 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 | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,8 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "liquidProperties.H" -#include "HashTable.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -121,57 +119,24 @@ Foam::autoPtr Foam::liquidProperties::New InfoInFunction << "Constructing liquidProperties" << endl; } - const word& liquidPropertiesTypeName = dict.dictName(); + // If the type is not specified use the entry name as the liquid type name + const word& liquidPropertiesTypeName = + dict.found("type") ? dict.lookup("type") : dict.dictName(); - if (dict.found("defaultCoeffs")) + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) { - // Backward-compatibility - - if (Switch(dict.lookup("defaultCoeffs"))) - { - return New(liquidPropertiesTypeName); - } - else - { - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName); - - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - FatalErrorInFunction - << "Unknown liquidProperties type " - << liquidPropertiesTypeName << nl << nl - << "Valid liquidProperties types are:" << nl - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalError); - } - - return autoPtr - ( - cstrIter() - ( - dict.optionalSubDict(liquidPropertiesTypeName + "Coeffs") - ) - ); - } + FatalErrorInFunction + << "Unknown liquidProperties type " + << liquidPropertiesTypeName << nl << nl + << "Valid liquidProperties types are:" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); } - else - { - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(liquidPropertiesTypeName); - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - FatalErrorInFunction - << "Unknown liquidProperties type " - << liquidPropertiesTypeName << nl << nl - << "Valid liquidProperties types are:" << nl - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalError); - } - - return autoPtr(cstrIter()(dict)); - } + return autoPtr(cstrIter()(dict)); }