diff --git a/src/diffusion.cpp b/src/diffusion.cpp index cda6f4b..52c71e0 100644 --- a/src/diffusion.cpp +++ b/src/diffusion.cpp @@ -13,6 +13,7 @@ #include #include #include +#include void BTCS2D(int x, int y, std::vector &c, std::vector &alpha, double timestep) { @@ -34,7 +35,10 @@ void BTCS2D(int x, int y, std::vector &c, std::vector &alpha, double sx = (alpha[i * x + j] * timestep) / (dx * dx); double sy = (alpha[i * x + j] * timestep) / (dy * dy); - tripletList.push_back(T(A_line, i * x + j, (1 + 2 * sx + 2 * sy))); + tripletList.push_back(T(A_line, i * x + j, (1. + 2. * sx + 2. * sy))); + + std::cout << sx << std::endl; + tripletList.push_back(T(A_line, (i - 1) * x + j, sy)); tripletList.push_back(T(A_line, (i + 1) * x + j, sy)); tripletList.push_back(T(A_line, i * x + (j + 1), sx)); @@ -47,7 +51,7 @@ void BTCS2D(int x, int y, std::vector &c, std::vector &alpha, std::cout << b << std::endl; - Eigen::SparseMatrix A(size, (x * y) - 4); + Eigen::SparseMatrix A(size, x*y); A.setFromTriplets(tripletList.begin(), tripletList.end()); Eigen::SparseQR, Eigen::COLAMDOrdering> diff --git a/src/main.cpp b/src/main.cpp index 8269d9b..be66bcc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,16 +7,16 @@ using namespace std; int main(int argc, char *argv[]) { - int x = 5; - int y = 5; + int x = 4; + int y = 4; - std::vector alpha(x * y, -1.5 * pow(10, -2)); - std::vector input(x * y, 0); - input[x + 1] = 5.55 * std::pow(10, -6); - input[x + 2] = 5.5556554 * std::pow(10, -6); - input[x + 3] = 5.234564213 * std::pow(10, -6); + std::vector alpha(x * y, 1 * pow(10, -9)); + std::vector input(x * y, 1 * std::pow(10,-6)); + input[x + 1] = 5 * std::pow(10, -6); + // input[x + 2] = 5.5556554 * std::pow(10, -6); + // input[x + 3] = 5.234564213 * std::pow(10, -6); - BTCS2D(x, y, input, alpha, 10.); + BTCS2D(x, y, input, alpha, 1.); return 0; }