From 04cdadc23d259cd3aa31e52f24b7f58e1dd6e3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Mon, 9 May 2022 09:39:46 +0200 Subject: [PATCH 1/2] Cleanup headers --- src/BTCSDiffusion.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/BTCSDiffusion.cpp b/src/BTCSDiffusion.cpp index 240d76a..d7ec8c0 100644 --- a/src/BTCSDiffusion.cpp +++ b/src/BTCSDiffusion.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -24,8 +25,6 @@ #define omp_get_thread_num() 0 #endif -#include - constexpr int BTCS_MAX_DEP_PER_CELL = 3; constexpr int BTCS_2D_DT_SIZE = 2; Diffusion::BTCSDiffusion::BTCSDiffusion(unsigned int dim) : grid_dim(dim) { @@ -185,7 +184,7 @@ auto Diffusion::BTCSDiffusion::calc_t0_c(const DMatrixRowMajor &c, for (int j = 0; j < n_cols; j++) { boundary_condition tmp_bc = bc(0, j + 1); - if (tmp_bc.type == Diffusion::BC_CLOSED){ + if (tmp_bc.type == Diffusion::BC_CLOSED) { continue; } From 9c3c478c63a87ed5b70d68535efed9cd2cf33db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Mon, 9 May 2022 09:43:57 +0200 Subject: [PATCH 2/2] Added comparison to machine epsilon when filling vector --- src/BTCSDiffusion.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/BTCSDiffusion.cpp b/src/BTCSDiffusion.cpp index d7ec8c0..5413a63 100644 --- a/src/BTCSDiffusion.cpp +++ b/src/BTCSDiffusion.cpp @@ -25,6 +25,8 @@ #define omp_get_thread_num() 0 #endif +#define DOUBLE_MACHINE_EPSILON 1.93e-34 + constexpr int BTCS_MAX_DEP_PER_CELL = 3; constexpr int BTCS_2D_DT_SIZE = 2; Diffusion::BTCSDiffusion::BTCSDiffusion(unsigned int dim) : grid_dim(dim) { @@ -302,7 +304,8 @@ void Diffusion::BTCSDiffusion::fillVectorFromRow( } double t0_c_j = time_step * alpha[j] * (t0_c[j] / (dx * dx)); - b_vector[j + 1] = -c[j] - t0_c_j; + double value = (c[j] < DOUBLE_MACHINE_EPSILON ? .0 : c[j]); + b_vector[j + 1] = -value - t0_c_j; } // this is not correct currently.We will fix this when we are able to define