mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
feat: add function to query wether a cell id exists
This commit is contained in:
parent
20333ced36
commit
5478ade84e
@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#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<int, std::vector<element>> _m_map;
|
||||
std::map<int, std::vector<base_names>> _m_internal_names;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "PhreeqcMatrix.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
std::vector<int> PhreeqcMatrix::getIds() const {
|
||||
std::vector<int> ids;
|
||||
@ -51,3 +50,7 @@ std::string PhreeqcMatrix::getDumpStringsPQI(int cell_id) const {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user