From 272f010047dc9838be5a193bdde74fc7561dc2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Tue, 5 Sep 2023 09:47:22 +0200 Subject: [PATCH] load constant velocities at instantiation --- src/Transport/AdvectionModule.cpp | 29 ++++++++++++++++++++--------- src/Transport/AdvectionModule.hpp | 3 +++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Transport/AdvectionModule.cpp b/src/Transport/AdvectionModule.cpp index 9a9781c76..6048b69ac 100644 --- a/src/Transport/AdvectionModule.cpp +++ b/src/Transport/AdvectionModule.cpp @@ -104,16 +104,17 @@ void AdvectionModule::simulate(double dt) { // HACK: constant flux for this moment imported from R runtime - RInsidePOET &R = RInsidePOET::getInstance(); - const auto flux_list = - Rcpp::as(R.parseEval("mysetup$advection$const_flux")); - std::vector> flux(flux_list.size()); + // auto parse_start = std::chrono::steady_clock::now(); + // RInsidePOET &R = RInsidePOET::getInstance(); + // const auto flux_list = + // Rcpp::as(R.parseEval("mysetup$advection$const_flux")); + // std::vector> flux(flux_list.size()); + // auto parse_end = std::chrono::steady_clock::now(); -#pragma omp parallel for schedule(dynamic) - for (std::size_t i = 0; i < flux_list.size(); i++) { - const auto flux_2d = Rcpp::as>(flux_list[i]); - flux[i] = flux_2d; - } + // MSG("Parsing took " + + // std::to_string(std::chrono::duration_cast( + // parse_end - parse_start) + // .count())); MSG("Advection time step requested: " + std::to_string(dt)); @@ -226,6 +227,16 @@ void AdvectionModule::initializeParams(RInsidePOET &R) { } this->t_field = Field(field_size, init_field, prop_names); + + // FIXME: parse velocities in instantiation of class + const auto rcpp_flux_list = + Rcpp::as(R.parseEval("mysetup$advection$const_flux")); + this->flux.resize(rcpp_flux_list.size()); + + for (std::size_t i = 0; i < rcpp_flux_list.size(); i++) { + const auto flux_2d = Rcpp::as>(rcpp_flux_list[i]); + this->flux[i] = flux_2d; + } } } // namespace poet diff --git a/src/Transport/AdvectionModule.hpp b/src/Transport/AdvectionModule.hpp index a54b82980..323744fc2 100644 --- a/src/Transport/AdvectionModule.hpp +++ b/src/Transport/AdvectionModule.hpp @@ -95,6 +95,9 @@ private: std::map> inactive_cells; std::vector boundary_condition; + // FIXME: parse velocities in instantiation of class + std::vector> flux; + Field t_field; /**