From: bangerth Date: Sun, 14 Oct 2012 00:41:25 +0000 (+0000) Subject: Merge from mainline. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c06807d3f9e12658c5a2eb6a315b006054617869;p=dealii-svn.git Merge from mainline. git-svn-id: https://svn.dealii.org/branches/branch_merge_mg_into_dof_handler@27114 0785d39b-7218-0410-832d-ea1e28bc413d --- c06807d3f9e12658c5a2eb6a315b006054617869 diff --cc deal.II/include/deal.II/dofs/dof_accessor.templates.h index 61b570bbb6,cefac603cc..ea84b5dbec --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@@ -734,42 -734,44 +734,44 @@@ namespace interna // leaves out is faces in 3d -- // let's hope that this never is // a problem - Assert ((dim==structdim - ? - typename - dealii::DoFHandler:: - raw_cell_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - (structdim==1 - ? - typename - dealii::DoFHandler:: - raw_line_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - true)) - == true, - ExcMessage ("This cell is not active and therefore can't be " - "queried for its active FE indices")); - Assert ((dim==structdim - ? - typename - dealii::internal::DoFHandler:: - Iterators >:: - raw_cell_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - (structdim==1 - ? - typename - dealii::internal::DoFHandler:: - Iterators >:: - raw_line_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - true)) - == true, - ExcMessage ("This cell is not active and therefore can't be " - "queried for its active FE indices")); - return 1; - } - - - - template - static - unsigned int - nth_active_fe_index (const dealii::DoFHandler &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type &) - { ++ Assert ((dim==structdim ++ ? ++ typename ++ dealii::internal::DoFHandler:: ++ Iterators >:: ++ raw_cell_iterator (&dof_handler.get_tria(), ++ obj_level, ++ obj_index, ++ &dof_handler)->used() ++ : ++ (structdim==1 ++ ? ++ typename ++ dealii::internal::DoFHandler:: ++ Iterators >:: ++ raw_line_iterator (&dof_handler.get_tria(), ++ obj_level, ++ obj_index, ++ &dof_handler)->used() ++ : ++ true)) ++ == true, ++ ExcMessage ("This cell is not active and therefore can't be " ++ "queried for its active FE indices")); + return 1; + } + + + + template + static + unsigned int + nth_active_fe_index (const dealii::DoFHandler &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type &) + { // check that the object we look // at is in fact active. the // problem is that we have @@@ -784,310 -786,312 +786,312 @@@ // leaves out is faces in 3d -- // let's hope that this never is // a problem - Assert ((dim==structdim - ? - typename - dealii::internal::DoFHandler:: - Iterators >:: - raw_cell_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - (structdim==1 - ? - typename - dealii::internal::DoFHandler:: - Iterators >:: - raw_line_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - true)) - == true, - ExcMessage ("This cell is not active and therefore can't be " - "queried for its active FE indices")); - Assert (n == 0, ExcIndexRange (n, 0, 1)); - - return dealii::DoFHandler::default_fe_index; - } - - - template - static - bool - fe_index_is_active (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler, - obj_index, - fe_index, - obj_level); - } - - - template - static - unsigned int - n_active_fe_indices (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler, - obj_index); - } - - - - template - static - unsigned int - nth_active_fe_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type<1> &) - { - return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler, - obj_level, - obj_index, - n); - } - - - template - static - bool - fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines.fe_index_is_active(dof_handler, - obj_index, - fe_index, - obj_level); - } - - - template - static - unsigned int - n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int , - const unsigned int obj_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines.n_active_fe_indices (dof_handler, - obj_index); - } - - - template - static - unsigned int - nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines.nth_active_fe_index (dof_handler, - obj_level, - obj_index, - n); - } - - - - template - static - bool - fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const dealii::internal::int2type<2> &) - { - return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler, - obj_index, - fe_index, - obj_level); - } - - - template - static - unsigned int - n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const dealii::internal::int2type<2> &) - { - return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler, - obj_index); - } - - - - template - static - unsigned int - nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type<2> &) - { - return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler, - obj_level, - obj_index, - n); - } - - - - template - static - bool - fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines.fe_index_is_active(dof_handler, - obj_index, - fe_index, - obj_level); - } - - - template - static - unsigned int - n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int, - const unsigned int obj_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines.n_active_fe_indices (dof_handler, - obj_index); - } - - - - template - static - unsigned int - nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines.nth_active_fe_index (dof_handler, - obj_level, - obj_index, - n); - } - - - - template - static - bool - fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const dealii::internal::int2type<2> &) - { - return dof_handler.faces->quads.fe_index_is_active(dof_handler, - obj_index, - fe_index, - obj_level); - } - - template - static - bool - fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const dealii::internal::int2type<3> &) - { - return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler, - obj_index, - fe_index, - obj_level); - } - - - template - static - unsigned int - n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int , - const unsigned int obj_index, - const dealii::internal::int2type<2> &) - { - return dof_handler.faces->quads.n_active_fe_indices (dof_handler, - obj_index); - } - - - - template - static - unsigned int - nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type<2> &) - { - return dof_handler.faces->quads.nth_active_fe_index (dof_handler, - obj_level, - obj_index, - n); - } - - - - template - static - unsigned int - n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const dealii::internal::int2type<3> &) - { - return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler, - obj_index); - } - - - - template - static - unsigned int - nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n, - const dealii::internal::int2type<3> &) - { - return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler, - obj_level, - obj_index, - n); - } + Assert ((dim==structdim - ? - typename - dealii::DoFHandler:: - raw_cell_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - (structdim==1 - ? - typename - dealii::DoFHandler:: - raw_line_iterator (&dof_handler.get_tria(), - obj_level, - obj_index, - &dof_handler)->used() - : - true)) - == true, - ExcMessage ("This cell is not active and therefore can't be " - "queried for its active FE indices")); ++ ? ++ typename ++ dealii::internal::DoFHandler:: ++ Iterators >:: ++ raw_cell_iterator (&dof_handler.get_tria(), ++ obj_level, ++ obj_index, ++ &dof_handler)->used() ++ : ++ (structdim==1 ++ ? ++ typename ++ dealii::internal::DoFHandler:: ++ Iterators >:: ++ raw_line_iterator (&dof_handler.get_tria(), ++ obj_level, ++ obj_index, ++ &dof_handler)->used() ++ : ++ true)) ++ == true, ++ ExcMessage ("This cell is not active and therefore can't be " ++ "queried for its active FE indices")); + Assert (n == 0, ExcIndexRange (n, 0, 1)); + + return dealii::DoFHandler::default_fe_index; + } + + + template + static + bool + fe_index_is_active (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler, + obj_index, + fe_index, + obj_level); + } + + + template + static + unsigned int + n_active_fe_indices (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler, + obj_index); + } + + + + template + static + unsigned int + nth_active_fe_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type<1> &) + { + return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler, + obj_level, + obj_index, + n); + } + + + template + static + bool + fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines.fe_index_is_active(dof_handler, + obj_index, + fe_index, + obj_level); + } + + + template + static + unsigned int + n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int , + const unsigned int obj_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines.n_active_fe_indices (dof_handler, + obj_index); + } + + + template + static + unsigned int + nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines.nth_active_fe_index (dof_handler, + obj_level, + obj_index, + n); + } + + + + template + static + bool + fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const dealii::internal::int2type<2> &) + { + return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler, + obj_index, + fe_index, + obj_level); + } + + + template + static + unsigned int + n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const dealii::internal::int2type<2> &) + { + return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler, + obj_index); + } + + + + template + static + unsigned int + nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type<2> &) + { + return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler, + obj_level, + obj_index, + n); + } + + + + template + static + bool + fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines.fe_index_is_active(dof_handler, + obj_index, + fe_index, + obj_level); + } + + + template + static + unsigned int + n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int, + const unsigned int obj_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines.n_active_fe_indices (dof_handler, + obj_index); + } + + + + template + static + unsigned int + nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines.nth_active_fe_index (dof_handler, + obj_level, + obj_index, + n); + } + + + + template + static + bool + fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const dealii::internal::int2type<2> &) + { + return dof_handler.faces->quads.fe_index_is_active(dof_handler, + obj_index, + fe_index, + obj_level); + } + + template + static + bool + fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const dealii::internal::int2type<3> &) + { + return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler, + obj_index, + fe_index, + obj_level); + } + + + template + static + unsigned int + n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int , + const unsigned int obj_index, + const dealii::internal::int2type<2> &) + { + return dof_handler.faces->quads.n_active_fe_indices (dof_handler, + obj_index); + } + + + + template + static + unsigned int + nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type<2> &) + { + return dof_handler.faces->quads.nth_active_fe_index (dof_handler, + obj_level, + obj_index, + n); + } + + + + template + static + unsigned int + n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const dealii::internal::int2type<3> &) + { + return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler, + obj_index); + } + + + + template + static + unsigned int + nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n, + const dealii::internal::int2type<3> &) + { + return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler, + obj_level, + obj_index, + n); + } /** * Set the @p local_index-th @@@ -1728,72 -1699,15 +1732,72 @@@ namespace interna // applies, if the face_rotation or // face_orientation is non-standard for (unsigned int quad=0; quad<6; ++quad) - for (unsigned int d=0; ddof_index(accessor.get_fe(fe_index). - adjust_quad_dof_index_for_face_orientation(d, - accessor.face_orientation(quad), - accessor.face_flip(quad), - accessor.face_rotation(quad)), - fe_index); + for (unsigned int d=0; ddof_index(accessor.get_fe(fe_index). + adjust_quad_dof_index_for_face_orientation(d, + accessor.face_orientation(quad), + accessor.face_flip(quad), + accessor.face_rotation(quad)), + fe_index); for (unsigned int d=0; d + void get_mg_dof_indices (const dealii::DoFAccessor<1, DH>& accessor, const int level, std::vector& dof_indices, const unsigned int fe_index) { + const FiniteElement& fe = accessor.get_dof_handler ().get_fe ()[fe_index]; + std::vector::iterator next = dof_indices.begin (); - ++ + for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; ++vertex) + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + *next++ = accessor.mg_vertex_dof_index (level, vertex, dof); - ++ + for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof) + *next++ = accessor.mg_dof_index (level, dof); - ++ + Assert (next == dof_indices.end (), ExcInternalError ()); + } - ++ + template + void get_mg_dof_indices (const dealii::DoFAccessor<2, DH>& accessor, const int level, std::vector& dof_indices, const unsigned int fe_index) { + const FiniteElement& fe = accessor.get_dof_handler ().get_fe ()[fe_index]; + std::vector::iterator next = dof_indices.begin (); - ++ + for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; ++vertex) + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + *next++ = accessor.mg_vertex_dof_index (level, vertex, dof); - ++ + for (unsigned int line = 0; line < GeometryInfo<2>::lines_per_cell; ++line) + for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof) + *next++ = accessor.line (line)->mg_dof_index (level, dof); - ++ + for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof) + *next++ = accessor.mg_dof_index (level, dof); - ++ + Assert (next == dof_indices.end (), ExcInternalError ()); + } - ++ + template + void get_mg_dof_indices (const dealii::DoFAccessor<3, DH>& accessor, const int level, std::vector& dof_indices, const unsigned int fe_index) { + const FiniteElement& fe = accessor.get_dof_handler ().get_fe ()[fe_index]; + std::vector::iterator next = dof_indices.begin (); - ++ + for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; ++vertex) + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + *next++ = accessor.mg_vertex_dof_index (level, vertex, dof); - ++ + for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell; ++line) + for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof) + *next++ = accessor.line (line)->mg_dof_index (level, dof); - ++ + for (unsigned int quad = 0; quad < GeometryInfo<3>::quads_per_cell; ++quad) + for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof) + *next++ = accessor.quad (quad)->mg_dof_index (level, dof); - ++ + for (unsigned int dof = 0; dof < fe.dofs_per_hex; ++dof) + *next++ = accessor.mg_dof_index (level, dof); - ++ + Assert (next == dof_indices.end (), ExcInternalError ()); } } } @@@ -1863,34 -1777,9 +1867,34 @@@ DoFAccessor::get_dof_indi dealii::internal::DoFAccessor::get_dof_indices (*this, dof_indices, fe_index); } +template +inline +void DoFAccessor::get_mg_dof_indices (const int level, std::vector& dof_indices, const unsigned int fe_index) const { + Assert (this->dof_handler != 0, ExcInvalidObject ()); + Assert (&this->dof_handler->get_fe () != 0, ExcInvalidObject ()); - ++ + switch (structdim) { + case 1: { + Assert (dof_indices.size () == 2 * this->dof_handler->get_fe ()[fe_index].dofs_per_vertex + this->dof_handler->get_fe ()[fe_index].dofs_per_line, ExcVectorDoesNotMatch ()); + break; + } - ++ + case 2: { + Assert (dof_indices.size () == 4 * (this->dof_handler->get_fe ()[fe_index].dofs_per_vertex + this->dof_handler->get_fe ()[fe_index].dofs_per_line) + this->dof_handler->get_fe ()[fe_index].dofs_per_quad, ExcVectorDoesNotMatch ()); + break; + } - + + case 3: { + Assert (dof_indices.size () == 8 * this->dof_handler->get_fe ()[fe_index].dofs_per_vertex + 12 * this->dof_handler->get_fe ()[fe_index].dofs_per_line + 6 * this->dof_handler->get_fe ()[fe_index].dofs_per_quad + this->dof_handler->get_fe ()[fe_index].dofs_per_hex, ExcVectorDoesNotMatch ()); + break; + } - + + default: + Assert (false, ExcNotImplemented ()); + } - + + internal::DoFAccessor::get_mg_dof_indices (*this, level, dof_indices, fe_index); +} template inline diff --cc deal.II/source/dofs/dof_handler.cc index ca50bf37d3,04a0624e41..d1a371c03f --- a/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/source/dofs/dof_handler.cc @@@ -257,427 -257,99 +257,427 @@@ namespace interna * was selected when calling * @p distribute_dofs the last time. */ - template - static - void reserve_space (DoFHandler<1,spacedim> &dof_handler) - { - dof_handler.vertex_dofs - .resize(dof_handler.tria->n_vertices() * - dof_handler.selected_fe->dofs_per_vertex, - DoFHandler<1,spacedim>::invalid_dof_index); - - for (unsigned int i=0; in_levels(); ++i) - { - dof_handler.levels - .push_back (new internal::DoFHandler::DoFLevel<1>); - - dof_handler.levels.back()->dof_object.dofs - .resize (dof_handler.tria->n_raw_cells(i) * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<1,spacedim>::invalid_dof_index); - - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_cells(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<1,spacedim>::invalid_dof_index); - } - } - - - template - static - void reserve_space (DoFHandler<2,spacedim> &dof_handler) - { - dof_handler.vertex_dofs - .resize(dof_handler.tria->n_vertices() * - dof_handler.selected_fe->dofs_per_vertex, - DoFHandler<2,spacedim>::invalid_dof_index); - - for (unsigned int i=0; in_levels(); ++i) - { - dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>); + template + static + void reserve_space (DoFHandler<1,spacedim> &dof_handler) + { + dof_handler.vertex_dofs + .resize(dof_handler.tria->n_vertices() * + dof_handler.selected_fe->dofs_per_vertex, + DoFHandler<1,spacedim>::invalid_dof_index); + + for (unsigned int i=0; in_levels(); ++i) + { - dof_handler.levels - .push_back (new internal::DoFHandler::DoFLevel<1>); - - dof_handler.levels.back()->dof_object.dofs - .resize (dof_handler.tria->n_raw_lines(i) * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<1,spacedim>::invalid_dof_index); - - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_lines(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<1,spacedim>::invalid_dof_index); - } ++ dof_handler.levels ++ .push_back (new internal::DoFHandler::DoFLevel<1>); ++ ++ dof_handler.levels.back()->dof_object.dofs ++ .resize (dof_handler.tria->n_raw_cells(i) * ++ dof_handler.selected_fe->dofs_per_line, ++ DoFHandler<1,spacedim>::invalid_dof_index); ++ ++ dof_handler.levels.back()->cell_dof_indices_cache ++ .resize (dof_handler.tria->n_raw_cells(i) * ++ dof_handler.selected_fe->dofs_per_cell, ++ DoFHandler<1,spacedim>::invalid_dof_index); ++ } + } + + + template + static + void reserve_space (DoFHandler<2,spacedim> &dof_handler) + { + dof_handler.vertex_dofs + .resize(dof_handler.tria->n_vertices() * + dof_handler.selected_fe->dofs_per_vertex, + DoFHandler<2,spacedim>::invalid_dof_index); + + for (unsigned int i=0; in_levels(); ++i) + { + dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>); - dof_handler.levels.back()->dof_object.dofs - .resize (dof_handler.tria->n_raw_quads(i) * - dof_handler.selected_fe->dofs_per_quad, - DoFHandler<2,spacedim>::invalid_dof_index); + dof_handler.levels.back()->dof_object.dofs + .resize (dof_handler.tria->n_raw_cells(i) * + dof_handler.selected_fe->dofs_per_quad, + DoFHandler<2,spacedim>::invalid_dof_index); - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_quads(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<2,spacedim>::invalid_dof_index); - } + dof_handler.levels.back()->cell_dof_indices_cache + .resize (dof_handler.tria->n_raw_cells(i) * + dof_handler.selected_fe->dofs_per_cell, + DoFHandler<2,spacedim>::invalid_dof_index); + } - dof_handler.faces = new internal::DoFHandler::DoFFaces<2>; - dof_handler.faces->lines.dofs - .resize (dof_handler.tria->n_raw_lines() * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<2,spacedim>::invalid_dof_index); - } + dof_handler.faces = new internal::DoFHandler::DoFFaces<2>; + dof_handler.faces->lines.dofs + .resize (dof_handler.tria->n_raw_lines() * + dof_handler.selected_fe->dofs_per_line, + DoFHandler<2,spacedim>::invalid_dof_index); + } - template - static - void reserve_space (DoFHandler<3,spacedim> &dof_handler) - { - dof_handler.vertex_dofs - .resize(dof_handler.tria->n_vertices() * - dof_handler.selected_fe->dofs_per_vertex, - DoFHandler<3,spacedim>::invalid_dof_index); + template + static + void reserve_space (DoFHandler<3,spacedim> &dof_handler) + { + dof_handler.vertex_dofs + .resize(dof_handler.tria->n_vertices() * + dof_handler.selected_fe->dofs_per_vertex, + DoFHandler<3,spacedim>::invalid_dof_index); - for (unsigned int i=0; in_levels(); ++i) - { - dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>); + for (unsigned int i=0; in_levels(); ++i) + { + dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>); - dof_handler.levels.back()->dof_object.dofs - .resize (dof_handler.tria->n_raw_hexs(i) * - dof_handler.selected_fe->dofs_per_hex, - DoFHandler<3,spacedim>::invalid_dof_index); + dof_handler.levels.back()->dof_object.dofs + .resize (dof_handler.tria->n_raw_cells(i) * + dof_handler.selected_fe->dofs_per_hex, + DoFHandler<3,spacedim>::invalid_dof_index); - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_hexs(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<3,spacedim>::invalid_dof_index); - } - dof_handler.faces = new internal::DoFHandler::DoFFaces<3>; + dof_handler.levels.back()->cell_dof_indices_cache + .resize (dof_handler.tria->n_raw_cells(i) * + dof_handler.selected_fe->dofs_per_cell, + DoFHandler<3,spacedim>::invalid_dof_index); + } + dof_handler.faces = new internal::DoFHandler::DoFFaces<3>; - dof_handler.faces->lines.dofs - .resize (dof_handler.tria->n_raw_lines() * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<3,spacedim>::invalid_dof_index); - dof_handler.faces->quads.dofs - .resize (dof_handler.tria->n_raw_quads() * - dof_handler.selected_fe->dofs_per_quad, - DoFHandler<3,spacedim>::invalid_dof_index); - } + dof_handler.faces->lines.dofs + .resize (dof_handler.tria->n_raw_lines() * + dof_handler.selected_fe->dofs_per_line, + DoFHandler<3,spacedim>::invalid_dof_index); + dof_handler.faces->quads.dofs + .resize (dof_handler.tria->n_raw_quads() * + dof_handler.selected_fe->dofs_per_quad, + DoFHandler<3,spacedim>::invalid_dof_index); + } - ++ + template + static + void reserve_space_mg (DoFHandler<1, spacedim>& dof_handler) { + Assert (dof_handler.get_tria ().n_levels () > 0, ExcMessage ("Invalid triangulation")); + dof_handler.clear_mg_space (); - ++ + const dealii::Triangulation<1, spacedim>& tria = dof_handler.get_tria (); + const unsigned int& dofs_per_line = dof_handler.get_fe ().dofs_per_line; + const unsigned int& n_levels = tria.n_levels (); - ++ + for (unsigned int i = 0; i < n_levels; ++i) { + dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<1>); + dof_handler.mg_levels.back ()->dof_object.dofs = std::vector (tria.n_raw_lines (i) * dofs_per_line, DoFHandler<1>::invalid_dof_index); + } - ++ + const unsigned int& n_vertices = tria.n_vertices (); - ++ + dof_handler.mg_vertex_dofs.resize (n_vertices); - ++ + std::vector max_level (n_vertices, 0); + std::vector min_level (n_vertices, n_levels); - ++ + for (typename dealii::Triangulation<1, spacedim>::cell_iterator cell = tria.begin (); cell != tria.end (); ++cell) { + const unsigned int level = cell->level (); - ++ + for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; ++vertex) { + const unsigned int vertex_index = cell->vertex_index (vertex); - ++ + if (min_level[vertex_index] > level) + min_level[vertex_index] = level; - ++ + if (max_level[vertex_index] < level) + max_level[vertex_index] = level; + } + } - ++ + for (unsigned int vertex = 0; vertex < n_vertices; ++vertex) + if (tria.vertex_used (vertex)) { + Assert (min_level[vertex] < n_levels, ExcInternalError ()); + Assert (max_level[vertex] >= min_level[vertex], ExcInternalError ()); + dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex], max_level[vertex], dof_handler.get_fe ().dofs_per_vertex); + } - ++ + else { + Assert (min_level[vertex] == n_levels, ExcInternalError ()); + Assert (max_level[vertex] == 0, ExcInternalError ()); + dof_handler.mg_vertex_dofs[vertex].init (1, 0, 0); + } + } - ++ + template + static + void reserve_space_mg (DoFHandler<2, spacedim>& dof_handler) { + Assert (dof_handler.get_tria ().n_levels () > 0, ExcMessage ("Invalid triangulation")); + dof_handler.clear_mg_space (); - ++ + const dealii::FiniteElement<2, spacedim>& fe = dof_handler.get_fe (); + const dealii::Triangulation<2, spacedim>& tria = dof_handler.get_tria (); + const unsigned int& n_levels = tria.n_levels (); - ++ + for (unsigned int i = 0; i < n_levels; ++i) { + dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<2>); + dof_handler.mg_levels.back ()->dof_object.dofs = std::vector (tria.n_raw_quads (i) * fe.dofs_per_quad, DoFHandler<2>::invalid_dof_index); + } - ++ + dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<2>; + dof_handler.mg_faces->lines.dofs = std::vector (tria.n_raw_lines () * fe.dofs_per_line, DoFHandler<2>::invalid_dof_index); - ++ + const unsigned int& n_vertices = tria.n_vertices (); - ++ + dof_handler.mg_vertex_dofs.resize (n_vertices); - ++ + std::vector max_level (n_vertices, 0); + std::vector min_level (n_vertices, n_levels); - ++ + for (typename dealii::Triangulation<2, spacedim>::cell_iterator cell = tria.begin (); cell != tria.end (); ++cell) { + const unsigned int level = cell->level (); - ++ + for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; ++vertex) { + const unsigned int vertex_index = cell->vertex_index (vertex); - ++ + if (min_level[vertex_index] > level) + min_level[vertex_index] = level; - ++ + if (max_level[vertex_index] < level) + max_level[vertex_index] = level; + } + } - ++ + for (unsigned int vertex = 0; vertex < n_vertices; ++vertex) + if (tria.vertex_used (vertex)) { + Assert (min_level[vertex] < n_levels, ExcInternalError ()); + Assert (max_level[vertex] >= min_level[vertex], ExcInternalError ()); + dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex], max_level[vertex], fe.dofs_per_vertex); + } - ++ + else { + Assert (min_level[vertex] == n_levels, ExcInternalError ()); + Assert (max_level[vertex] == 0, ExcInternalError ()); + dof_handler.mg_vertex_dofs[vertex].init (1, 0, 0); + } + } - ++ + template + static + void reserve_space_mg (DoFHandler<3, spacedim>& dof_handler) { + Assert (dof_handler.get_tria ().n_levels () > 0, ExcMessage ("Invalid triangulation")); + dof_handler.clear_mg_space (); - ++ + const dealii::FiniteElement<3, spacedim>& fe = dof_handler.get_fe (); + const dealii::Triangulation<3, spacedim>& tria = dof_handler.get_tria (); + const unsigned int& n_levels = tria.n_levels (); - ++ + for (unsigned int i = 0; i < n_levels; ++i) { + dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<3>); + dof_handler.mg_levels.back ()->dof_object.dofs = std::vector (tria.n_raw_hexs (i) * fe.dofs_per_hex, DoFHandler<3>::invalid_dof_index); + } - ++ + dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<3>; + dof_handler.mg_faces->lines.dofs = std::vector (tria.n_raw_lines () * fe.dofs_per_line, DoFHandler<3>::invalid_dof_index); + dof_handler.mg_faces->quads.dofs = std::vector (tria.n_raw_quads () * fe.dofs_per_quad, DoFHandler<3>::invalid_dof_index); - ++ + const unsigned int& n_vertices = tria.n_vertices (); - ++ + dof_handler.mg_vertex_dofs.resize (n_vertices); - ++ + std::vector max_level (n_vertices, 0); + std::vector min_level (n_vertices, n_levels); - ++ + for (typename dealii::Triangulation<3, spacedim>::cell_iterator cell = tria.begin (); cell != tria.end (); ++cell) { + const unsigned int level = cell->level (); - ++ + for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; ++vertex) { + const unsigned int vertex_index = cell->vertex_index (vertex); - ++ + if (min_level[vertex_index] > level) + min_level[vertex_index] = level; - ++ + if (max_level[vertex_index] < level) + max_level[vertex_index] = level; + } + } - ++ + for (unsigned int vertex = 0; vertex < n_vertices; ++vertex) + if (tria.vertex_used (vertex)) { + Assert (min_level[vertex] < n_levels, ExcInternalError ()); + Assert (max_level[vertex] >= min_level[vertex], ExcInternalError ()); + dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex], max_level[vertex], fe.dofs_per_vertex); + } - ++ + else { + Assert (min_level[vertex] == n_levels, ExcInternalError ()); + Assert (max_level[vertex] == 0, ExcInternalError ()); + dof_handler.mg_vertex_dofs[vertex].init (1, 0, 0); + } + } - ++ + template + static + unsigned int distribute_dofs_on_cell (typename DoFHandler<1, spacedim>::cell_iterator& cell, unsigned int next_free_dof) { + const FiniteElement<1, spacedim>& fe = cell->get_fe (); - ++ + if (fe.dofs_per_vertex > 0) + for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; ++vertex) { + typename DoFHandler<1, spacedim>::cell_iterator neighbor = cell->neighbor (vertex); - ++ + if (neighbor.state () == IteratorState::valid) + if (neighbor->user_flag_set () && (neighbor->level () == cell->level ())) { + if (vertex == 0) + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + cell->set_mg_vertex_dof_index (cell->level (), 0, dof, neighbor->mg_vertex_dof_index (cell->level (), 1, dof)); - ++ + else + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + cell->set_mg_vertex_dof_index (cell->level (), 1, dof, neighbor->mg_vertex_dof_index (cell->level (), 0, dof)); - ++ + continue; + } - ++ + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + cell->set_mg_vertex_dof_index (cell->level (), vertex, dof, next_free_dof++); + } - ++ + if (fe.dofs_per_line > 0) + for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof) + cell->set_mg_dof_index (cell->level (), dof, next_free_dof++); - ++ + cell->set_user_flag (); + return next_free_dof; + } - ++ + template + static + unsigned int distribute_dofs_on_cell (typename DoFHandler<2, spacedim>::cell_iterator& cell, unsigned int next_free_dof) { + const FiniteElement<2, spacedim>& fe = cell->get_fe (); - ++ + if (fe.dofs_per_vertex > 0) + for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; ++vertex) + if (cell->mg_vertex_dof_index (cell->level (), vertex, 0) == DoFHandler<2>::invalid_dof_index) + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + cell->set_mg_vertex_dof_index (cell->level (), vertex, dof, next_free_dof++); - ++ + if (fe.dofs_per_line > 0) + for (unsigned int face = 0; face < GeometryInfo<2>::faces_per_cell; ++face) { + typename DoFHandler<2, spacedim>::line_iterator line = cell->line (face); - ++ + if (line->mg_dof_index (cell->level (), 0) == DoFHandler<2>::invalid_dof_index) + for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof) + line->set_mg_dof_index (cell->level (), dof, next_free_dof++); + } - ++ + if (fe.dofs_per_quad > 0) + for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof) + cell->set_mg_dof_index (cell->level (), dof, next_free_dof++); - ++ + cell->set_user_flag (); + return next_free_dof; + } - ++ + template + static + unsigned int distribute_dofs_on_cell (typename DoFHandler<3, spacedim>::cell_iterator& cell, unsigned int next_free_dof) { + const FiniteElement<3, spacedim>& fe = cell->get_fe (); - ++ + if (fe.dofs_per_vertex > 0) + for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; ++vertex) + if (cell->mg_vertex_dof_index (cell->level (), vertex, 0) == DoFHandler<3>::invalid_dof_index) + for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof) + cell->set_mg_vertex_dof_index (cell->level (), vertex, dof, next_free_dof++); - ++ + if (fe.dofs_per_line > 0) + for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell; ++line) { + typename DoFHandler<3, spacedim>::line_iterator line_it = cell->line (line); - ++ + if (line_it->mg_dof_index (cell->level (), 0) == DoFHandler<3>::invalid_dof_index) + for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof) + line_it->set_mg_dof_index (cell->level (), dof, next_free_dof++); + } - ++ + if (fe.dofs_per_quad > 0) + for (unsigned int face = 0; face < GeometryInfo<3>::quads_per_cell; ++face) { + typename DoFHandler<3, spacedim>::quad_iterator quad = cell->quad (face); - ++ + if (quad->mg_dof_index (cell->level (), 0) == DoFHandler<3>::invalid_dof_index) + for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof) + quad->set_mg_dof_index (cell->level (), dof, next_free_dof++); + } - ++ + if (fe.dofs_per_hex > 0) + for (unsigned int dof = 0; dof < fe.dofs_per_hex; ++dof) + cell->set_mg_dof_index (cell->level (), dof, next_free_dof++); - ++ + cell->set_user_flag (); + return next_free_dof; + } - ++ + template + static + unsigned int get_dof_index (const DoFHandler<1, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<1>& mg_level, internal::DoFHandler::DoFFaces<1>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<1>) { + return mg_level.dof_object.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } - ++ + template + static + unsigned int get_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>&, internal::DoFHandler::DoFFaces<2>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<1>) { + return mg_faces.lines.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } - ++ + template + static + unsigned int get_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>& mg_level, internal::DoFHandler::DoFFaces<2>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<2>) { + return mg_level.dof_object.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } - ++ + template + static + unsigned int get_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<1>) { + return mg_faces.lines.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } - ++ + template + static + unsigned int get_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<2>) { + return mg_faces.quads.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } - ++ + template + static + unsigned int get_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>& mg_level, internal::DoFHandler::DoFFaces<3>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<3>) { + return mg_level.dof_object.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } - ++ + template + static + void set_dof_index (const DoFHandler<1, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<1>& mg_level, internal::DoFHandler::DoFFaces<1>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<1>) { + mg_level.dof_object.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } - ++ + template + static + void set_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>&, internal::DoFHandler::DoFFaces<2>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<1>) { + mg_faces.lines.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } - ++ + template + static + void set_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>& mg_level, internal::DoFHandler::DoFFaces<2>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<2>) { + mg_level.dof_object.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } - ++ + template + static + void set_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<1>) { + mg_faces.lines.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } - ++ + template + static + void set_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<2>) { + mg_faces.quads.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } - ++ + template + static + void set_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>& mg_level, internal::DoFHandler::DoFFaces<3>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<3>) { + mg_level.dof_object.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } }; } } @@@ -1656,25 -671,16 +1001,25 @@@ std::size_ DoFHandler::memory_consumption () const { std::size_t mem = (MemoryConsumption::memory_consumption (tria) + - MemoryConsumption::memory_consumption (selected_fe) + - MemoryConsumption::memory_consumption (block_info_object) + - MemoryConsumption::memory_consumption (levels) + - MemoryConsumption::memory_consumption (*faces) + - MemoryConsumption::memory_consumption (faces) + - sizeof (number_cache) + - MemoryConsumption::memory_consumption (vertex_dofs)); + MemoryConsumption::memory_consumption (selected_fe) + + MemoryConsumption::memory_consumption (block_info_object) + + MemoryConsumption::memory_consumption (levels) + + MemoryConsumption::memory_consumption (*faces) + + MemoryConsumption::memory_consumption (faces) + + sizeof (number_cache) + + MemoryConsumption::memory_consumption (vertex_dofs)); for (unsigned int i=0; imemory_consumption (); - ++ + mem += MemoryConsumption::memory_consumption (*mg_faces); - ++ + for (unsigned int i = 0; i < mg_vertex_dofs.size (); ++i) + mem += sizeof (MGVertexDoFs) + (1 + mg_vertex_dofs[i].get_finest_level () - mg_vertex_dofs[i].get_coarsest_level ()) * sizeof (unsigned int); - ++ + mem += MemoryConsumption::memory_consumption (mg_used_dofs); return mem; } @@@ -1717,53 -723,6 +1062,53 @@@ distribute_dofs (const FiniteElement +void DoFHandler::distribute_mg_dofs (const FiniteElement& fe) { + Assert ((dynamic_cast*> (&*tria) == 0), ExcMessage ("Invalid triangulation")); + distribute_dofs (fe); + reserve_space (); - ++ + const unsigned int& n_levels = (*tria).n_levels (); - ++ + mg_used_dofs.resize (n_levels, 0); - ++ + std::vector user_flags; - ++ + (*tria).save_user_flags (user_flags); + const_cast&>(*tria).clear_user_flags (); - ++ + for (unsigned int level = 0; level < n_levels; ++level) { + unsigned int next_free_dof = 0; - ++ + for (cell_iterator cell = begin (level); cell != end (level); ++cell) + next_free_dof = internal::DoFHandler::Implementation::distribute_dofs_on_cell (cell, next_free_dof); - ++ + mg_used_dofs[level] = next_free_dof; + } - ++ + const_cast&>(*tria).load_user_flags (user_flags); + block_info_object.initialize (*this, true, true); +} + +template +void DoFHandler::reserve_space () { + internal::DoFHandler::Implementation::reserve_space_mg (*this); +} + +template +void DoFHandler::clear_mg_space () { + for (unsigned int i = 0; i < mg_levels.size (); ++i) + delete mg_levels[i]; - ++ + mg_levels.clear (); + delete mg_faces; + mg_faces = NULL; - ++ + std::vector tmp; - ++ + std::swap (mg_vertex_dofs, tmp); +} + template void DoFHandler::initialize_local_block_info () @@@ -1886,72 -844,6 +1231,72 @@@ void DoFHandler::clear_sp std::swap (vertex_dofs, tmp); } +template +template +unsigned int DoFHandler::get_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const { + return internal::DoFHandler::Implementation::get_dof_index (*this, *this->mg_levels[obj_level], *this->mg_faces, obj_index, fe_index, local_index, internal::int2type ()); +} + +template +template +void DoFHandler::set_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index) const { + internal::DoFHandler::Implementation::set_dof_index (*this, *this->mg_levels[obj_level], *this->mg_faces, obj_index, fe_index, local_index, global_index, internal::int2type ()); +} + +template +DoFHandler::MGVertexDoFs::MGVertexDoFs (): coarsest_level (numbers::invalid_unsigned_int), finest_level (0), indices (0), indices_offset (0) { +} + +template +DoFHandler::MGVertexDoFs::~MGVertexDoFs () { + delete[] indices; + delete[] indices_offset; +} + +template +void DoFHandler::MGVertexDoFs::init (const unsigned int cl, const unsigned int fl, const unsigned int dofs_per_vertex) { + if (indices != 0) { + delete[] indices; + indices = 0; + } - ++ + if (indices_offset != 0) { + delete[] indices_offset; + indices_offset = 0; + } - ++ + coarsest_level = cl; + finest_level = fl; - ++ + if (cl > fl) + return; - ++ + const unsigned int n_levels = finest_level - coarsest_level + 1; + const unsigned int n_indices = n_levels * dofs_per_vertex; - ++ + indices = new unsigned int[n_indices]; + Assert (indices != 0, ExcNoMemory ()); - ++ + for (unsigned int i = 0; i < n_indices; ++i) + indices[i] = DoFHandler::invalid_dof_index; - ++ + indices_offset = new unsigned int[n_levels]; + Assert (indices != 0, ExcNoMemory ()); - ++ + for (unsigned int i = 0; i < n_levels; ++i) + indices_offset[i] = i * dofs_per_vertex; +} + +template +unsigned int DoFHandler::MGVertexDoFs::get_coarsest_level () const { + return coarsest_level; +} + +template +unsigned int DoFHandler::MGVertexDoFs::get_finest_level () const { + return finest_level; +} + /*-------------- Explicit Instantiations -------------------------------*/ #include "dof_handler.inst" diff --cc deal.II/source/hp/dof_handler.cc index 9ccba56110,1e162dcfb9..064fb2f90a --- a/deal.II/source/hp/dof_handler.cc +++ b/deal.II/source/hp/dof_handler.cc @@@ -3161,10 -2189,15 +2190,15 @@@ template < // at most 2 Table<2,std_cxx1x::shared_ptr > line_dof_identities (finite_elements->size(), - finite_elements->size()); + finite_elements->size()); - for (line_iterator line=begin_line(); line!=end_line(); ++line) - { + for (active_cell_iterator cell=begin_active(); cell!=end(); ++cell) + for (unsigned int l=0; l::lines_per_cell; ++l) + if (cell->line(l)->user_flag_set() == false) + { + const line_iterator line = cell->line(l); + line->set_user_flag (); + unsigned int unique_sets_of_dofs = line->n_active_fe_indices(); @@@ -3396,59 -2442,69 +2443,69 @@@ // particularly frequent case Table<2,std_cxx1x::shared_ptr > quad_dof_identities (finite_elements->size(), - finite_elements->size()); + finite_elements->size()); - for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad) - if (quad->n_active_fe_indices() == 2) - { - // find out which is the - // most dominating finite - // element of the ones that - // are used on this quad - const unsigned int most_dominating_fe_index - = internal::hp::get_most_dominating_fe_index (quad); - - const unsigned int n_active_fe_indices - = quad->n_active_fe_indices (); - - // loop over the indices of - // all the finite elements - // that are not dominating, - // and identify their dofs - // to the most dominating - // one - for (unsigned int f=0; fnth_active_fe_index (f) != - most_dominating_fe_index) - { - const unsigned int - other_fe_index = quad->nth_active_fe_index (f); - - internal::hp::ensure_existence_of_dof_identities<2> - ((*finite_elements)[most_dominating_fe_index], - (*finite_elements)[other_fe_index], - quad_dof_identities[most_dominating_fe_index][other_fe_index]); - - internal::hp::DoFIdentities &identities - = *quad_dof_identities[most_dominating_fe_index][other_fe_index]; - for (unsigned int i=0; idof_index (identities[i].first, most_dominating_fe_index); - const unsigned int slave_dof_index - = quad->dof_index (identities[i].second, other_fe_index); - - Assert ((new_dof_indices[master_dof_index] == - numbers::invalid_unsigned_int) - || - (new_dof_indices[slave_dof_index] == - master_dof_index), - ExcInternalError()); - - new_dof_indices[slave_dof_index] = master_dof_index; - } - } - } + for (active_cell_iterator cell=begin_active(); cell!=end(); ++cell) + for (unsigned int q=0; q::quads_per_cell; ++q) + if ((cell->quad(q)->user_flag_set() == false) + && + (cell->quad(q)->n_active_fe_indices() == 2)) + { + const quad_iterator quad = cell->quad(q); + quad->set_user_flag (); + + // find out which is the + // most dominating finite + // element of the ones that + // are used on this quad + const unsigned int most_dominating_fe_index + = internal::hp::get_most_dominating_fe_index (quad); + + const unsigned int n_active_fe_indices + = quad->n_active_fe_indices (); + + // loop over the indices of + // all the finite elements + // that are not dominating, + // and identify their dofs + // to the most dominating + // one + for (unsigned int f=0; fnth_active_fe_index (f) != + most_dominating_fe_index) + { + const unsigned int + other_fe_index = quad->nth_active_fe_index (f); + + internal::hp::ensure_existence_of_dof_identities<2> + ((*finite_elements)[most_dominating_fe_index], + (*finite_elements)[other_fe_index], + quad_dof_identities[most_dominating_fe_index][other_fe_index]); + + internal::hp::DoFIdentities &identities + = *quad_dof_identities[most_dominating_fe_index][other_fe_index]; + for (unsigned int i=0; idof_index (identities[i].first, most_dominating_fe_index); + const unsigned int slave_dof_index + = quad->dof_index (identities[i].second, other_fe_index); + + Assert ((new_dof_indices[master_dof_index] == + numbers::invalid_unsigned_int) + || + (new_dof_indices[slave_dof_index] == + master_dof_index), + ExcInternalError()); + + new_dof_indices[slave_dof_index] = master_dof_index; + } + } + } + + // finally restore the user flags + const_cast &>(this->get_tria()) + .load_user_flags_quad(user_flags); } @@@ -3739,8 -2813,11 +2814,11 @@@ void DoFHandler<2,2>:: renumber_dofs_internal (const std::vector &new_numbers, - internal::int2type<2>) + internal::int2type<2>) { + const unsigned int dim = 2; + const unsigned int spacedim = 2; + Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete()); renumber_dofs_internal (new_numbers, internal::int2type<1>()); @@@ -3769,8 -2865,11 +2866,11 @@@ void DoFHandler<2,3>:: renumber_dofs_internal (const std::vector &new_numbers, - internal::int2type<2>) + internal::int2type<2>) { + const unsigned int dim = 2; + const unsigned int spacedim = 3; + Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete()); renumber_dofs_internal (new_numbers, internal::int2type<1>()); @@@ -3798,8 -2916,11 +2917,11 @@@ void DoFHandler<3,3>:: renumber_dofs_internal (const std::vector &new_numbers, - internal::int2type<2>) + internal::int2type<2>) { + const unsigned int dim = 3; + const unsigned int spacedim = 3; + Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete()); renumber_dofs_internal (new_numbers, internal::int2type<1>()); @@@ -3827,8 -2967,11 +2968,11 @@@ void DoFHandler<3,3>:: renumber_dofs_internal (const std::vector &new_numbers, - internal::int2type<3>) + internal::int2type<3>) { + const unsigned int dim = 3; + const unsigned int spacedim = 3; + Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete()); renumber_dofs_internal (new_numbers, internal::int2type<2>()); @@@ -4142,32 -3306,6 +3308,32 @@@ template < } + template + template + unsigned int + DoFHandler::get_dof_index (const unsigned int, + const unsigned int, + const unsigned int, + const unsigned int) const + { + Assert (false, ExcNotImplemented()); + return numbers::invalid_unsigned_int; + } + + + template + template + void + DoFHandler::set_dof_index (const unsigned int, + const unsigned int, + const unsigned int, + const unsigned int, + const unsigned int) const + { - Assert (false, ExcNotImplemented()); ++ Assert (false, ExcNotImplemented()); + } + + template void DoFHandler::clear_space () {