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