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 <vector>
|
||||||
|
|
||||||
#include "IPhreeqc.hpp"
|
#include "IPhreeqc.hpp"
|
||||||
|
#include "global_structures.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Class for storing information from Phreeqc
|
* @brief Class for storing information from Phreeqc
|
||||||
@ -258,6 +259,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::string getDatabase() const;
|
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:
|
private:
|
||||||
std::map<int, std::vector<element>> _m_map;
|
std::map<int, std::vector<element>> _m_map;
|
||||||
std::map<int, std::vector<base_names>> _m_internal_names;
|
std::map<int, std::vector<base_names>> _m_internal_names;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
#include "PhreeqcMatrix.hpp"
|
#include "PhreeqcMatrix.hpp"
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
std::vector<int> PhreeqcMatrix::getIds() const {
|
std::vector<int> PhreeqcMatrix::getIds() const {
|
||||||
std::vector<int> ids;
|
std::vector<int> ids;
|
||||||
@ -50,4 +49,8 @@ std::string PhreeqcMatrix::getDumpStringsPQI(int cell_id) const {
|
|||||||
return dump_string;
|
return dump_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PhreeqcMatrix::getDatabase() const { return _m_database; }
|
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.size(), 1);
|
||||||
EXPECT_EQ(ids[0], 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();
|
PhreeqcMatrix::STLExport exported_init = pqc_mat.get();
|
||||||
// ID + H,O,Charge,H(0),O(0) + 4 Solutions + 4 Equil incl. params
|
// ID + H,O,Charge,H(0),O(0) + 4 Solutions + 4 Equil incl. params
|
||||||
EXPECT_EQ(exported_init.names.size(), 14);
|
EXPECT_EQ(exported_init.names.size(), 14);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user