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..ffd1ccc0 100644 --- a/source/pidomus_mesh_refinement.cc +++ b/source/pidomus_mesh_refinement.cc @@ -77,6 +77,13 @@ piDoMUS::solver_should_restart(const double t, if (max_kelly > kelly_threshold) { + 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)) + { + signals.end_solver_should_restart(); + return false; + } pcout << " ################ restart ######### \n" << "max_kelly > threshold\n" << max_kelly << " > " << kelly_threshold 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",