diff --git a/src/thermophysicalModels/SLGThermo/Make/files b/src/thermophysicalModels/SLGThermo/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..0549b92c6805b82f04933518f8d3bd27b243b0c3 --- /dev/null +++ b/src/thermophysicalModels/SLGThermo/Make/files @@ -0,0 +1,3 @@ +SLGThermo/SLGThermo.C + +LIB = $(FOAM_LIBBIN)/libSLGThermo diff --git a/src/thermophysicalModels/SLGThermo/Make/options b/src/thermophysicalModels/SLGThermo/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..4a54dad0d4b80cf542c5e6abe870e9b4d3134b66 --- /dev/null +++ b/src/thermophysicalModels/SLGThermo/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/liquids/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/liquidMixture/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solids/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidMixture/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude + +LIB_LIBS = \ + -lfiniteVolume diff --git a/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C new file mode 100644 index 0000000000000000000000000000000000000000..468b870d869876a3e3a314067a2d7c7a3ee31777 --- /dev/null +++ b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.C @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SLGThermo.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(SLGThermo, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::SLGThermo::SLGThermo(const fvMesh& mesh, basicThermo& thermo) +: + MeshObject<fvMesh, SLGThermo>(mesh), + thermo_(thermo), + carrier_(NULL), + liquids_(NULL), + solids_(NULL) +{ + Info<< "Creating component thermo properties:" << endl; + + if (isA<basicMultiComponentMixtureNew>(thermo)) + { + basicMultiComponentMixtureNew& mcThermo = + dynamic_cast<basicMultiComponentMixtureNew&>(thermo); + carrier_ = &mcThermo; + + Info<< " multi-component carrier - " << mcThermo.species().size() + << " species" << endl; + } + else + { + Info<< " single component carrier" << endl; + } + + if (thermo.found("liquids")) + { + liquids_ = liquidMixture::New(thermo.subDict("liquids")); + Info<< " liquids - " << liquids_->components().size() + << " components" << endl; + } + else + { + Info<< " no liquid components" << endl; + } + + if (thermo.found("solids")) + { + solids_ = solidMixture::New(thermo.subDict("solids")); + Info<< " solids - " << solids_->components().size() + << " components" << endl; + } + else + { + Info<< " no solid components" << endl; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::SLGThermo::~SLGThermo() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::basicThermo& Foam::SLGThermo::thermo() const +{ + return thermo_; +} + + +const Foam::basicMultiComponentMixtureNew& Foam::SLGThermo::carrier() const +{ + if (carrier_ == NULL) + { + FatalErrorIn + ( + "const Foam::basicMultiComponentMixtureNew& " + "Foam::SLGThermo::carrier() const" + ) << "carrier requested, but object is not allocated" + << abort(FatalError); + } + + return *carrier_; +} + + +const Foam::liquidMixture& Foam::SLGThermo::liquids() const +{ + if (!liquids_.valid()) + { + FatalErrorIn + ( + "const Foam::liquidMixture& Foam::SLGThermo::liquids() const" + ) << "liquids requested, but object is not allocated" + << abort(FatalError); + } + + return liquids_(); +} + + +const Foam::solidMixture& Foam::SLGThermo::solids() const +{ + if (!solids_.valid()) + { + FatalErrorIn + ( + "const Foam::solidMixture& Foam::SLGThermo::solids() const" + ) << "solids requested, but object is not allocated" + << abort(FatalError); + } + + return solids_(); +} + + +Foam::label Foam::SLGThermo::carrierId +( + const word& cmptName, + bool allowNotfound +) const +{ + forAll(carrier().species(), i) + { + if (cmptName == carrier_->species()[i]) + { + return i; + } + } + + if (!allowNotfound) + { + FatalErrorIn + ( + "Foam::label Foam::SLGThermo::carrierId(const word&, bool) const" + ) << "Unknown carrier component " << cmptName + << ". Valid carrier components are:" << nl + << carrier_->species() << exit(FatalError); + } + + return -1; +} + + +Foam::label Foam::SLGThermo::liquidId +( + const word& cmptName, + bool allowNotfound +) const +{ + forAll(liquids().components(), i) + { + if (cmptName == liquids_->components()[i]) + { + return i; + } + } + + if (!allowNotfound) + { + FatalErrorIn + ( + "Foam::label Foam::SLGThermo::liquidId(const word&, bool) const" + ) << "Unknown liquid component " << cmptName << ". Valid liquids are:" + << nl << liquids_->components() << exit(FatalError); + } + + return -1; +} + + +Foam::label Foam::SLGThermo::solidId +( + const word& cmptName, + bool allowNotfound +) const +{ + forAll(solids().components(), i) + { + if (cmptName == solids_->components()[i]) + { + return i; + } + } + + if (!allowNotfound) + { + FatalErrorIn + ( + "Foam::label Foam::SLGThermo::solidId(const word&, bool) const" + ) << "Unknown solid component " << cmptName << ". Valid solids are:" + << nl << solids_->components() << exit(FatalError); + } + + return -1; +} + + +bool Foam::SLGThermo::hasMultiComponentCarrier() const +{ + return (carrier_ != NULL); +} + + +bool Foam::SLGThermo::hasLiquids() const +{ + return liquids_.valid(); +} + + +bool Foam::SLGThermo::hasSolids() const +{ + return solids_.valid(); +} + + +// ************************************************************************* // + diff --git a/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..91989a012380f30cd64ec5ce4ded8a740dc6625e --- /dev/null +++ b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::SLGThermo + +Description + Thermo package for (S)olids (L)iquids and (G)ases + Takes reference to thermo package, and provides: + - carrier : components of thermo - access to elemental properties + - liquids : liquid components - access to elemental properties + - solids : solid components - access to elemental properties + + If thermo is not a multi-component thermo package, carrier is NULL. + Similarly, if no liquids or solids are specified, their respective + pointers will also be NULL. + + Registered to the mesh so that it can be looked-up + +SourceFiles + SLGThermo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SLGThermo_H +#define SLGThermo_H + +#include "MeshObject.H" +#include "basicThermo.H" +#include "basicMultiComponentMixtureNew.H" +#include "liquidMixture.H" +#include "solidMixture.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class SLGThermo Declaration +\*---------------------------------------------------------------------------*/ + +class SLGThermo +: + public MeshObject<fvMesh, SLGThermo> +{ + // Private data + + //- Thermo package + basicThermo& thermo_; + + //- Reference to the multi-component carrier phase thermo + basicMultiComponentMixtureNew* carrier_; + + //- Additional liquid properties data + autoPtr<liquidMixture> liquids_; + + //- Additional solid properties data + autoPtr<solidMixture> solids_; + + +public: + + //- Runtime type information + TypeName("SLGThermo"); + + // Constructors + + //- Construct from mesh + SLGThermo(const fvMesh& mesh, basicThermo& thermo); + + + //- Destructor + virtual ~SLGThermo(); + + + // Member Functions + + // Access + + //- Return reference to the thermo database + const basicThermo& thermo() const; + + //- Return reference to the gaseous components + const basicMultiComponentMixtureNew& carrier() const; + + //- Return reference to the global (additional) liquids + const liquidMixture& liquids() const; + + //- Return reference to the global (additional) solids + const solidMixture& solids() const; + + + // Index retrieval + + //- Index of carrier component + label carrierId + ( + const word& cmptName, + bool allowNotFound = false + ) const; + + //- Index of liquid component + label liquidId + ( + const word& cmptName, + bool allowNotFound = false + ) const; + + //- Index of solid component + label solidId + ( + const word& cmptName, + bool allowNotFound = false + ) const; + + + // Checks + + //- Thermo database has multi-component carrier flag + bool hasMultiComponentCarrier() const; + + //- Thermo database has liquid components flag + bool hasLiquids() const; + + //- Thermo database has solid components flag + bool hasSolids() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //