From a9554b1dc160e72f1365fe2b89f28ca7b5df9977 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 12 Dec 2000 16:51:40 +0000 Subject: [PATCH] Check that the mesh refinement criteria are actually non-negative values. git-svn-id: https://svn.dealii.org/trunk@3530 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/grid/grid_refinement.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deal.II/deal.II/source/grid/grid_refinement.cc b/deal.II/deal.II/source/grid/grid_refinement.cc index a6e36d378e..1aeff52c7d 100644 --- a/deal.II/deal.II/source/grid/grid_refinement.cc +++ b/deal.II/deal.II/source/grid/grid_refinement.cc @@ -79,6 +79,8 @@ void GridRefinement::refine (Triangulation &tria, { Assert (criteria.size() == tria.n_active_cells(), ExcInvalidVectorSize(criteria.size(), tria.n_active_cells())); + Assert (*min_element(criteria.begin(), criteria.end()) >= 0, + ExcInvalidParameterValue()); // nothing to do; especially we // do not want to flag with zero @@ -105,6 +107,8 @@ void GridRefinement::coarsen (Triangulation &tria, { Assert (criteria.size() == tria.n_active_cells(), ExcInvalidVectorSize(criteria.size(), tria.n_active_cells())); + Assert (*min_element(criteria.begin(), criteria.end()) >= 0, + ExcInvalidParameterValue()); Triangulation::active_cell_iterator cell = tria.begin_active(); const unsigned int n_cells = criteria.size(); @@ -128,6 +132,8 @@ GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tria, Assert ((top_fraction>=0) && (top_fraction<=1), ExcInvalidParameterValue()); Assert ((bottom_fraction>=0) && (bottom_fraction<=1), ExcInvalidParameterValue()); Assert (top_fraction+bottom_fraction <= 1, ExcInvalidParameterValue()); + Assert (*min_element(criteria.begin(), criteria.end()) >= 0, + ExcInvalidParameterValue()); const int refine_cells=static_cast(top_fraction*criteria.size()); const int coarsen_cells=static_cast(bottom_fraction*criteria.size()); @@ -167,6 +173,8 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation &tria, Assert ((top_fraction>=0) && (top_fraction<=1), ExcInvalidParameterValue()); Assert ((bottom_fraction>=0) && (bottom_fraction<=1), ExcInvalidParameterValue()); Assert (top_fraction+bottom_fraction <= 1, ExcInvalidParameterValue()); + Assert (*min_element(criteria.begin(), criteria.end()) >= 0, + ExcInvalidParameterValue()); // let tmp be the cellwise square of the // error, which is what we have to sum @@ -250,6 +258,8 @@ GridRefinement::refine_and_coarsen_optimize (Triangulation &tria, { Assert (criteria.size() == tria.n_active_cells(), ExcInvalidVectorSize(criteria.size(), tria.n_active_cells())); + Assert (*min_element(criteria.begin(), criteria.end()) >= 0, + ExcInvalidParameterValue()); // get an increasing order on // the error indicator -- 2.39.5