From: bangerth Date: Fri, 14 Sep 2012 21:46:41 +0000 (+0000) Subject: Merge from the upstream branch. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1b740840b7aeb357965038f9e46e3244a606db0;p=dealii-svn.git Merge from the upstream branch. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_3@26395 0785d39b-7218-0410-832d-ea1e28bc413d --- d1b740840b7aeb357965038f9e46e3244a606db0 diff --cc deal.II/examples/step-42/step-42.cc index 54bdc04736,3085e6a0ce..6eaa6c85d4 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@@ -659,7 -662,8 +662,8 @@@ namespace Step4 FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); Vector cell_rhs (dofs_per_cell); - std::vector local_dof_indices (dofs_per_cell); + std::vector local_dof_indices (dofs_per_cell); + typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); @@@ -1365,21 -1355,45 +1355,45 @@@ void PlasticityContactProblem::run () { pcout << "Solving problem in " << dim << " space dimensions." << std::endl; - + + Timer t; run_time.resize (8); - clock_t start, end; + const unsigned int n_cycles = 5; + for (unsigned int cycle=0; cycle(-2); - /** - * The type used to denote global dof - * indices. - */ + +#ifdef DEAL_II_USE_LARGE_INDEX_TYPE + /** + * The type used for global indices of + * degrees of freedom. While in sequential + * computations the 4 billion indices of + * 32-bit unsigned integers is plenty, + * parallel computations using the + * parallel::distributed::Triangulation + * class can overflow this number and we + * need a bigger index space. + * + * The data type always indicates an + * unsigned integer type. + */ + typedef unsigned long long int global_dof_index; + + /** + * An identifier that denotes the MPI type + * associated with types::global_dof_index. + */ +# define DEAL_II_DOF_INDEX_MPI_TYPE MPI_UNSIGNED_LONG_LONG +#else + /** + * The type used for global indices of + * degrees of freedom. While in sequential + * computations the 4 billion indices of + * 32-bit unsigned integers is plenty, + * parallel computations using the + * parallel::distributed::Triangulation + * class can overflow this number and we + * need a bigger index space. + * + * The data type always indicates an + * unsigned integer type. + */ typedef unsigned int global_dof_index; + /** + * An identifier that denotes the MPI type + * associated with types::global_dof_index. + */ +# define DEAL_II_DOF_INDEX_MPI_TYPE MPI_UNSIGNED +#endif + - /** - * An invalid value for indices of degrees - * of freedom. - */ + /** + * @deprecated Use numbers::invalid_dof_index + */ const global_dof_index invalid_dof_index = static_cast(-1); + /** * The type used to denote boundary indicators associated with every * piece of the boundary and, in the case of meshes that describe @@@ -154,14 -95,88 +135,88 @@@ */ typedef material_id material_id_t; - /** - * Invalid material_id which we need in several places as a default value. - * We assume that all material_ids lie in the range [0, invalid_material_id). - */ - const material_id invalid_material_id = static_cast(-1); + } + ++ + // this part of the namespace numbers got moved to the bottom types.h file, + // because otherwise we get a circular inclusion of config.h, types.h, and + // numbers.h + namespace numbers + { + /** + * Representation of the + * largest number that + * can be put into an + * unsigned integer. This + * value is widely used + * throughout the library + * as a marker for an + * invalid unsigned + * integer value, such as + * an invalid array + * index, an invalid + * array size, and the + * like. + */ + static const unsigned int + invalid_unsigned_int = static_cast (-1); + + /** + * An invalid value for indices of degrees + * of freedom. + */ + const types::global_dof_index invalid_dof_index = static_cast(-1); + /** + * Invalid material_id which we + * need in several places as a + * default value. We assume that + * all material_ids lie in the + * range [0, invalid_material_id). + */ + const types::material_id invalid_material_id = static_cast(-1); + /** + * The number which we reserve for + * internal faces. We assume that + * all boundary_ids lie in the + * range [0, + * internal_face_boundary_id). + */ + const types::boundary_id internal_face_boundary_id = static_cast(-1); + /** + * A special id for an invalid + * subdomain id. This value may not + * be used as a valid id but is + * used, for example, for default + * arguments to indicate a + * subdomain id that is not to be + * used. + * + * See the @ref GlossSubdomainId + * "glossary" for more information. + */ + const types::subdomain_id invalid_subdomain_id = static_cast(-1); + + /** + * The subdomain id assigned to a + * cell whose true subdomain id we + * don't know, for example because + * it resides on a different + * processor on a mesh that is kept + * distributed on many + * processors. Such cells are + * called "artificial". + * + * See the glossary entries on @ref + * GlossSubdomainId "subdomain ids" + * and @ref GlossArtificialCell + * "artificial cells" as well as + * the @ref distributed module for + * more information. + */ + const types::subdomain_id artificial_subdomain_id = static_cast(-2); - } diff --cc deal.II/include/deal.II/dofs/dof_accessor.templates.h index 2f5c092e16,3db0ddefe8..ae4b831bc8 --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@@ -218,510 -216,510 +218,510 @@@ namespace interna * Implementations of the * get_dof_index/set_dof_index functions. */ - template - static - unsigned int - get_dof_index (const dealii::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<1>) - { - return dof_handler.levels[obj_level]->dof_object. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index); - } - - - template - static - void - set_dof_index (const dealii::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<1>, - const unsigned int global_index) - { - dof_handler.levels[obj_level]->dof_object. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index); - } - - - template - static - unsigned int - get_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<1>) - { + template + static + types::global_dof_index + get_dof_index (const dealii::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<1>) + { - return dof_handler.levels[obj_level]->lines. ++ return dof_handler.levels[obj_level]->dof_object. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index); + } + + + template + static + void + set_dof_index (const dealii::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<1>, + const types::global_dof_index global_index) + { - dof_handler.levels[obj_level]->lines. ++ dof_handler.levels[obj_level]->dof_object. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<1>) + { // faces have no levels - Assert (obj_level == 0, ExcInternalError()); - return dof_handler.faces->lines. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index); - } - - - template - static - void - set_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<1>, - const unsigned int global_index) - { + Assert (obj_level == 0, ExcInternalError()); + return dof_handler.faces->lines. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index); + } + + + template + static + void + set_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<1>, + const types::global_dof_index global_index) + { // faces have no levels - Assert (obj_level == 0, ExcInternalError()); - dof_handler.faces->lines. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index); - } - - - template - static - unsigned int - get_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<2>) - { - return dof_handler.levels[obj_level]->dof_object. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index); - } - - - template - static - void - set_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<2>, - const unsigned int global_index) - { - dof_handler.levels[obj_level]->dof_object. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index); - } - - - template - static - unsigned int - get_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<1>) - { + Assert (obj_level == 0, ExcInternalError()); + dof_handler.faces->lines. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<2>) + { - return dof_handler.levels[obj_level]->quads. ++ return dof_handler.levels[obj_level]->dof_object. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index); + } + + + template + static + void + set_dof_index (const dealii::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<2>, + const types::global_dof_index global_index) + { - dof_handler.levels[obj_level]->quads. ++ dof_handler.levels[obj_level]->dof_object. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<1>) + { // faces have no levels - Assert (obj_level == 0, ExcInternalError()); - return dof_handler.faces->lines. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index); - } - - - template - static - void - set_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<1>, - const unsigned int global_index) - { + Assert (obj_level == 0, ExcInternalError()); + return dof_handler.faces->lines. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index); + } + + + template + static + void + set_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<1>, + const types::global_dof_index global_index) + { // faces have no levels - Assert (obj_level == 0, ExcInternalError()); - dof_handler.faces->lines. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index); - } - - - - template - static - unsigned int - get_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<2>) - { + Assert (obj_level == 0, ExcInternalError()); + dof_handler.faces->lines. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index); + } + + + + template + static + types::global_dof_index + get_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<2>) + { // faces have no levels - Assert (obj_level == 0, ExcInternalError()); - return dof_handler.faces->quads. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index); - } - - - template - static - void - set_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<2>, - const unsigned int global_index) - { + Assert (obj_level == 0, ExcInternalError()); + return dof_handler.faces->quads. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index); + } + + + template + static + void + set_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<2>, + const types::global_dof_index global_index) + { // faces have no levels - Assert (obj_level == 0, ExcInternalError()); - dof_handler.faces->quads. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index); - } - - - - template - static - unsigned int - get_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<3>) - { - return dof_handler.levels[obj_level]->dof_object. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index); - } - - - template - static - void - set_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - dealii::internal::int2type<3>, - const unsigned int global_index) - { - dof_handler.levels[obj_level]->dof_object. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index); - } - - - template - static - unsigned int - get_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.levels[obj_level]->dof_object. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - obj_level); - } - - - template - static - void - set_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<1> &, - const unsigned int global_index) - { - dof_handler.levels[obj_level]->dof_object. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index, - obj_level); - } - - - template - static - unsigned int - get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - obj_level); - } - - - template - static - void - set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<1> &, - const unsigned int global_index) - { - dof_handler.faces->lines. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index, - obj_level); - } - - - template - static - unsigned int - get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<2> &) - { - return dof_handler.levels[obj_level]->dof_object. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - obj_level); - } - - - template - static - void - set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<2> &, - const unsigned int global_index) - { - dof_handler.levels[obj_level]->dof_object. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index, - obj_level); - } - - - template - static - unsigned int - get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<1> &) - { - return dof_handler.faces->lines. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - obj_level); - } - - - template - static - void - set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<1> &, - const unsigned int global_index) - { - dof_handler.faces->lines. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index, - obj_level); - } - - - template - static - unsigned int - get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<2> &) - { - return dof_handler.faces->quads. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - obj_level); - } - - - template - static - void - set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<2> &, - const unsigned int global_index) - { - dof_handler.faces->quads. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index, - obj_level); - } - - - template - static - unsigned int - get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<3> &) - { - return dof_handler.levels[obj_level]->dof_object. - get_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - obj_level); - } - - - template - static - void - set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const dealii::internal::int2type<3> &, - const unsigned int global_index) - { - dof_handler.levels[obj_level]->dof_object. - set_dof_index (dof_handler, - obj_index, - fe_index, - local_index, - global_index, - obj_level); - } - - - template - static - bool - fe_index_is_active (const dealii::DoFHandler &, - const unsigned int, - const unsigned int, - const unsigned int fe_index, - const dealii::internal::int2type &) - { - return (fe_index == 0); - } - - - - template - static - unsigned int - n_active_fe_indices (const dealii::DoFHandler &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const dealii::internal::int2type &) - { + Assert (obj_level == 0, ExcInternalError()); + dof_handler.faces->quads. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index); + } + + + + template + static + types::global_dof_index + get_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<3>) + { - return dof_handler.levels[obj_level]->hexes. ++ return dof_handler.levels[obj_level]->dof_object. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index); + } + + + template + static + void + set_dof_index (const dealii::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + dealii::internal::int2type<3>, + const types::global_dof_index global_index) + { - dof_handler.levels[obj_level]->hexes. ++ dof_handler.levels[obj_level]->dof_object. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<1> &) + { - return dof_handler.levels[obj_level]->lines. ++ return dof_handler.levels[obj_level]->dof_object. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + obj_level); + } + + + template + static + void + set_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<1> &, + const types::global_dof_index global_index) + { - dof_handler.levels[obj_level]->lines. ++ dof_handler.levels[obj_level]->dof_object. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index, + obj_level); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + obj_level); + } + + + template + static + void + set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<1> &, + const types::global_dof_index global_index) + { + dof_handler.faces->lines. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index, + obj_level); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<2> &) + { - return dof_handler.levels[obj_level]->quads. ++ return dof_handler.levels[obj_level]->dof_object. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + obj_level); + } + + + template + static + void + set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<2> &, + const types::global_dof_index global_index) + { - dof_handler.levels[obj_level]->quads. ++ dof_handler.levels[obj_level]->dof_object. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index, + obj_level); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<1> &) + { + return dof_handler.faces->lines. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + obj_level); + } + + + template + static + void + set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<1> &, + const types::global_dof_index global_index) + { + dof_handler.faces->lines. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index, + obj_level); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<2> &) + { + return dof_handler.faces->quads. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + obj_level); + } + + + template + static + void + set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<2> &, + const types::global_dof_index global_index) + { + dof_handler.faces->quads. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index, + obj_level); + } + + + template + static + types::global_dof_index + get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<3> &) + { - return dof_handler.levels[obj_level]->hexes. ++ return dof_handler.levels[obj_level]->dof_object. + get_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + obj_level); + } + + + template + static + void + set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const dealii::internal::int2type<3> &, + const types::global_dof_index global_index) + { - dof_handler.levels[obj_level]->hexes. ++ dof_handler.levels[obj_level]->dof_object. + set_dof_index (dof_handler, + obj_index, + fe_index, + local_index, + global_index, + obj_level); + } + + + template + static + bool + fe_index_is_active (const dealii::DoFHandler &, + const unsigned int, + const unsigned int, + const unsigned int fe_index, + const dealii::internal::int2type &) + { + return (fe_index == 0); + } + + + + template + static + unsigned int + n_active_fe_indices (const dealii::DoFHandler &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const dealii::internal::int2type &) + { // check that the object we look // at is in fact active. the // problem is that we have @@@ -786,310 -784,310 +786,310 @@@ // 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 (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")); + 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]->lines.fe_index_is_active(dof_handler, ++ 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]->lines.n_active_fe_indices (dof_handler, ++ 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]->lines.nth_active_fe_index (dof_handler, ++ 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]->quads.fe_index_is_active(dof_handler, ++ 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]->quads.n_active_fe_indices (dof_handler, ++ 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]->quads.nth_active_fe_index (dof_handler, ++ 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]->hexes.fe_index_is_active(dof_handler, ++ 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]->hexes.n_active_fe_indices (dof_handler, ++ 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]->hexes.nth_active_fe_index (dof_handler, ++ 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 diff --cc deal.II/include/deal.II/dofs/dof_handler.h index d352b8d2f5,68fdcc45d8..9beeb0fb0b --- a/deal.II/include/deal.II/dofs/dof_handler.h +++ b/deal.II/include/deal.II/dofs/dof_handler.h @@@ -317,11 -305,8 +305,12 @@@ class DoFHandler : public Subscripto * releases the lock of this * object to the finite element. */ - virtual void distribute_dofs (const FiniteElement &fe, - const types::global_dof_index offset = 0); + virtual void distribute_dofs (const FiniteElement &fe); + ++ virtual void distribute_mg_dofs (const FiniteElement& fe); + + virtual void distribute_mg_dofs (const FiniteElement& fe, const types::global_dof_index offset = 0); + /** * After distribute_dofs() with * an FESystem element, the block diff --cc deal.II/include/deal.II/dofs/dof_levels.h index fd103594e9,e35c38aa05..dff7c9fd8d --- a/deal.II/include/deal.II/dofs/dof_levels.h +++ b/deal.II/include/deal.II/dofs/dof_levels.h @@@ -108,106 -77,14 +77,14 @@@ namespace interna * times * selected_fe.dofs_per_cell. */ - std::vector cell_dof_indices_cache; + std::vector cell_dof_indices_cache; + /** + * The object containing dof-indices + * and related access-functions + */ + DoFObjects dof_object; - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. - */ - std::size_t memory_consumption () const; - - /** - * Read or write the data of this object to or - * from a stream for the purpose of serialization - */ - template - void serialize(Archive & ar, - const unsigned int version); - }; - - /** - * Store the indices of the degrees of freedom which are located on - * lines. See the general template DoFLevel for more information. - * - * @author Wolfgang Bangerth, 1998, 2006 - */ - template <> - class DoFLevel<1> : public DoFLevel<0> - { - public: - /** - * The object containing dof-indices - * and related access-functions - */ - DoFObjects<1> lines; - - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. - */ - std::size_t memory_consumption () const; - - /** - * Read or write the data of this object to or - * from a stream for the purpose of serialization - */ - template - void serialize(Archive & ar, - const unsigned int version); - }; - - - /** - * Store the indices of the degrees of freedom which are located on - * quads. See the general template DoFLevel for more information. - * - * @author Wolfgang Bangerth, 1998, 2006 - */ - template <> - class DoFLevel<2> : public DoFLevel<0> - { - public: - /** - * The object containing dof-indices - * and related access-functions - */ - internal::DoFHandler::DoFObjects<2> quads; - - /** - * Determine an estimate for the - * memory consumption (in bytes) - * of this object. - */ - std::size_t memory_consumption () const; - - /** - * Read or write the data of this object to or - * from a stream for the purpose of serialization - */ - template - void serialize(Archive & ar, - const unsigned int version); - }; - - - /** - * Store the indices of the degrees of freedom which are located on - * hexhedra. See the general template DoFLevel for more information. - * - * @author Wolfgang Bangerth, 1998, 2006 - */ - template <> - class DoFLevel<3> : public DoFLevel<0> - { - public: - /** - * The object containing dof-indices - * and related access-functions - */ - internal::DoFHandler::DoFObjects<3> hexes; /** * Determine an estimate for the diff --cc deal.II/include/deal.II/lac/constraint_matrix.h index 3ad0737d1c,446aebe8b9..8fabf6a013 --- a/deal.II/include/deal.II/lac/constraint_matrix.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.h @@@ -451,10 -467,10 +467,10 @@@ class ConstraintMatrix : public Subscri * to the same degrees of freedom, * you'd generate several constraint * objects, then shift them, and - * finally @p merge them together + * finally merge() them together * again. */ - void shift (const unsigned int offset); + void shift (const types::global_dof_index offset); /** * Clear all entries of this diff --cc deal.II/source/dofs/dof_handler.cc index 4be24de818,b0ae632789..b808d04f5e --- 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_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); - } - } - - - 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()->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.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); - - 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()->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.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 (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()->lines.dofs ++ 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); + } + } + + + 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()->quads.dofs ++ 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()->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.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); + + for (unsigned int i=0; in_levels(); ++i) + { + dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>); + - dof_handler.levels.back()->hexes.dofs ++ 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()->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.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 ()->lines.dofs = std::vector (tria.n_raw_lines (i) * dofs_per_line, DoFHandler<1>::invalid_dof_index); ++ 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 ()->quads.dofs = std::vector (tria.n_raw_quads (i) * fe.dofs_per_quad, DoFHandler<2>::invalid_dof_index); ++ 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 ()->hexes.dofs = std::vector (tria.n_raw_hexs (i) * fe.dofs_per_hex, DoFHandler<3>::invalid_dof_index); ++ 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 + types::global_dof_index distribute_dofs_on_cell (typename DoFHandler<1, spacedim>::cell_iterator& cell, types::global_dof_index 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 + types::global_dof_index distribute_dofs_on_cell (typename DoFHandler<2, spacedim>::cell_iterator& cell, types::global_dof_index 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 + types::global_dof_index distribute_dofs_on_cell (typename DoFHandler<3, spacedim>::cell_iterator& cell, types::global_dof_index 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 + types::global_dof_index 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.lines.get_dof_index (dof_handler, obj_index, fe_index, local_index); ++ return mg_level.dof_object.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } + + template + static + types::global_dof_index 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 + types::global_dof_index 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.quads.get_dof_index (dof_handler, obj_index, fe_index, local_index); ++ return mg_level.dof_object.get_dof_index (dof_handler, obj_index, fe_index, local_index); + } + + template + static + types::global_dof_index 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 + types::global_dof_index 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 + types::global_dof_index 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.hexes.get_dof_index (dof_handler, obj_index, fe_index, local_index); ++ 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 types::global_dof_index global_index, const int2type<1>) { - mg_level.lines.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); ++ 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 types::global_dof_index 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 types::global_dof_index global_index, const int2type<2>) { - mg_level.quads.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); ++ 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 types::global_dof_index 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 types::global_dof_index 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 types::global_dof_index global_index, const int2type<3>) { - mg_level.hexes.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); ++ mg_level.dof_object.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index); + } }; } } @@@ -1906,11 -1576,11 +1906,11 @@@ types::global_dof_index DoFHandler -unsigned int +types::global_dof_index DoFHandler::n_boundary_dofs (const FunctionMap &boundary_indicators) const { - Assert (boundary_indicators.find(types::internal_face_boundary_id) == boundary_indicators.end(), + Assert (boundary_indicators.find(numbers::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); std::set boundary_dofs; @@@ -1932,11 -1602,11 +1932,11 @@@ template -unsigned int +types::global_dof_index DoFHandler::n_boundary_dofs (const std::set &boundary_indicators) const { - Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(), + Assert (boundary_indicators.find (numbers::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); std::set boundary_dofs; @@@ -2027,53 -1686,6 +2025,53 @@@ distribute_dofs (const FiniteElement - void DoFHandler::distribute_mg_dofs (const FiniteElement& fe, const types::global_dof_index offset) { ++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) { - types::global_dof_index next_free_dof = offset; ++ types::global_dof_index 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 () diff --cc deal.II/source/dofs/dof_handler_policy.cc index ea53851a2d,bbfd215918..08f5fdedf2 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@@ -223,8 -224,8 +223,8 @@@ namespace interna */ template static - types::global_dof_index - unsigned int - distribute_dofs (const unsigned int offset, ++ types::global_dof_index + distribute_dofs (const types::global_dof_index offset, const types::subdomain_id subdomain_id, DoFHandler &dof_handler) { @@@ -324,9 -325,9 +324,9 @@@ ExcInternalError ()); for (unsigned int level=0; level::iterator + for (std::vector::iterator - i=dof_handler.levels[level]->lines.dofs.begin(); - i!=dof_handler.levels[level]->lines.dofs.end(); ++i) + i=dof_handler.levels[level]->dof_object.dofs.begin(); + i!=dof_handler.levels[level]->dof_object.dofs.end(); ++i) if (*i != DoFHandler<1,spacedim>::invalid_dof_index) *i = new_numbers[*i]; @@@ -386,9 -387,9 +386,9 @@@ for (unsigned int level=0; level::iterator + for (std::vector::iterator - i=dof_handler.levels[level]->quads.dofs.begin(); - i!=dof_handler.levels[level]->quads.dofs.end(); ++i) + i=dof_handler.levels[level]->dof_object.dofs.begin(); + i!=dof_handler.levels[level]->dof_object.dofs.end(); ++i) if (*i != DoFHandler<2,spacedim>::invalid_dof_index) *i = ((indices.n_elements() == 0) ? new_numbers[*i] : @@@ -457,9 -458,9 +457,9 @@@ for (unsigned int level=0; level::iterator + for (std::vector::iterator - i=dof_handler.levels[level]->hexes.dofs.begin(); - i!=dof_handler.levels[level]->hexes.dofs.end(); ++i) + i=dof_handler.levels[level]->dof_object.dofs.begin(); + i!=dof_handler.levels[level]->dof_object.dofs.end(); ++i) if (*i != DoFHandler<3,spacedim>::invalid_dof_index) *i = ((indices.n_elements() == 0) ? new_numbers[*i] : @@@ -491,11 -492,10 +491,10 @@@ template NumberCache Sequential:: - distribute_dofs (const types::global_dof_index offset, - DoFHandler &dof_handler) const + distribute_dofs (DoFHandler &dof_handler) const { - const unsigned int n_dofs = + const types::global_dof_index n_dofs = - Implementation::distribute_dofs (offset, + Implementation::distribute_dofs (0, types::invalid_subdomain_id, dof_handler); diff --cc deal.II/source/dofs/dof_tools.cc index d42c9c7f96,6b7d727666..90b14baf48 --- a/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/source/dofs/dof_tools.cc @@@ -472,12 -472,12 +472,12 @@@ namespace DoFTool const unsigned int n_dofs = dof.n_dofs(); AssertDimension (dof_to_boundary_mapping.size(), n_dofs); - Assert (boundary_indicators.find(types::internal_face_boundary_id) == boundary_indicators.end(), + Assert (boundary_indicators.find(numbers::internal_face_boundary_id) == boundary_indicators.end(), - typename DH::ExcInvalidBoundaryIndicator()); + typename DH::ExcInvalidBoundaryIndicator()); Assert (sparsity.n_rows() == dof.n_boundary_dofs (boundary_indicators), - ExcDimensionMismatch (sparsity.n_rows(), dof.n_boundary_dofs (boundary_indicators))); + ExcDimensionMismatch (sparsity.n_rows(), dof.n_boundary_dofs (boundary_indicators))); Assert (sparsity.n_cols() == dof.n_boundary_dofs (boundary_indicators), - ExcDimensionMismatch (sparsity.n_cols(), dof.n_boundary_dofs (boundary_indicators))); + ExcDimensionMismatch (sparsity.n_cols(), dof.n_boundary_dofs (boundary_indicators))); #ifdef DEBUG if (sparsity.n_rows() != 0) { @@@ -4071,13 -4071,13 +4071,13 @@@ template void extract_dofs_with_support_on_boundary (const DH &dof_handler, - const std::vector &component_select, - std::vector &selected_dofs, - const std::set &boundary_indicators) + const std::vector &component_select, + std::vector &selected_dofs, + const std::set &boundary_indicators) { AssertDimension (component_select.size(), n_components(dof_handler)); - Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(), + Assert (boundary_indicators.find (numbers::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); // let's see whether we have to // check for certain boundary @@@ -5872,11 -5872,11 +5872,11 @@@ void map_dof_to_boundary_indices ( const DH &dof_handler, const std::set &boundary_indicators, - std::vector &mapping) + std::vector &mapping) { Assert (&dof_handler.get_fe() != 0, ExcNoFESelected()); - Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(), + Assert (boundary_indicators.find (numbers::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); mapping.clear (); mapping.insert (mapping.end(), dof_handler.n_dofs(), diff --cc deal.II/source/hp/dof_handler.cc index 6db6f20fa7,734b8c7f0c..41abf8114c --- a/deal.II/source/hp/dof_handler.cc +++ b/deal.II/source/hp/dof_handler.cc @@@ -571,26 -571,26 +571,26 @@@ namespace interna // other (lower dimensional) // objects since exactly one // finite element is used for it - for (unsigned int level=0; leveln_levels(); ++level) - { - dof_handler.levels[level]->dof_object.dof_offsets - = std::vector (dof_handler.tria->n_raw_lines(level), - DoFHandler::invalid_dof_index); - - unsigned int next_free_dof = 0; - for (typename DoFHandler::active_cell_iterator - cell=dof_handler.begin_active(level); - cell!=dof_handler.end_active(level); ++cell) - if (!cell->has_children()) - { - dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof; - next_free_dof += cell->get_fe().dofs_per_line; - } - - dof_handler.levels[level]->dof_object.dofs - = std::vector (next_free_dof, - DoFHandler::invalid_dof_index); - } + for (unsigned int level=0; leveln_levels(); ++level) + { - dof_handler.levels[level]->lines.dof_offsets ++ dof_handler.levels[level]->dof_object.dof_offsets + = std::vector (dof_handler.tria->n_raw_lines(level), + DoFHandler::invalid_dof_index); + + types::global_dof_index next_free_dof = 0; + for (typename DoFHandler::active_cell_iterator + cell=dof_handler.begin_active(level); + cell!=dof_handler.end_active(level); ++cell) + if (!cell->has_children()) + { - dof_handler.levels[level]->lines.dof_offsets[cell->index()] = next_free_dof; ++ dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof; + next_free_dof += cell->get_fe().dofs_per_line; + } + - dof_handler.levels[level]->lines.dofs ++ dof_handler.levels[level]->dof_object.dofs + = std::vector (next_free_dof, + DoFHandler::invalid_dof_index); + } // safety check: make sure that // the number of DoFs we @@@ -600,25 -600,25 +600,25 @@@ // we couldn't use this simpler // algorithm) #ifdef DEBUG - for (unsigned int level=0; leveln_levels(); ++level) - { - unsigned int counter = 0; - for (typename DoFHandler::cell_iterator - cell=dof_handler.begin_active(level); - cell!=dof_handler.end_active(level); ++cell) - if (!cell->has_children()) - counter += cell->get_fe().dofs_per_line; - - Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter, - ExcInternalError()); - Assert (static_cast - (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(), - dof_handler.levels[level]->dof_object.dof_offsets.end(), - DoFHandler::invalid_dof_index)) - == - dof_handler.tria->n_raw_lines(level) - dof_handler.tria->n_active_lines(level), - ExcInternalError()); - } + for (unsigned int level=0; leveln_levels(); ++level) + { + types::global_dof_index counter = 0; + for (typename DoFHandler::cell_iterator + cell=dof_handler.begin_active(level); + cell!=dof_handler.end_active(level); ++cell) + if (!cell->has_children()) + counter += cell->get_fe().dofs_per_line; + - Assert (dof_handler.levels[level]->lines.dofs.size() == counter, ++ Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter, + ExcInternalError()); + Assert (static_cast - (std::count (dof_handler.levels[level]->lines.dof_offsets.begin(), - dof_handler.levels[level]->lines.dof_offsets.end(), ++ (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(), ++ dof_handler.levels[level]->dof_object.dof_offsets.end(), + DoFHandler::invalid_dof_index)) + == + dof_handler.tria->n_raw_lines(level) - dof_handler.tria->n_active_lines(level), + ExcInternalError()); + } #endif @@@ -687,26 -687,26 +687,26 @@@ // other (lower dimensional) // objects since exactly one // finite element is used for it - for (unsigned int level=0; leveln_levels(); ++level) - { - dof_handler.levels[level]->dof_object.dof_offsets - = std::vector (dof_handler.tria->n_raw_quads(level), - DoFHandler::invalid_dof_index); - - unsigned int next_free_dof = 0; - for (typename DoFHandler::active_cell_iterator - cell=dof_handler.begin_active(level); - cell!=dof_handler.end_active(level); ++cell) - if (!cell->has_children()) - { - dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof; - next_free_dof += cell->get_fe().dofs_per_quad; - } - - dof_handler.levels[level]->dof_object.dofs - = std::vector (next_free_dof, - DoFHandler::invalid_dof_index); - } + for (unsigned int level=0; leveln_levels(); ++level) + { - dof_handler.levels[level]->quads.dof_offsets ++ dof_handler.levels[level]->dof_object.dof_offsets + = std::vector (dof_handler.tria->n_raw_quads(level), + DoFHandler::invalid_dof_index); + + types::global_dof_index next_free_dof = 0; + for (typename DoFHandler::active_cell_iterator + cell=dof_handler.begin_active(level); + cell!=dof_handler.end_active(level); ++cell) + if (!cell->has_children()) + { - dof_handler.levels[level]->quads.dof_offsets[cell->index()] = next_free_dof; ++ dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof; + next_free_dof += cell->get_fe().dofs_per_quad; + } + - dof_handler.levels[level]->quads.dofs ++ dof_handler.levels[level]->dof_object.dofs + = std::vector (next_free_dof, + DoFHandler::invalid_dof_index); + } // safety check: make sure that // the number of DoFs we @@@ -716,25 -716,25 +716,25 @@@ // we couldn't use this simpler // algorithm) #ifdef DEBUG - for (unsigned int level=0; leveln_levels(); ++level) - { - unsigned int counter = 0; - for (typename DoFHandler::cell_iterator - cell=dof_handler.begin_active(level); - cell!=dof_handler.end_active(level); ++cell) - if (!cell->has_children()) - counter += cell->get_fe().dofs_per_quad; - - Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter, - ExcInternalError()); - Assert (static_cast - (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(), - dof_handler.levels[level]->dof_object.dof_offsets.end(), - DoFHandler::invalid_dof_index)) - == - dof_handler.tria->n_raw_quads(level) - dof_handler.tria->n_active_quads(level), - ExcInternalError()); - } + for (unsigned int level=0; leveln_levels(); ++level) + { + types::global_dof_index counter = 0; + for (typename DoFHandler::cell_iterator + cell=dof_handler.begin_active(level); + cell!=dof_handler.end_active(level); ++cell) + if (!cell->has_children()) + counter += cell->get_fe().dofs_per_quad; + - Assert (dof_handler.levels[level]->quads.dofs.size() == counter, ++ Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter, + ExcInternalError()); + Assert (static_cast - (std::count (dof_handler.levels[level]->quads.dof_offsets.begin(), - dof_handler.levels[level]->quads.dof_offsets.end(), ++ (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(), ++ dof_handler.levels[level]->dof_object.dof_offsets.end(), + DoFHandler::invalid_dof_index)) + == + dof_handler.tria->n_raw_quads(level) - dof_handler.tria->n_active_quads(level), + ExcInternalError()); + } #endif @@@ -1051,26 -1051,26 +1051,26 @@@ // other (lower dimensional) // objects since exactly one // finite element is used for it - for (unsigned int level=0; leveln_levels(); ++level) - { - dof_handler.levels[level]->dof_object.dof_offsets - = std::vector (dof_handler.tria->n_raw_hexs(level), - DoFHandler::invalid_dof_index); - - unsigned int next_free_dof = 0; - for (typename DoFHandler::active_cell_iterator - cell=dof_handler.begin_active(level); - cell!=dof_handler.end_active(level); ++cell) - if (!cell->has_children()) - { - dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof; - next_free_dof += cell->get_fe().dofs_per_hex; - } - - dof_handler.levels[level]->dof_object.dofs - = std::vector (next_free_dof, - DoFHandler::invalid_dof_index); - } + for (unsigned int level=0; leveln_levels(); ++level) + { - dof_handler.levels[level]->hexes.dof_offsets ++ dof_handler.levels[level]->dof_object.dof_offsets + = std::vector (dof_handler.tria->n_raw_hexs(level), + DoFHandler::invalid_dof_index); + + types::global_dof_index next_free_dof = 0; + for (typename DoFHandler::active_cell_iterator + cell=dof_handler.begin_active(level); + cell!=dof_handler.end_active(level); ++cell) + if (!cell->has_children()) + { - dof_handler.levels[level]->hexes.dof_offsets[cell->index()] = next_free_dof; ++ dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof; + next_free_dof += cell->get_fe().dofs_per_hex; + } + - dof_handler.levels[level]->hexes.dofs ++ dof_handler.levels[level]->dof_object.dofs + = std::vector (next_free_dof, + DoFHandler::invalid_dof_index); + } // safety check: make sure that // the number of DoFs we @@@ -1080,25 -1080,25 +1080,25 @@@ // we couldn't use this simpler // algorithm) #ifdef DEBUG - for (unsigned int level=0; leveln_levels(); ++level) - { - unsigned int counter = 0; - for (typename DoFHandler::cell_iterator - cell=dof_handler.begin_active(level); - cell!=dof_handler.end_active(level); ++cell) - if (!cell->has_children()) - counter += cell->get_fe().dofs_per_hex; - - Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter, - ExcInternalError()); - Assert (static_cast - (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(), - dof_handler.levels[level]->dof_object.dof_offsets.end(), - DoFHandler::invalid_dof_index)) - == - dof_handler.tria->n_raw_hexs(level) - dof_handler.tria->n_active_hexs(level), - ExcInternalError()); - } + for (unsigned int level=0; leveln_levels(); ++level) + { + types::global_dof_index counter = 0; + for (typename DoFHandler::cell_iterator + cell=dof_handler.begin_active(level); + cell!=dof_handler.end_active(level); ++cell) + if (!cell->has_children()) + counter += cell->get_fe().dofs_per_hex; + - Assert (dof_handler.levels[level]->hexes.dofs.size() == counter, ++ Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter, + ExcInternalError()); + Assert (static_cast - (std::count (dof_handler.levels[level]->hexes.dof_offsets.begin(), - dof_handler.levels[level]->hexes.dof_offsets.end(), ++ (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(), ++ dof_handler.levels[level]->dof_object.dof_offsets.end(), + DoFHandler::invalid_dof_index)) + == + dof_handler.tria->n_raw_hexs(level) - dof_handler.tria->n_active_hexs(level), + ExcInternalError()); + } #endif diff --cc deal.II/source/multigrid/mg_tools.inst.in index ad42c3ce05,b4d74691ff..4f657ada47 --- a/deal.II/source/multigrid/mg_tools.inst.in +++ b/deal.II/source/multigrid/mg_tools.inst.in @@@ -24,7 -24,7 +24,13 @@@ for (PATTERN : SPARSITY_PATTERNS; deal_ const MGDoFHandler &, PATTERN &, const unsigned int); ++ template void ++ make_sparsity_pattern, PATTERN> ( ++ const DoFHandler &, ++ PATTERN &, ++ const unsigned int); #endif ++ #if deal_II_dimension == deal_II_space_dimension template void make_flux_sparsity_pattern ( @@@ -96,6 -93,6 +102,12 @@@ for (deal_II_dimension : DIMENSIONS const FunctionMap::type&, std::vector >&, const std::vector&); ++ ++ template void make_boundary_list( ++ const DoFHandler&, ++ const FunctionMap::type&, ++ std::vector >&, ++ const std::vector&); #endif template void make_boundary_list( @@@ -109,6 -106,6 +121,11 @@@ extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, std::vector > &interface_dofs, std::vector > &boundary_interface_dofs); ++ template ++ void ++ extract_inner_interface_dofs (const DoFHandler &mg_dof_handler, ++ std::vector > &interface_dofs, ++ std::vector > &boundary_interface_dofs); template void extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, @@@ -119,26 -116,16 +136,22 @@@ std::vector > &non_interface_dofs); #if deal_II_dimension < 3 - template void count_dofs_per_block ( + template void count_dofs_per_block ( const MGDoFHandler&, std::vector >&, std::vector); ++ template void count_dofs_per_block > ( ++ const DoFHandler&, ++ std::vector >&, std::vector); #endif #if deal_II_dimension == 3 - template void count_dofs_per_block<1,3> ( + template void count_dofs_per_block ( const MGDoFHandler<1,3>&, std::vector >&, std::vector); - + template void count_dofs_per_block ( + const DoFHandler<1,3>&, + std::vector >&, std::vector); - template void count_dofs_per_block ( - const DoFHandler<2,3>&, - std::vector >&, std::vector); - template void count_dofs_per_block ( - const DoFHandler<1,2>&, - std::vector >&, std::vector); #endif -- \} ++ \} }