From: bangerth Date: Wed, 20 Sep 2006 03:50:22 +0000 (+0000) Subject: Clean up a few things X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14d6fd12fa16246641b018c98a4282cdba2ca5c0;p=dealii-svn.git Clean up a few things git-svn-id: https://svn.dealii.org/trunk@13931 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 b5e95644d9..d6d7d778c0 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -37,7 +37,7 @@ #include #include -#define WOLFGANG +//#define WOLFGANG #if deal_II_dimension == 1 @@ -1562,6 +1562,78 @@ namespace internal { namespace { + /** + * Make sure that the given @p + * face_interpolation_matrix + * pointer points to a valid + * matrix. If the pointer is zero + * beforehand, create an entry + * with the correct data. If it + * is nonzero, don't touch it. + */ + template + void + assert_existence_of_face_matrix (const FiniteElement &fe1, + const FiniteElement &fe2, + boost::shared_ptr > &matrix) + { + if (matrix == 0) + { + matrix = new FullMatrix (fe2.dofs_per_face, + fe1.dofs_per_face); + fe1.get_face_interpolation_matrix (fe2, + *matrix); + } + } + + + + /** + * Same, but for subface + * interpolation matrices. + */ + template + void + assert_existence_of_subface_matrix (const FiniteElement &fe1, + const FiniteElement &fe2, + const unsigned int subface, + boost::shared_ptr > &matrix) + { + if (matrix == 0) + { + matrix = new FullMatrix (fe2.dofs_per_face, + fe1.dofs_per_face); + fe1.get_subface_interpolation_matrix (fe2, + subface, + *matrix); + } + } + + + // a template that can + // determine statically whether + // a given DoFHandler class + // supports different finite + // element elements + template struct DoFHandlerSupportsDifferentP + { + static const bool value = true; + }; + + + template struct DoFHandlerSupportsDifferentP< ::DoFHandler > + { + static const bool value = false; + }; + + + template struct DoFHandlerSupportsDifferentP< ::MGDoFHandler > + { + static const bool value = false; + }; + + + #ifdef DEAL_II_ANON_NAMESPACE_BUG static #endif @@ -2084,7 +2156,7 @@ namespace internal std::vector dofs_on_mother; std::vector dofs_on_children; - FullMatrix face_constraints; + FullMatrix constraint_matrix; // loop over all faces; only on // face there can be constraints. @@ -2136,34 +2208,52 @@ namespace internal Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1, ExcInternalError()); - // first find out whether we - // can constrain each of the - // subfaces to the mother - // face. in the lingo of the hp - // paper, this would be the - // simple case + // first find out + // whether we can + // constrain each of + // the subfaces to the + // mother face. in the + // lingo of the hp + // paper, this would be + // the simple + // case. note that we + // can short-circuit + // this decision if the + // dof_handler doesn't + // support hp at all FiniteElementDomination::Domination mother_face_dominates = FiniteElementDomination::either_element_can_dominate; - for (unsigned int c=0; c::subfaces_per_face; ++c) - mother_face_dominates = mother_face_dominates & - (cell->get_fe().compare_for_face_domination - (cell->neighbor_child_on_subface (face, c)->get_fe())); + + if (DoFHandlerSupportsDifferentP::value == true) + for (unsigned int c=0; c::subfaces_per_face; ++c) + mother_face_dominates = mother_face_dominates & + (cell->get_fe().compare_for_face_domination + (cell->neighbor_child_on_subface (face, c)->get_fe())); switch (mother_face_dominates) { case FiniteElementDomination::this_element_dominates: case FiniteElementDomination::either_element_can_dominate: { - // Case 1 (the simple - // case): The coarse - // element dominates the - // elements on the - // subfaces (or they are + // Case 1 (the + // simple case + // and the only + // case that can + // happen for + // non-hp + // DoFHandlers): + // The coarse + // element + // dominates the + // elements on + // the subfaces + // (or they are // all the same) const unsigned int n_dofs_on_mother = cell->get_fe().dofs_per_face; dofs_on_mother.resize (n_dofs_on_mother); - cell->face(face)->get_dof_indices (dofs_on_mother, cell->active_fe_index ()); + cell->face(face)->get_dof_indices (dofs_on_mother, + cell->active_fe_index ()); // Now create constraint matrix for // the subfaces and assemble it. @@ -2241,11 +2331,11 @@ namespace internal // properties of a // finite element onto // that mesh - face_constraints.reinit (n_dofs_on_children, - n_dofs_on_mother); + constraint_matrix.reinit (n_dofs_on_children, + n_dofs_on_mother); cell->get_fe() .get_subface_interpolation_matrix (subface->get_fe(subface_fe_index), - c, face_constraints); + c, constraint_matrix); // Add constraints to global constraint // matrix. @@ -2258,7 +2348,7 @@ namespace internal filter_constraints (dofs_on_mother, dofs_on_children, - face_constraints, + constraint_matrix, constraints); } @@ -2279,13 +2369,23 @@ namespace internal // deal with this // situation // + // since this is + // something that + // can only + // happen for hp + // dof handlers, + // add a check + // here... + Assert (DoFHandlerSupportsDifferentP::value == true, + ExcInternalError()); + // we first have to find // one of the children // for which the finite // element is able to // generate a space that // all the other ones can - // be constrained to + // be constrained to unsigned int dominating_subface_no = 0; for (; dominating_subface_no::subfaces_per_face; ++dominating_subface_no)