Fix uncommenting solving function.
Now x is actually solved with the help of the equation system.
This commit is contained in:
parent
f6dbc3fb16
commit
6308cd52af
@ -112,11 +112,13 @@ void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
|||||||
A_matrix.reserve(Eigen::VectorXi::Constant(size + bc_offset, 3));
|
A_matrix.reserve(Eigen::VectorXi::Constant(size + bc_offset, 3));
|
||||||
|
|
||||||
A_matrix.insert(0, 0) = 1;
|
A_matrix.insert(0, 0) = 1;
|
||||||
b_vector[0] = (left_is_constant ? left.value : getBCFromFlux(left, c[0], alpha[0]));
|
b_vector[0] =
|
||||||
|
(left_is_constant ? left.value : getBCFromFlux(left, c[0], alpha[0]));
|
||||||
|
|
||||||
A_matrix.insert((size + bc_offset) - 1, (size + bc_offset) - 1) = 1;
|
A_matrix.insert((size + bc_offset) - 1, (size + bc_offset) - 1) = 1;
|
||||||
b_vector[size + bc_offset - 1] =
|
b_vector[size + bc_offset - 1] =
|
||||||
(right_is_constant ? right.value : getBCFromFlux(right, c[size - 1], alpha[size - 1]));
|
(right_is_constant ? right.value
|
||||||
|
: getBCFromFlux(right, c[size - 1], alpha[size - 1]));
|
||||||
|
|
||||||
// A_matrix.insert(0, 0) = 1;
|
// A_matrix.insert(0, 0) = 1;
|
||||||
// A_matrix.insert(size + 1, size + 1) = 1;
|
// A_matrix.insert(size + 1, size + 1) = 1;
|
||||||
@ -141,7 +143,7 @@ std::cout << b_vector << "\n" << A_matrix << std::endl;
|
|||||||
|
|
||||||
std::cout << solver.lastErrorMessage() << std::endl;
|
std::cout << solver.lastErrorMessage() << std::endl;
|
||||||
|
|
||||||
// x_vector = solver.solve(b_vector);
|
x_vector = solver.solve(b_vector);
|
||||||
|
|
||||||
std::cout << std::setprecision(10) << x_vector << std::endl << std::endl;
|
std::cout << std::setprecision(10) << x_vector << std::endl << std::endl;
|
||||||
|
|
||||||
@ -165,7 +167,8 @@ void BTCSDiffusion::simulate(std::vector<double> &c,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double BTCSDiffusion::getBCFromFlux(boundary_condition bc, double neighbor_c,
|
inline double BTCSDiffusion::getBCFromFlux(boundary_condition bc,
|
||||||
|
double neighbor_c,
|
||||||
double neighbor_alpha) {
|
double neighbor_alpha) {
|
||||||
|
|
||||||
double val;
|
double val;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// loop 100 times
|
// loop 100 times
|
||||||
// output is currently generated by the method itself
|
// output is currently generated by the method itself
|
||||||
for (int i = 0; i < 1; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
diffu.simulate(field, alpha);
|
diffu.simulate(field, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user