Add module sizes

This commit is contained in:
Max Luebke 2024-03-13 23:49:57 +01:00
parent f3f86bb4ac
commit 54136c8e0c
2 changed files with 24 additions and 8 deletions

View File

@ -9,11 +9,15 @@
#include <Surface.h> #include <Surface.h>
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <cxxKinetics.h> #include <cxxKinetics.h>
#include <map> #include <map>
#include <string> #include <string>
#include <sys/types.h>
#include <vector> #include <vector>
enum { POET_SOL = 0, POET_EXCH, POET_KIN, POET_EQUIL, POET_SURF };
class IPhreeqcPOET : public IPhreeqc { class IPhreeqcPOET : public IPhreeqc {
public: public:
std::vector<double> std::vector<double>
@ -48,6 +52,7 @@ public:
std::vector<int> getSolutionIds() const { return this->solution_ids; } std::vector<int> getSolutionIds() const { return this->solution_ids; }
std::map<int, std::string> raw_dumps() { std::map<int, std::string> raw_dumps() {
std::map<int, std::string> dumps; std::map<int, std::string> dumps;
@ -62,6 +67,17 @@ public:
return dumps; return dumps;
} }
using ModulesArray = std::array<std::uint32_t, 5>;
ModulesArray getModuleSizes() const {
ModulesArray module_sizes;
for (std::uint8_t i = 0; i < 5; i++) {
module_sizes[i] = this->initial_names[i].size();
}
return module_sizes;
}
private: private:
using essential_names = std::array<std::vector<std::string>, 5>; using essential_names = std::array<std::vector<std::string>, 5>;

View File

@ -44,15 +44,15 @@ void IPhreeqcPOET::valuesFromModule(const std::string &module_name,
std::size_t dest_module_i = 0; std::size_t dest_module_i = 0;
std::vector<double> to_insert; std::vector<double> to_insert;
if (module_name == "exchange") { // 1 if (module_name == "exchange") { // 1
this->Get_exchange(cell_number)->dump_essential_names(names[1]); this->Get_exchange(cell_number)->dump_essential_names(names[POET_EXCH]);
this->Get_exchange(cell_number)->get_essential_values(to_insert); this->Get_exchange(cell_number)->get_essential_values(to_insert);
dest_module_i = 1; dest_module_i = 1;
} else if (module_name == "kinetics") { // 2 } else if (module_name == "kinetics") { // 2
this->Get_kinetic(cell_number)->dump_essential_names(names[2]); this->Get_kinetic(cell_number)->dump_essential_names(names[POET_KIN]);
this->Get_kinetic(cell_number)->get_essential_values(to_insert); this->Get_kinetic(cell_number)->get_essential_values(to_insert);
dest_module_i = 2; dest_module_i = 2;
} else if (module_name == "surface") { // 4 } else if (module_name == "surface") { // 4
this->Get_surface(cell_number)->dump_essential_names(names[4]); this->Get_surface(cell_number)->dump_essential_names(names[POET_SURF]);
this->Get_surface(cell_number)->get_essential_values(to_insert); this->Get_surface(cell_number)->get_essential_values(to_insert);
dest_module_i = 4; dest_module_i = 4;
} }
@ -191,31 +191,31 @@ IPhreeqcPOET::dump_essential_names(std::size_t cell_number) {
// Solutions // Solutions
if (this->Get_solution(cell_number) != NULL) { if (this->Get_solution(cell_number) != NULL) {
std::vector<std::string> &eSolNames = eNames[0]; std::vector<std::string> &eSolNames = eNames[POET_SOL];
this->Get_solution(cell_number)->dump_essential_names(eSolNames); this->Get_solution(cell_number)->dump_essential_names(eSolNames);
} }
// Exchange // Exchange
if (this->Get_exchange(cell_number) != NULL) { if (this->Get_exchange(cell_number) != NULL) {
std::vector<std::string> &eExchNames = eNames[1]; std::vector<std::string> &eExchNames = eNames[POET_EXCH];
this->Get_exchange(cell_number)->dump_essential_names(eExchNames); this->Get_exchange(cell_number)->dump_essential_names(eExchNames);
} }
// Kinetics // Kinetics
if (this->Get_kinetic(cell_number) != NULL) { if (this->Get_kinetic(cell_number) != NULL) {
std::vector<std::string> &eKinNames = eNames[2]; std::vector<std::string> &eKinNames = eNames[POET_KIN];
this->Get_kinetic(cell_number)->dump_essential_names(eKinNames); this->Get_kinetic(cell_number)->dump_essential_names(eKinNames);
} }
// PPassemblage // PPassemblage
if (this->Get_equilibrium(cell_number) != NULL) { if (this->Get_equilibrium(cell_number) != NULL) {
std::vector<std::string> &eEquNames = eNames[3]; std::vector<std::string> &eEquNames = eNames[POET_EQUIL];
this->Get_equilibrium(cell_number)->dump_essential_names(eEquNames); this->Get_equilibrium(cell_number)->dump_essential_names(eEquNames);
} }
// Surface // Surface
if (this->Get_surface(cell_number) != NULL) { if (this->Get_surface(cell_number) != NULL) {
std::vector<std::string> &eSurfNames = eNames[4]; std::vector<std::string> &eSurfNames = eNames[POET_SURF];
this->Get_surface(cell_number)->dump_essential_names(eSurfNames); this->Get_surface(cell_number)->dump_essential_names(eSurfNames);
} }