| Cantera 3.0.0

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
6#include "cantera/zeroD/ReactorFactory.h"
7#include "cantera/zeroD/Reservoir.h"
8#include "cantera/zeroD/Reactor.h"
9#include "cantera/zeroD/MoleReactor.h"
10#include "cantera/zeroD/FlowReactor.h"
11#include "cantera/zeroD/ConstPressureReactor.h"
12#include "cantera/zeroD/ConstPressureMoleReactor.h"
13#include "cantera/zeroD/IdealGasReactor.h"
14#include "cantera/zeroD/IdealGasMoleReactor.h"
15#include "cantera/zeroD/IdealGasConstPressureReactor.h"
16#include "cantera/zeroD/ReactorDelegator.h"
17#include "cantera/zeroD/IdealGasConstPressureMoleReactor.h"
18
19 namespace Cantera
20{
21
22ReactorFactory* ReactorFactory::s_factory = 0;
23std::mutex ReactorFactory::reactor_mutex;
24
25ReactorFactory::ReactorFactory()
26{
27 reg("Reservoir", []() { return new Reservoir(); });
28 reg("Reactor", []() { return new Reactor(); });
29 reg("ConstPressureReactor", []() { return new ConstPressureReactor(); });
30 reg("FlowReactor", []() { return new FlowReactor(); });
31 reg("IdealGasReactor", []() { return new IdealGasReactor(); });
32 reg("IdealGasConstPressureReactor", []() { return new IdealGasConstPressureReactor(); });
33 reg("ExtensibleReactor", []() { return new ReactorDelegator<Reactor>(); });
34 reg("ExtensibleIdealGasReactor",
35 []() { return new ReactorDelegator<IdealGasReactor>(); });
36 reg("ExtensibleConstPressureReactor",
37 []() { return new ReactorDelegator<ConstPressureReactor>(); });
38 reg("ExtensibleIdealGasConstPressureReactor",
39 []() { return new ReactorDelegator<IdealGasConstPressureReactor>(); });
40 reg("ExtensibleMoleReactor",
41 []() { return new ReactorDelegator<MoleReactor>(); });
42 reg("ExtensibleConstPressureMoleReactor",
43 []() { return new ReactorDelegator<ConstPressureMoleReactor>(); });
44 reg("ExtensibleIdealGasMoleReactor",
45 []() { return new ReactorDelegator<IdealGasMoleReactor>(); });
46 reg("ExtensibleIdealGasConstPressureMoleReactor",
47 []() { return new ReactorDelegator<IdealGasConstPressureMoleReactor>(); });
48 reg("IdealGasConstPressureMoleReactor", []() { return new
49 IdealGasConstPressureMoleReactor(); });
50 reg("IdealGasMoleReactor", []() { return new IdealGasMoleReactor(); });
51 reg("ConstPressureMoleReactor", []() { return new ConstPressureMoleReactor(); });
52 reg("MoleReactor", []() { return new MoleReactor(); });
53}
54
55ReactorFactory* ReactorFactory::factory() {
56 std::unique_lock<std::mutex> lock(reactor_mutex);
57 if (!s_factory) {
58 s_factory = new ReactorFactory;
59 }
60 return s_factory;
61}
62
63 void ReactorFactory::deleteFactory() {
64 std::unique_lock<std::mutex> lock(reactor_mutex);
65 delete s_factory;
66 s_factory = 0;
67}
68
69 ReactorBase* ReactorFactory::newReactor(const string& reactorType)
70{
71 warn_deprecated("ReactorFactory::newReactor",
72 "To be removed after Cantera 3.0; for new behavior, see 'newReactor3'.");
73 return create(reactorType);
74}
75
76 ReactorBase* newReactor(const string& model)
77{
78 warn_deprecated("newReactor",
79 "To be changed after Cantera 3.0; for new behavior, see 'newReactor3'.");
80 return ReactorFactory::factory()->newReactor(model);
81}
82
83shared_ptr<ReactorBase> newReactor3(const string& model)
84{
85 shared_ptr<ReactorBase> rptr(ReactorFactory::factory()->create(model));
86 return rptr;
87}
88
89}
ConstPressureMoleReactor.h
ConstPressureReactor.h
FlowReactor.h
IdealGasConstPressureMoleReactor.h
IdealGasMoleReactor.h
IdealGasReactor.h
MoleReactor.h
ReactorDelegator.h
ReactorFactory.h
Reactor.h
Reservoir.h
Cantera::Factory< ReactorBase >::create
ReactorBase * create(const string &name, Args... args)
Create an object using the object construction function corresponding to "name" and the provided cons...
Definition FactoryBase.h:75
Cantera::Factory< ReactorBase >::reg
void reg(const string &name, function< ReactorBase *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
Cantera::ReactorBase
Base class for stirred reactors.
Definition ReactorBase.h:50
Cantera::ReactorFactory::deleteFactory
void deleteFactory() override
Virtual abstract function that deletes the factory.
Definition ReactorFactory.cpp:63
Cantera::ReactorFactory::newReactor
ReactorBase * newReactor(const string &reactorType)
Create a new reactor by type name.
Definition ReactorFactory.cpp:69
Cantera::newReactor3
shared_ptr< ReactorBase > newReactor3(const string &model)
Create a Reactor object of the specified type.
Definition ReactorFactory.cpp:83
Cantera::newReactor
ReactorBase * newReactor(const string &model)
Create a Reactor object of the specified type.
Definition ReactorFactory.cpp:76
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::warn_deprecated
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926