Commit c8c12f4a authored by Leon Merten Lohse's avatar Leon Merten Lohse
Browse files

check dimensions

parent e4018d28
Pipeline #235984 passed with stage
in 1 minute and 46 seconds
......@@ -124,15 +124,13 @@ class Solver2D {
fp = std::move(f);
f = compute_f(F, dz);
u = compute_step(f, bl, br);
u = compute_step(bl, br);
return u;
}
private:
const array_1D compute_step(const Eigen::Ref<const array_1D> &f,
const scalar bl,
const scalar br) const {
const array_1D compute_step(const scalar bl, const scalar br) const {
// _p : i
// _ : i+1
......@@ -231,14 +229,13 @@ class Solver2DSym {
fp = std::move(f);
f = compute_f(F, dz);
u = compute_step(f, br);
u = compute_step(br);
return u;
}
private:
const array_1D compute_step(const Eigen::Ref<const array_1D> &f,
const scalar br) const {
const array_1D compute_step(const scalar br) const {
size_t n = up.size()-1;
// setup tridiagonal n x n matrix M = tridiag(a,b,c) and rhs r
......@@ -337,6 +334,14 @@ class Solver3D {
void initialize(const Eigen::Ref<const array_2D> &F0,
const Eigen::Ref<const array_2D> &u0 ) {
if (F0.rows() != nx || F0.cols() != ny) {
throw std::runtime_error("F0 shape mismatch");
}
if (u0.rows() != nx || u0.cols() != ny) {
throw std::runtime_error("u0 shape mismatch");
}
f = compute_f(F0, dz);
u = u0;
}
......@@ -346,17 +351,21 @@ class Solver3D {
const Eigen::Ref<const array_1D> &bxr,
const Eigen::Ref<const array_1D> &byl,
const Eigen::Ref<const array_1D> &byr) {
if (F.rows() != nx || F.cols() != ny) {
throw std::runtime_error("F shape mismatch");
}
up = std::move(u);
fp = std::move(f);
f = compute_f(F, dz);
u = compute_step(f, bxl, bxr, byl, byr);
u = compute_step(bxl, bxr, byl, byr);
return u;
}
private:
const array_2D compute_step(const Eigen::Ref<const array_2D> &f,
const array_2D compute_step(
const Eigen::Ref<const array_1D> &bxl,
const Eigen::Ref<const array_1D> &bxr,
const Eigen::Ref<const array_1D> &byl,
......@@ -367,8 +376,8 @@ class Solver3D {
// coordinate system:
// numpy (z,y,x), eigen (rows, cols): x <-> cols, y <-> rows
size_t nx_in = up.rows() - 2;
size_t ny_in = up.cols() - 2;
const size_t nx_in = up.rows() - 2;
const size_t ny_in = up.cols() - 2;
// first halfstep
array_2D uhalf(up.rows(), up.cols());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment