define fluxes and max fluxes as class members

This commit is contained in:
Max Lübke 2023-09-01 16:24:17 +02:00 committed by Max Lübke
parent 75f1036e3e
commit 7dfe4efc23
2 changed files with 25 additions and 2 deletions

View File

@ -107,8 +107,6 @@ void AdvectionModule::simulate(double dt) {
flux[i] = flux_2d;
}
MSG("Advection time step requested: " + std::to_string(dt));
std::vector<double> max_fluxes(flux.size());
for (std::size_t i = 0; i < max_fluxes.size(); i++) {
std::array<double, 4> abs_flux;
@ -118,6 +116,8 @@ void AdvectionModule::simulate(double dt) {
max_fluxes[i] = *std::max_element(abs_flux.begin(), abs_flux.end());
}
MSG("Advection time step requested: " + std::to_string(dt));
const auto time_vec = CFLTimeVec(dt, max_fluxes);
MSG("CFL yielding " + std::to_string(time_vec.size()) + " inner iterations");
@ -215,6 +215,24 @@ void AdvectionModule::initializeParams(RInsidePOET &R) {
}
this->t_field = Field(field_size, init_field, prop_names);
// FIXME: this should be done before each iteration
const auto flux_list =
Rcpp::as<Rcpp::DataFrame>(R.parseEval("mysetup$advection$const_flux"));
this->flux.resize(flux_list.size());
for (std::size_t i = 0; i < flux_list.size(); i++) {
const auto flux_2d = Rcpp::as<std::vector<double>>(flux_list[i]);
this->flux[i] = flux_2d;
}
this->max_fluxes.resize(flux.size());
for (std::size_t i = 0; i < max_fluxes.size(); i++) {
std::array<double, 4> abs_flux;
for (std::size_t j = 0; j < abs_flux.size(); j++) {
abs_flux[j] = std::abs(flux[i][j]);
}
this->max_fluxes[i] = *std::max_element(abs_flux.begin(), abs_flux.end());
}
}
} // namespace poet

View File

@ -95,6 +95,11 @@ private:
std::map<std::uint32_t, std::vector<double>> inactive_cells;
std::vector<double> boundary_condition;
// FIXME: This will be removed in the future and is now only intended for
// speed purposes
std::vector<double> max_fluxes;
std::vector<std::vector<double>> flux;
Field t_field;
/**