feat: allow more than one iteration in sequential mode

fix: enable timesteps to simulate
This commit is contained in:
Max Lübke 2022-10-25 11:29:09 +02:00
parent d40bad186d
commit 776e7d14c7
3 changed files with 23 additions and 7 deletions

View File

@ -89,6 +89,7 @@ int main(int argc, char *argv[]) {
// purposes
//
// bool dt_differ;
R.parseEvalQ("mysetup <- setup");
if (world_rank == 0) { // get timestep vector from
// grid_init function ... //
std::string master_init_code = "mysetup <- master_init(setup=setup)";
@ -113,7 +114,6 @@ int main(int argc, char *argv[]) {
// TODO: Grid anpassen
R.parseEvalQ("mysetup <- setup");
Grid grid(R, poet::GridParams(R));
// grid.init_from_R();

View File

@ -156,6 +156,8 @@ selout <- c(
# TODO: dt and iterations
iterations <- 10
setup <- list(
# bound = myboundmat,
base = base,
@ -181,8 +183,8 @@ setup <- list(
s_grid = c(n, m),
n_grid = c(n, m),
dt = 1,
iterations = 1,
timesteps = rep(1, 10)
iterations = iterations,
timesteps = rep(1, iterations)
)
# not needed yet

View File

@ -18,6 +18,7 @@
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poet/ChemSim.hpp"
#include "poet/SimParams.hpp"
#include "tug/BoundaryCondition.hpp"
#include "tug/Diffusion.hpp"
@ -90,8 +91,7 @@ void DiffusionModule::initialize(poet::DiffusionParams args) {
// initialize field
field.resize(this->n_cells_per_prop * this->prop_count);
for (uint32_t i = 0; i < this->prop_count; i++) {
std::vector<double> prop_vec =
grid.getSpeciesByName(this->prop_names[i]);
std::vector<double> prop_vec = grid.getSpeciesByName(this->prop_names[i]);
std::copy(prop_vec.begin(), prop_vec.end(),
field.begin() + (i * this->n_cells_per_prop));
if (this->dim == this->DIM_2D) {
@ -106,7 +106,7 @@ void DiffusionModule::initialize(poet::DiffusionParams args) {
// apply inner grid constant cells
// NOTE: opening a scope here for distinguish variable names
if (args.vecinj_inner.rows() != 0){
if (args.vecinj_inner.rows() != 0) {
// get indices of constant grid cells
Rcpp::NumericVector indices_const_cells = args.vecinj_inner(Rcpp::_, 0);
this->index_constant_cells =
@ -159,7 +159,21 @@ void DiffusionModule::simulate(double dt) {
sim_b_transport = MPI_Wtime();
auto *field = this->state->mem.data();
std::vector<double> &curr_field = this->state->mem;
for (uint32_t i = 0; i < this->prop_names.size(); i++) {
try {
std::vector<double> t_prop_vec = this->grid.getSpeciesByName(
this->prop_names[i], poet::CHEMISTRY_MODULE_NAME);
std::copy(t_prop_vec.begin(), t_prop_vec.end(),
curr_field.begin() + (i * this->n_cells_per_prop));
} catch (...) {
continue;
}
}
auto *field = curr_field.data();
this->diff_input.setTimestep(dt);