remove bug because of Matrix2d and Vector2d
This commit is contained in:
parent
542601fdcd
commit
99925dbd4f
@ -1,6 +1,8 @@
|
||||
#include <tug/Simulation.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
Grid grid = Grid(20,20);
|
||||
|
||||
Boundary bc = Boundary(grid, BC_TYPE_CONSTANT);
|
||||
@ -8,4 +10,6 @@ int main(int argc, char *argv[]) {
|
||||
Simulation simulation = Simulation(grid, bc, FTCS_APPROACH);
|
||||
|
||||
simulation.run();
|
||||
|
||||
|
||||
}
|
||||
@ -25,21 +25,21 @@ class Grid {
|
||||
*
|
||||
* @param concentrations
|
||||
*/
|
||||
void setConcentrations(Matrix2d concentrations);
|
||||
void setConcentrations(MatrixXd concentrations);
|
||||
|
||||
/**
|
||||
* @brief Get the Concentrations object
|
||||
*
|
||||
* @return auto
|
||||
*/
|
||||
Matrix2d getConcentrations();
|
||||
MatrixXd getConcentrations();
|
||||
|
||||
/**
|
||||
* @brief Set the Alpha object
|
||||
*
|
||||
* @param alpha
|
||||
*/
|
||||
void setAlpha(Matrix2d alpha);
|
||||
void setAlpha(MatrixXd alpha);
|
||||
|
||||
/**
|
||||
* @brief Set the Alpha object
|
||||
@ -47,11 +47,11 @@ class Grid {
|
||||
* @param alpha_x
|
||||
* @param alpha_y
|
||||
*/
|
||||
void setAlpha(Matrix2d alpha_x, Matrix2d alpha_y);
|
||||
void setAlpha(MatrixXd alpha_x, MatrixXd alpha_y);
|
||||
|
||||
Matrix2d getAlphaX();
|
||||
MatrixXd getAlphaX();
|
||||
|
||||
Matrix2d getAlphaY();
|
||||
MatrixXd getAlphaY();
|
||||
|
||||
int getDim();
|
||||
|
||||
@ -77,7 +77,7 @@ class Grid {
|
||||
int domain_row;
|
||||
double delta_col;
|
||||
double delta_row;
|
||||
Matrix2d concentrations;
|
||||
Matrix2d alpha_x;
|
||||
Matrix2d alpha_y;
|
||||
MatrixXd concentrations;
|
||||
MatrixXd alpha_x;
|
||||
MatrixXd alpha_y;
|
||||
};
|
||||
@ -10,13 +10,14 @@ Boundary::Boundary(Grid &grid, BC_TYPE type) : grid(grid) {
|
||||
|
||||
if (type == BC_TYPE_CONSTANT) {
|
||||
if (grid.getDim() == 1) {
|
||||
this->left = VectorXd::Constant(1, 1, 1);
|
||||
this->right = VectorXd::Constant(1, 1, 1);
|
||||
this->left = VectorXd::Constant(1, 1);
|
||||
this->right = VectorXd::Constant(1, 1);
|
||||
} else if (grid.getDim() == 2) {
|
||||
this->left = VectorXd::Constant(grid.getRow(), 1, 1);
|
||||
this->right = VectorXd::Constant(grid.getRow(), 1, 1);
|
||||
this->top = VectorXd::Constant(1, grid.getCol(), 1);
|
||||
this->bottom = VectorXd::Constant(1, grid.getCol(), 1);
|
||||
this->left = VectorXd::Constant(grid.getRow(), 1);
|
||||
this->right = VectorXd::Constant(grid.getRow(), 1);
|
||||
this->top = VectorXd::Constant(grid.getCol(), 1);
|
||||
this->bottom = VectorXd::Constant(grid.getCol(), 1);
|
||||
|
||||
} else {
|
||||
throw invalid_argument("Dimension must be 1 or 2!");
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include <tug/Boundary.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
auto calc_alpha_intercell(double alpha1, double alpha2, bool useHarmonic = false) {
|
||||
if (useHarmonic) {
|
||||
@ -17,7 +17,7 @@ auto FTCS_constant(Grid &grid, Boundary &bc, double timestep) {
|
||||
|
||||
// Matrix with concentrations at time t+1
|
||||
// TODO profiler / only use 2 matrices
|
||||
Matrix2d concentrations_t1 = Matrix2d(rowMax, colMax);
|
||||
MatrixXd concentrations_t1 = MatrixXd(rowMax, colMax);
|
||||
|
||||
// inner cells
|
||||
for (int row = 1; row < rowMax-1; row++) {
|
||||
|
||||
24
src/Grid.cpp
24
src/Grid.cpp
@ -1,11 +1,12 @@
|
||||
#include <tug/Grid.hpp>
|
||||
#include <iostream>
|
||||
|
||||
Grid::Grid(int col) {
|
||||
this->col = col;
|
||||
|
||||
this->dim = 1;
|
||||
this->concentrations = Matrix2d::Constant(1, col, 1);
|
||||
this->alpha_x = Matrix2d::Constant(1, col, 1);
|
||||
this->concentrations = MatrixXd::Constant(1, col, 1);
|
||||
this->alpha_x = MatrixXd::Constant(1, col, 1);
|
||||
}
|
||||
|
||||
Grid::Grid(int row, int col) {
|
||||
@ -13,33 +14,34 @@ Grid::Grid(int row, int col) {
|
||||
this->col = col;
|
||||
|
||||
this->dim = 2;
|
||||
this->concentrations = Matrix2d::Constant(row, col, 1);
|
||||
this->alpha_x = Matrix2d::Constant(row, col, 1);
|
||||
this->alpha_y = Matrix2d::Constant(row, col, 1);
|
||||
this->concentrations = MatrixXd::Constant(row, col, 1);
|
||||
this->alpha_x = MatrixXd::Constant(row, col, 1);
|
||||
this->alpha_y = MatrixXd::Constant(row, col, 1);
|
||||
|
||||
}
|
||||
|
||||
void Grid::setConcentrations(Matrix2d concentrations) {
|
||||
void Grid::setConcentrations(MatrixXd concentrations) {
|
||||
this->concentrations = concentrations;
|
||||
}
|
||||
|
||||
Matrix2d Grid::getConcentrations() {
|
||||
MatrixXd Grid::getConcentrations() {
|
||||
return this->concentrations;
|
||||
}
|
||||
|
||||
void Grid::setAlpha(Matrix2d alpha) {
|
||||
void Grid::setAlpha(MatrixXd alpha) {
|
||||
this->alpha_x = alpha;
|
||||
}
|
||||
|
||||
void Grid::setAlpha(Matrix2d alpha_x, Matrix2d alpha_y) {
|
||||
void Grid::setAlpha(MatrixXd alpha_x, MatrixXd alpha_y) {
|
||||
this->alpha_x = alpha_x;
|
||||
this->alpha_y = alpha_y;
|
||||
}
|
||||
|
||||
Matrix2d Grid::getAlphaX() {
|
||||
MatrixXd Grid::getAlphaX() {
|
||||
return this->alpha_x;
|
||||
}
|
||||
|
||||
Matrix2d Grid::getAlphaY() {
|
||||
MatrixXd Grid::getAlphaY() {
|
||||
return this->alpha_y;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user