Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Thermo] Add PDSS objects to VPStandardStateTP without XML
Added PDSSFactory class to generalize PDSS object creation
- Loading branch information
Showing
5 changed files
with
130 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! @file PDSSFactory.h | ||
|
||
// This file is part of Cantera. See License.txt in the top-level directory or | ||
// at http://www.cantera.org/license.txt for license and copyright information. | ||
|
||
#ifndef PDSS_FACTORY_H | ||
#define PDSS_FACTORY_H | ||
|
||
#include "PDSS.h" | ||
#include "cantera/base/FactoryBase.h" | ||
#include "cantera/thermo/VPStandardStateTP.h" | ||
|
||
namespace Cantera | ||
{ | ||
|
||
class PDSSFactory : public Factory<PDSS> | ||
{ | ||
public: | ||
//! Static function that creates a static instance of the factory. | ||
static PDSSFactory* factory() { | ||
std::unique_lock<std::mutex> lock(thermo_mutex); | ||
if (!s_factory) { | ||
s_factory = new PDSSFactory; | ||
} | ||
return s_factory; | ||
} | ||
|
||
//! delete the static instance of this factory | ||
virtual void deleteFactory() { | ||
std::unique_lock<std::mutex> lock(thermo_mutex); | ||
delete s_factory; | ||
s_factory = 0; | ||
} | ||
|
||
//! Create a new thermodynamic property manager. | ||
/*! | ||
* @param model String to look up the model against | ||
* @returns a pointer to a new PDSS instance matching the model string. | ||
* Returns NULL if something went wrong. Throws an exception if the string | ||
* wasn't matched. | ||
*/ | ||
virtual PDSS* newPDSS(const std::string& model); | ||
|
||
private: | ||
//! static member of a single instance | ||
static PDSSFactory* s_factory; | ||
|
||
//! Private constructors prevents usage | ||
PDSSFactory(); | ||
|
||
//! Decl for locking mutex for thermo factory singleton | ||
static std::mutex thermo_mutex; | ||
}; | ||
|
||
PDSS* newPDSS(const std::string& model); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! @file PDSSFactory.cpp | ||
|
||
// This file is part of Cantera. See License.txt in the top-level directory or | ||
// at http://www.cantera.org/license.txt for license and copyright information. | ||
|
||
#include "cantera/thermo/PDSSFactory.h" | ||
#include "cantera/thermo/PDSS_IdealGas.h" | ||
#include "cantera/thermo/PDSS_Water.h" | ||
#include "cantera/thermo/PDSS_ConstVol.h" | ||
#include "cantera/thermo/PDSS_SSVol.h" | ||
#include "cantera/thermo/PDSS_HKFT.h" | ||
#include "cantera/thermo/PDSS_IonsFromNeutral.h" | ||
|
||
namespace Cantera | ||
{ | ||
|
||
PDSSFactory* PDSSFactory::s_factory = 0; | ||
std::mutex PDSSFactory::thermo_mutex; | ||
|
||
PDSSFactory::PDSSFactory() | ||
{ | ||
reg("ideal-gas", []() { return new PDSS_IdealGas(); }); | ||
reg("constant-incompressible", []() { return new PDSS_ConstVol(); }); | ||
m_synonyms["constant_incompressible"] = "constant-incompressible"; | ||
reg("water", []() { return new PDSS_Water(); }); | ||
m_synonyms["waterPDSS"] = m_synonyms["waterIAPWS"] = "water"; | ||
reg("ions-from-neutral", []() { return new PDSS_IonsFromNeutral(); }); | ||
m_synonyms["IonFromNeutral"] = "ions-from-neutral"; | ||
reg("constant", []() { return new PDSS_SSVol(); }); | ||
m_synonyms["temperature_polynomial"] = "constant"; | ||
m_synonyms["temperature-polynomial"] = "constant"; | ||
m_synonyms["density_temperature_polynomial"] = "constant"; | ||
m_synonyms["density-temperature-polynomial"] = "constant"; | ||
reg("HKFT", []() { return new PDSS_HKFT(); }); | ||
} | ||
|
||
PDSS* PDSSFactory::newPDSS(const std::string& model) | ||
{ | ||
return create(model); | ||
} | ||
|
||
PDSS* newPDSS(const std::string& model) | ||
{ | ||
return PDSSFactory::factory()->newPDSS(model); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters