From ebc17a6a2d05540b86235fe7bf78614eecf59be9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 4 Jun 1998 12:03:04 +0000 Subject: [PATCH] Fix various bugs. git-svn-id: https://svn.dealii.org/trunk@378 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/dofs/dof_handler.cc | 3 ++- deal.II/deal.II/source/grid/tria.cc | 31 +++++++++++++++++++--- deal.II/deal.II/source/numerics/vectors.cc | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index 8b44e7658e..7d60ac272c 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -1794,7 +1794,8 @@ void DoFHandler::map_dof_to_boundary_indices (const FunctionMap &boundary_i mapping[dofs_on_face[i]] = next_boundary_index++; }; - Assert (static_cast(next_boundary_index) == n_boundary_dofs(), + Assert (static_cast(next_boundary_index) + == n_boundary_dofs(boundary_indicators), ExcInternalError()); }; diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 5d0320dcef..c91b3bdf10 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -1942,15 +1942,33 @@ double sqr(double a) { template void Triangulation::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(fraction_of_error * criteria.size() / n_sorting_parts); + unsigned cells_per_part + = static_cast(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::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()); }; diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index f206162778..6c5c03ea0a 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -275,7 +275,7 @@ VectorTools::project_boundary_values (const DoFHandler &dof, const Boundary &boundary, map &boundary_values) { vector 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), -- 2.39.5