]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make the GridRefinement::refine function work also when the threshold happens to...
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 26 Nov 2001 16:20:56 +0000 (16:20 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 26 Nov 2001 16:20:56 +0000 (16:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@5271 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/grid_refinement.cc

index ab1518c9f3c72c3e5fb632918b1dd2599904acc1..0f7c10939011084b0eaa542b2f0f1a7ef9cc15d6 100644 (file)
@@ -81,21 +81,24 @@ void GridRefinement::refine (Triangulation<dim>   &tria,
   Assert (criteria.size() == tria.n_active_cells(),
          ExcInvalidVectorSize(criteria.size(), tria.n_active_cells()));
   Assert (*std::min_element(criteria.begin(), criteria.end()) >= 0,
-         ExcInvalidParameterValue());  
-
-                                  // nothing to do; especially we
-                                  // do not want to flag with zero
-                                  // error since then we may get
-                                  // into conflict with coarsening
-                                  // in some cases
-  if (threshold==0)
-    return;
+         ExcInvalidParameterValue());
   
   typename Triangulation<dim>::active_cell_iterator cell = tria.begin_active();
   const unsigned int n_cells = criteria.size();
+
+  double new_threshold=threshold;
+                                  // when threshold==0 find the
+                                  // smallest value in criteria
+                                  // greater 0
+  if (new_threshold==0)
+    for (unsigned int index=0; index<n_cells; ++index)
+      if (criteria(index)>0
+         && (criteria(index)<new_threshold
+             || new_threshold==0))
+       new_threshold=criteria(index);
   
   for (unsigned int index=0; index<n_cells; ++cell, ++index)
-    if (std::fabs(criteria(index)) >= threshold)
+    if (std::fabs(criteria(index)) >= new_threshold)
       cell->set_refine_flag();
 };
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.