Cantera  4.0.0a1
Loading...
Searching...
No Matches
ReactorFactory.h
Go to the documentation of this file.
1//! @file ReactorFactory.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef REACTOR_FACTORY_H
7#define REACTOR_FACTORY_H
8
11
12namespace Cantera
13{
14
15class Reactor;
16class Reservoir;
17
18//! Factory class to create reactor objects
19//!
20//! This class is mainly used via the newReactor() function, for example:
21//!
22//! ```cpp
23//! shared_ptr<ReactorBase> r1 = newReactor("IdealGasReactor");
24//! ```
25class ReactorFactory : public Factory<ReactorBase, shared_ptr<Solution>, bool, const string&>
26{
27public:
28 static ReactorFactory* factory();
29
30 void deleteFactory() override;
31
32private:
33 static ReactorFactory* s_factory;
34 static std::mutex reactor_mutex;
36};
37
38//! Factory class to create ReactorSurface objects
39//!
40//! This class is mainly used via the newReactorSurface() function, for example:
41//!
42//! ```cpp
43//! shared_ptr<ReactorSurface> rsurf1 = newReactorSurface(
44//! surf_phase, {reactor1, reactor2});
45//! @tem
46//! ```
47class ReactorSurfaceFactory : public Factory<ReactorSurface,
48 shared_ptr<Solution> /* surface */,
49 const vector<shared_ptr<ReactorBase>>& /* adjacent reactors */,
50 bool /* clone */, const string& /* name */>
51{
52public:
53 static ReactorSurfaceFactory* factory();
54 void deleteFactory() override;
55
56private:
57 static ReactorSurfaceFactory* s_factory;
58 static std::mutex s_mutex;
60};
61
62//! @defgroup reactorGroup Reactors
63//! Zero-dimensional objects representing stirred reactors.
64//! Reactors simulate time-dependent behavior considering gas-phase chemistry.
65//! Reactor objects should be instantiated via the newReactor() function, for example:
66//!
67//! ```cpp
68//! shared_ptr<ReactorBase> r1 = newReactor("IdealGasReactor");
69//! ```
70//! @ingroup zerodGroup
71//! @{
72
73//! Create a ReactorBase object of the specified type and contents.
74//! @since New in %Cantera 3.2.
75shared_ptr<ReactorBase> newReactorBase(
76 const string& model, shared_ptr<Solution> phase, bool clone=true,
77 const string& name="(none)");
78
79//! Create a Reactor object of the specified type and contents
80//! @param model Reactor type to be created. See [this list of reactor
81//! types](../reference/reactors/index.html) for available options.
82//! @param phase Solution object to model the thermodynamic properties and
83//! reactions occurring in the reactor
84//! @param clone Determines whether to clone `sol` so that the internal state of this
85//! reactor is independent of the original Solution object and any Solution objects
86//! used by other reactors in the network.
87//! @param name Name of the reactor.
88//! @since Starting in %Cantera 4.0, returns a `shared_ptr<Reactor>` instead of a
89//! `shared_ptr<ReactorBase>`.
90shared_ptr<Reactor> newReactor(
91 const string& model, shared_ptr<Solution> phase, bool clone=true,
92 const string& name="(none)");
93
94//! @copydoc newReactor
95//! @deprecated Transitional method; to be removed after %Cantera 4.0.
96inline shared_ptr<Reactor> newReactor4(const string& model, shared_ptr<Solution> phase,
97 bool clone=true, const string& name="(none)")
98{
99 return newReactor(model, phase, clone, name);
100}
101
102//! Create a Reservoir object with the specified contents
103//! @param phase Solution object to model the contents of this reservoir
104//! @param clone Determines whether to clone `sol` so that the internal state of this
105//! reservoir is independent of the original Solution object and any Solution
106//! objects used by other reactors in the network.
107//! @param name Name of the reservoir.
108//! @since New in %Cantera 3.2.
109shared_ptr<Reservoir> newReservoir(
110 shared_ptr<Solution> phase, bool clone=true, const string& name="(none)");
111
112//! Create a ReactorSurface object with the specified contents and adjacent reactors
113//! participating in surface reactions.
114//!
115//! The type of the reactor surface is automatically determined based on the types of
116//! the adjacent reactors.
117//!
118//! @param phase Solution (Interface) object to model the thermodynamic properties
119//! and reactions occurring in the reactor
120//! @param reactors List of Reactors adjacent to this surface, whose contents
121//! participate in reactions occurring on this surface.
122//! @param clone Determines whether to clone `sol` so that the internal state of this
123//! surface is independent of the original Interface object and any Solution objects
124//! used by other reactors in the network except those in the `reactors` list.
125//! @param name Name of the reactor surface.
126//! @since New in %Cantera 3.2.
127shared_ptr<ReactorSurface> newReactorSurface(
128 shared_ptr<Solution> phase, const vector<shared_ptr<ReactorBase>>& reactors,
129 bool clone=true, const string& name="(none)");
130
131//! Create a ReactorSurface object with the specified contents and adjacent reactors
132//! participating in surface reactions.
133//! @param model Type of ReactorSurface to be created.
134//! @param phase Solution (Interface) object to model the thermodynamic properties
135//! and reactions occurring in the reactor
136//! @param reactors List of Reactors adjacent to this surface, whose contents
137//! participate in reactions occurring on this surface.
138//! @param clone Determines whether to clone `sol` so that the internal state of this
139//! surface is independent of the original Interface object and any Solution objects
140//! used by other reactors in the network except those in the `reactors` list.
141//! @param name Name of the reactor surface.
142//! @since New in %Cantera 4.0.
143shared_ptr<ReactorSurface> newReactorSurface(
144 const string& model, shared_ptr<Solution> phase,
145 const vector<shared_ptr<ReactorBase>>& reactors,
146 bool clone=true, const string& name="(none)");
147
148//! @}
149
150}
151
152#endif
File contains the FactoryBase class declarations.
Factory class that supports registering functions to create objects.
Definition FactoryBase.h:69
Factory class to create reactor objects.
void deleteFactory() override
Virtual abstract function that deletes the factory.
Factory class to create ReactorSurface objects.
void deleteFactory() override
Virtual abstract function that deletes the factory.
shared_ptr< Reactor > newReactor(const string &model, shared_ptr< Solution > phase, bool clone, const string &name)
Create a Reactor object of the specified type and contents.
shared_ptr< ReactorBase > newReactorBase(const string &model, shared_ptr< Solution > phase, bool clone, const string &name)
Create a ReactorBase object of the specified type and contents.
shared_ptr< Reactor > newReactor4(const string &model, shared_ptr< Solution > phase, bool clone=true, const string &name="(none)")
Create a Reactor object of the specified type and contents.
shared_ptr< Reservoir > newReservoir(shared_ptr< Solution > phase, bool clone, const string &name)
Create a Reservoir object with the specified contents.
shared_ptr< ReactorSurface > newReactorSurface(shared_ptr< Solution > phase, const vector< shared_ptr< ReactorBase > > &reactors, bool clone, const string &name)
Create a ReactorSurface object with the specified contents and adjacent reactors participating in sur...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595