mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-14 01:48:23 +01:00
Merge branch 'eigen_datatructures' into 2D
This commit is contained in:
commit
93a84fa624
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <Eigen/SparseLU>
|
#include <Eigen/SparseLU>
|
||||||
|
|
||||||
|
#include <Eigen/src/Core/Map.h>
|
||||||
|
#include <Eigen/src/Core/Matrix.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -68,7 +70,8 @@ void BTCSDiffusion::updateInternals() {
|
|||||||
bc.resize(cells, {BTCSDiffusion::BC_CLOSED, 0});
|
bc.resize(cells, {BTCSDiffusion::BC_CLOSED, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
void BTCSDiffusion::simulate1D(Eigen::Map<Eigen::VectorXd> &c,
|
||||||
|
boundary_condition left,
|
||||||
boundary_condition right,
|
boundary_condition right,
|
||||||
const std::vector<double> &alpha, double dx,
|
const std::vector<double> &alpha, double dx,
|
||||||
int size) {
|
int size) {
|
||||||
@ -78,8 +81,8 @@ void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
|||||||
|
|
||||||
// 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 ghost
|
// Then we will need ghost nodes. So this variable will give the count of
|
||||||
//nodes.
|
// ghost nodes.
|
||||||
int bc_offset = !left_is_constant + !right_is_constant;
|
int bc_offset = !left_is_constant + !right_is_constant;
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -131,10 +134,8 @@ void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
|||||||
|
|
||||||
solveLES();
|
solveLES();
|
||||||
|
|
||||||
//fill solution back in place into =c= vector
|
// write back result to input/output vector
|
||||||
for (int i = 0, j = i + !left_is_constant; i < c.size(); i++, j++) {
|
c = x_vector.segment(!left_is_constant, c.size());
|
||||||
c[i] = x_vector[i + !left_is_constant];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTCSDiffusion::setTimestep(double time_step) {
|
void BTCSDiffusion::setTimestep(double time_step) {
|
||||||
@ -144,7 +145,9 @@ void BTCSDiffusion::setTimestep(double time_step) {
|
|||||||
void BTCSDiffusion::simulate(std::vector<double> &c,
|
void BTCSDiffusion::simulate(std::vector<double> &c,
|
||||||
const std::vector<double> &alpha) {
|
const std::vector<double> &alpha) {
|
||||||
if (this->grid_dim == 1) {
|
if (this->grid_dim == 1) {
|
||||||
simulate1D(c, bc[0], bc[grid_cells[0] + 1], alpha, this->deltas[0],
|
assert(c.size() == grid_cells[0]);
|
||||||
|
Eigen::Map<Eigen::VectorXd> c_in(c.data(), this->grid_cells[0]);
|
||||||
|
simulate1D(c_in, bc[0], bc[grid_cells[0] + 1], alpha, this->deltas[0],
|
||||||
this->grid_cells[0]);
|
this->grid_cells[0]);
|
||||||
}
|
}
|
||||||
if (this->grid_dim == 2) {
|
if (this->grid_dim == 2) {
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
#define BTCSDIFFUSION_H_
|
#define BTCSDIFFUSION_H_
|
||||||
|
|
||||||
#include <Eigen/Sparse>
|
#include <Eigen/Sparse>
|
||||||
|
#include <Eigen/src/Core/Map.h>
|
||||||
|
#include <Eigen/src/Core/Matrix.h>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -135,7 +137,7 @@ private:
|
|||||||
} boundary_condition;
|
} boundary_condition;
|
||||||
typedef Eigen::Triplet<double> T;
|
typedef Eigen::Triplet<double> T;
|
||||||
|
|
||||||
void simulate1D(std::vector<double> &c, boundary_condition left,
|
void simulate1D(Eigen::Map<Eigen::VectorXd> &c, boundary_condition left,
|
||||||
boundary_condition right, const std::vector<double> &alpha,
|
boundary_condition right, const std::vector<double> &alpha,
|
||||||
double dx, int size);
|
double dx, int size);
|
||||||
void simulate2D(std::vector<double> &c);
|
void simulate2D(std::vector<double> &c);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user