15#include "cantera/zeroD/IdealGasConstPressureReactor.h"
22ReactorFactory* ReactorFactory::s_factory = 0;
23std::mutex ReactorFactory::reactor_mutex;
25ReactorFactory::ReactorFactory()
28 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
29 {
return new Reservoir(sol, clone, name); });
31 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
32 {
return new Reactor(sol, clone, name); });
33 reg(
"ConstPressureReactor",
34 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
35 {
return new ConstPressureReactor(sol, clone, name); });
37 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
38 {
return new FlowReactor(sol, clone, name); });
39 reg(
"IdealGasReactor",
40 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
41 {
return new IdealGasReactor(sol, clone, name); });
42 reg(
"IdealGasConstPressureReactor",
43 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
44 {
return new IdealGasConstPressureReactor(sol, clone, name); });
45 reg(
"ExtensibleReactor",
46 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
47 {
return new ReactorDelegator<Reactor>(sol, clone, name); });
48 reg(
"ExtensibleIdealGasReactor",
49 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
50 {
return new ReactorDelegator<IdealGasReactor>(sol, clone, name); });
51 reg(
"ExtensibleConstPressureReactor",
52 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
53 {
return new ReactorDelegator<ConstPressureReactor>(sol, clone, name); });
54 reg(
"ExtensibleIdealGasConstPressureReactor",
55 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
56 {
return new ReactorDelegator<IdealGasConstPressureReactor>(sol, clone, name); });
57 reg(
"ExtensibleMoleReactor",
58 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
59 {
return new ReactorDelegator<MoleReactor>(sol, clone, name); });
60 reg(
"ExtensibleConstPressureMoleReactor",
61 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
62 {
return new ReactorDelegator<ConstPressureMoleReactor>(sol, clone, name); });
63 reg(
"ExtensibleIdealGasMoleReactor",
64 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
65 {
return new ReactorDelegator<IdealGasMoleReactor>(sol, clone, name); });
66 reg(
"ExtensibleIdealGasConstPressureMoleReactor",
67 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
68 {
return new ReactorDelegator<IdealGasConstPressureMoleReactor>(sol, clone, name); });
69 reg(
"IdealGasConstPressureMoleReactor",
70 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
71 {
return new IdealGasConstPressureMoleReactor(sol, clone, name); });
72 reg(
"IdealGasMoleReactor",
73 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
74 {
return new IdealGasMoleReactor(sol, clone, name); });
75 reg(
"ConstPressureMoleReactor",
76 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
77 {
return new ConstPressureMoleReactor(sol, clone, name); });
79 [](shared_ptr<Solution> sol,
bool clone,
const string& name)
80 {
return new MoleReactor(sol, clone, name); });
83ReactorFactory* ReactorFactory::factory() {
84 std::unique_lock<std::mutex> lock(reactor_mutex);
86 s_factory =
new ReactorFactory;
92 std::unique_lock<std::mutex> lock(reactor_mutex);
100std::mutex ReactorSurfaceFactory::s_mutex;
103 std::unique_lock<std::mutex> lock(s_mutex);
111 std::unique_lock<std::mutex> lock(s_mutex);
116ReactorSurfaceFactory::ReactorSurfaceFactory()
118 reg(
"ReactorSurface",
119 [](shared_ptr<Solution> surf,
const vector<shared_ptr<ReactorBase>>& reactors,
120 bool clone,
const string& name)
122 reg(
"MoleReactorSurface",
123 [](shared_ptr<Solution> surf,
const vector<shared_ptr<ReactorBase>>& reactors,
124 bool clone,
const string& name)
125 {
return new MoleReactorSurface(surf, reactors, clone, name); });
126 reg(
"FlowReactorSurface",
127 [](shared_ptr<Solution> surf,
const vector<shared_ptr<ReactorBase>>& reactors,
128 bool clone,
const string& name)
129 {
return new FlowReactorSurface(surf, reactors, clone, name); });
130 reg(
"ExtensibleReactorSurface",
131 [](shared_ptr<Solution> surf,
const vector<shared_ptr<ReactorBase>>& reactors,
132 bool clone,
const string& name)
133 {
return new ReactorDelegator<ReactorSurface>(surf, reactors, clone, name); });
134 reg(
"ExtensibleMoleReactorSurface",
135 [](shared_ptr<Solution> surf,
const vector<shared_ptr<ReactorBase>>& reactors,
136 bool clone,
const string& name)
137 {
return new ReactorDelegator<MoleReactorSurface>(surf, reactors, clone, name); });
138 reg(
"ExtensibleFlowReactorSurface",
139 [](shared_ptr<Solution> surf,
const vector<shared_ptr<ReactorBase>>& reactors,
140 bool clone,
const string& name)
141 {
return new ReactorDelegator<FlowReactorSurface>(surf, reactors, clone, name); });
147 const string& model, shared_ptr<Solution> phase,
bool clone,
const string& name)
149 return shared_ptr<ReactorBase>(
150 ReactorFactory::factory()->create(model, phase, clone, name));
154 const string& model, shared_ptr<Solution> phase,
bool clone,
const string& name)
156 auto reactor = std::dynamic_pointer_cast<Reactor>(
160 "Model type '{}' does not specify a bulk reactor.", model);
166 shared_ptr<Solution> phase,
bool clone,
const string& name)
168 auto reservoir = std::dynamic_pointer_cast<Reservoir>(
172 "Caught unexpected inconsistency in factory method.");
178 const vector<shared_ptr<ReactorBase>>& reactors,
bool clone,
const string& name)
180 if (reactors.empty()) {
182 "At least one adjacent reactor must be specified.");
184 string model =
"ReactorSurface";
185 if (std::dynamic_pointer_cast<FlowReactor>(reactors[0])) {
186 model =
"FlowReactorSurface";
188 for (
const auto& r : reactors) {
189 if (std::dynamic_pointer_cast<MoleReactor>(r)) {
190 model =
"MoleReactorSurface";
194 return shared_ptr<ReactorSurface>(ReactorSurfaceFactory::factory()->create(
195 model, phase, reactors, clone, name));
199 shared_ptr<Solution> phase,
const vector<shared_ptr<ReactorBase>>& reactors,
200 bool clone,
const string& name)
202 return shared_ptr<ReactorSurface>(ReactorSurfaceFactory::factory()->create(
203 model, phase, reactors, clone, name));
Base class for exceptions thrown by Cantera classes.
void reg(const string &name, function< ReactorBase *(Args...)> f)
Register a new object construction function.
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.
A surface where reactions can occur that is in contact with the bulk fluid of a Reactor.
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< 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.