Cantera  3.1.0b1
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"
15
16namespace 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 */
30class ThermoFactory : public Factory<ThermoPhase>
31{
32public:
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
39private:
40 //! static member of a single instance
42
43 //! Private constructors prevents usage
45
46 //! Decl for locking mutex for thermo factory singleton
47 static std::mutex thermo_mutex;
48};
49
50//! Create a new ThermoPhase instance.
51 /*!
52 * @param model String to look up the model against
53 * @returns a shared pointer to a new ThermoPhase object of the type specified. Throws a
54 * CanteraError if the named model is not registered with ThermoFactory.
55 * @since New in %Cantera 3.0. Replaces newThermo
56 */
57 shared_ptr<ThermoPhase> newThermoModel(const string& model);
58
59//! Create a new ThermoPhase object and initialize it
60/*!
61 * @param phaseNode The node containing the phase definition (that is, thermo
62 * model, list of species, and initial state)
63 * @param rootNode The root node of the tree containing the phase definition,
64 * which will be used as the default location from which to read species
65 * definitions.
66 * @since New in %Cantera 3.0.
67 */
68shared_ptr<ThermoPhase> newThermo(const AnyMap& phaseNode,
69 const AnyMap& rootNode=AnyMap());
70
71//! Create and Initialize a ThermoPhase object from an input file.
72/*!
73 * This function uses AnyMap::fromYamlFile() to read the input file, newThermo()
74 * to create an empty ThermoPhase of the appropriate type, and setupPhase() to
75 * initialize the phase.
76 *
77 * @param infile name of the input file
78 * @param id name (id) of the phase in the file.
79 * If this is blank, the first phase in the file is used.
80 * @returns an initialized ThermoPhase object.
81 * @since Changed in %Cantera 3.0. Prior to %Cantera 3.0, the function used a single
82 * argument specifying the thermo model, which is now deprecated.
83 */
84shared_ptr<ThermoPhase> newThermo(const string& infile, const string& id="");
85
86//! Initialize a ThermoPhase object
87/*!
88 * @param phase The ThermoPhase object to be initialized
89 * @param phaseNode The node containing the phase definition (that is, thermo
90 * model, list of species, and initial state)
91 * @param rootNode The root node of the tree containing the phase definition,
92 * which will be used as the default location from which to read species
93 * definitions.
94 */
95void setupPhase(ThermoPhase& phase, const AnyMap& phaseNode,
96 const AnyMap& rootNode=AnyMap());
97
98//! @}
99
100}
101
102#endif
File contains the FactoryBase class declarations.
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
Factory class that supports registering functions to create objects.
Definition FactoryBase.h:69
Factory class for thermodynamic property managers.
void deleteFactory() override
delete the static instance of this factory
ThermoFactory()
Private constructors prevents usage.
static ThermoFactory * factory()
Static function that creates a static instance of the factory.
static std::mutex thermo_mutex
Decl for locking mutex for thermo factory singleton.
static ThermoFactory * s_factory
static member of a single instance
Base class for a phase with thermodynamic properties.
shared_ptr< ThermoPhase > newThermo(const AnyMap &phaseNode, const AnyMap &rootNode)
Create a new ThermoPhase object and initialize it.
void setupPhase(ThermoPhase &thermo, const AnyMap &phaseNode, const AnyMap &rootNode)
Initialize a ThermoPhase object.
shared_ptr< ThermoPhase > newThermoModel(const string &model)
Create a new ThermoPhase instance.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595