Skip to content

Commit 6c96f6c

Browse files
committed
[Kinetics] Use BulkRate<> template for CustomFunc1Rate
1 parent efa8aa0 commit 6c96f6c

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

include/cantera/kinetics/BulkRate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define CT_BULKRATE_H
1111

1212
#include "Arrhenius.h"
13+
#include "Custom.h"
1314

1415
namespace Cantera
1516
{
@@ -40,6 +41,7 @@ class BulkRate : public RateType
4041
using ArrheniusRate = BulkRate<Arrhenius3, ReactionData>;
4142
using TwoTempPlasmaRate = BulkRate<TwoTempPlasma, TwoTempPlasmaData>;
4243
using BlowersMaselRate = BulkRate<BlowersMasel, BulkData>;
44+
using CustomFunc1Rate = BulkRate<CustomFunc1Base, ReactionData>;
4345

4446

4547
class ThreeBodyBase

include/cantera/kinetics/Custom.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,14 @@ class Func1;
3333
* @warning This class is an experimental part of the %Cantera API and
3434
* may be changed or removed without notice.
3535
*/
36-
class CustomFunc1Rate final : public ReactionRate
36+
class CustomFunc1Base : public ReactionRate
3737
{
3838
public:
39-
CustomFunc1Rate();
40-
CustomFunc1Rate(const AnyMap& node, const UnitStack& rate_units)
41-
: CustomFunc1Rate()
42-
{
43-
setParameters(node, rate_units);
44-
}
45-
46-
unique_ptr<MultiRateBase> newMultiRate() const override {
47-
return unique_ptr<MultiRateBase>(new MultiRate<CustomFunc1Rate, ReactionData>);
48-
}
39+
CustomFunc1Base() = default;
4940

5041
const std::string type() const override { return "custom-rate-function"; }
5142

5243
void getParameters(AnyMap& rateNode, const Units& rate_units=Units(0.)) const;
53-
using ReactionRate::getParameters;
5444

5545
//! Update information specific to reaction
5646
/*!
@@ -66,7 +56,7 @@ class CustomFunc1Rate final : public ReactionRate
6656
void setRateFunction(shared_ptr<Func1> f);
6757

6858
protected:
69-
shared_ptr<Func1> m_ratefunc;
59+
shared_ptr<Func1> m_ratefunc = 0;
7060
};
7161

7262

src/kinetics/Custom.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,22 @@
99
namespace Cantera
1010
{
1111

12-
CustomFunc1Rate::CustomFunc1Rate()
13-
: m_ratefunc(0)
14-
{
15-
}
16-
17-
void CustomFunc1Rate::setRateFunction(shared_ptr<Func1> f)
12+
void CustomFunc1Base::setRateFunction(shared_ptr<Func1> f)
1813
{
1914
m_ratefunc = f;
2015
}
2116

22-
double CustomFunc1Rate::evalFromStruct(const ReactionData& shared_data) const
17+
double CustomFunc1Base::evalFromStruct(const ReactionData& shared_data) const
2318
{
2419
if (m_ratefunc) {
2520
return m_ratefunc->eval(shared_data.temperature);
2621
}
2722
return NAN;
2823
}
2924

30-
void CustomFunc1Rate::getParameters(AnyMap& rateNode, const Units& rate_units) const
25+
void CustomFunc1Base::getParameters(AnyMap& rateNode, const Units& rate_units) const
3126
{
32-
throw NotImplementedError("CustomFunc1Rate::getParameters",
27+
throw NotImplementedError("CustomFunc1Base::getParameters",
3328
"Not implemented by '{}' object.", type());
3429
}
3530

0 commit comments

Comments
 (0)