1105
This commit is contained in:
parent
00dad33b0f
commit
8dff22c7bf
@ -13,6 +13,7 @@
|
|||||||
#include <Eigen/src/SparseLU/SparseLU.h>
|
#include <Eigen/src/SparseLU/SparseLU.h>
|
||||||
#include <Eigen/src/SparseQR/SparseQR.h>
|
#include <Eigen/src/SparseQR/SparseQR.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
void BTCS2D(int x, int y, std::vector<double> &c, std::vector<double> &alpha,
|
void BTCS2D(int x, int y, std::vector<double> &c, std::vector<double> &alpha,
|
||||||
double timestep) {
|
double timestep) {
|
||||||
@ -34,7 +35,10 @@ void BTCS2D(int x, int y, std::vector<double> &c, std::vector<double> &alpha,
|
|||||||
double sx = (alpha[i * x + j] * timestep) / (dx * dx);
|
double sx = (alpha[i * x + j] * timestep) / (dx * dx);
|
||||||
double sy = (alpha[i * x + j] * timestep) / (dy * dy);
|
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 + 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));
|
tripletList.push_back(T(A_line, i * x + (j + 1), sx));
|
||||||
@ -47,7 +51,7 @@ void BTCS2D(int x, int y, std::vector<double> &c, std::vector<double> &alpha,
|
|||||||
|
|
||||||
std::cout << b << std::endl;
|
std::cout << b << std::endl;
|
||||||
|
|
||||||
Eigen::SparseMatrix<double> A(size, (x * y) - 4);
|
Eigen::SparseMatrix<double> A(size, x*y);
|
||||||
A.setFromTriplets(tripletList.begin(), tripletList.end());
|
A.setFromTriplets(tripletList.begin(), tripletList.end());
|
||||||
|
|
||||||
Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
|
Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
|
||||||
|
|||||||
16
src/main.cpp
16
src/main.cpp
@ -7,16 +7,16 @@ using namespace std;
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int x = 5;
|
int x = 4;
|
||||||
int y = 5;
|
int y = 4;
|
||||||
|
|
||||||
std::vector<double> alpha(x * y, -1.5 * pow(10, -2));
|
std::vector<double> alpha(x * y, 1 * pow(10, -9));
|
||||||
std::vector<double> input(x * y, 0);
|
std::vector<double> input(x * y, 1 * std::pow(10,-6));
|
||||||
input[x + 1] = 5.55 * std::pow(10, -6);
|
input[x + 1] = 5 * std::pow(10, -6);
|
||||||
input[x + 2] = 5.5556554 * std::pow(10, -6);
|
// input[x + 2] = 5.5556554 * std::pow(10, -6);
|
||||||
input[x + 3] = 5.234564213 * 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user