diff --git a/poet/include/PhreeqcMatrix.hpp b/poet/include/PhreeqcMatrix.hpp index 08a1f47f..ad8f6b1a 100644 --- a/poet/include/PhreeqcMatrix.hpp +++ b/poet/include/PhreeqcMatrix.hpp @@ -9,6 +9,7 @@ #include #include "IPhreeqc.hpp" +#include "global_structures.h" /** * @brief Class for storing information from Phreeqc @@ -258,6 +259,15 @@ public: */ std::string getDatabase() const; + /** + * @brief Check if a cell with given ID exists in the PhreeqcMatrix. + * + * @param cell_id ID of the cell (user id from Phreeqc script) to check for. + * @return true Entry exists + * @return false Entry doesn't exist + */ + bool checkIfExists(int cell_id) const; + private: std::map> _m_map; std::map> _m_internal_names; diff --git a/poet/src/PhreeqcMatrix/Misc.cpp b/poet/src/PhreeqcMatrix/Misc.cpp index fffe8ad8..e5d7d515 100644 --- a/poet/src/PhreeqcMatrix/Misc.cpp +++ b/poet/src/PhreeqcMatrix/Misc.cpp @@ -1,5 +1,4 @@ #include "PhreeqcMatrix.hpp" -#include std::vector PhreeqcMatrix::getIds() const { std::vector ids; @@ -50,4 +49,8 @@ std::string PhreeqcMatrix::getDumpStringsPQI(int cell_id) const { return dump_string; } -std::string PhreeqcMatrix::getDatabase() const { return _m_database; } \ No newline at end of file +std::string PhreeqcMatrix::getDatabase() const { return _m_database; } + +bool PhreeqcMatrix::checkIfExists(int cell_id) const { + return this->_m_map.find(cell_id) != this->_m_map.end(); +} \ No newline at end of file diff --git a/poet/test/testPhreeqcMatrix.cpp b/poet/test/testPhreeqcMatrix.cpp index dda31d60..55fa3e9b 100644 --- a/poet/test/testPhreeqcMatrix.cpp +++ b/poet/test/testPhreeqcMatrix.cpp @@ -21,6 +21,9 @@ POET_TEST(PhreeqcMatrixOneSolution) { EXPECT_EQ(ids.size(), 1); EXPECT_EQ(ids[0], 1); + EXPECT_TRUE(pqc_mat.checkIfExists(1)); + EXPECT_FALSE(pqc_mat.checkIfExists(2)); + PhreeqcMatrix::STLExport exported_init = pqc_mat.get(); // ID + H,O,Charge,H(0),O(0) + 4 Solutions + 4 Equil incl. params EXPECT_EQ(exported_init.names.size(), 14);