feat(composition): added ability to change composition modes
This commit is contained in:
@@ -459,4 +459,25 @@ Composition Composition::subset(const std::vector<std::string>& symbols, std::st
|
||||
}
|
||||
}
|
||||
return subsetComposition;
|
||||
}
|
||||
|
||||
void Composition::setCompositionMode(bool massFracMode) {
|
||||
if (!m_finalized) {
|
||||
LOG_ERROR(m_logger, "Composition has not been finalized. Mode cannot be set unless composition is finalized.");
|
||||
throw std::runtime_error("Composition has not been finalized (Consider running .finalize()). The mode cannot be set unless the composition is finalized.");
|
||||
}
|
||||
|
||||
bool okay = true;
|
||||
for (auto& [_, entry] : m_compositions) {
|
||||
if (massFracMode) {
|
||||
okay = entry.setMassFracMode(m_meanParticleMass);
|
||||
} else {
|
||||
okay = entry.setNumberFracMode(m_specificNumberDensity);
|
||||
}
|
||||
if (!okay) {
|
||||
LOG_ERROR(m_logger, "Composition mode could not be set.");
|
||||
throw std::runtime_error("Composition mode could not be set.");
|
||||
}
|
||||
}
|
||||
m_massFracMode = massFracMode;
|
||||
}
|
||||
@@ -403,6 +403,12 @@ namespace composition{
|
||||
*/
|
||||
Composition subset(const std::vector<std::string>& symbols, std::string method="norm") const;
|
||||
|
||||
/**
|
||||
* @brief Sets the composition mode.
|
||||
* @param massFracMode True if mass fraction mode, false if number fraction mode.
|
||||
*/
|
||||
void setCompositionMode(bool massFracMode);
|
||||
|
||||
/**
|
||||
* @brief Overloaded output stream operator for Composition.
|
||||
* @param os The output stream.
|
||||
|
||||
Reference in New Issue
Block a user