Skip to content

Commit

Permalink
[Reactor] Deprecate possibly-ambiguous names in componentIndex
Browse files Browse the repository at this point in the history
Resolves #274.
  • Loading branch information
speth committed Jun 22, 2015
1 parent eb75e8b commit 0590b2c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 6 deletions.
5 changes: 3 additions & 2 deletions include/cantera/zeroD/ConstPressureReactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class ConstPressureReactor : public Reactor
virtual void updateState(doublereal* y);

//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "m", "H", the name
//! of a homogeneous phase species, or the name of a surface species.
//! component named *nm*. Possible values for *nm* are "mass", "enthalpy",
//! the name of a homogeneous phase species, or the name of a surface
//! species.
virtual size_t componentIndex(const std::string& nm) const;
};

Expand Down
5 changes: 3 additions & 2 deletions include/cantera/zeroD/IdealGasConstPressureReactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class IdealGasConstPressureReactor : public ConstPressureReactor
virtual void updateState(doublereal* y);

//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "m", "T", the name
//! of a homogeneous phase species, or the name of a surface species.
//! component named *nm*. Possible values for *nm* are "mass",
//! "temperature", the name of a homogeneous phase species, or the name of a
//! surface species.
virtual size_t componentIndex(const std::string& nm) const;

protected:
Expand Down
4 changes: 4 additions & 0 deletions include/cantera/zeroD/IdealGasReactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class IdealGasReactor : public Reactor

virtual void updateState(doublereal* y);

//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "mass",
//! "volume", "temperature", the name of a homogeneous phase species, or the
//! name of a surface species.
virtual size_t componentIndex(const std::string& nm) const;

protected:
Expand Down
5 changes: 3 additions & 2 deletions include/cantera/zeroD/Reactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ class Reactor : public ReactorBase
std::vector<std::pair<void*, int> > getSensitivityOrder() const;

//! Return the index in the solution vector for this reactor of the
//! component named *nm*. Possible values for *nm* are "m", "V", "T", the
//! name of a homogeneous phase species, or the name of a surface species.
//! component named *nm*. Possible values for *nm* are "mass", "volume",
//! "int_energy", the name of a homogeneous phase species, or the name of a
//! surface species.
virtual size_t componentIndex(const std::string& nm) const;

protected:
Expand Down
10 changes: 10 additions & 0 deletions src/zeroD/ConstPressureReactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,18 @@ size_t ConstPressureReactor::componentIndex(const string& nm) const
if (k != npos) {
return k + 2;
} else if (nm == "m" || nm == "mass") {
if (nm == "m") {
warn_deprecated("ConstPressureReactor::componentIndex(\"m\")",
"Using the name 'm' for mass is deprecated, and will be "
"disabled after Cantera 2.3. Use 'mass' instead.");
}
return 0;
} else if (nm == "H" || nm == "enthalpy") {
if (nm == "H") {
warn_deprecated("ConstPressureReactor::componentIndex(\"H\")",
"Using the name 'H' for enthalpy is deprecated, and will be "
"disabled after Cantera 2.3. Use 'enthalpy' instead.");
}
return 1;
} else {
return npos;
Expand Down
10 changes: 10 additions & 0 deletions src/zeroD/IdealGasConstPressureReactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,18 @@ size_t IdealGasConstPressureReactor::componentIndex(const string& nm) const
if (k != npos) {
return k + 2;
} else if (nm == "m" || nm == "mass") {
if (nm == "m") {
warn_deprecated("IdealGasConstPressureReactor::componentIndex(\"m\")",
"Using the name 'm' for mass is deprecated, and will be "
"disabled after Cantera 2.3. Use 'mass' instead.");
}
return 0;
} else if (nm == "T" || nm == "temperature") {
if (nm == "T") {
warn_deprecated("IdealGasConstPressureReactor::componentIndex(\"T\")",
"Using the name 'T' for temperature is deprecated, and will be "
"disabled after Cantera 2.3. Use 'temperature' instead.");
}
return 1;
} else {
return npos;
Expand Down
15 changes: 15 additions & 0 deletions src/zeroD/IdealGasReactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,25 @@ size_t IdealGasReactor::componentIndex(const string& nm) const
if (k != npos) {
return k + 3;
} else if (nm == "m" || nm == "mass") {
if (nm == "m") {
warn_deprecated("IdealGasReactor::componentIndex(\"m\")",
"Using the name 'm' for mass is deprecated, and will be "
"disabled after Cantera 2.3. Use 'mass' instead.");
}
return 0;
} else if (nm == "V" || nm == "volume") {
if (nm == "V") {
warn_deprecated("IdealGasReactor::componentIndex(\"V\")",
"Using the name 'V' for volume is deprecated, and will be "
"disabled after Cantera 2.3. Use 'volume' instead.");
}
return 1;
} else if (nm == "T" || nm == "temperature") {
if (nm == "T") {
warn_deprecated("IdealGasReactor::componentIndex(\"T\")",
"Using the name 'T' for temperature is deprecated, and will be "
"disabled after Cantera 2.3. Use 'temperature' instead.");
}
return 2;
} else {
return npos;
Expand Down
15 changes: 15 additions & 0 deletions src/zeroD/Reactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,25 @@ size_t Reactor::componentIndex(const string& nm) const
if (k != npos) {
return k + 3;
} else if (nm == "m" || nm == "mass") {
if (nm == "m") {
warn_deprecated("Reactor::componentIndex(\"m\")",
"Using the name 'm' for mass is deprecated, and will be "
"disabled after Cantera 2.3. Use 'mass' instead.");
}
return 0;
} else if (nm == "V" || nm == "volume") {
if (nm == "V") {
warn_deprecated("Reactor::componentIndex(\"V\")",
"Using the name 'V' for volume is deprecated, and will be "
"disabled after Cantera 2.3. Use 'volume' instead.");
}
return 1;
} else if (nm == "U" || nm == "int_energy") {
if (nm == "U") {
warn_deprecated("Reactor::componentIndex(\"U\")",
"Using the name 'U' for internal energy is deprecated, and "
"will be disabled after Cantera 2.3. Use 'int_energy' instead.");
}
return 2;
} else {
return npos;
Expand Down

0 comments on commit 0590b2c

Please sign in to comment.