From cfb6343466bdeccabd1d18ecb8435899e0ede780 Mon Sep 17 00:00:00 2001 From: Alex Zimmerman Date: Fri, 22 Jul 2016 11:49:29 +0200 Subject: [PATCH 1/2] The 'max number of cells' parameter in the refinement section does not work for my simple code that uses the poisson problem interface. I have not found the root cause. This commit is a quick work-around that instead adds a new parameter max_cells to the pi-DoMUS interface. Such a parameter seems at least as relevant as already existing parameters such as 'kelly threshold' and 'max iterations', so maybe this is actually what we want. This 'work-around' commit violates the concept of 'do not repeat yourself', so I would call this an open issue. --- include/pidomus.h | 1 + source/pidomus_mesh_refinement.cc | 8 ++++++++ source/pidomus_parameters.cc | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/include/pidomus.h b/include/pidomus.h index 6e302718..491329ca 100644 --- a/include/pidomus.h +++ b/include/pidomus.h @@ -442,6 +442,7 @@ class piDoMUS : public ParameterAcceptor std::vector relevant_partitioning; bool adaptive_refinement; + unsigned int max_cells; const bool we_are_parallel; bool use_direct_solver; diff --git a/source/pidomus_mesh_refinement.cc b/source/pidomus_mesh_refinement.cc index e9be375a..3d953834 100644 --- a/source/pidomus_mesh_refinement.cc +++ b/source/pidomus_mesh_refinement.cc @@ -82,6 +82,14 @@ piDoMUS::solver_should_restart(const double t, << max_kelly << " > " << kelly_threshold << std::endl << "######################################\n"; + unsigned int n_active_cells=triangulation->n_active_cells(); + unsigned int max_cells=this->max_cells; + if ((max_cells > 0) & (n_active_cells > max_cells)) + { + pcout << "Maximum number of active cells has already been exceeded." << std::endl; + signals.end_solver_should_restart(); + return false; + } pgr.mark_cells(estimated_error_per_cell, *triangulation); refine_and_transfer_solutions(solution, diff --git a/source/pidomus_parameters.cc b/source/pidomus_parameters.cc index c5112ea3..91bc8c12 100644 --- a/source/pidomus_parameters.cc +++ b/source/pidomus_parameters.cc @@ -42,6 +42,12 @@ declare_parameters (ParameterHandler &prm) "true", Patterns::Bool()); + add_parameter( prm, + &max_cells, + "Max number of cells", + "0", + Patterns::Integer (0)); + add_parameter( prm, &verbose, "Print some useful informations about processes", From 296be93de652b20d972d2aa94e6d9e1beaaf5326 Mon Sep 17 00:00:00 2001 From: Alex Zimmerman Date: Thu, 28 Jul 2016 13:59:27 +0200 Subject: [PATCH 2/2] Moved the return statement up so that the Kellythreshold message doesn't repeat at each time step. --- source/pidomus_mesh_refinement.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/pidomus_mesh_refinement.cc b/source/pidomus_mesh_refinement.cc index 3d953834..ffd1ccc0 100644 --- a/source/pidomus_mesh_refinement.cc +++ b/source/pidomus_mesh_refinement.cc @@ -77,19 +77,18 @@ piDoMUS::solver_should_restart(const double t, if (max_kelly > kelly_threshold) { - pcout << " ################ restart ######### \n" - << "max_kelly > threshold\n" - << max_kelly << " > " << kelly_threshold - << std::endl - << "######################################\n"; unsigned int n_active_cells=triangulation->n_active_cells(); unsigned int max_cells=this->max_cells; if ((max_cells > 0) & (n_active_cells > max_cells)) { - pcout << "Maximum number of active cells has already been exceeded." << std::endl; signals.end_solver_should_restart(); return false; } + pcout << " ################ restart ######### \n" + << "max_kelly > threshold\n" + << max_kelly << " > " << kelly_threshold + << std::endl + << "######################################\n"; pgr.mark_cells(estimated_error_per_cell, *triangulation); refine_and_transfer_solutions(solution,