| Cantera 3.0.0

Loading...
Searching...
No Matches
ThermoFactory.h
Go to the documentation of this file.
1/**
2 * @file ThermoFactory.h
3 * Headers for the factory class that can create known ThermoPhase objects
4 * (see @ref thermoprops and class @link Cantera::ThermoFactory ThermoFactory@endlink).
5 */
6
7// This file is part of Cantera. See License.txt in the top-level directory or
8// at https://cantera.org/license.txt for license and copyright information.
9
10#ifndef THERMO_FACTORY_H
11#define THERMO_FACTORY_H
12
13#include "ThermoPhase.h"
14#include "cantera/base/FactoryBase.h"
15
16 namespace Cantera
17{
18
19/**
20 * @addtogroup thermoprops
21 */
22//! @{
23
24
25//! Factory class for thermodynamic property managers.
26/*!
27 * This class keeps a list of the known ThermoPhase classes, and is
28 * used to create new instances of these classes.
29 */
30 class ThermoFactory : public Factory<ThermoPhase>
31{
32 public:
33 //! Static function that creates a static instance of the factory.
34 static ThermoFactory* factory();
35
36 //! delete the static instance of this factory
37 void deleteFactory() override;
38
39 //! Create a new thermodynamic property manager.
40 /*!
41 * @param model The name of the thermo model
42 * @returns a pointer to a new ThermoPhase object of the type specified. Throws a
43 * CanteraError if the named model isn't registered with ThermoFactory.
44 * @deprecated To be removed after %Cantera 3.0; superseded by newThermo()
45 */
46 ThermoPhase* newThermoPhase(const string& model);
47
48 private:
49 //! static member of a single instance
50 static ThermoFactory* s_factory;
51
52 //! Private constructors prevents usage
53 ThermoFactory();
54
55 //! Decl for locking mutex for thermo factory singleton
56 static std::mutex thermo_mutex;
57};
58
59//! @copydoc newThermoModel(const string&)
60//! @deprecated To be removed after %Cantera 3.0; superseded by newThermoModel()
61 ThermoPhase* newThermoPhase(const string& model);
62
63//! Create a new ThermoPhase instance.
64 /*!
65 * @param model String to look up the model against
66 * @returns a shared pointer to a new ThermoPhase object of the type specified. Throws a
67 * CanteraError if the named model is not registered with ThermoFactory.
68 * @since New in %Cantera 3.0. Replaces newThermo
69 */
70 shared_ptr<ThermoPhase> newThermoModel(const string& model);
71
72//! Create a new ThermoPhase object and initialize it
73/*!
74 * @param phaseNode The node containing the phase definition (that is, thermo
75 * model, list of species, and initial state)
76 * @param rootNode The root node of the tree containing the phase definition,
77 * which will be used as the default location from which to read species
78 * definitions.
79 * @since New in %Cantera 3.0.
80 */
81shared_ptr<ThermoPhase> newThermo(const AnyMap& phaseNode,
82 const AnyMap& rootNode=AnyMap());
83
84//! Create and Initialize a ThermoPhase object from an input file.
85/*!
86 * This function uses AnyMap::fromYamlFile() to read the input file, newThermo()
87 * to create an empty ThermoPhase of the appropriate type, and setupPhase() to
88 * initialize the phase.
89 *
90 * @param infile name of the input file
91 * @param id name (id) of the phase in the file.
92 * If this is blank, the first phase in the file is used.
93 * @returns an initialized ThermoPhase object.
94 * @since Changed in %Cantera 3.0. Prior to %Cantera 3.0, the function used a single
95 * argument specifying the thermo model, which is now deprecated.
96 */
97shared_ptr<ThermoPhase> newThermo(const string& infile, const string& id="");
98
99//! @copydoc newThermo(const AnyMap&, const AnyMap&)
100//! @deprecated To be removed after %Cantera 3.0; superseded by newThermo()
101 unique_ptr<ThermoPhase> newPhase(const AnyMap& phaseNode,
102 const AnyMap& rootNode=AnyMap());
103
104//! @copydoc newThermo(const string&, const string&)
105//! @deprecated To be removed after %Cantera 3.0; superseded by newThermo()
106 ThermoPhase* newPhase(const string& infile, string id="");
107
108//! Initialize a ThermoPhase object
109/*!
110 * @param phase The ThermoPhase object to be initialized
111 * @param phaseNode The node containing the phase definition (that is, thermo
112 * model, list of species, and initial state)
113 * @param rootNode The root node of the tree containing the phase definition,
114 * which will be used as the default location from which to read species
115 * definitions.
116 */
117 void setupPhase(ThermoPhase& phase, const AnyMap& phaseNode,
118 const AnyMap& rootNode=AnyMap());
119
120//! @}
121
122}
123
124#endif
FactoryBase.h
File contains the FactoryBase class declarations.
ThermoPhase.h
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::Factory
Factory class that supports registering functions to create objects.
Definition FactoryBase.h:69
Cantera::ThermoFactory
Factory class for thermodynamic property managers.
Definition ThermoFactory.h:31
Cantera::ThermoFactory::deleteFactory
void deleteFactory() override
delete the static instance of this factory
Definition ThermoFactory.cpp:120
Cantera::ThermoFactory::ThermoFactory
ThermoFactory()
Private constructors prevents usage.
Definition ThermoFactory.cpp:51
Cantera::ThermoFactory::factory
static ThermoFactory * factory()
Static function that creates a static instance of the factory.
Definition ThermoFactory.cpp:111
Cantera::ThermoFactory::thermo_mutex
static std::mutex thermo_mutex
Decl for locking mutex for thermo factory singleton.
Definition ThermoFactory.h:56
Cantera::ThermoFactory::newThermoPhase
ThermoPhase * newThermoPhase(const string &model)
Create a new thermodynamic property manager.
Definition ThermoFactory.cpp:127
Cantera::ThermoFactory::s_factory
static ThermoFactory * s_factory
static member of a single instance
Definition ThermoFactory.h:50
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition ThermoPhase.h:390
Cantera::newThermo
shared_ptr< ThermoPhase > newThermo(const AnyMap &phaseNode, const AnyMap &rootNode)
Create a new ThermoPhase object and initialize it.
Definition ThermoFactory.cpp:147
Cantera::setupPhase
void setupPhase(ThermoPhase &thermo, const AnyMap &phaseNode, const AnyMap &rootNode)
Initialize a ThermoPhase object.
Definition ThermoFactory.cpp:278
Cantera::newPhase
unique_ptr< ThermoPhase > newPhase(const AnyMap &phaseNode, const AnyMap &rootNode)
Create a new ThermoPhase object and initialize it.
Definition ThermoFactory.cpp:185
Cantera::newThermoModel
shared_ptr< ThermoPhase > newThermoModel(const string &model)
Create a new ThermoPhase instance.
Definition ThermoFactory.cpp:141
Cantera::newThermoPhase
ThermoPhase * newThermoPhase(const string &model)
Create a new ThermoPhase instance.
Definition ThermoFactory.cpp:134
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564