Commit 5e59b510 authored by Henry's avatar Henry
Browse files

Thermodynamics: Updated tutorials to use the new dictionary based thermo...

Thermodynamics: Updated tutorials to use the new dictionary based thermo package selection mechanism
parent cb29fc7c
......@@ -156,12 +156,14 @@ Foam::basicThermo::basicThermo
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::basicThermo> Foam::basicThermo::New
(
const fvMesh& mesh
)
{
return NewThermo<basicThermo>(mesh);
return New<basicThermo>(mesh);
}
......
......@@ -29,7 +29,6 @@ Description
SourceFiles
basicThermo.C
basicThermoNew.C
\*---------------------------------------------------------------------------*/
......@@ -104,8 +103,14 @@ public:
basicThermo(const fvMesh&, const dictionary&);
//- Selector
static autoPtr<basicThermo> New(const fvMesh&);
// Selectors
//- Generic New for each of the related thermodynamics packages
template<class Thermo>
static autoPtr<Thermo> New(const fvMesh&);
//- Specialisation of the Generic New for basicThermo
static autoPtr<basicThermo> New(const fvMesh&);
//- Destructor
......@@ -344,129 +349,15 @@ public:
};
template<class Thermo>
autoPtr<Thermo> NewThermo
(
const fvMesh& mesh
)
{
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
word thermoTypeName;
if (thermoDict.isDict("thermoType"))
{
const dictionary& thermoTypeDict(thermoDict.subDict("thermoType"));
Info<< "Selecting thermodynamics package " << thermoTypeDict << endl;
const int nCmpt = 7;
const char* cmptNames[nCmpt] =
{
"type",
"mixture",
"transport",
"thermo",
"equationOfState",
"specie",
"energy"
};
// Construct the name of the thermo package from the components
thermoTypeName =
word(thermoTypeDict.lookup("type")) + '<'
+ word(thermoTypeDict.lookup("mixture")) + '<'
+ word(thermoTypeDict.lookup("transport")) + '<'
+ word(thermoTypeDict.lookup("thermo")) + '<'
+ word(thermoTypeDict.lookup("equationOfState")) + '<'
+ word(thermoTypeDict.lookup("specie")) + ">>,"
+ word(thermoTypeDict.lookup("energy")) + ">>>";
// Lookup the thermo package
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
// Print error message if package not found in the table
if (cstrIter == Thermo::fvMeshConstructorTablePtr_->end())
{
FatalErrorIn(Thermo::typeName + "::New(const fvMesh&)")
<< "Unknown " << Thermo::typeName << " type " << nl
<< "thermoType" << thermoTypeDict << nl << nl
<< "Valid " << Thermo::typeName << " types are:" << nl << nl;
// Get the list of all the suitable thermo packages available
wordList validThermoTypeNames
(
Thermo::fvMeshConstructorTablePtr_->sortedToc()
);
// Build a table of the thermo packages constituent parts
// Note: row-0 contains the names of constituent parts
List<wordList> validThermoTypeNameCmpts
(
validThermoTypeNames.size() + 1
);
validThermoTypeNameCmpts[0].setSize(nCmpt);
forAll(validThermoTypeNameCmpts[0], j)
{
validThermoTypeNameCmpts[0][j] = cmptNames[j];
}
// Split the thermo package names into their constituent parts
forAll(validThermoTypeNames, i)
{
validThermoTypeNameCmpts[i+1] =
Thermo::splitThermoName(validThermoTypeNames[i], nCmpt);
}
// Print the table of available packages
// in terms of their constituent parts
printTable(validThermoTypeNameCmpts, FatalError);
FatalError<< exit(FatalError);
}
return autoPtr<Thermo>(cstrIter()(mesh));
}
else
{
thermoTypeName = word(thermoDict.lookup("thermoType"));
Info<< "Selecting thermodynamics package " << thermoTypeName << endl;
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
if (cstrIter == Thermo::fvMeshConstructorTablePtr_->end())
{
FatalErrorIn(Thermo::typeName + "::New(const fvMesh&)")
<< "Unknown " << Thermo::typeName << " type "
<< thermoTypeName << nl << nl
<< "Valid " << Thermo::typeName << " types are:" << nl
<< Thermo::fvMeshConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
return autoPtr<Thermo>(cstrIter()(mesh));
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#ifdef NoRepository
# include "basicThermoTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "basicThermo.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Thermo>
Foam::autoPtr<Thermo> Foam::basicThermo::New
(
const fvMesh& mesh
)
{
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
word thermoTypeName;
if (thermoDict.isDict("thermoType"))
{
const dictionary& thermoTypeDict(thermoDict.subDict("thermoType"));
Info<< "Selecting thermodynamics package " << thermoTypeDict << endl;
const int nCmpt = 7;
const char* cmptNames[nCmpt] =
{
"type",
"mixture",
"transport",
"thermo",
"equationOfState",
"specie",
"energy"
};
// Construct the name of the thermo package from the components
thermoTypeName =
word(thermoTypeDict.lookup("type")) + '<'
+ word(thermoTypeDict.lookup("mixture")) + '<'
+ word(thermoTypeDict.lookup("transport")) + '<'
+ word(thermoTypeDict.lookup("thermo")) + '<'
+ word(thermoTypeDict.lookup("equationOfState")) + '<'
+ word(thermoTypeDict.lookup("specie")) + ">>,"
+ word(thermoTypeDict.lookup("energy")) + ">>>";
// Lookup the thermo package
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
// Print error message if package not found in the table
if (cstrIter == Thermo::fvMeshConstructorTablePtr_->end())
{
FatalErrorIn(Thermo::typeName + "::New(const fvMesh&)")
<< "Unknown " << Thermo::typeName << " type " << nl
<< "thermoType" << thermoTypeDict << nl << nl
<< "Valid " << Thermo::typeName << " types are:" << nl << nl;
// Get the list of all the suitable thermo packages available
wordList validThermoTypeNames
(
Thermo::fvMeshConstructorTablePtr_->sortedToc()
);
// Build a table of the thermo packages constituent parts
// Note: row-0 contains the names of constituent parts
List<wordList> validThermoTypeNameCmpts
(
validThermoTypeNames.size() + 1
);
validThermoTypeNameCmpts[0].setSize(nCmpt);
forAll(validThermoTypeNameCmpts[0], j)
{
validThermoTypeNameCmpts[0][j] = cmptNames[j];
}
// Split the thermo package names into their constituent parts
forAll(validThermoTypeNames, i)
{
validThermoTypeNameCmpts[i+1] =
Thermo::splitThermoName(validThermoTypeNames[i], nCmpt);
}
// Print the table of available packages
// in terms of their constituent parts
printTable(validThermoTypeNameCmpts, FatalError);
FatalError<< exit(FatalError);
}
return autoPtr<Thermo>(cstrIter()(mesh));
}
else
{
thermoTypeName = word(thermoDict.lookup("thermoType"));
Info<< "Selecting thermodynamics package " << thermoTypeName << endl;
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
if (cstrIter == Thermo::fvMeshConstructorTablePtr_->end())
{
FatalErrorIn(Thermo::typeName + "::New(const fvMesh&)")
<< "Unknown " << Thermo::typeName << " type "
<< thermoTypeName << nl << nl
<< "Valid " << Thermo::typeName << " types are:" << nl
<< Thermo::fvMeshConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
return autoPtr<Thermo>(cstrIter()(mesh));
}
}
// ************************************************************************* //
......@@ -49,12 +49,14 @@ Foam::fluidThermo::fluidThermo(const fvMesh& mesh, const dictionary& dict)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::fluidThermo> Foam::fluidThermo::New
(
const fvMesh& mesh
)
{
return NewThermo<fluidThermo>(mesh);
return basicThermo::New<fluidThermo>(mesh);
}
......
......@@ -29,7 +29,6 @@ Description
SourceFiles
fluidThermo.C
fluidThermoNew.C
\*---------------------------------------------------------------------------*/
......
......@@ -70,12 +70,14 @@ Foam::psiThermo::psiThermo(const fvMesh& mesh)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::psiThermo> Foam::psiThermo::New
(
const fvMesh& mesh
)
{
return NewThermo<psiThermo>(mesh);
return basicThermo::New<psiThermo>(mesh);
}
......
......@@ -29,7 +29,6 @@ Description
SourceFiles
psiThermo.C
psiThermoNew.C
\*---------------------------------------------------------------------------*/
......
......@@ -130,12 +130,14 @@ Foam::rhoThermo::rhoThermo(const fvMesh& mesh, const dictionary& dict)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::rhoThermo> Foam::rhoThermo::New
(
const fvMesh& mesh
)
{
return NewThermo<rhoThermo>(mesh);
return basicThermo::New<rhoThermo>(mesh);
}
......
......@@ -29,7 +29,6 @@ Description
SourceFiles
rhoThermo.C
rhoThermoNew.C
\*---------------------------------------------------------------------------*/
......
......@@ -76,7 +76,8 @@ Foam::autoPtr<Foam::solidThermo> Foam::solidThermo::New
Foam::autoPtr<Foam::solidThermo> Foam::solidThermo::New
(
const fvMesh& mesh, const dictionary& dict
const fvMesh& mesh,
const dictionary& dict
)
{
if (debug)
......@@ -106,4 +107,5 @@ Foam::autoPtr<Foam::solidThermo> Foam::solidThermo::New
return autoPtr<solidThermo>(cstrIter()(mesh, dict));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<sutherlandTransport<hConstThermo<perfectGas<specie>>,sensibleInternalEnergy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport sutherlandTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<sutherlandTransport<janafThermo<perfectGas<specie>>,sensibleInternalEnergy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport sutherlandTransport;
thermo janafThermo;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<constTransport<hConstThermo<perfectGas<specie>>,sensibleInternalEnergy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport constTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
// Note: these are the properties for a "normalised" inviscid gas
// for which the speed of sound is 1 m/s at a temperature of 1K
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<constTransport<hConstThermo<perfectGas<specie>>,sensibleInternalEnergy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport constTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<constTransport<hConstThermo<perfectGas<specie>>,sensibleInternalEnergy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport constTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<constTransport<hConstThermo<perfectGas<specie>>,sensibleInternalEnergy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport constTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleInternalEnergy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<constTransport<hConstThermo<perfectGas<specie>>,sensibleEnthalpy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport constTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<sutherlandTransport<hConstThermo<perfectGas<specie>>,sensibleEnthalpy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport sutherlandTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<constTransport<hConstThermo<perfectGas<specie>>,sensibleEnthalpy>>>;
thermoType
{
type hePsiThermo;
mixture pureMixture;
transport constTransport;
thermo hConstThermo;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}
mixture
{
......
......@@ -15,7 +15,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hePsiThermo<pureMixture<sutherlandTransport<hConstThermo<perfectGas<specie>>,sensibleEnthalpy>>>;
thermoType
{
type hePsiThermo;