mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-14 01:48:23 +01:00
Refactor code and rebase code to solve LES into function.
- Also created new condition if dimension is 2 @ simulate
This commit is contained in:
parent
83d11d44e1
commit
55adc41e61
@ -129,14 +129,7 @@ void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
|||||||
b_vector[i] = -c[j];
|
b_vector[i] = -c[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
// start to solve
|
solveLES();
|
||||||
Eigen::SparseLU<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
|
|
||||||
solver;
|
|
||||||
solver.analyzePattern(A_matrix);
|
|
||||||
|
|
||||||
solver.factorize(A_matrix);
|
|
||||||
|
|
||||||
x_vector = solver.solve(b_vector);
|
|
||||||
|
|
||||||
//fill solution back in place into =c= vector
|
//fill solution back in place into =c= vector
|
||||||
for (int i = 0, j = i + !left_is_constant; i < c.size(); i++, j++) {
|
for (int i = 0, j = i + !left_is_constant; i < c.size(); i++, j++) {
|
||||||
@ -154,6 +147,9 @@ void BTCSDiffusion::simulate(std::vector<double> &c,
|
|||||||
simulate1D(c, bc[0], bc[grid_cells[0] + 1], alpha, this->deltas[0],
|
simulate1D(c, bc[0], bc[grid_cells[0] + 1], alpha, this->deltas[0],
|
||||||
this->grid_cells[0]);
|
this->grid_cells[0]);
|
||||||
}
|
}
|
||||||
|
if (this->grid_dim == 2) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double BTCSDiffusion::getBCFromFlux(boundary_condition bc,
|
inline double BTCSDiffusion::getBCFromFlux(boundary_condition bc,
|
||||||
@ -179,3 +175,14 @@ void BTCSDiffusion::setBoundaryCondition(int index, bctype type, double value) {
|
|||||||
bc[index].type = type;
|
bc[index].type = type;
|
||||||
bc[index].value = value;
|
bc[index].value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void BTCSDiffusion::solveLES() {
|
||||||
|
// start to solve
|
||||||
|
Eigen::SparseLU<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
|
||||||
|
solver;
|
||||||
|
solver.analyzePattern(A_matrix);
|
||||||
|
|
||||||
|
solver.factorize(A_matrix);
|
||||||
|
|
||||||
|
x_vector = solver.solve(b_vector);
|
||||||
|
}
|
||||||
|
|||||||
@ -142,6 +142,7 @@ private:
|
|||||||
void simulate3D(std::vector<double> &c);
|
void simulate3D(std::vector<double> &c);
|
||||||
inline double getBCFromFlux(boundary_condition bc, double nearest_value,
|
inline double getBCFromFlux(boundary_condition bc, double nearest_value,
|
||||||
double neighbor_alpha);
|
double neighbor_alpha);
|
||||||
|
inline void solveLES();
|
||||||
void updateInternals();
|
void updateInternals();
|
||||||
|
|
||||||
std::vector<boundary_condition> bc;
|
std::vector<boundary_condition> bc;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user