Replace copying of output vector by oneliner

This commit is contained in:
Max Luebke 2022-02-08 11:26:54 +01:00
parent f4253f2e6a
commit 8de34ad65b

View File

@ -70,7 +70,8 @@ void BTCSDiffusion::updateInternals() {
bc.resize(cells, {BTCSDiffusion::BC_CLOSED, 0}); bc.resize(cells, {BTCSDiffusion::BC_CLOSED, 0});
} }
void BTCSDiffusion::simulate1D(Eigen::Map<Eigen::VectorXd> &c, boundary_condition left, void BTCSDiffusion::simulate1D(Eigen::Map<Eigen::VectorXd> &c,
boundary_condition left,
boundary_condition right, boundary_condition right,
const std::vector<double> &alpha, double dx, const std::vector<double> &alpha, double dx,
int size) { int size) {
@ -78,10 +79,10 @@ void BTCSDiffusion::simulate1D(Eigen::Map<Eigen::VectorXd> &c, boundary_conditio
bool left_is_constant = (left.type == BTCSDiffusion::BC_CONSTANT); bool left_is_constant = (left.type == BTCSDiffusion::BC_CONSTANT);
bool right_is_constant = (right.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 // 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. // 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 // Then we will need ghost nodes. So this variable will give the count of
//nodes. // ghost nodes.
int bc_offset = !left_is_constant + !right_is_constant; int bc_offset = !left_is_constant + !right_is_constant;
; ;
@ -140,10 +141,8 @@ void BTCSDiffusion::simulate1D(Eigen::Map<Eigen::VectorXd> &c, boundary_conditio
x_vector = solver.solve(b_vector); x_vector = solver.solve(b_vector);
//fill solution back in place into =c= vector // write back result to input/output vector
for (int i = 0, j = i + !left_is_constant; i < c.size(); i++, j++) { c = x_vector.segment(!left_is_constant, c.size());
c[i] = x_vector[i + !left_is_constant];
}
} }
void BTCSDiffusion::setTimestep(double time_step) { void BTCSDiffusion::setTimestep(double time_step) {