Using std::map

This commit is contained in:
Ingmar Schoegl
2023-08-05 16:26:32 -04:00
committed by Ray Speth
parent ddd803c630
commit 0df90be93e
46 changed files with 113 additions and 113 deletions
+5 -5
View File
@@ -248,12 +248,12 @@ public:
AnyValue& operator=(const std::unordered_map<std::string, T> items); AnyValue& operator=(const std::unordered_map<std::string, T> items);
template<class T> template<class T>
AnyValue& operator=(const std::map<std::string, T> items); AnyValue& operator=(const map<std::string, T> items);
//! Return the held `AnyMap` as a `std::map` where all of the values have //! Return the held `AnyMap` as a `map` where all of the values have
//! the specified type. //! the specified type.
template<class T> template<class T>
std::map<std::string, T> asMap() const; map<std::string, T> asMap() const;
//! Access a `vector<AnyMap>` as a mapping using the value of `name` from //! Access a `vector<AnyMap>` as a mapping using the value of `name` from
//! each item as the key in the new mapping. //! each item as the key in the new mapping.
@@ -372,7 +372,7 @@ vector<AnyMap>& AnyValue::asVector<AnyMap>(size_t nMin, size_t nMax);
* breakfast["beans"]["baked"] = v; * breakfast["beans"]["baked"] = v;
* *
* // Create a nested AnyMap with values of the same type * // Create a nested AnyMap with values of the same type
* std::map<std::string, double> breads{{"wheat", 4.0}, {"white", 2.5}}; * map<std::string, double> breads{{"wheat", 4.0}, {"white", 2.5}};
* breakfast["toast"] = breads; * breakfast["toast"] = breads;
* // Equivalent to: * // Equivalent to:
* breakfast["toast"]["wheat"] = 4.0 * breakfast["toast"]["wheat"] = 4.0
@@ -386,7 +386,7 @@ vector<AnyMap>& AnyValue::asVector<AnyMap>(size_t nMin, size_t nMax);
* std::string val2 = breakfast["eggs"].asString(); * std::string val2 = breakfast["eggs"].asString();
* vector<double> val3 = breakfast["beans"]["baked"].asVector<double>(); * vector<double> val3 = breakfast["beans"]["baked"].asVector<double>();
* *
* std::map<std::string, double> = breakfast["toast"].asMap<double>(); * map<std::string, double> = breakfast["toast"].asMap<double>();
* ``` * ```
* *
* ## Checking for elements * ## Checking for elements
+3 -3
View File
@@ -131,7 +131,7 @@ AnyValue& AnyValue::operator=(const std::unordered_map<std::string, T> items) {
} }
template<class T> template<class T>
AnyValue& AnyValue::operator=(const std::map<std::string, T> items) { AnyValue& AnyValue::operator=(const map<std::string, T> items) {
m_value = AnyMap(); m_value = AnyMap();
m_equals = eq_comparer<AnyMap>; m_equals = eq_comparer<AnyMap>;
AnyMap& dest = as<AnyMap>(); AnyMap& dest = as<AnyMap>();
@@ -159,9 +159,9 @@ inline AnyMap& AnyValue::as<AnyMap>() {
} }
template<class T> template<class T>
std::map<std::string, T> AnyValue::asMap() const map<std::string, T> AnyValue::asMap() const
{ {
std::map<std::string, T> dest; map<std::string, T> dest;
for (const auto& item : as<AnyMap>()) { for (const auto& item : as<AnyMap>()) {
dest[item.first] = item.second.as<T>(); dest[item.first] = item.second.as<T>();
} }
+14 -14
View File
@@ -520,34 +520,34 @@ protected:
//! @{ //! @{
// Delegates with no return value // Delegates with no return value
std::map<std::string, function<void()>*> m_funcs_v; map<std::string, function<void()>*> m_funcs_v;
std::map<std::string, function<void(bool)>*> m_funcs_v_b; map<std::string, function<void(bool)>*> m_funcs_v_b;
std::map<std::string, function<void(double)>*> m_funcs_v_d; map<std::string, function<void(double)>*> m_funcs_v_d;
map<string, function<void(AnyMap&)>*> m_funcs_v_AMr; map<string, function<void(AnyMap&)>*> m_funcs_v_AMr;
std::map<std::string, map<std::string,
function<void(const AnyMap&, const UnitStack&)>*> m_funcs_v_cAMr_cUSr; function<void(const AnyMap&, const UnitStack&)>*> m_funcs_v_cAMr_cUSr;
map<string, function<void(const string&, void*)>*> m_funcs_v_csr_vp; map<string, function<void(const string&, void*)>*> m_funcs_v_csr_vp;
std::map<std::string, map<std::string,
function<void(std::array<size_t, 1>, double*)>*> m_funcs_v_dp; function<void(std::array<size_t, 1>, double*)>*> m_funcs_v_dp;
std::map<std::string, map<std::string,
function<void(std::array<size_t, 1>, double, double*)>*> m_funcs_v_d_dp; function<void(std::array<size_t, 1>, double, double*)>*> m_funcs_v_d_dp;
std::map<std::string, map<std::string,
function<void(std::array<size_t, 2>, double, double*, double*)>*> m_funcs_v_d_dp_dp; function<void(std::array<size_t, 2>, double, double*, double*)>*> m_funcs_v_d_dp_dp;
std::map<std::string, map<std::string,
function<void(std::array<size_t, 3>, double*, double*, double*)>*> m_funcs_v_dp_dp_dp; function<void(std::array<size_t, 3>, double*, double*, double*)>*> m_funcs_v_dp_dp_dp;
// Delegates with a return value // Delegates with a return value
std::map<std::string, function<double(void*)>> m_base_d_vp; map<std::string, function<double(void*)>> m_base_d_vp;
std::map<std::string, function<double(void*)>*> m_funcs_d_vp; map<std::string, function<double(void*)>*> m_funcs_d_vp;
std::map<std::string, map<std::string,
function<std::string(size_t)>> m_base_s_sz; function<std::string(size_t)>> m_base_s_sz;
std::map<std::string, map<std::string,
function<std::string(size_t)>*> m_funcs_s_sz; function<std::string(size_t)>*> m_funcs_s_sz;
std::map<std::string, map<std::string,
function<size_t(const std::string&)>> m_base_sz_csr; function<size_t(const std::string&)>> m_base_sz_csr;
std::map<std::string, map<std::string,
function<size_t(const std::string&)>*> m_funcs_sz_csr; function<size_t(const std::string&)>*> m_funcs_sz_csr;
//! @} //! @}
+2 -2
View File
@@ -108,11 +108,11 @@ public:
protected: protected:
//! Functions for wrapping and linking ReactionData objects //! Functions for wrapping and linking ReactionData objects
static std::map<std::string, static map<std::string,
function<void(ReactionDataDelegator&)>> s_ReactionData_linkers; function<void(ReactionDataDelegator&)>> s_ReactionData_linkers;
//! Functions for wrapping and linking Solution objects //! Functions for wrapping and linking Solution objects
static std::map<std::string, static map<std::string,
function<shared_ptr<ExternalHandle>(shared_ptr<Solution>)>> s_Solution_linkers; function<shared_ptr<ExternalHandle>(shared_ptr<Solution>)>> s_Solution_linkers;
//! Mapping from user-defined rate types to Solution wrapper types //! Mapping from user-defined rate types to Solution wrapper types
+3 -3
View File
@@ -155,13 +155,13 @@ protected:
vector<shared_ptr<Solution>> m_adjacent; vector<shared_ptr<Solution>> m_adjacent;
//! Adjacent phases, for access by name //! Adjacent phases, for access by name
std::map<std::string, shared_ptr<Solution>> m_adjacentByName; map<std::string, shared_ptr<Solution>> m_adjacentByName;
AnyMap m_header; //!< Additional input fields; usually from a YAML input file AnyMap m_header; //!< Additional input fields; usually from a YAML input file
//! Wrappers for this Solution object in extension languages, for evaluation //! Wrappers for this Solution object in extension languages, for evaluation
//! of user-defined reaction rates //! of user-defined reaction rates
std::map<std::string, shared_ptr<ExternalHandle>> m_externalHandles; map<std::string, shared_ptr<ExternalHandle>> m_externalHandles;
//! Callback functions that are invoked when the therm, kinetics, or transport //! Callback functions that are invoked when the therm, kinetics, or transport
//! members of the Solution are replaced. //! members of the Solution are replaced.
@@ -229,7 +229,7 @@ shared_ptr<Solution> newSolution(
const AnyMap& phaseNode, const AnyMap& rootNode=AnyMap(), const AnyMap& phaseNode, const AnyMap& rootNode=AnyMap(),
const std::string& transport="", const std::string& transport="",
const vector<shared_ptr<Solution>>& adjacent={}, const vector<shared_ptr<Solution>>& adjacent={},
const std::map<std::string, shared_ptr<Solution>>& related={}); const map<std::string, shared_ptr<Solution>>& related={});
} }
+4 -4
View File
@@ -176,7 +176,7 @@ public:
UnitSystem() : UnitSystem({}) {} UnitSystem() : UnitSystem({}) {}
//! Return default units used by the unit system //! Return default units used by the unit system
std::map<std::string, std::string> defaults() const; map<std::string, std::string> defaults() const;
//! Set the default units to convert from when explicit units are not //! Set the default units to convert from when explicit units are not
//! provided. Defaults can be set for mass, length, time, quantity, energy, //! provided. Defaults can be set for mass, length, time, quantity, energy,
@@ -193,14 +193,14 @@ public:
//! Cantera's default units: //! Cantera's default units:
//! ``` //! ```
//! UnitSystem system; //! UnitSystem system;
//! std::map<string, string> defaults{ //! map<string, string> defaults{
//! {"length", "m"}, {"mass", "kg"}, {"time", "s"}, //! {"length", "m"}, {"mass", "kg"}, {"time", "s"},
//! {"quantity", "kmol"}, {"pressure", "Pa"}, {"energy", "J"}, //! {"quantity", "kmol"}, {"pressure", "Pa"}, {"energy", "J"},
//! {"activation-energy", "J/kmol"} //! {"activation-energy", "J/kmol"}
//! }; //! };
//! setDefaults(defaults); //! setDefaults(defaults);
//! ``` //! ```
void setDefaults(const std::map<std::string, std::string>& units); void setDefaults(const map<std::string, std::string>& units);
//! Set the default units to convert from when using the //! Set the default units to convert from when using the
//! `convertActivationEnergy` function. //! `convertActivationEnergy` function.
@@ -295,7 +295,7 @@ private:
//! Map of dimensions (mass, length, etc.) to names of specified default //! Map of dimensions (mass, length, etc.) to names of specified default
//! units //! units
std::map<std::string, std::string> m_defaults; map<std::string, std::string> m_defaults;
}; };
} }
+2 -2
View File
@@ -176,10 +176,10 @@ public:
protected: protected:
//! Cached scalar values //! Cached scalar values
std::map<int, CachedValue<double> > m_scalarCache; map<int, CachedValue<double> > m_scalarCache;
//! Cached array values //! Cached array values
std::map<int, CachedValue<vector<double>> > m_arrayCache; map<int, CachedValue<vector<double>> > m_arrayCache;
//! The last assigned id. Automatically incremented by the getId() method. //! The last assigned id. Automatically incremented by the getId() method.
static int m_last_id; static int m_last_id;
+1 -1
View File
@@ -66,7 +66,7 @@ public:
//! @param units A map where keys are dimensions (mass, length, time, //! @param units A map where keys are dimensions (mass, length, time,
//! quantity, pressure, energy, activation-energy) and the values are //! quantity, pressure, energy, activation-energy) and the values are
//! corresponding units supported by the UnitSystem class. //! corresponding units supported by the UnitSystem class.
void setUnits(const std::map<std::string, std::string>& units={}); void setUnits(const map<std::string, std::string>& units={});
//! Set the units to be used in the output file. Dimensions not specified //! Set the units to be used in the output file. Dimensions not specified
//! will use Cantera's defaults. //! will use Cantera's defaults.
+4 -4
View File
@@ -182,14 +182,14 @@ void checkFinite(const double tmp);
*/ */
void checkFinite(const std::string& name, double* values, size_t N); void checkFinite(const std::string& name, double* values, size_t N);
//! Const accessor for a value in a std::map. //! Const accessor for a value in a map.
/* /*
* Similar to std::map.at(key), but returns *default_val* if the key is not * Similar to map.at(key), but returns *default_val* if the key is not
* found instead of throwing an exception. * found instead of throwing an exception.
*/ */
template <class T, class U> template <class T, class U>
const U& getValue(const std::map<T, U>& m, const T& key, const U& default_val) { const U& getValue(const map<T, U>& m, const T& key, const U& default_val) {
typename std::map<T,U>::const_iterator iter = m.find(key); typename map<T,U>::const_iterator iter = m.find(key);
return (iter == m.end()) ? default_val : iter->second; return (iter == m.end()) ? default_val : iter->second;
} }
+1 -1
View File
@@ -612,7 +612,7 @@ private:
/*! /*!
* -> used in the construction. However, wonder if it needs to be global. * -> used in the construction. However, wonder if it needs to be global.
*/ */
std::map<std::string, size_t> m_enamemap; map<std::string, size_t> m_enamemap;
//! Current value of the temperature (kelvin) //! Current value of the temperature (kelvin)
double m_temp = 298.15; double m_temp = 298.15;
+1 -1
View File
@@ -354,7 +354,7 @@ protected:
//! Vector of rate handlers for interface reactions //! Vector of rate handlers for interface reactions
vector<unique_ptr<MultiRateBase>> m_interfaceRates; vector<unique_ptr<MultiRateBase>> m_interfaceRates;
std::map<std::string, size_t> m_interfaceTypes; //!< Rate handler mapping map<std::string, size_t> m_interfaceTypes; //!< Rate handler mapping
//! Vector of irreversible reaction numbers //! Vector of irreversible reaction numbers
/*! /*!
+3 -3
View File
@@ -1512,8 +1512,8 @@ protected:
* @return 0.0 if the stoichiometries are not multiples of one another * @return 0.0 if the stoichiometries are not multiples of one another
* Otherwise, it returns the ratio of the stoichiometric coefficients. * Otherwise, it returns the ratio of the stoichiometric coefficients.
*/ */
double checkDuplicateStoich(std::map<int, double>& r1, double checkDuplicateStoich(map<int, double>& r1,
std::map<int, double>& r2) const; map<int, double>& r2) const;
//! @name Stoichiometry management //! @name Stoichiometry management
//! //!
@@ -1580,7 +1580,7 @@ protected:
* function, phaseIndex() decrements by one before returning the index * function, phaseIndex() decrements by one before returning the index
* value, so that missing phases return -1. * value, so that missing phases return -1.
*/ */
std::map<std::string, size_t> m_phaseindex; map<std::string, size_t> m_phaseindex;
//! Index in the list of phases of the one surface phase. //! Index in the list of phases of the one surface phase.
//! @deprecated To be removed after %Cantera 3.0. //! @deprecated To be removed after %Cantera 3.0.
+1 -1
View File
@@ -210,7 +210,7 @@ protected:
//! Vector of pairs of reaction rates indices and reaction rates //! Vector of pairs of reaction rates indices and reaction rates
vector<pair<size_t, RateType>> m_rxn_rates; vector<pair<size_t, RateType>> m_rxn_rates;
std::map<size_t, size_t> m_indices; //! Mapping of indices map<size_t, size_t> m_indices; //! Mapping of indices
DataType m_shared; DataType m_shared;
}; };
+1 -1
View File
@@ -182,7 +182,7 @@ public:
protected: protected:
//! log(p) to (index range) in the rates_ vector //! log(p) to (index range) in the rates_ vector
std::map<double, pair<size_t, size_t>> pressures_; map<double, pair<size_t, size_t>> pressures_;
// Rate expressions which are referenced by the indices stored in pressures_ // Rate expressions which are referenced by the indices stored in pressures_
vector<ArrheniusRate> rates_; vector<ArrheniusRate> rates_;
+5 -5
View File
@@ -81,7 +81,7 @@ protected:
class Path class Path
{ {
public: public:
typedef std::map<size_t, double> rxn_path_map; typedef map<size_t, double> rxn_path_map;
/** /**
* Constructor. Construct a one-way path from \c begin to \c end. * Constructor. Construct a one-way path from \c begin to \c end.
@@ -147,7 +147,7 @@ public:
void writeLabel(std::ostream& s, double threshold = 0.005); void writeLabel(std::ostream& s, double threshold = 0.005);
protected: protected:
std::map<std::string, double> m_label; map<std::string, double> m_label;
SpeciesNode* m_a, *m_b; SpeciesNode* m_a, *m_b;
rxn_path_map m_rxn; rxn_path_map m_rxn;
double m_total = 0.0; double m_total = 0.0;
@@ -281,7 +281,7 @@ public:
protected: protected:
double m_flxmax = 0.0; double m_flxmax = 0.0;
std::map<size_t, std::map<size_t, Path*> > m_paths; map<size_t, map<size_t, Path*> > m_paths;
//! map of species index to SpeciesNode //! map of species index to SpeciesNode
map<size_t, SpeciesNode*> m_nodes; map<size_t, SpeciesNode*> m_nodes;
@@ -329,11 +329,11 @@ protected:
//! m_transfer[reaction][reactant number][product number] where "reactant //! m_transfer[reaction][reactant number][product number] where "reactant
//! number" means the number of the reactant in the reaction equation. For example, //! number" means the number of the reactant in the reaction equation. For example,
//! for "A+B -> C+D", "B" is reactant number 1 and "C" is product number 0. //! for "A+B -> C+D", "B" is reactant number 1 and "C" is product number 0.
std::map<size_t, std::map<size_t, std::map<size_t, Group> > > m_transfer; map<size_t, map<size_t, map<size_t, Group> > > m_transfer;
vector<bool> m_determinate; vector<bool> m_determinate;
Array2D m_atoms; Array2D m_atoms;
std::map<std::string, size_t> m_enamemap; map<std::string, size_t> m_enamemap;
}; };
} }
+5 -5
View File
@@ -156,7 +156,7 @@ public:
R[m_rxn] -= S[m_ic0]; R[m_rxn] -= S[m_ic0];
} }
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices) void resizeCoeffs(const map<pair<size_t, size_t>, size_t>& indices)
{ {
m_jc0 = indices.at({m_rxn, m_ic0}); m_jc0 = indices.at({m_rxn, m_ic0});
} }
@@ -218,7 +218,7 @@ public:
R[m_rxn] -= (S[m_ic0] + S[m_ic1]); R[m_rxn] -= (S[m_ic0] + S[m_ic1]);
} }
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices) void resizeCoeffs(const map<pair<size_t, size_t>, size_t>& indices)
{ {
m_jc0 = indices.at({m_rxn, m_ic0}); m_jc0 = indices.at({m_rxn, m_ic0});
m_jc1 = indices.at({m_rxn, m_ic1}); m_jc1 = indices.at({m_rxn, m_ic1});
@@ -289,7 +289,7 @@ public:
R[m_rxn] -= (S[m_ic0] + S[m_ic1] + S[m_ic2]); R[m_rxn] -= (S[m_ic0] + S[m_ic1] + S[m_ic2]);
} }
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices) void resizeCoeffs(const map<pair<size_t, size_t>, size_t>& indices)
{ {
m_jc0 = indices.at({m_rxn, m_ic0}); m_jc0 = indices.at({m_rxn, m_ic0});
m_jc1 = indices.at({m_rxn, m_ic1}); m_jc1 = indices.at({m_rxn, m_ic1});
@@ -392,7 +392,7 @@ public:
} }
} }
void resizeCoeffs(const std::map<pair<size_t, size_t>, size_t>& indices) void resizeCoeffs(const map<pair<size_t, size_t>, size_t>& indices)
{ {
for (size_t i = 0; i < m_n; i++) { for (size_t i = 0; i < m_n; i++) {
m_jc[i] = indices.at({m_rxn, m_ic[i]}); m_jc[i] = indices.at({m_rxn, m_ic[i]});
@@ -622,7 +622,7 @@ public:
m_values.resize(nCoeffs, 0.); m_values.resize(nCoeffs, 0.);
// Set up index pairs for derivatives // Set up index pairs for derivatives
std::map<pair<size_t, size_t>, size_t> indices; map<pair<size_t, size_t>, size_t> indices;
size_t n = 0; size_t n = 0;
for (int i = 0; i < tmp.outerSize(); i++) { for (int i = 0; i < tmp.outerSize(); i++) {
for (Eigen::SparseMatrix<double>::InnerIterator it(tmp, i); it; ++it) { for (Eigen::SparseMatrix<double>::InnerIterator it(tmp, i); it; ++it) {
+1 -1
View File
@@ -20,7 +20,7 @@ class ThirdBodyCalc
{ {
public: public:
//! Install reaction that uses third-body effects in ThirdBodyCalc manager //! Install reaction that uses third-body effects in ThirdBodyCalc manager
void install(size_t rxnNumber, const std::map<size_t, double>& efficiencies, void install(size_t rxnNumber, const map<size_t, double>& efficiencies,
double default_efficiency, bool mass_action) { double default_efficiency, bool mass_action) {
m_reaction_index.push_back(rxnNumber); m_reaction_index.push_back(rxnNumber);
m_default.push_back(default_efficiency); m_default.push_back(default_efficiency);
+1 -1
View File
@@ -172,7 +172,7 @@ protected:
* DAE, and zero if it is not. * DAE, and zero if it is not.
*/ */
vector<int> m_alg; vector<int> m_alg;
std::map<int, int> m_constrain; map<int, int> m_constrain;
}; };
} }
+1 -1
View File
@@ -99,7 +99,7 @@ public:
protected: protected:
//! Indices of grid points that need new grid points added after them //! Indices of grid points that need new grid points added after them
set<size_t> m_loc; set<size_t> m_loc;
std::map<size_t, int> m_keep; map<size_t, int> m_keep;
//! Names of components that require the addition of new grid points //! Names of components that require the addition of new grid points
set<string> m_c; set<string> m_c;
vector<bool> m_active; vector<bool> m_active;
@@ -270,9 +270,9 @@ public:
//! a target species //! a target species
size_t j; size_t j;
//! map of <coverage[dimensionless], enthalpy[J/kmol]> pairs //! map of <coverage[dimensionless], enthalpy[J/kmol]> pairs
std::map<double, double> enthalpy_map; map<double, double> enthalpy_map;
//! map of <coverage[dimensionless], entropy[J/kmol/K]> pairs //! map of <coverage[dimensionless], entropy[J/kmol/K]> pairs
std::map<double, double> entropy_map; map<double, double> entropy_map;
//! boolean indicating whether the dependency is piecewise-linear //! boolean indicating whether the dependency is piecewise-linear
bool isPiecewise; bool isPiecewise;
}; };
+1 -1
View File
@@ -100,7 +100,7 @@ const vector<std::string>& elementNames();
* *
* @since New in version 3.0 * @since New in version 3.0
*/ */
const std::map<std::string, double>& elementWeights(); const map<std::string, double>& elementWeights();
//! Get the atomic weight of an element. //! Get the atomic weight of an element.
/*! /*!
+1 -1
View File
@@ -200,7 +200,7 @@ public:
return false; return false;
} }
std::map<std::string, size_t> nativeState() const { map<std::string, size_t> nativeState() const {
return { {"T", 0}, {"P", 1}, {"X", 2} }; return { {"T", 0}, {"P", 1}, {"X", 2} };
} }
+1 -1
View File
@@ -123,7 +123,7 @@ public:
return false; return false;
} }
std::map<std::string, size_t> nativeState() const { map<std::string, size_t> nativeState() const {
return { {"T", 0}, {"P", 1}, {"X", 2} }; return { {"T", 0}, {"P", 1}, {"X", 2} };
} }
+1 -1
View File
@@ -107,7 +107,7 @@ public:
* energy [J/kmol] as the values. Must contain one point at * energy [J/kmol] as the values. Must contain one point at
* 298.15 K. * 298.15 K.
*/ */
void setParameters(double h0, const std::map<double, double>& T_mu); void setParameters(double h0, const map<double, double>& T_mu);
virtual int reportType() const { virtual int reportType() const {
return MU0_INTERP; return MU0_INTERP;
+3 -3
View File
@@ -204,8 +204,8 @@ protected:
void markInstalled(size_t k); void markInstalled(size_t k);
typedef pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT; typedef pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT;
typedef std::map<int, vector<index_STIT> > STIT_map; typedef map<int, vector<index_STIT> > STIT_map;
typedef std::map<int, vector<double>> tpoly_map; typedef map<int, vector<double>> tpoly_map;
//! This is the main data structure, which contains the //! This is the main data structure, which contains the
//! SpeciesThermoInterpType objects, sorted by the parameterization type. //! SpeciesThermoInterpType objects, sorted by the parameterization type.
@@ -219,7 +219,7 @@ protected:
//! Map from species index to location within #m_sp, such that //! Map from species index to location within #m_sp, such that
//! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
//! SpeciesThermoInterpType object for species `k`. //! SpeciesThermoInterpType object for species `k`.
std::map<size_t, pair<int, size_t> > m_speciesLoc; map<size_t, pair<int, size_t> > m_speciesLoc;
//! Maximum value of the lowest temperature //! Maximum value of the lowest temperature
double m_tlow_max = 0.0; double m_tlow_max = 0.0;
@@ -74,7 +74,7 @@ public:
* region and each value is the array of 9 polynomial * region and each value is the array of 9 polynomial
* coefficients for that region. * coefficients for that region.
*/ */
void setParameters(const std::map<double, vector<double>>& regions); void setParameters(const map<double, vector<double>>& regions);
virtual int reportType() const; virtual int reportType() const;
@@ -99,7 +99,7 @@ protected:
//! Pointer to the Neutral Molecule ThermoPhase object //! Pointer to the Neutral Molecule ThermoPhase object
shared_ptr<ThermoPhase> neutralMoleculePhase_; shared_ptr<ThermoPhase> neutralMoleculePhase_;
std::map<std::string, double> neutralSpeciesMultipliers_; map<std::string, double> neutralSpeciesMultipliers_;
//! Number of neutral molecule species that make up the stoichiometric //! Number of neutral molecule species that make up the stoichiometric
//! vector for this species, in terms of calculating thermodynamic functions //! vector for this species, in terms of calculating thermodynamic functions
+1 -1
View File
@@ -273,7 +273,7 @@ protected:
Array2D m_aAlpha_binary; Array2D m_aAlpha_binary;
//! Explicitly-specified binary interaction parameters, to enable serialization //! Explicitly-specified binary interaction parameters, to enable serialization
std::map<std::string, std::map<std::string, double>> m_binaryParameters; map<std::string, map<std::string, double>> m_binaryParameters;
int m_NSolns = 0; int m_NSolns = 0;
+4 -4
View File
@@ -290,7 +290,7 @@ public:
//! 2, respectively. Mass fractions "Y" are omitted for pure species. //! 2, respectively. Mass fractions "Y" are omitted for pure species.
//! In all cases, offsets into the state vector are used by saveState() //! In all cases, offsets into the state vector are used by saveState()
//! and restoreState(). //! and restoreState().
virtual std::map<std::string, size_t> nativeState() const; virtual map<std::string, size_t> nativeState() const;
//! Return string acronym representing the native state of a Phase. //! Return string acronym representing the native state of a Phase.
//! Examples: "TP", "TDY", "TPY". //! Examples: "TP", "TDY", "TPY".
@@ -969,7 +969,7 @@ protected:
vector<double> m_speciesCharge; //!< Vector of species charges. length m_kk. vector<double> m_speciesCharge; //!< Vector of species charges. length m_kk.
std::map<std::string, shared_ptr<Species> > m_species; map<std::string, shared_ptr<Species> > m_species;
//! Flag determining behavior when adding species with an undefined element //! Flag determining behavior when adding species with an undefined element
UndefElement::behavior m_undefinedElementBehavior = UndefElement::add; UndefElement::behavior m_undefinedElementBehavior = UndefElement::add;
@@ -1021,10 +1021,10 @@ private:
vector<std::string> m_speciesNames; vector<std::string> m_speciesNames;
//! Map of species names to indices //! Map of species names to indices
std::map<std::string, size_t> m_speciesIndices; map<std::string, size_t> m_speciesIndices;
//! Map of lower-case species names to indices //! Map of lower-case species names to indices
std::map<std::string, size_t> m_speciesLower; map<std::string, size_t> m_speciesLower;
size_t m_mm = 0; //!< Number of elements. size_t m_mm = 0; //!< Number of elements.
vector<double> m_atomicWeights; //!< element atomic weights (kg kmol-1) vector<double> m_atomicWeights; //!< element atomic weights (kg kmol-1)
+1 -1
View File
@@ -238,7 +238,7 @@ protected:
Array2D a_coeff_vec; Array2D a_coeff_vec;
//! Explicitly-specified binary interaction parameters //! Explicitly-specified binary interaction parameters
std::map<std::string, std::map<std::string, pair<double, double>>> m_binaryParameters; map<std::string, map<std::string, pair<double, double>>> m_binaryParameters;
enum class CoeffSource { EoS, CritProps, Database }; enum class CoeffSource { EoS, CritProps, Database };
//! For each species, specifies the source of the a and b coefficients //! For each species, specifies the source of the a and b coefficients
+1 -1
View File
@@ -83,7 +83,7 @@ private:
TransportFactory(); TransportFactory();
//! Models included in this map are initialized in CK compatibility mode //! Models included in this map are initialized in CK compatibility mode
std::map<std::string, bool> m_CK_mode; map<std::string, bool> m_CK_mode;
}; };
//! @copydoc TransportFactory::newTransport(const std::string&, ThermoPhase*, int) //! @copydoc TransportFactory::newTransport(const std::string&, ThermoPhase*, int)
+1 -1
View File
@@ -17,7 +17,7 @@
using namespace Cantera; using namespace Cantera;
std::map<std::string,double> h, s, T, P, x; map<std::string,double> h, s, T, P, x;
vector<std::string> states; vector<std::string> states;
template<class F> template<class F>
+1 -1
View File
@@ -223,7 +223,7 @@ shared_ptr<Solution> newSolution(const AnyMap& phaseNode,
const AnyMap& rootNode, const AnyMap& rootNode,
const std::string& transport, const std::string& transport,
const vector<shared_ptr<Solution>>& adjacent, const vector<shared_ptr<Solution>>& adjacent,
const std::map<std::string, shared_ptr<Solution>>& related) const map<std::string, shared_ptr<Solution>>& related)
{ {
// thermo phase // thermo phase
auto thermo = newThermo(phaseNode, rootNode); auto thermo = newThermo(phaseNode, rootNode);
+6 -6
View File
@@ -14,7 +14,7 @@
namespace { namespace {
using namespace Cantera; using namespace Cantera;
const std::map<std::string, Units> knownUnits{ const map<std::string, Units> knownUnits{
{"", Units(1.0)}, {"", Units(1.0)},
{"1", Units(1.0)}, {"1", Units(1.0)},
@@ -80,7 +80,7 @@ const std::map<std::string, Units> knownUnits{
{"J/kmol", Units(1.0, 1, 2, -2, 0, 0, -1)}, {"J/kmol", Units(1.0, 1, 2, -2, 0, 0, -1)},
}; };
const std::map<std::string, double> prefixes{ const map<std::string, double> prefixes{
{"Y", 1e24}, {"Y", 1e24},
{"Z", 1e21}, {"Z", 1e21},
{"E", 1e18}, {"E", 1e18},
@@ -233,7 +233,7 @@ Units Units::pow(double exponent) const
std::string Units::str(bool skip_unity) const std::string Units::str(bool skip_unity) const
{ {
std::map<std::string, double> dims{ map<std::string, double> dims{
{"kg", m_mass_dim}, {"kg", m_mass_dim},
{"m", m_length_dim}, {"m", m_length_dim},
{"s", m_time_dim}, {"s", m_time_dim},
@@ -395,10 +395,10 @@ UnitSystem::UnitSystem(std::initializer_list<std::string> units)
setDefaults(units); setDefaults(units);
} }
std::map<std::string, std::string> UnitSystem::defaults() const map<std::string, std::string> UnitSystem::defaults() const
{ {
// Unit system defaults // Unit system defaults
std::map<std::string, std::string> units{ map<std::string, std::string> units{
{"mass", "kg"}, {"mass", "kg"},
{"length", "m"}, {"length", "m"},
{"time", "s"}, {"time", "s"},
@@ -469,7 +469,7 @@ void UnitSystem::setDefaults(std::initializer_list<std::string> units)
} }
} }
void UnitSystem::setDefaults(const std::map<std::string, std::string>& units) void UnitSystem::setDefaults(const map<std::string, std::string>& units)
{ {
for (const auto& [dimension, name] : units) { for (const auto& [dimension, name] : units) {
Units unit(name); Units unit(name);
+3 -3
View File
@@ -122,7 +122,7 @@ std::string YamlWriter::toYamlString() const
output["species"] = speciesDefs; output["species"] = speciesDefs;
// build reaction definitions for all phases // build reaction definitions for all phases
std::map<std::string, vector<AnyMap>> allReactions; map<std::string, vector<AnyMap>> allReactions;
for (const auto& phase : m_phases) { for (const auto& phase : m_phases) {
const auto kin = phase->kinetics(); const auto kin = phase->kinetics();
if (!kin || !kin->nReactions()) { if (!kin || !kin->nReactions()) {
@@ -140,7 +140,7 @@ std::string YamlWriter::toYamlString() const
// key: canonical phase in allReactions // key: canonical phase in allReactions
// value: phases using this reaction set // value: phases using this reaction set
std::map<std::string, vector<std::string>> phaseGroups; map<std::string, vector<std::string>> phaseGroups;
for (const auto& phase : m_phases) { for (const auto& phase : m_phases) {
const auto kin = phase->kinetics(); const auto kin = phase->kinetics();
@@ -192,7 +192,7 @@ void YamlWriter::toYamlFile(const std::string& filename) const
out << toYamlString(); out << toYamlString();
} }
void YamlWriter::setUnits(const std::map<std::string, std::string>& units) void YamlWriter::setUnits(const map<std::string, std::string>& units)
{ {
m_output_units = UnitSystem(); m_output_units = UnitSystem();
m_output_units.setDefaults(units); m_output_units.setDefaults(units);
+1 -1
View File
@@ -180,7 +180,7 @@ protected:
void removeThreadMessages(); void removeThreadMessages();
//! Typedef for map between a thread and the message //! Typedef for map between a thread and the message
typedef std::map<std::thread::id, pMessages_t> threadMsgMap_t; typedef map<std::thread::id, pMessages_t> threadMsgMap_t;
private: private:
//! Thread Msg Map //! Thread Msg Map
+1 -1
View File
@@ -213,7 +213,7 @@ vector<FactoryBase*> FactoryBase::s_vFactoryRegistry;
std::string demangle(const std::type_info& type) std::string demangle(const std::type_info& type)
{ {
static std::map<std::string, std::string> typenames = { static map<std::string, std::string> typenames = {
{typeid(void).name(), "void"}, {typeid(void).name(), "void"},
{typeid(double).name(), "double"}, {typeid(double).name(), "double"},
{typeid(long int).name(), "long int"}, {typeid(long int).name(), "long int"},
+5 -5
View File
@@ -107,8 +107,8 @@ void Kinetics::checkSpeciesArraySize(size_t kk) const
pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const
{ {
//! Map of (key indicating participating species) to reaction numbers //! Map of (key indicating participating species) to reaction numbers
std::map<size_t, vector<size_t> > participants; map<size_t, vector<size_t> > participants;
vector<std::map<int, double> > net_stoich; vector<map<int, double> > net_stoich;
std::unordered_set<size_t> unmatched_duplicates; std::unordered_set<size_t> unmatched_duplicates;
for (size_t i = 0; i < m_reactions.size(); i++) { for (size_t i = 0; i < m_reactions.size(); i++) {
if (m_reactions[i]->duplicate) { if (m_reactions[i]->duplicate) {
@@ -121,7 +121,7 @@ pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const
unsigned long int key = 0; unsigned long int key = 0;
Reaction& R = *m_reactions[i]; Reaction& R = *m_reactions[i];
net_stoich.emplace_back(); net_stoich.emplace_back();
std::map<int, double>& net = net_stoich.back(); map<int, double>& net = net_stoich.back();
for (const auto& [name, stoich] : R.reactants) { for (const auto& [name, stoich] : R.reactants) {
int k = static_cast<int>(kineticsSpeciesIndex(name)); int k = static_cast<int>(kineticsSpeciesIndex(name));
key += k*(k+1); key += k*(k+1);
@@ -197,8 +197,8 @@ pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const
return {npos, npos}; return {npos, npos};
} }
double Kinetics::checkDuplicateStoich(std::map<int, double>& r1, double Kinetics::checkDuplicateStoich(map<int, double>& r1,
std::map<int, double>& r2) const map<int, double>& r2) const
{ {
std::unordered_set<int> keys; // species keys (k+1 or -k-1) std::unordered_set<int> keys; // species keys (k+1 or -k-1)
for (auto& [speciesKey, stoich] : r1) { for (auto& [speciesKey, stoich] : r1) {
+6 -6
View File
@@ -207,7 +207,7 @@ AnyMap legacyH5(shared_ptr<SolutionArray> arr, const AnyMap& header={})
auto meta = arr->meta(); auto meta = arr->meta();
AnyMap out; AnyMap out;
std::map<std::string, std::string> meta_pairs = { map<std::string, std::string> meta_pairs = {
{"type", "Domain1D_type"}, {"type", "Domain1D_type"},
{"name", "name"}, {"name", "name"},
{"emissivity-left", "emissivity_left"}, {"emissivity-left", "emissivity_left"},
@@ -219,7 +219,7 @@ AnyMap legacyH5(shared_ptr<SolutionArray> arr, const AnyMap& header={})
} }
} }
std::map<std::string, std::string> tol_pairs = { map<std::string, std::string> tol_pairs = {
{"transient-abstol", "transient_abstol"}, {"transient-abstol", "transient_abstol"},
{"steady-abstol", "steady_abstol"}, {"steady-abstol", "steady_abstol"},
{"transient-reltol", "transient_reltol"}, {"transient-reltol", "transient_reltol"},
@@ -240,7 +240,7 @@ AnyMap legacyH5(shared_ptr<SolutionArray> arr, const AnyMap& header={})
return out; return out;
} }
std::map<std::string, std::string> header_pairs = { map<std::string, std::string> header_pairs = {
{"transport-model", "transport_model"}, {"transport-model", "transport_model"},
{"radiation-enabled", "radiation_enabled"}, {"radiation-enabled", "radiation_enabled"},
{"energy-enabled", "energy_enabled"}, {"energy-enabled", "energy_enabled"},
@@ -253,7 +253,7 @@ AnyMap legacyH5(shared_ptr<SolutionArray> arr, const AnyMap& header={})
} }
} }
std::map<std::string, std::string> refiner_pairs = { map<std::string, std::string> refiner_pairs = {
{"ratio", "ratio"}, {"ratio", "ratio"},
{"slope", "slope"}, {"slope", "slope"},
{"curve", "curve"}, {"curve", "curve"},
@@ -303,7 +303,7 @@ AnyMap Sim1D::restore(const std::string& fname, const std::string& name)
} }
AnyMap header; AnyMap header;
if (extension == "h5" || extension == "hdf" || extension == "hdf5") { if (extension == "h5" || extension == "hdf" || extension == "hdf5") {
std::map<std::string, shared_ptr<SolutionArray>> arrs; map<std::string, shared_ptr<SolutionArray>> arrs;
header = SolutionArray::readHeader(fname, name); header = SolutionArray::readHeader(fname, name);
for (auto dom : m_dom) { for (auto dom : m_dom) {
@@ -323,7 +323,7 @@ AnyMap Sim1D::restore(const std::string& fname, const std::string& name)
finalize(); finalize();
} else if (extension == "yaml" || extension == "yml") { } else if (extension == "yaml" || extension == "yml") {
AnyMap root = AnyMap::fromYamlFile(fname); AnyMap root = AnyMap::fromYamlFile(fname);
std::map<std::string, shared_ptr<SolutionArray>> arrs; map<std::string, shared_ptr<SolutionArray>> arrs;
header = SolutionArray::readHeader(root, name); header = SolutionArray::readHeader(root, name);
for (auto dom : m_dom) { for (auto dom : m_dom) {
+2 -2
View File
@@ -25,7 +25,7 @@ Mu0Poly::Mu0Poly(double tlow, double thigh, double pref, const double* coeffs) :
m_numIntervals(0), m_numIntervals(0),
m_H298(0.0) m_H298(0.0)
{ {
std::map<double, double> T_mu; map<double, double> T_mu;
size_t nPoints = (size_t) coeffs[0]; size_t nPoints = (size_t) coeffs[0];
for (size_t i = 0; i < nPoints; i++) { for (size_t i = 0; i < nPoints; i++) {
T_mu[coeffs[2*i+2]] = coeffs[2*i+3]; T_mu[coeffs[2*i+2]] = coeffs[2*i+3];
@@ -33,7 +33,7 @@ Mu0Poly::Mu0Poly(double tlow, double thigh, double pref, const double* coeffs) :
setParameters(coeffs[1], T_mu); setParameters(coeffs[1], T_mu);
} }
void Mu0Poly::setParameters(double h0, const std::map<double, double>& T_mu) void Mu0Poly::setParameters(double h0, const map<double, double>& T_mu)
{ {
size_t nPoints = T_mu.size(); size_t nPoints = T_mu.size();
if (nPoints < 2) { if (nPoints < 2) {
+1 -1
View File
@@ -79,7 +79,7 @@ Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion(double tlow, double thigh, do
} }
} }
void Nasa9PolyMultiTempRegion::setParameters(const std::map<double, vector<double>>& regions) void Nasa9PolyMultiTempRegion::setParameters(const map<double, vector<double>>& regions)
{ {
m_regionPts.clear(); m_regionPts.clear();
m_lowerTempBounds.clear(); m_lowerTempBounds.clear();
+1 -1
View File
@@ -179,7 +179,7 @@ std::string Phase::speciesSPName(int k) const
return m_name + ":" + speciesName(k); return m_name + ":" + speciesName(k);
} }
std::map<std::string, size_t> Phase::nativeState() const map<std::string, size_t> Phase::nativeState() const
{ {
if (isPure()) { if (isPure()) {
if (isCompressible()) { if (isCompressible()) {
+2 -2
View File
@@ -190,7 +190,7 @@ TEST(AnyMap, map_conversion) {
EXPECT_EQ(keys.size(), (size_t) 13); EXPECT_EQ(keys.size(), (size_t) 13);
EXPECT_EQ(m["empty"].as<AnyMap>().keys_str(), ""); EXPECT_EQ(m["empty"].as<AnyMap>().keys_str(), "");
std::map<std::string, double> zz{{"a", 9.1}, {"b", 13.5}}; map<std::string, double> zz{{"a", 9.1}, {"b", 13.5}};
m["foo"] = zz; m["foo"] = zz;
EXPECT_TRUE(m["foo"].hasKey("a")); EXPECT_TRUE(m["foo"].hasKey("a"));
EXPECT_DOUBLE_EQ(m["foo"]["b"].asDouble(), 13.5); EXPECT_DOUBLE_EQ(m["foo"]["b"].asDouble(), 13.5);
@@ -246,7 +246,7 @@ TEST(AnyMap, vector_length)
TEST(AnyMap, getters_with_defaults) TEST(AnyMap, getters_with_defaults)
{ {
AnyMap m; AnyMap m;
std::map<std::string, double> zz{{"a", 9.0}, {"b", 13.5}}; map<std::string, double> zz{{"a", 9.0}, {"b", 13.5}};
m["foo"] = zz; m["foo"] = zz;
m["foo"]["c"] = 4; m["foo"]["c"] = 4;
m["bar"] = "baz"; m["bar"] = "baz";
+1 -1
View File
@@ -197,7 +197,7 @@ TEST(YamlWriter, reaction_units_from_Yaml)
writer.addPhase(original); writer.addPhase(original);
writer.setPrecision(14); writer.setPrecision(14);
auto units = UnitSystem(); auto units = UnitSystem();
std::map<std::string, std::string> defaults{ map<std::string, std::string> defaults{
{"activation-energy", "K"}, {"activation-energy", "K"},
{"quantity", "mol"}, {"quantity", "mol"},
{"length", "cm"} {"length", "cm"}
+5 -5
View File
@@ -93,7 +93,7 @@ TEST(Units, with_defaults2) {
} }
TEST(Units, with_defaults_map) { TEST(Units, with_defaults_map) {
std::map<std::string, std::string> defaults{ map<std::string, std::string> defaults{
{"length", "cm"}, {"mass", "g"}, {"quantity", "mol"}, {"length", "cm"}, {"mass", "g"}, {"quantity", "mol"},
{"pressure", "atm"}, {"energy", "J"} {"pressure", "atm"}, {"energy", "J"}
}; };
@@ -111,9 +111,9 @@ TEST(Units, with_defaults_map) {
TEST(Units, bad_defaults) { TEST(Units, bad_defaults) {
UnitSystem U; UnitSystem U;
std::map<std::string, std::string> bad_key{{"length", "m"}, {"joy", "MJ"}}; map<std::string, std::string> bad_key{{"length", "m"}, {"joy", "MJ"}};
EXPECT_THROW(U.setDefaults(bad_key), CanteraError); EXPECT_THROW(U.setDefaults(bad_key), CanteraError);
std::map<std::string, std::string> bad_value{{"length", "m"}, {"time", "J"}}; map<std::string, std::string> bad_value{{"length", "m"}, {"time", "J"}};
EXPECT_THROW(U.setDefaults(bad_value), CanteraError); EXPECT_THROW(U.setDefaults(bad_value), CanteraError);
} }
@@ -153,7 +153,7 @@ TEST(Units, activation_energies4) {
TEST(Units, activation_energies5) { TEST(Units, activation_energies5) {
UnitSystem U; UnitSystem U;
std::map<std::string, std::string> defaults{ map<std::string, std::string> defaults{
{"quantity", "mol"}, {"energy", "cal"}, {"activation-energy", "K"} {"quantity", "mol"}, {"energy", "cal"}, {"activation-energy", "K"}
}; };
U.setDefaults(defaults); U.setDefaults(defaults);
@@ -163,7 +163,7 @@ TEST(Units, activation_energies5) {
TEST(Units, activation_energies6) { TEST(Units, activation_energies6) {
UnitSystem U; UnitSystem U;
std::map<std::string, std::string> defaults{ map<std::string, std::string> defaults{
{"activation-energy", "eV"} {"activation-energy", "eV"}
}; };
U.setDefaults(defaults); U.setDefaults(defaults);
+1 -1
View File
@@ -621,7 +621,7 @@ public:
BulkKinetics kin; BulkKinetics kin;
shared_ptr<Kinetics> kin_ref; shared_ptr<Kinetics> kin_ref;
vector<shared_ptr<Reaction>> reactions; vector<shared_ptr<Reaction>> reactions;
std::map<std::string, shared_ptr<Species>> species; map<std::string, shared_ptr<Species>> species;
void check_rates(size_t N, const std::string& X) { void check_rates(size_t N, const std::string& X) {
for (size_t i = 0; i < kin_ref->nReactions(); i++) { for (size_t i = 0; i < kin_ref->nReactions(); i++) {