From: Ralf Hartmann Date: Thu, 2 Mar 2006 09:02:23 +0000 (+0000) Subject: Use of new TriaObjectAccessor::n_children function. X-Git-Tag: v8.0.0~12160 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63250e0c128cefdd0900a24851291eb8e625cdd5;p=dealii.git Use of new TriaObjectAccessor::n_children function. git-svn-id: https://svn.dealii.org/trunk@12525 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index ebff141a97..78a33f9810 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -1007,7 +1007,7 @@ DoFTools::make_flux_sparsity_pattern ( if (cell_face->user_flag_set ()) continue; - if (! cell->at_boundary (face) ) + if (! cell_face->at_boundary() ) { typename DH::cell_iterator neighbor = cell->neighbor(face); // Refinement edges are @@ -1019,10 +1019,10 @@ DoFTools::make_flux_sparsity_pattern ( const unsigned int neighbor_face = cell->neighbor_of_neighbor(face); - if (neighbor->has_children()) + if (cell_face->has_children()) { for (unsigned int sub_nr = 0; - sub_nr != GeometryInfo::subfaces_per_face; + sub_nr != cell_face->n_children(); ++sub_nr) { const typename DH::cell_iterator @@ -1231,13 +1231,14 @@ DoFTools::make_flux_sparsity_pattern ( if (neighbor->level() < cell->level()) continue; + typename DH::face_iterator cell_face = cell->face(face); const unsigned int neighbor_face = cell->neighbor_of_neighbor(face); - if (neighbor->has_children()) + if (cell_face->has_children()) { for (unsigned int sub_nr = 0; - sub_nr != GeometryInfo::subfaces_per_face; + sub_nr != cell_face->n_children(); ++sub_nr) { const typename DH::cell_iterator diff --git a/deal.II/deal.II/source/dofs/hp_dof_handler.cc b/deal.II/deal.II/source/dofs/hp_dof_handler.cc index 09d09a39ab..2efebfba63 100644 --- a/deal.II/deal.II/source/dofs/hp_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/hp_dof_handler.cc @@ -2530,7 +2530,7 @@ namespace hp { // Set active_fe_index in children to the // same value as in the parent cell. - for (unsigned int i = 0; i < GeometryInfo::children_per_cell; ++i) + for (unsigned int i = 0; i < cell->n_children(); ++i) cell->child (i)->set_active_fe_index (cell->active_fe_index ()); } } diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 39a09ab5b4..ad6160d4a9 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -1614,8 +1614,21 @@ void FESubfaceValues::reinit (const typename DoFHandler::cell_iterator // typename FEValuesBase::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - Assert (subface_no < GeometryInfo::subfaces_per_face, + // We would like to check for + // subface_no < cell->face(face_no)->n_children(), + // but unfortunately the current + // function is also called for + // faces without children (see + // tests/fe/mapping.cc). Therefore, + // we must use following workaround + // of two separate assertions + Assert (cell->face(face_no)->has_children() || + subface_no < GeometryInfo::subfaces_per_face, ExcIndexRange (subface_no, 0, GeometryInfo::subfaces_per_face)); + Assert (!cell->face(face_no)->has_children() || + subface_no < cell->face(face_no)->n_children(), + ExcIndexRange (subface_no, 0, cell->face(face_no)->n_children())); + Assert (cell->has_children() == false, ExcMessage ("You can't use subface data for cells that are " "already refined. Iterate over their children " @@ -1657,8 +1670,8 @@ void FESubfaceValues::reinit (const typename hp::DoFHandler::cell_iter typename FEValuesBase::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - Assert (subface_no < GeometryInfo::subfaces_per_face, - ExcIndexRange (subface_no, 0, GeometryInfo::subfaces_per_face)); + Assert (subface_no < cell->face(face_no)->n_children(), + ExcIndexRange (subface_no, 0, cell->face(face_no)->n_children())); Assert (cell->has_children() == false, ExcMessage ("You can't use subface data for cells that are " "already refined. Iterate over their children " @@ -1692,8 +1705,8 @@ void FESubfaceValues::reinit (const typename MGDoFHandler::cell_iterat typename FEValuesBase::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - Assert (subface_no < GeometryInfo::subfaces_per_face, - ExcIndexRange (subface_no, 0, GeometryInfo::subfaces_per_face)); + Assert (subface_no < cell->face(face_no)->n_children(), + ExcIndexRange (subface_no, 0, cell->face(face_no)->n_children())); Assert (cell->has_children() == false, ExcMessage ("You can't use subface data for cells that are " "already refined. Iterate over their children " @@ -1725,8 +1738,8 @@ void FESubfaceValues::reinit (const typename Triangulation::cell_itera { Assert (face_no < GeometryInfo::faces_per_cell, ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - Assert (subface_no < GeometryInfo::subfaces_per_face, - ExcIndexRange (subface_no, 0, GeometryInfo::subfaces_per_face)); + Assert (subface_no < cell->face(face_no)->n_children(), + ExcIndexRange (subface_no, 0, cell->face(face_no)->n_children())); // set new cell. auto_ptr will take // care that old object gets diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index 1666ef9c80..b0bd4befc1 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -427,15 +427,15 @@ GridTools::find_active_cell_around_point (const Container &container, // grandchild while (cell->has_children()) { + const unsigned int n_children=cell->n_children(); unsigned int c=0; - for (; c::children_per_cell; ++c) + for (; cchild(c)->point_inside (p)) break; // make sure we found a child // cell - AssertThrow (c != GeometryInfo::children_per_cell, - ExcPointNotFound (p)); + AssertThrow (c != n_children, ExcPointNotFound (p)); // then reset cell to the child cell = cell->child(c); diff --git a/deal.II/deal.II/source/grid/intergrid_map.cc b/deal.II/deal.II/source/grid/intergrid_map.cc index 49bd07e002..409e6a5563 100644 --- a/deal.II/deal.II/source/grid/intergrid_map.cc +++ b/deal.II/deal.II/source/grid/intergrid_map.cc @@ -140,7 +140,7 @@ InterGridMap::set_mapping (const cell_iterator &src_cell, // set entries for all children // of this cell to the one // dst_cell - for (unsigned int c=0; c::children_per_cell; ++c) + for (unsigned int c=0; cn_children(); ++c) set_entries_to_cell (src_cell->child(c), dst_cell); // else (no cell is refined or @@ -161,7 +161,7 @@ InterGridMap::set_entries_to_cell (const cell_iterator &src_cell, // then do so for the children as well // if there are any if (src_cell->has_children()) - for (unsigned int c=0; c::children_per_cell; ++c) + for (unsigned int c=0; cn_children(); ++c) set_entries_to_cell (src_cell->child(c), dst_cell); } diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index d601a9e130..277edc594a 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -314,7 +314,7 @@ void TriaObjectAccessor<2, dim>::recursively_set_user_flag () const set_user_flag (); if (has_children()) - for (unsigned int c=0; c<4; ++c) + for (unsigned int c=0; crecursively_set_user_flag (); } @@ -326,7 +326,7 @@ void TriaObjectAccessor<2, dim>::recursively_clear_user_flag () const clear_user_flag (); if (has_children()) - for (unsigned int c=0; c<4; ++c) + for (unsigned int c=0; crecursively_clear_user_flag (); } @@ -366,7 +366,7 @@ TriaObjectAccessor<2, dim>::recursively_set_user_pointer (void *p) const set_user_pointer (p); if (has_children()) - for (unsigned int c=0; c<4; ++c) + for (unsigned int c=0; crecursively_set_user_pointer (p); } @@ -379,7 +379,7 @@ TriaObjectAccessor<2, dim>::recursively_clear_user_pointer () const clear_user_pointer (); if (has_children()) - for (unsigned int c=0; c<4; ++c) + for (unsigned int c=0; crecursively_clear_user_pointer (); } @@ -659,7 +659,7 @@ unsigned int TriaObjectAccessor<2, dim>::number_of_children () const else { unsigned int sum = 0; - for (unsigned int c=0; c<4; ++c) + for (unsigned int c=0; cnumber_of_children(); return sum; }; @@ -749,7 +749,7 @@ void TriaObjectAccessor<3, dim>::recursively_set_user_flag () const set_user_flag (); if (has_children()) - for (unsigned int c=0; c<8; ++c) + for (unsigned int c=0; crecursively_set_user_flag (); } @@ -761,7 +761,7 @@ void TriaObjectAccessor<3, dim>::recursively_clear_user_flag () const clear_user_flag (); if (has_children()) - for (unsigned int c=0; c<8; ++c) + for (unsigned int c=0; crecursively_clear_user_flag (); } @@ -801,7 +801,7 @@ TriaObjectAccessor<3, dim>::recursively_set_user_pointer (void *p) const set_user_pointer (p); if (has_children()) - for (unsigned int c=0; c<8; ++c) + for (unsigned int c=0; crecursively_set_user_pointer (p); } @@ -814,7 +814,7 @@ TriaObjectAccessor<3, dim>::recursively_clear_user_pointer () const clear_user_pointer (); if (has_children()) - for (unsigned int c=0; c<8; ++c) + for (unsigned int c=0; crecursively_clear_user_pointer (); } @@ -1596,7 +1596,7 @@ unsigned int TriaObjectAccessor<3, dim>::number_of_children () const else { unsigned int sum = 0; - for (unsigned int c=0; c<8; ++c) + for (unsigned int c=0; cnumber_of_children(); return sum; }; @@ -1754,7 +1754,7 @@ void CellAccessor<2>::recursively_set_material_id (const unsigned char mat_id) c set_material_id (mat_id); if (this->has_children()) - for (unsigned int c=0; c<4; ++c) + for (unsigned int c=0; crecursively_set_material_id (mat_id); } @@ -1855,7 +1855,7 @@ void CellAccessor<3>::recursively_set_material_id (const unsigned char mat_id) c set_material_id (mat_id); if (this->has_children()) - for (unsigned int c=0; c<8; ++c) + for (unsigned int c=0; crecursively_set_material_id (mat_id); } @@ -2040,7 +2040,7 @@ CellAccessor::neighbor_of_coarser_neighbor (const unsigned int neighbor) co =neighbor_cell->face(face_no_guess); if (face_guess->has_children()) - for (unsigned int subface_no=0; subface_no::subfaces_per_face; ++subface_no) + for (unsigned int subface_no=0; face_guess->n_children(); ++subface_no) if (face_guess->child(subface_no)==this_face) return std::make_pair (face_no_guess, subface_no); @@ -2055,7 +2055,7 @@ CellAccessor::neighbor_of_coarser_neighbor (const unsigned int neighbor) co const TriaIterator > face =neighbor_cell->face(face_no); if (face->has_children()) - for (unsigned int subface_no=0; subface_no::subfaces_per_face; ++subface_no) + for (unsigned int subface_no=0; subface_non_children(); ++subface_no) if (face->child(subface_no)==this_face) return std::make_pair (face_no, subface_no); } diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc index 42b119affa..bf6101ae42 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc @@ -200,8 +200,7 @@ void MGTransferBlockBase::build_matrices ( { cell->get_mg_dof_indices (dof_indices_parent); - for (unsigned int child=0; - child::children_per_cell; ++child) + for (unsigned int child=0; childn_children(); ++child) { // set an alias to the // prolongation matrix for @@ -238,8 +237,7 @@ void MGTransferBlockBase::build_matrices ( { cell->get_mg_dof_indices (dof_indices_parent); - for (unsigned int child=0; - child::children_per_cell; ++child) + for (unsigned int child=0; childn_children(); ++child) { // set an alias to the // prolongation matrix for diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc index 42f06b0f84..94fc01bbca 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc @@ -93,8 +93,7 @@ void MGTransferPrebuilt::build_matrices ( { cell->get_mg_dof_indices (dof_indices_parent); - for (unsigned int child=0; - child::children_per_cell; ++child) + for (unsigned int child=0; childn_children(); ++child) { // set an alias to the // prolongation matrix for @@ -129,8 +128,7 @@ void MGTransferPrebuilt::build_matrices ( { cell->get_mg_dof_indices (dof_indices_parent); - for (unsigned int child=0; - child::children_per_cell; ++child) + for (unsigned int child=0; childn_children(); ++child) { // set an alias to the // prolongation matrix for diff --git a/deal.II/deal.II/source/numerics/derivative_approximation.cc b/deal.II/deal.II/source/numerics/derivative_approximation.cc index 93af5b2ae3..d5188042c4 100644 --- a/deal.II/deal.II/source/numerics/derivative_approximation.cc +++ b/deal.II/deal.II/source/numerics/derivative_approximation.cc @@ -662,7 +662,7 @@ DerivativeApproximation::approximate (const Mapping &mapping, // children. find out // which border to the // present cell - for (unsigned int c=0; c::children_per_cell; ++c) + for (unsigned int c=0; cn_children(); ++c) for (unsigned int f=0; f::faces_per_cell; ++f) if (neighbor->child(c)->neighbor(f) == cell) active_neighbors.push_back (neighbor->child(c)); diff --git a/deal.II/deal.II/source/numerics/error_estimator.cc b/deal.II/deal.II/source/numerics/error_estimator.cc index 68f928132a..2822785992 100644 --- a/deal.II/deal.II/source/numerics/error_estimator.cc +++ b/deal.II/deal.II/source/numerics/error_estimator.cc @@ -540,6 +540,9 @@ estimate_some (const Mapping &mapping, for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { + const typename DoFHandler::face_iterator + face=cell->face(face_no); + // make sure we do work // only once: this face // may either be regular @@ -554,7 +557,7 @@ estimate_some (const Mapping &mapping, // boundary, or if the // face is irregular, // then do the work below - if ((cell->face(face_no)->has_children() == false) && + if ((face->has_children() == false) && !cell->at_boundary(face_no) && (cell->neighbor(face_no)->level() == cell->level()) && (cell->neighbor(face_no)->index() < cell->index())) @@ -567,7 +570,7 @@ estimate_some (const Mapping &mapping, // solution vector, as we // treat them all at the // same time - if (face_integrals[cell->face(face_no)][0] >=0) + if (face_integrals[face][0] >=0) continue; @@ -590,13 +593,13 @@ estimate_some (const Mapping &mapping, // the list of faces with // contribution zero. const unsigned char boundary_indicator - = cell->face(face_no)->boundary_indicator(); - if (cell->face(face_no)->at_boundary() + = face->boundary_indicator(); + if (face->at_boundary() && neumann_bc.find(boundary_indicator)==neumann_bc.end()) { for (unsigned int n=0; nface(face_no)][n] = 0; + face_integrals[face][n] = 0; continue; } @@ -620,11 +623,11 @@ estimate_some (const Mapping &mapping, // the face we presently work // on? oh is there a face at // all? - if (cell->at_boundary(face_no)) + if (face->at_boundary()) continue; bool care_for_cell = false; - if (cell->neighbor(face_no)->has_children() == false) + if (face->has_children() == false) care_for_cell |= ((cell->neighbor(face_no)->subdomain_id() == subdomain_id) || (subdomain_id == deal_II_numbers::invalid_unsigned_int)) @@ -634,8 +637,7 @@ estimate_some (const Mapping &mapping, (material_id == deal_II_numbers::invalid_unsigned_int)); else { - for (unsigned int sf=0; - sf::subfaces_per_face; ++sf) + for (unsigned int sf=0; sfn_children(); ++sf) if (((cell->neighbor_child_on_subface(face_no,sf) ->subdomain_id() == subdomain_id) && @@ -665,7 +667,7 @@ estimate_some (const Mapping &mapping, // so now we know that we care for // this face, let's do something // about it: - if (cell->face(face_no)->has_children() == false) + if (face->has_children() == false) // if the face is a regular one, // i.e. either on the other side // there is nirvana (face is at @@ -1138,9 +1140,11 @@ integrate_over_irregular_face (const DoFHandler &dof_handler, const unsigned int n_q_points = quadrature.n_quadrature_points, n_components = dof_handler.get_fe().n_components(), n_solution_vectors = solutions.size(); + const typename DoFHandler::face_iterator + face=cell->face(face_no); Assert (neighbor.state() == IteratorState::valid, ExcInternalError()); - Assert (neighbor->has_children(), ExcInternalError()); + Assert (face->has_children(), ExcInternalError()); // set up a vector of the gradients // of the finite element function // on this cell at the quadrature @@ -1162,9 +1166,7 @@ integrate_over_irregular_face (const DoFHandler &dof_handler, ExcInternalError()); // loop over all subfaces - for (unsigned int subface_no=0; - subface_no::subfaces_per_face; - ++subface_no) + for (unsigned int subface_no=0; subface_non_children(); ++subface_no) { // get an iterator pointing to the // cell behind the present subface @@ -1288,9 +1290,7 @@ integrate_over_irregular_face (const DoFHandler &dof_handler, // subfaces and store them with the // mother face std::vector sum (n_solution_vectors, 0); - typename DoFHandler::face_iterator face = cell->face(face_no); - for (unsigned int subface_no=0; subface_no::subfaces_per_face; - ++subface_no) + for (unsigned int subface_no=0; subface_non_children(); ++subface_no) { Assert (face_integrals.find(face->child(subface_no)) != face_integrals.end(), diff --git a/deal.II/deal.II/source/numerics/solution_transfer.cc b/deal.II/deal.II/source/numerics/solution_transfer.cc index 21dfb796df..a426a20fc4 100644 --- a/deal.II/deal.II/source/numerics/solution_transfer.cc +++ b/deal.II/deal.II/source/numerics/solution_transfer.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -248,7 +248,7 @@ prepare_for_coarsening_and_refinement(const std::vector > &all_in // coaresen flag, then all should // have if Tria::prepare_* has // worked correctly - for (unsigned int i=1; i::children_per_cell; ++i) + for (unsigned int i=1; in_children(); ++i) Assert(cell->child(i)->coarsen_flag_set(), ExcTriaPrepCoarseningNotCalledBefore()); diff --git a/deal.II/deal.II/source/numerics/time_dependent.cc b/deal.II/deal.II/source/numerics/time_dependent.cc index 8267832956..eaa2372dbd 100644 --- a/deal.II/deal.II/source/numerics/time_dependent.cc +++ b/deal.II/deal.II/source/numerics/time_dependent.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -581,9 +581,12 @@ namespace return; }; - if (old_cell->has_children() && new_cell->has_children()) - for (unsigned int c=0; c::children_per_cell; ++c) - ::mirror_refinement_flags (new_cell->child(c), old_cell->child(c)); + if (old_cell->has_children() && new_cell->has_children()) + { + Assert(old_cell->n_children()==new_cell->n_children(), ExcNotImplemented()); + for (unsigned int c=0; cn_children(); ++c) + ::mirror_refinement_flags (new_cell->child(c), old_cell->child(c)); + } } @@ -597,8 +600,9 @@ namespace if (cell2->has_children() && cell1->has_children()) { bool grids_changed = false; - - for (unsigned int c=0; c::children_per_cell; ++c) + + Assert(cell2->n_children()==cell1->n_children(), ExcNotImplemented()); + for (unsigned int c=0; cn_children(); ++c) grids_changed |= ::adapt_grid_cells (cell1->child(c), cell2->child(c)); return grids_changed; @@ -654,7 +658,7 @@ namespace }; if (!cell2->refine_flag_set()) - for (unsigned int c=0; c::children_per_cell; ++c) + for (unsigned int c=0; cn_children(); ++c) if (cell1->child(c)->refine_flag_set() || cell1->child(c)->has_children()) { @@ -676,7 +680,7 @@ namespace }; if (!cell1->refine_flag_set()) - for (unsigned int c=0; c::children_per_cell; ++c) + for (unsigned int c=0; cn_children(); ++c) if (cell2->child(c)->refine_flag_set() || cell2->child(c)->has_children()) {