fix: calculation of wp_sizes_vector

This commit is contained in:
Max Luebke 2023-01-20 14:57:03 +01:00
parent 5429696d89
commit f7404110ab
3 changed files with 10 additions and 8 deletions

View File

@ -264,3 +264,8 @@ StoreSetup <- function(setup) {
saveRDS(to_store, file = paste0(fileout, "/setup.rds"))
msgm("initialization stored in ", paste0(fileout, "/setup.rds"))
}
GetWorkPackageSizesVector <- function(n_packages, package_size, len) {
ids <- rep(1:n_packages, times=package_size, each = 1)[1:len]
return(as.integer(table(ids)))
}

@ -1 +1 @@
Subproject commit d4e3ab8544628c72921bf60d4462d6d131b0ffb5
Subproject commit 79d7a32fc25fd97b78f320bba854b1db64e059f7

View File

@ -26,6 +26,7 @@
#include <Rcpp.h>
#include <array>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <string>
@ -56,13 +57,9 @@ ChemMaster::ChemMaster(SimParams &params, RInside &R_, Grid &grid_)
uint32_t n_packages = (uint32_t)(grid.GetTotalCellCount() / this->wp_size) +
(mod_pkgs != 0 ? 1 : 0);
this->wp_sizes_vector = std::vector<uint32_t>(n_packages, this->wp_size);
if (mod_pkgs) {
auto itEndVector = this->wp_sizes_vector.end() - 1;
for (uint32_t i = 0; i < this->wp_size - mod_pkgs; i++) {
*(itEndVector - i) -= 1;
}
}
Rcpp::Function wp_f("GetWorkPackageSizesVector");
this->wp_sizes_vector = Rcpp::as<std::vector<uint32_t>>(
wp_f(n_packages, this->wp_size, grid.GetTotalCellCount()));
this->state = this->grid.RegisterState(
poet::BaseChemModule::CHEMISTRY_MODULE_NAME, this->prop_names);