mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 12:54:50 +01:00
Refactor chemistry module and RHookFunction
This commit is contained in:
parent
f2e8f6023d
commit
90287ab445
@ -58,6 +58,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RHookFunction &operator=(const RHookFunction &rhs) {
|
||||||
|
this->func = rhs.func;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RHookFunction(const RHookFunction &rhs) { this->func = rhs.func; }
|
||||||
|
|
||||||
bool isValid() const { return this->func.has_value(); }
|
bool isValid() const { return this->func.has_value(); }
|
||||||
|
|
||||||
SEXP asSEXP() const { return Rcpp::as<SEXP>(this->func.value()); }
|
SEXP asSEXP() const { return Rcpp::as<SEXP>(this->func.value()); }
|
||||||
|
|||||||
@ -155,11 +155,9 @@ inverseDistanceWeighting(const std::vector<std::int32_t> &to_calc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
poet::ChemistryModule::ChemistryModule(
|
poet::ChemistryModule::ChemistryModule(
|
||||||
uint32_t wp_size_, const InitialList::ChemistryInit &chem_params,
|
uint32_t wp_size_, const InitialList::ChemistryInit chem_params,
|
||||||
MPI_Comm communicator)
|
MPI_Comm communicator)
|
||||||
: params(chem_params), wp_size(wp_size_), group_comm(communicator),
|
: params(chem_params), wp_size(wp_size_), group_comm(communicator) {
|
||||||
dht_species(chem_params.dht_species),
|
|
||||||
interp_species(chem_params.interp_species) {
|
|
||||||
MPI_Comm_rank(communicator, &comm_rank);
|
MPI_Comm_rank(communicator, &comm_rank);
|
||||||
MPI_Comm_size(communicator, &comm_size);
|
MPI_Comm_size(communicator, &comm_size);
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public:
|
|||||||
* \param communicator MPI communicator to distribute work in.
|
* \param communicator MPI communicator to distribute work in.
|
||||||
*/
|
*/
|
||||||
ChemistryModule(uint32_t wp_size,
|
ChemistryModule(uint32_t wp_size,
|
||||||
const InitialList::ChemistryInit &chem_params,
|
const InitialList::ChemistryInit chem_params,
|
||||||
MPI_Comm communicator);
|
MPI_Comm communicator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,12 +97,13 @@ public:
|
|||||||
this->interp_enabled = setup.interp_enabled;
|
this->interp_enabled = setup.interp_enabled;
|
||||||
|
|
||||||
if (this->dht_enabled || this->interp_enabled) {
|
if (this->dht_enabled || this->interp_enabled) {
|
||||||
this->initializeDHT(setup.dht_size_mb, this->dht_species);
|
this->initializeDHT(setup.dht_size_mb, this->params.dht_species);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->interp_enabled) {
|
if (this->interp_enabled) {
|
||||||
this->initializeInterp(setup.interp_bucket_size, setup.interp_size_mb,
|
this->initializeInterp(setup.interp_bucket_size, setup.interp_size_mb,
|
||||||
setup.interp_min_entries, this->interp_species);
|
setup.interp_min_entries,
|
||||||
|
this->params.interp_species);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,12 +377,9 @@ protected:
|
|||||||
uint32_t prop_count = 0;
|
uint32_t prop_count = 0;
|
||||||
std::vector<std::string> prop_names;
|
std::vector<std::string> prop_names;
|
||||||
|
|
||||||
NamedVector<std::uint32_t> dht_species;
|
|
||||||
NamedVector<std::uint32_t> interp_species;
|
|
||||||
|
|
||||||
Field chem_field;
|
Field chem_field;
|
||||||
|
|
||||||
const InitialList::ChemistryInit ¶ms;
|
const InitialList::ChemistryInit params;
|
||||||
|
|
||||||
std::map<int, std::unique_ptr<IPhreeqcPOET>> phreeqc_instances;
|
std::map<int, std::unique_ptr<IPhreeqcPOET>> phreeqc_instances;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -42,10 +42,18 @@ InitialList::ChemistryInit InitialList::getChemistryInit() const {
|
|||||||
chem_init.interp_species = interp_species;
|
chem_init.interp_species = interp_species;
|
||||||
|
|
||||||
if (this->chem_hooks.size() > 0) {
|
if (this->chem_hooks.size() > 0) {
|
||||||
chem_init.hooks.dht_fill = this->chem_hooks["dht_fill"];
|
if (this->chem_hooks.containsElementNamed("dht_fill")) {
|
||||||
chem_init.hooks.dht_fuzz = this->chem_hooks["dht_fuzz"];
|
chem_init.hooks.dht_fill = this->chem_hooks["dht_fill"];
|
||||||
chem_init.hooks.interp_pre = this->chem_hooks["interp_pre"];
|
}
|
||||||
chem_init.hooks.interp_post = this->chem_hooks["interp_post"];
|
if (this->chem_hooks.containsElementNamed("dht_fuzz")) {
|
||||||
|
chem_init.hooks.dht_fuzz = this->chem_hooks["dht_fuzz"];
|
||||||
|
}
|
||||||
|
if (this->chem_hooks.containsElementNamed("interp_pre")) {
|
||||||
|
chem_init.hooks.interp_pre = this->chem_hooks["interp_pre"];
|
||||||
|
}
|
||||||
|
if (this->chem_hooks.containsElementNamed("interp_post")) {
|
||||||
|
chem_init.hooks.interp_post = this->chem_hooks["interp_post"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return chem_init;
|
return chem_init;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user