Cantera  3.1.0b1
Loading...
Searching...
No Matches
ReactorFactory.cpp
Go to the documentation of this file.
1//! @file ReactorFactory.cpp
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
15#include "cantera/zeroD/IdealGasConstPressureReactor.h"
18
19namespace Cantera
20{
21
22ReactorFactory* ReactorFactory::s_factory = 0;
23std::mutex ReactorFactory::reactor_mutex;
24
25ReactorFactory::ReactorFactory()
26{
27 reg("Reservoir",
28 [](shared_ptr<Solution> sol, const string& name)
29 { return new Reservoir(sol, name); });
30 reg("Reactor",
31 [](shared_ptr<Solution> sol, const string& name)
32 { return new Reactor(sol, name); });
33 reg("ConstPressureReactor",
34 [](shared_ptr<Solution> sol, const string& name)
35 { return new ConstPressureReactor(sol, name); });
36 reg("FlowReactor",
37 [](shared_ptr<Solution> sol, const string& name)
38 { return new FlowReactor(sol, name); });
39 reg("IdealGasReactor",
40 [](shared_ptr<Solution> sol, const string& name)
41 { return new IdealGasReactor(sol, name); });
42 reg("IdealGasConstPressureReactor",
43 [](shared_ptr<Solution> sol, const string& name)
44 { return new IdealGasConstPressureReactor(sol, name); });
45 reg("ExtensibleReactor",
46 [](shared_ptr<Solution> sol, const string& name)
47 { return new ReactorDelegator<Reactor>(sol, name); });
48 reg("ExtensibleIdealGasReactor",
49 [](shared_ptr<Solution> sol, const string& name)
50 { return new ReactorDelegator<IdealGasReactor>(sol, name); });
51 reg("ExtensibleConstPressureReactor",
52 [](shared_ptr<Solution> sol, const string& name)
53 { return new ReactorDelegator<ConstPressureReactor>(sol, name); });
54 reg("ExtensibleIdealGasConstPressureReactor",
55 [](shared_ptr<Solution> sol, const string& name)
56 { return new ReactorDelegator<IdealGasConstPressureReactor>(sol, name); });
57 reg("ExtensibleMoleReactor",
58 [](shared_ptr<Solution> sol, const string& name)
59 { return new ReactorDelegator<MoleReactor>(sol, name); });
60 reg("ExtensibleConstPressureMoleReactor",
61 [](shared_ptr<Solution> sol, const string& name)
62 { return new ReactorDelegator<ConstPressureMoleReactor>(sol, name); });
63 reg("ExtensibleIdealGasMoleReactor",
64 [](shared_ptr<Solution> sol, const string& name)
65 { return new ReactorDelegator<IdealGasMoleReactor>(sol, name); });
66 reg("ExtensibleIdealGasConstPressureMoleReactor",
67 [](shared_ptr<Solution> sol, const string& name)
68 { return new ReactorDelegator<IdealGasConstPressureMoleReactor>(sol, name); });
69 reg("IdealGasConstPressureMoleReactor",
70 [](shared_ptr<Solution> sol, const string& name)
71 { return new IdealGasConstPressureMoleReactor(sol, name); });
72 reg("IdealGasMoleReactor",
73 [](shared_ptr<Solution> sol, const string& name)
74 { return new IdealGasMoleReactor(sol, name); });
75 reg("ConstPressureMoleReactor",
76 [](shared_ptr<Solution> sol, const string& name)
77 { return new ConstPressureMoleReactor(sol, name); });
78 reg("MoleReactor",
79 [](shared_ptr<Solution> sol, const string& name)
80 { return new MoleReactor(sol, name); });
81}
82
83ReactorFactory* ReactorFactory::factory() {
84 std::unique_lock<std::mutex> lock(reactor_mutex);
85 if (!s_factory) {
86 s_factory = new ReactorFactory;
87 }
88 return s_factory;
89}
90
92 std::unique_lock<std::mutex> lock(reactor_mutex);
93 delete s_factory;
94 s_factory = 0;
95}
96
97shared_ptr<ReactorBase> newReactor(const string& model)
98{
99 return shared_ptr<ReactorBase>(
100 ReactorFactory::factory()->create(model, nullptr, ""));
101}
102
103shared_ptr<ReactorBase> newReactor(
104 const string& model, shared_ptr<Solution> contents, const string& name)
105{
106 return shared_ptr<ReactorBase>(
107 ReactorFactory::factory()->create(model, contents, name));
108}
109
110shared_ptr<ReactorBase> newReactor3(const string& model)
111{
112 warn_deprecated("newReactor3", "To be removed after Cantera 3.1.");
113 return newReactor(model);
114}
115
116}
void reg(const string &name, function< ReactorBase *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
void deleteFactory() override
Virtual abstract function that deletes the factory.
shared_ptr< ReactorBase > newReactor3(const string &model)
Create a Reactor object of the specified type.
shared_ptr< ReactorBase > newReactor(const string &model)
Create a Reactor object of the specified type.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1997