Cantera  2.5.1
FalloffFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file FalloffFactory.cpp
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at https://cantera.org/license.txt for license and copyright information.
7 
10 
11 namespace Cantera
12 {
13 
14 FalloffFactory* FalloffFactory::s_factory = 0;
16 
18 {
19  reg("Lindemann", []() { return new Falloff(); });
20  addAlias("Lindemann", "Simple");
21  reg("Troe", []() { return new Troe(); });
22  reg("SRI", []() { return new SRI(); });
23 }
24 
26 {
27  warn_deprecated("FalloffFactory::newFalloff",
28  "Instantiation using magic numbers is deprecated; use string "
29  "identifier instead. To be removed after Cantera 2.5.");
30  static const std::unordered_map<int, std::string> types {
31  {SIMPLE_FALLOFF, "Simple"},
32  {TROE_FALLOFF, "Troe"},
33  {SRI_FALLOFF, "SRI"}
34  };
35 
36  Falloff* f = create(types.at(type));
37  f->init(c);
38  return f;
39 }
40 
41 Falloff* FalloffFactory::newFalloff(const std::string& type, const vector_fp& c)
42 {
43  Falloff* f = create(type);
44  f->init(c);
45  return f;
46 }
47 
48 shared_ptr<Falloff> newFalloff(int type, const vector_fp& c)
49 {
50  shared_ptr<Falloff> f(FalloffFactory::factory()->newFalloff(type, c));
51  return f;
52 }
53 
54 shared_ptr<Falloff> newFalloff(const std::string& type, const vector_fp& c)
55 {
56  shared_ptr<Falloff> f(FalloffFactory::factory()->newFalloff(type, c));
57  return f;
58 }
59 
60 }
Parameterizations for reaction falloff functions.
Falloff * create(const std::string &name, Args... args)
Create an object using the object construction function corresponding to "name" and the provided cons...
Definition: FactoryBase.h:77
void addAlias(const std::string &original, const std::string &alias)
Add an alias for an existing registered type.
Definition: FactoryBase.h:87
void reg(const std::string &name, std::function< Falloff *(Args...)> f)
Register a new object construction function.
Definition: FactoryBase.h:82
static FalloffFactory * factory()
Return a pointer to the factory.
static FalloffFactory * s_factory
Pointer to the single instance of the factory.
static std::mutex falloff_mutex
Mutex for use when calling the factory.
virtual Falloff * newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
FalloffFactory()
default constructor, which is defined as private
Base class for falloff function calculators.
Definition: Falloff.h:30
virtual void init(const vector_fp &c)
Initialize.
Definition: Falloff.cpp:17
The SRI falloff function.
Definition: Falloff.h:213
The 3- or 4-parameter Troe falloff parameterization.
Definition: Falloff.h:134
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:180
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
shared_ptr< Falloff > newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
This file defines some constants used to specify reaction types.