From 5bd40afa4a0a255a0283f7c6acbb311ee199016f Mon Sep 17 00:00:00 2001
From: ryan-bournes <88587235+ryan-bournes@users.noreply.github.com>
Date: Tue, 6 Feb 2024 15:59:40 +0000
Subject: [PATCH] Fix Ubuntu-System-CI (#357)

---
 test/unit/core/diffusion_test.cc | 22 ++++++++---------
 util/valgrind-bdm.supp           | 41 ++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/test/unit/core/diffusion_test.cc b/test/unit/core/diffusion_test.cc
index 5cfcc43bf..1da466a8a 100644
--- a/test/unit/core/diffusion_test.cc
+++ b/test/unit/core/diffusion_test.cc
@@ -974,8 +974,8 @@ TEST(DiffusionTest, EulerDirichletBoundaries) {
   double simulation_time_step{0.1};
   auto set_param = [](auto* param) {
     param->bound_space = Param::BoundSpaceMode::kClosed;
-    param->min_bound = -100;
-    param->max_bound = 100;
+    param->min_bound = -50;
+    param->max_bound = 50;
     param->diffusion_boundary_condition = "Dirichlet";
   };
   Simulation simulation(TEST_NAME, set_param);
@@ -984,7 +984,7 @@ TEST(DiffusionTest, EulerDirichletBoundaries) {
 
   double decay_coef = 0.0;
   double diff_coef = 100.0;
-  int res = 20;
+  int res = 10;
   // Depleting substance is fixed, i.e. no diff and no decay
   auto* dgrid = new EulerGrid(0, "Kalium", diff_coef, decay_coef, res);
 
@@ -996,7 +996,7 @@ TEST(DiffusionTest, EulerDirichletBoundaries) {
   rm->AddContinuum(dgrid);
 
   // Simulate diffusion / exponential decay for `tot` timesteps
-  int tot = 100000;  // ToDo This should probably be lower for final version
+  int tot = 5000;  // ToDo This should probably be lower for final version
   for (int t = 0; t < tot; t++) {
     dgrid->Diffuse(simulation_time_step);
   }
@@ -1016,8 +1016,8 @@ TEST(DiffusionTest, EulerNeumannZeroBoundaries) {
   double simulation_time_step{0.1};
   auto set_param = [](auto* param) {
     param->bound_space = Param::BoundSpaceMode::kClosed;
-    param->min_bound = -100;
-    param->max_bound = 100;
+    param->min_bound = -50;
+    param->max_bound = 50;
     param->diffusion_boundary_condition = "Neumann";
   };
   Simulation simulation(TEST_NAME, set_param);
@@ -1026,12 +1026,12 @@ TEST(DiffusionTest, EulerNeumannZeroBoundaries) {
 
   double decay_coef = 0.0;
   double diff_coef = 10.0;
-  int res = 20;
+  int res = 10;
   double init = 1e5;
   std::vector<Real3> sources;
   sources.push_back({0, 0, 0});
-  sources.push_back({50, 50, 50});
-  sources.push_back({-50, -50, -50});
+  sources.push_back({49, 49, 49});
+  sources.push_back({-49, -49, -49});
 
   // Test multiple positions for the source
   for (size_t s = 0; s < sources.size(); s++) {
@@ -1045,7 +1045,7 @@ TEST(DiffusionTest, EulerNeumannZeroBoundaries) {
     rm->AddContinuum(dgrid);
 
     // Simulate diffusion / exponential decay for `tot` timesteps
-    int tot = 10000;
+    int tot = 1000;
     for (int t = 0; t < tot; t++) {
       dgrid->Diffuse(simulation_time_step);
     }
@@ -1104,7 +1104,7 @@ TEST(DiffusionTest, EulerNeumannNonZeroBoundaries) {
   // ----------------------------------------------------------
 
   double intermediate_concentration_backup = 0.0;
-  int tot = 10000;
+  int tot = 1000;
   for (int t = 0; t < tot; t++) {
     dgrid->Diffuse(simulation_time_step);
     conc = dgrid->GetAllConcentrations();  // get current concentrations.
diff --git a/util/valgrind-bdm.supp b/util/valgrind-bdm.supp
index cc3956d2a..f102bf758 100644
--- a/util/valgrind-bdm.supp
+++ b/util/valgrind-bdm.supp
@@ -529,3 +529,44 @@
    fun:__cxa_finalize
    ...
 }
+
+######### Suppress Memory Leak for Ubuntu
+
+{
+   ignore_memory_leak_ubuntu_20_04
+   Memcheck:Leak
+   match-leak-kinds: possible
+   fun:calloc
+   fun:allocate_dtv
+   fun:_dl_allocate_tls
+   fun:allocate_stack
+   fun:pthread_create@@GLIBC_2.2.5
+   fun:launch
+   fun:wake_or_launch
+   fun:_ZN3tbb8internal3rml14private_server9wake_someEi
+   fun:propagate_chain_reaction
+   fun:_ZN3tbb8internal3rml14private_worker3runEv
+   fun:_ZN3tbb8internal3rml14private_worker14thread_routineEPv
+   fun:start_thread
+   fun:clone
+}
+
+{
+   ignore_memory_leak_ubuntu_22_04
+   Memcheck:Leak
+   match-leak-kinds: possible
+   fun:calloc
+   fun:calloc
+   fun:allocate_dtv
+   fun:_dl_allocate_tls
+   fun:allocate_stack
+   fun:pthread_create@@GLIBC_2.34
+   fun:launch
+   fun:wake_or_launch
+   fun:_ZN3tbb8internal3rml14private_server9wake_someEi
+   fun:propagate_chain_reaction
+   fun:_ZN3tbb8internal3rml14private_worker3runEv
+   fun:_ZN3tbb8internal3rml14private_worker14thread_routineEPv
+   fun:start_thread
+   fun:clone
+}