15#include "cantera/zeroD/IdealGasConstPressureReactor.h"
22ReactorFactory* ReactorFactory::s_factory = 0;
23std::mutex ReactorFactory::reactor_mutex;
25ReactorFactory::ReactorFactory()
28 [](shared_ptr<Solution> sol,
const string& name)
29 {
return new Reservoir(sol, name); });
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); });
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); });
79 [](shared_ptr<Solution> sol,
const string& name)
80 {
return new MoleReactor(sol, name); });
82 [](shared_ptr<Solution> sol,
const string& name)
83 {
return new ReactorSurface(sol, name); });
86ReactorFactory* ReactorFactory::factory() {
87 std::unique_lock<std::mutex> lock(reactor_mutex);
89 s_factory =
new ReactorFactory;
95 std::unique_lock<std::mutex> lock(reactor_mutex);
101 const string& model, shared_ptr<Solution> contents,
const string& name)
103 return shared_ptr<ReactorBase>(
104 ReactorFactory::factory()->create(model, contents, name));
108 const string& model, shared_ptr<Solution> contents,
const string& name)
110 warn_deprecated(
"newReactor",
"Behavior changes after Cantera 3.2, when a "
111 "'shared_ptr<Reactor>' is returned.\nFor new behavior, use 'newReactor4'.");
116 const string& model, shared_ptr<Solution> contents,
const string& name)
118 auto reactor = std::dynamic_pointer_cast<Reactor>(
122 "Model type '{}' does not specify a bulk reactor.", model);
127shared_ptr<Reservoir>
newReservoir(shared_ptr<Solution> contents,
const string& name)
129 auto reservoir = std::dynamic_pointer_cast<Reservoir>(
133 "Caught unexpected inconsistency in factory method.");
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.
shared_ptr< ReactorBase > newReactor(const string &model, shared_ptr< Solution > contents, const string &name)
Create a Reactor object of the specified type and contents.
shared_ptr< ReactorBase > newReactorBase(const string &model, shared_ptr< Solution > contents, const string &name)
Create a ReactorBase object of the specified type and contents.
shared_ptr< Reactor > newReactor4(const string &model, shared_ptr< Solution > contents, const string &name)
Create a Reactor object of the specified type and contents.
shared_ptr< Reservoir > newReservoir(shared_ptr< Solution > contents, const string &name)
Create a Reservoir object with the specified contents.
Namespace for the Cantera kernel.
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.