]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix various bugs.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 4 Jun 1998 12:03:04 +0000 (12:03 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 4 Jun 1998 12:03:04 +0000 (12:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@378 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/dofs/dof_handler.cc
deal.II/deal.II/source/grid/tria.cc
deal.II/deal.II/source/numerics/vectors.cc

index 8b44e7658e137e8a4a01a4b04e74961782f4f29d..7d60ac272ccd5fb8972cbf6dcaeed68500d27cb2 100644 (file)
@@ -1794,7 +1794,8 @@ void DoFHandler<dim>::map_dof_to_boundary_indices (const FunctionMap &boundary_i
            mapping[dofs_on_face[i]] = next_boundary_index++;
       };
 
-  Assert (static_cast<unsigned int>(next_boundary_index) == n_boundary_dofs(),
+  Assert (static_cast<unsigned int>(next_boundary_index)
+         == n_boundary_dofs(boundary_indicators),
          ExcInternalError());
 };
 
index 5d0320dcefb241146632d419b27609b5fdecbb67..c91b3bdf10c5b0acc5158cfb44fdb3f5402a2443 100644 (file)
@@ -1942,15 +1942,33 @@ double sqr(double a) {
 template <int dim>
 void Triangulation<dim>::refine_fixed_fraction (const dVector     &criteria,
                                                const double       fraction_of_error,
-                                               const unsigned int n_sorting_parts) {
+                                               const unsigned int n_sorting_steps) {
                                   // correct number of cells is
                                   // checked in #refine#
   Assert ((fraction_of_error>0) && (fraction_of_error<=1),
          ExcInvalidParameterValue());
 
+                                  // rename variable since we have to change it
+  unsigned n_sorting_parts = n_sorting_steps;
+  
+
                                   // number of cells to be sorted per part
-  const unsigned cells_per_part
-    = static_cast<int>(fraction_of_error * criteria.size() / n_sorting_parts);
+  unsigned cells_per_part
+    = static_cast<int>(rint(fraction_of_error * criteria.size() / n_sorting_parts));
+
+                                  // if number of elements is so small or the
+                                  // fraction so high that we will get into trouble
+                                  // with the maximum number of elements to be
+                                  // sorted, fall back to only one sorting step.
+                                  // Do so also if cells_per_part was rounded
+                                  // to zero
+  if ((cells_per_part*n_sorting_parts > criteria.size()) ||
+      (cells_per_part == 0)) 
+    {
+      cells_per_part = criteria.size();
+      n_sorting_parts = 1;
+    };
+  
                                   // let tmp be the cellwise square of the
                                   // error, which is what we have to sum
                                   // up and compare with
@@ -2018,7 +2036,12 @@ void Triangulation<dim>::refine_fixed_fraction (const dVector     &criteria,
                                   // used more cells than the given fraction
                                   // to reach the fraction_of_error, or
                                   // something has gone terribly wrong.
-  Assert (false, ExcInternalError());
+                                  //
+                                  // Only exception: there are so few cells
+                                  // that fraction*n_cells == n_cells
+                                  // (integer arithmetic!)
+  Assert (n_sorting_parts * cells_per_part == criteria.size(),
+         ExcInternalError());
 };
 
 
index f206162778847136f9b39948c75db781e145ce62..6c5c03ea0aef07515970b34bccdeffba11ea7f86 100644 (file)
@@ -275,7 +275,7 @@ VectorTools<dim>::project_boundary_values (const DoFHandler<dim>    &dof,
                                           const Boundary<dim>      &boundary,
                                           map<int,double>   &boundary_values) {
   vector<int>    dof_to_boundary_mapping;
-  dof.map_dof_to_boundary_indices (dof_to_boundary_mapping);
+  dof.map_dof_to_boundary_indices (boundary_functions, dof_to_boundary_mapping);
   
                                   // set up sparsity structure
   dSMatrixStruct sparsity(dof.n_boundary_dofs(boundary_functions),

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.