Revert to commit d65fcd4.

This commit is contained in:
Max Luebke 2022-03-01 13:01:03 +01:00
parent fb5ee6431e
commit d0072f9f32
2 changed files with 69 additions and 73 deletions

View File

@ -77,74 +77,74 @@ void Diffusion::BTCSDiffusion::updateInternals() {
} }
} }
// void Diffusion::BTCSDiffusion::simulate_base( void Diffusion::BTCSDiffusion::simulate_base(
// DVectorRowMajor &c, Eigen::Map<const BCVectorRowMajor> &bc, DVectorRowMajor &c, Eigen::Map<const BCVectorRowMajor> &bc,
// Eigen::Map<const DVectorRowMajor> &alpha, double dx, double time_step, Eigen::Map<const DVectorRowMajor> &alpha, double dx, double time_step,
// int size, DVectorRowMajor &t0_c) { int size, DVectorRowMajor &t0_c) {
// // The sizes for matrix and vectors of the equation system is defined by the // The sizes for matrix and vectors of the equation system is defined by the
// // actual size of the input vector and if the system is (partially) closed. // actual size of the input vector and if the system is (partially) closed.
// // Then we will need ghost nodes. So this variable will give the count of // Then we will need ghost nodes. So this variable will give the count of
// // ghost nodes. // ghost nodes.
// // int bc_offset = !left_is_constant + !right_is_constant; // int bc_offset = !left_is_constant + !right_is_constant;
// // ; // ;
// // set sizes of private and yet allocated vectors // set sizes of private and yet allocated vectors
// // b_vector.resize(size + bc_offset); // b_vector.resize(size + bc_offset);
// // x_vector.resize(size + bc_offset); // x_vector.resize(size + bc_offset);
// // /* // /*
// // * Begin to solve the equation system using LU solver of Eigen. // * Begin to solve the equation system using LU solver of Eigen.
// // * // *
// // * But first fill the A matrix and b vector. // * But first fill the A matrix and b vector.
// // */ // */
// // // Set boundary condition for ghost nodes (for closed or flux system) or // // Set boundary condition for ghost nodes (for closed or flux system) or
// // outer // outer
// // // inlet nodes (constant boundary condition) // // inlet nodes (constant boundary condition)
// // A_matrix.resize(size + bc_offset, size + bc_offset); // A_matrix.resize(size + bc_offset, size + bc_offset);
// // 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] = // b_vector[0] =
// // (left_is_constant ? left.value : getBCFromFlux(left, c[0], alpha[0])); // (left_is_constant ? left.value : getBCFromFlux(left, c[0], alpha[0]));
// // A_matrix.insert(size + 1, size + 1) = 1; // A_matrix.insert(size + 1, size + 1) = 1;
// // b_vector[size + 1] = // b_vector[size + 1] =
// // (right_is_constant ? right.value // (right_is_constant ? right.value
// // : getBCFromFlux(right, c[size - 1], alpha[size - // : getBCFromFlux(right, c[size - 1], alpha[size -
// // 1])); // 1]));
// // Start filling the A matrix // Start filling the A matrix
// // =i= is used for equation system matrix and vector indexing // =i= is used for equation system matrix and vector indexing
// // and =j= for indexing of c,alpha and bc // and =j= for indexing of c,alpha and bc
// // for (int i = 1, j = i + !(left_is_constant); i < size - right_is_constant; // for (int i = 1, j = i + !(left_is_constant); i < size - right_is_constant;
// // i++, j++) { // i++, j++) {
// // // if current grid cell is considered as constant boundary conditon // // if current grid cell is considered as constant boundary conditon
// // if (bc[j].type == Diffusion::BC_CONSTANT) { // if (bc[j].type == Diffusion::BC_CONSTANT) {
// // A_matrix.insert(i, i) = 1; // A_matrix.insert(i, i) = 1;
// // b_vector[i] = bc[j].value; // b_vector[i] = bc[j].value;
// // continue; // continue;
// // } // }
// // double sx = (alpha[j] * 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. - 2. * sx;
// // A_matrix.insert(i, i - 1) = sx; // A_matrix.insert(i, i - 1) = sx;
// // A_matrix.insert(i, i + 1) = sx; // A_matrix.insert(i, i + 1) = sx;
// // b_vector[i] = -c[j]; // b_vector[i] = -c[j];
// // } // }
// fillMatrixFromRow(alpha, bc, size, dx, time_step); fillMatrixFromRow(alpha, bc, size, dx, time_step);
// fillVectorFromRowADI(c, alpha, bc, t0_c, size, dx, time_step); fillVectorFromRowADI(c, alpha, bc, t0_c, size, dx, time_step);
// solveLES(); solveLES();
// // write back result to input/output vector // write back result to input/output vector
// // c = x_vector.segment(!left_is_constant, c.size()); // c = x_vector.segment(!left_is_constant, c.size());
// } }
inline void Diffusion::BTCSDiffusion::reserveMemory(int size, inline void Diffusion::BTCSDiffusion::reserveMemory(int size,
int max_count_per_line) { int max_count_per_line) {
@ -159,13 +159,17 @@ inline void Diffusion::BTCSDiffusion::reserveMemory(int size,
void Diffusion::BTCSDiffusion::simulate1D( void Diffusion::BTCSDiffusion::simulate1D(
Eigen::Map<DVectorRowMajor> &c, Eigen::Map<const DVectorRowMajor> &alpha, Eigen::Map<DVectorRowMajor> &c, Eigen::Map<const DVectorRowMajor> &alpha,
Eigen::Map<const BCVectorRowMajor> &bc, const DVectorRowMajor &t0_c, Eigen::Map<const BCVectorRowMajor> &bc) {
int size, double dx, double time_step) {
int size = this->grid_cells[0];
double dx = this->deltas[0];
double time_step = this->time_step;
reserveMemory(size, BTCS_MAX_DEP_PER_CELL); reserveMemory(size, BTCS_MAX_DEP_PER_CELL);
fillMatrixFromRow(alpha.row(0), bc.row(0), size, dx, time_step); fillMatrixFromRow(alpha.row(0), bc.row(0), size, dx, time_step);
fillVectorFromRowADI(c, alpha, bc, t0_c, size, dx, time_step); fillVectorFromRowADI(c, alpha, bc, Eigen::VectorXd::Constant(size, 0), size,
dx, time_step);
solveLES(); solveLES();
@ -247,9 +251,8 @@ void Diffusion::BTCSDiffusion::simulate2D(
} }
inline void Diffusion::BTCSDiffusion::fillMatrixFromRow( inline void Diffusion::BTCSDiffusion::fillMatrixFromRow(
const DVectorRowMajor &alpha, const DVectorRowMajor &alpha, const BCVectorRowMajor &bc, int size,
const BCVectorRowMajor &bc, double dx, double time_step) {
int size, double dx, double time_step) {
Diffusion::boundary_condition left = bc[0]; Diffusion::boundary_condition left = bc[0];
Diffusion::boundary_condition right = bc[size - 1]; Diffusion::boundary_condition right = bc[size - 1];
@ -325,8 +328,7 @@ inline void Diffusion::BTCSDiffusion::fillVectorFromRowADI(
} }
if (!right_constant) { if (!right_constant) {
b_vector[b_size - 1] = b_vector[b_size - 1] = getBCFromFlux(right, c[size - 1], alpha[size - 1]);
getBCFromFlux(right, c[size - 1], alpha[size - 1]);
} }
} }
@ -341,9 +343,7 @@ void Diffusion::BTCSDiffusion::simulate(double *c, double *alpha,
Eigen::Map<const DVectorRowMajor> alpha_in(alpha, this->grid_cells[0]); Eigen::Map<const DVectorRowMajor> alpha_in(alpha, this->grid_cells[0]);
Eigen::Map<const BCVectorRowMajor> bc_in(bc, this->grid_cells[0]); Eigen::Map<const BCVectorRowMajor> bc_in(bc, this->grid_cells[0]);
simulate1D(c_in, alpha_in, bc_in, simulate1D(c_in, alpha_in, bc_in);
Eigen::VectorXd::Constant(this->grid_cells[0], 0),
this->grid_cells[0], this->deltas[0], this->time_step);
} }
if (this->grid_dim == 2) { if (this->grid_dim == 2) {
Eigen::Map<DMatrixRowMajor> c_in(c, this->grid_cells[1], Eigen::Map<DMatrixRowMajor> c_in(c, this->grid_cells[1],

View File

@ -115,16 +115,13 @@ private:
Eigen::RowMajor> Eigen::RowMajor>
BCVectorRowMajor; BCVectorRowMajor;
// void simulate_base(DVectorRowMajor &c, Eigen::Map<const BCVectorRowMajor> void simulate_base(DVectorRowMajor &c, Eigen::Map<const BCVectorRowMajor> &bc,
// &bc, Eigen::Map<const DVectorRowMajor> &alpha, double dx,
// Eigen::Map<const DVectorRowMajor> &alpha, double dx, double time_step, int size, DVectorRowMajor &t0_c);
// double time_step, int size, DVectorRowMajor &t0_c);
void simulate1D(Eigen::Map<DVectorRowMajor> &c, void simulate1D(Eigen::Map<DVectorRowMajor> &c,
Eigen::Map<const DVectorRowMajor> &alpha, Eigen::Map<const DVectorRowMajor> &alpha,
Eigen::Map<const BCVectorRowMajor> &bc, Eigen::Map<const BCVectorRowMajor> &bc);
const DVectorRowMajor &t0_c, int size, double dx,
double time_step);
void simulate2D(Eigen::Map<DMatrixRowMajor> &c, void simulate2D(Eigen::Map<DMatrixRowMajor> &c,
Eigen::Map<const DMatrixRowMajor> &alpha, Eigen::Map<const DMatrixRowMajor> &alpha,
@ -133,7 +130,6 @@ private:
inline void fillMatrixFromRow(const DVectorRowMajor &alpha, inline void fillMatrixFromRow(const DVectorRowMajor &alpha,
const BCVectorRowMajor &bc, int size, double dx, const BCVectorRowMajor &bc, int size, double dx,
double time_step); double time_step);
inline void fillVectorFromRowADI(const DVectorRowMajor &c, inline void fillVectorFromRowADI(const DVectorRowMajor &c,
const DVectorRowMajor alpha, const DVectorRowMajor alpha,
const BCVectorRowMajor &bc, const BCVectorRowMajor &bc,