diff --git a/src/BTCSDiffusion.cpp b/src/BTCSDiffusion.cpp index 870479c..ceef611 100644 --- a/src/BTCSDiffusion.cpp +++ b/src/BTCSDiffusion.cpp @@ -70,7 +70,8 @@ void BTCSDiffusion::updateInternals() { bc.resize(cells, {BTCSDiffusion::BC_CLOSED, 0}); } -void BTCSDiffusion::simulate1D(Eigen::Map &c, boundary_condition left, +void BTCSDiffusion::simulate1D(Eigen::Map &c, + boundary_condition left, boundary_condition right, const std::vector &alpha, double dx, int size) { @@ -78,10 +79,10 @@ void BTCSDiffusion::simulate1D(Eigen::Map &c, boundary_conditio bool left_is_constant = (left.type == BTCSDiffusion::BC_CONSTANT); bool right_is_constant = (right.type == BTCSDiffusion::BC_CONSTANT); - //The sizes for matrix and vectors of the equation system is defined by the - //actual size of the input vector and if the system is (partially) closed. - //Then we will need ghost nodes. So this variable will give the count of ghost - //nodes. + // The sizes for matrix and vectors of the equation system is defined by the + // actual size of the input vector and if the system is (partially) closed. + // Then we will need ghost nodes. So this variable will give the count of + // ghost nodes. int bc_offset = !left_is_constant + !right_is_constant; ; @@ -140,10 +141,8 @@ void BTCSDiffusion::simulate1D(Eigen::Map &c, boundary_conditio x_vector = solver.solve(b_vector); - //fill solution back in place into =c= vector - for (int i = 0, j = i + !left_is_constant; i < c.size(); i++, j++) { - c[i] = x_vector[i + !left_is_constant]; - } + // write back result to input/output vector + c = x_vector.segment(!left_is_constant, c.size()); } void BTCSDiffusion::setTimestep(double time_step) {