#include "../include/diffusion/BTCSDiffusion.hpp" #include "../include/diffusion/BoundaryCondition.hpp" #include // for copy, max #include #include #include // for std #include // for vector #include using namespace std; using namespace Diffusion; using namespace Rcpp; //using namespace Eigen; // [[Rcpp::depends(RcppEigen)]] // [[Rcpp::plugins("cpp11")]] // [[Rcpp::export]] std::vector & diff1D(int n, double length, std::vector & field, std::vector & alpha, double timestep, double bc_left, double bc_right, int iterations) { // dimension of grid int dim = 1; // create input + diffusion coefficients for each grid cell // std::vector alpha(n, 1 * pow(10, -1)); // std::vector field(n, 1 * std::pow(10, -6)); std::vector bc(n, {0,0}); // create instance of diffusion module BTCSDiffusion diffu(dim); diffu.setXDimensions(length, n); // set the boundary condition for the left ghost cell to dirichlet bc[0] = {Diffusion::BC_CONSTANT, bc_left}; bc[n-1] = {Diffusion::BC_CONSTANT, bc_right}; // set timestep for simulation to 1 second diffu.setTimestep(timestep); //cout << setprecision(12); // loop 100 times // output is currently generated by the method itself for (int i = 0; i < iterations; i++) { diffu.simulate(field.data(), alpha.data(), bc.data()); } // for (auto & cell : field) { // Rcout << cell << "\n"; // } return(field); }