Cantera  2.4.0
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 http://www.cantera.org/license.txt for license and copyright information.
5 
12 #include "cantera/zeroD/IdealGasConstPressureReactor.h"
13 
14 using namespace std;
15 namespace Cantera
16 {
17 
18 ReactorFactory* ReactorFactory::s_factory = 0;
19 std::mutex ReactorFactory::reactor_mutex;
20 
21 ReactorFactory::ReactorFactory()
22 {
23  reg("Reservoir", []() { return new Reservoir(); });
24  reg("Reactor", []() { return new Reactor(); });
25  reg("ConstPressureReactor", []() { return new ConstPressureReactor(); });
26  reg("FlowReactor", []() { return new FlowReactor(); });
27  reg("IdealGasReactor", []() { return new IdealGasReactor(); });
28  reg("IdealGasConstPressureReactor", []() { return new IdealGasConstPressureReactor(); });
29 }
30 
31 ReactorBase* ReactorFactory::newReactor(const std::string& reactorType)
32 {
33  return create(reactorType);
34 }
35 
36 
37 ReactorBase* ReactorFactory::newReactor(int ir)
38 {
39  static const unordered_map<int, string> types {
40  {ReservoirType, "Reservoir"},
41  {ReactorType, "Reactor"},
42  {ConstPressureReactorType, "ConstPressureReactor"},
43  {FlowReactorType, "FlowReactor"},
44  {IdealGasReactorType, "IdealGasReactor"},
45  {IdealGasConstPressureReactorType, "IdealGasConstPressureReactor"}
46  };
47 
48  try {
49  return create(types.at(ir));
50  } catch (out_of_range&) {
51  throw CanteraError("ReactorFactory::newReactor",
52  "unknown reactor type!");
53  }
54 }
55 
56 }
STL namespace.
ReactorBase * newReactor(const std::string &model)
Create a Reactor object of the specified type.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8