mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-15 12:28:22 +01:00
Revert "feat: make output of H(0) and O(0) optional"
This reverts commit bdb5ce944fd001cb36c8369d8c792f2f4a54c7be.
This commit is contained in:
parent
5664153cf9
commit
a718c3efaf
@ -3,6 +3,7 @@
|
||||
// Rcpp include
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "DataStructures/Field.hpp"
|
||||
#include "InitialList.hpp"
|
||||
@ -14,6 +15,7 @@
|
||||
#include <Rinternals.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -24,9 +26,9 @@ namespace poet {
|
||||
enum SEXP_TYPE { SEXP_IS_LIST, SEXP_IS_VEC };
|
||||
|
||||
const std::map<std::uint8_t, std::string> tug_side_mapping = {
|
||||
{tug::BC_SIDE_RIGHT, "E"},
|
||||
{tug::BC_SIDE_LEFT, "W"},
|
||||
{tug::BC_SIDE_TOP, "N"},
|
||||
{tug::BC_SIDE_RIGHT , "E"},
|
||||
{tug::BC_SIDE_LEFT , "W"},
|
||||
{tug::BC_SIDE_TOP , "N"},
|
||||
{tug::BC_SIDE_BOTTOM, "S"}};
|
||||
|
||||
static std::vector<TugType> colMajToRowMaj(const Rcpp::NumericVector &vec,
|
||||
@ -164,8 +166,8 @@ InitialList::resolveBoundaries(const Rcpp::List &boundaries_list,
|
||||
if (boundaries_list.containsElementNamed(side.second.c_str())) {
|
||||
const Rcpp::List mapping = boundaries_list[side.second];
|
||||
|
||||
const Rcpp::IntegerVector cells = mapping["cell"]; // MDL 2024-06-13
|
||||
const Rcpp::IntegerVector values = mapping["sol_id"]; // MDL
|
||||
const Rcpp::IntegerVector cells = mapping["cell"]; // MDL 2024-06-13
|
||||
const Rcpp::IntegerVector values = mapping["sol_id"]; // MDL
|
||||
const Rcpp::CharacterVector type_str = mapping["type"];
|
||||
|
||||
if (cells.size() != values.size()) {
|
||||
|
||||
@ -15,42 +15,6 @@
|
||||
|
||||
namespace poet {
|
||||
|
||||
// static Rcpp::NumericMatrix pqcMatToR(const PhreeqcMatrix &phreeqc, RInside
|
||||
// &R) {
|
||||
|
||||
// PhreeqcMatrix::STLExport phreeqc_mat = phreeqc.get();
|
||||
|
||||
// // PhreeqcInit::PhreeqcMat phreeqc_mat = phreeqc->getPhreeqcMat();
|
||||
|
||||
// // add "id" to the front of the column names
|
||||
|
||||
// const std::size_t ncols = phreeqc_mat.names.size();
|
||||
// const std::size_t nrows = phreeqc_mat.values.size();
|
||||
|
||||
// phreeqc_mat.names.insert(phreeqc_mat.names.begin(), "ID");
|
||||
|
||||
// Rcpp::NumericMatrix mat(nrows, ncols + 1);
|
||||
|
||||
// for (std::size_t i = 0; i < nrows; i++) {
|
||||
// mat(i, 0) = phreeqc_mat.ids[i];
|
||||
// for (std::size_t j = 0; j < ncols; ++j) {
|
||||
// mat(i, j + 1) = phreeqc_mat.values[i][j];
|
||||
// }
|
||||
// }
|
||||
|
||||
// Rcpp::colnames(mat) = Rcpp::wrap(phreeqc_mat.names);
|
||||
|
||||
// return mat;
|
||||
// }
|
||||
|
||||
// static inline Rcpp::List matToGrid(RInside &R, const Rcpp::NumericMatrix
|
||||
// &mat,
|
||||
// const Rcpp::NumericMatrix &grid) {
|
||||
// Rcpp::Function pqc_to_grid_R("pqc_to_grid");
|
||||
|
||||
// return pqc_to_grid_R(mat, grid);
|
||||
// }
|
||||
|
||||
static inline std::map<int, std::string>
|
||||
replaceRawKeywordIDs(std::map<int, std::string> raws) {
|
||||
for (auto &raw : raws) {
|
||||
@ -64,26 +28,6 @@ replaceRawKeywordIDs(std::map<int, std::string> raws) {
|
||||
return raws;
|
||||
}
|
||||
|
||||
// static inline uint32_t getSolutionCount(std::unique_ptr<PhreeqcInit>
|
||||
// &phreeqc,
|
||||
// const Rcpp::List &initial_grid) {
|
||||
// PhreeqcInit::ModulesArray mod_array;
|
||||
// Rcpp::Function unique_R("unique");
|
||||
|
||||
// std::vector<int> row_ids =
|
||||
// Rcpp::as<std::vector<int>>(unique_R(initial_grid["ID"]));
|
||||
|
||||
// // std::vector<std::uint32_t> sizes_vec(sizes.begin(), sizes.end());
|
||||
|
||||
// // Rcpp::Function modify_sizes("modify_module_sizes");
|
||||
// // sizes_vec = Rcpp::as<std::vector<std::uint32_t>>(
|
||||
// // modify_sizes(sizes_vec, phreeqc_mat, initial_grid));
|
||||
|
||||
// // std::copy(sizes_vec.begin(), sizes_vec.end(), sizes.begin());
|
||||
|
||||
// return phreeqc->getModuleSizes(row_ids)[POET_SOL];
|
||||
// }
|
||||
|
||||
static std::string readFile(const std::string &path) {
|
||||
std::string string_rpath(PATH_MAX, '\0');
|
||||
|
||||
@ -121,8 +65,7 @@ static Rcpp::List expandGrid(const PhreeqcMatrix &pqc_mat,
|
||||
return Rcpp::Function("pqc_to_grid")(pqc_mat_R, grid_def);
|
||||
}
|
||||
|
||||
PhreeqcMatrix InitialList::prepareGrid(const Rcpp::List &grid_input,
|
||||
bool include_h0_o0) {
|
||||
PhreeqcMatrix InitialList::prepareGrid(const Rcpp::List &grid_input) {
|
||||
// parse input values
|
||||
std::string script;
|
||||
std::string database;
|
||||
@ -186,11 +129,23 @@ PhreeqcMatrix InitialList::prepareGrid(const Rcpp::List &grid_input,
|
||||
grid_input[GRID_MEMBER_STR(GridMembers::PQC_WITH_REDOX)])
|
||||
: false;
|
||||
|
||||
this->with_h0_o0 = include_h0_o0;
|
||||
bool with_h0_o0 =
|
||||
grid_input.containsElementNamed(
|
||||
GRID_MEMBER_STR(GridMembers::PQC_WITH_H0_O0))
|
||||
? Rcpp::as<bool>(
|
||||
grid_input[GRID_MEMBER_STR(GridMembers::PQC_WITH_H0_O0)])
|
||||
: false;
|
||||
|
||||
if (with_h0_o0 && !with_redox) {
|
||||
throw std::runtime_error(
|
||||
"Output of H(0) and O(0) can only be used with redox.");
|
||||
}
|
||||
|
||||
this->with_h0_o0 = with_h0_o0;
|
||||
this->with_redox = with_redox;
|
||||
|
||||
PhreeqcMatrix pqc_mat =
|
||||
PhreeqcMatrix(database, script, include_h0_o0, with_redox);
|
||||
PhreeqcMatrix(database, script, with_h0_o0, with_redox);
|
||||
|
||||
this->transport_names = pqc_mat.getSolutionNames();
|
||||
|
||||
|
||||
@ -10,9 +10,8 @@
|
||||
#include <vector>
|
||||
|
||||
namespace poet {
|
||||
void InitialList::initializeFromList(const Rcpp::List &setup,
|
||||
bool include_h0_o0) {
|
||||
PhreeqcMatrix phreeqc = prepareGrid(setup[grid_key], include_h0_o0);
|
||||
void InitialList::initializeFromList(const Rcpp::List &setup) {
|
||||
PhreeqcMatrix phreeqc = prepareGrid(setup[grid_key]);
|
||||
initDiffusion(setup[diffusion_key], phreeqc);
|
||||
initChemistry(setup[chemistry_key]);
|
||||
}
|
||||
@ -89,8 +88,7 @@ void InitialList::importList(const Rcpp::List &setup, bool minimal) {
|
||||
this->chem_hooks =
|
||||
Rcpp::as<Rcpp::List>(setup[static_cast<int>(ExportList::CHEM_HOOKS)]);
|
||||
|
||||
this->ai_surrogate_input_script = Rcpp::as<std::string>(
|
||||
setup[static_cast<int>(ExportList::AI_SURROGATE_INPUT_SCRIPT)]);
|
||||
this->ai_surrogate_input_script = Rcpp::as<std::string>(setup[static_cast<int>(ExportList::AI_SURROGATE_INPUT_SCRIPT)]);
|
||||
}
|
||||
|
||||
Rcpp::List InitialList::exportList() {
|
||||
@ -142,8 +140,7 @@ Rcpp::List InitialList::exportList() {
|
||||
out[static_cast<int>(ExportList::CHEM_INTERP_SPECIES)] =
|
||||
Rcpp::wrap(this->interp_species);
|
||||
out[static_cast<int>(ExportList::CHEM_HOOKS)] = this->chem_hooks;
|
||||
out[static_cast<int>(ExportList::AI_SURROGATE_INPUT_SCRIPT)] =
|
||||
this->ai_surrogate_input_script;
|
||||
out[static_cast<int>(ExportList::AI_SURROGATE_INPUT_SCRIPT)] = this->ai_surrogate_input_script;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -26,9 +26,9 @@ using TugType = double;
|
||||
|
||||
class InitialList {
|
||||
public:
|
||||
InitialList(RInside &R) : R(R) {};
|
||||
InitialList(RInside &R) : R(R){};
|
||||
|
||||
void initializeFromList(const Rcpp::List &setup, bool include_h0_o0 = false);
|
||||
void initializeFromList(const Rcpp::List &setup);
|
||||
|
||||
void importList(const Rcpp::List &setup, bool minimal = false);
|
||||
Rcpp::List exportList();
|
||||
@ -56,14 +56,6 @@ private:
|
||||
CHEM_PQC_WITH_REDOX,
|
||||
CHEM_PQC_IDS,
|
||||
CHEM_FIELD_HEADER,
|
||||
// CHEM_PQC_SCRIPTS,
|
||||
// CHEM_PQC_SOLUTIONS,
|
||||
// CHEM_PQC_SOLUTION_PRIMARY,
|
||||
// CHEM_PQC_EXCHANGER,
|
||||
// CHEM_PQC_KINETICS,
|
||||
// CHEM_PQC_EQUILIBRIUM,
|
||||
// CHEM_PQC_SURFACE_COMPS,
|
||||
// CHEM_PQC_SURFACE_CHARGES,
|
||||
CHEM_DHT_SPECIES,
|
||||
CHEM_INTERP_SPECIES,
|
||||
CHEM_HOOKS,
|
||||
@ -78,6 +70,7 @@ private:
|
||||
PQC_SCRIPT_STRING,
|
||||
PQC_SCRIPT_FILE,
|
||||
PQC_WITH_REDOX,
|
||||
PQC_WITH_H0_O0,
|
||||
PQC_DB_STRING,
|
||||
PQC_DB_FILE,
|
||||
GRID_DEF,
|
||||
@ -91,9 +84,10 @@ private:
|
||||
static_cast<std::size_t>(InitialList::GridMembers::ENUM_SIZE);
|
||||
|
||||
static constexpr std::array<const char *, size_GridMembers>
|
||||
GridMembersString = {"pqc_in_string", "pqc_in_file", "pqc_with_redox",
|
||||
"pqc_db_string", "pqc_db_file", "grid_def",
|
||||
"grid_size", "constant_cells", "porosity"};
|
||||
GridMembersString = {"pqc_in_string", "pqc_in_file", "pqc_with_redox",
|
||||
"pqc_wth_h0_o0", "pqc_db_string", "pqc_db_file",
|
||||
"grid_def", "grid_size", "constant_cells",
|
||||
"porosity"};
|
||||
|
||||
constexpr const char *GRID_MEMBER_STR(GridMembers member) const {
|
||||
return GridMembersString[static_cast<std::size_t>(member)];
|
||||
@ -101,7 +95,7 @@ private:
|
||||
|
||||
// std::unique_ptr<PhreeqcMatrix> pqc_mat;
|
||||
|
||||
PhreeqcMatrix prepareGrid(const Rcpp::List &grid_input, bool include_h0_o0);
|
||||
PhreeqcMatrix prepareGrid(const Rcpp::List &grid_input);
|
||||
|
||||
std::uint8_t dim{0};
|
||||
|
||||
|
||||
@ -40,11 +40,6 @@ int main(int argc, char **argv) {
|
||||
bool asQS{false};
|
||||
app.add_flag("-q, --qs", asQS, "Save output as .qs")->default_val(false);
|
||||
|
||||
bool includeH0O0{false};
|
||||
app.add_flag("--include-h0-o0", includeH0O0,
|
||||
"Include H(0) and O(0) in the output")
|
||||
->default_val(false);
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
// source the input script
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user