Skip to content
Snippets Groups Projects
Commit 470ef283 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Added SLGThermo class - container for solid, liquid and gas thermos

parent c40f289c
Branches
Tags
No related merge requests found
SLGThermo/SLGThermo.C
LIB = $(FOAM_LIBBIN)/libSLGThermo
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
/*---------------------------------------------------------------------------*\
========= |
\\ / 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();
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment