mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
Refactor loop of filling of matrix A.
- make now use of another variable 'j' for c, bc and alpha indexing instead of always incrementing with =i= and the negation of =left_is_constant=
This commit is contained in:
parent
e3d10336a9
commit
e2707858c1
@ -133,21 +133,21 @@ void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
||||
// A_matrix.insert(0, 0) = 1;
|
||||
// A_matrix.insert(size + 1, size + 1) = 1;
|
||||
|
||||
for (int i = 1; i < size - right_is_constant; i++) {
|
||||
if (bc[i + !(left_is_constant)].type == BTCSDiffusion::BC_CONSTANT) {
|
||||
A_matrix.insert(i,i) = 1;
|
||||
b_vector[i] = bc[i + !(left_is_constant)].value;
|
||||
for (int i = 1, j = i + !(left_is_constant); i < size - right_is_constant;
|
||||
i++, j++) {
|
||||
if (bc[j].type == BTCSDiffusion::BC_CONSTANT) {
|
||||
A_matrix.insert(i, i) = 1;
|
||||
b_vector[i] = bc[j].value;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
double sx = (alpha[i + !(left_is_constant)] * time_step) / (dx * dx);
|
||||
double sx = (alpha[j] * time_step) / (dx * dx);
|
||||
|
||||
A_matrix.insert(i, i) = -1. - 2. * sx;
|
||||
A_matrix.insert(i, i - 1) = sx;
|
||||
A_matrix.insert(i, i + 1) = sx;
|
||||
|
||||
b_vector[i] = -c[i + !(left_is_constant)];
|
||||
b_vector[i] = -c[j];
|
||||
}
|
||||
|
||||
Eigen::SparseLU<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user