From: turcksin Date: Mon, 3 Jun 2013 14:09:16 +0000 (+0000) Subject: Merge from mainline. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80c67d7364869b7aa02f35b023951d8990fca947;p=dealii-svn.git Merge from mainline. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@29740 0785d39b-7218-0410-832d-ea1e28bc413d --- 80c67d7364869b7aa02f35b023951d8990fca947 diff --cc deal.II/include/deal.II/dofs/dof_accessor.h index ee733aee95,cd438a8fc6..29b9cca9f3 --- a/deal.II/include/deal.II/dofs/dof_accessor.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.h @@@ -368,45 -368,41 +368,43 @@@ public */ /** - * Return the indices of the dofs of this object in the standard - * ordering: dofs on vertex 0, dofs on vertex 1, etc, dofs on line - * 0, dofs on line 1, etc, dofs on quad 0, etc. + * Return the global indices of the degrees of freedom located on + * this object in the standard ordering defined by the finite element (i.e., + * dofs on vertex 0, dofs on vertex 1, etc, dofs on line 0, dofs on line 1, + * etc, dofs on quad 0, etc.) This function is only available on + * active objects (see @ref GlossActive "this glossary entry"). * - * @param[out] dof_indices The vector into which the indices will be - * written. It has to have the right size (namely, - * fe.dofs_per_cell, fe.dofs_per_face, - * or fe.dofs_per_line, depending on which kind of - * object this function is called) before being passed to this - * function. - * @param[in] fe_index The finite element index. For the - * standard ::DoFHandler class, this value must be equal to its default - * value since that class only supports the same finite element on all - * cells anyway. However, for hp objects (i.e. the hp::DoFHandler - * class), different finite element objects may be used on different - * cells. On faces between two cells, as well as vertices, there may - * therefore be two sets of degrees of freedom, one for each of the - * finite elements used on the adjacent cells. In order to specify which - * set of degrees of freedom to work on, the last argument is used to - * disambiguate. Finally, if this function is called for a cell object, - * there can only be a single set of degrees of freedom, and fe_index - * has to match the result of active_fe_index(). (Consequently, - * the derived DoFCellAccessor class has an overloaded version of this - * function that calls the present function with - * cell-@>active_fe_index as last argument.) - * - * - * @note In many places in the tutorial and elsewhere in the library, the - * first argument to this function is called - * local_dof_indices by convention. The name is not meant to - * indicate the local numbers of degrees of freedom (which are - * always between zero and fe.dofs_per_cell, or similar faces - * or edges) but instead that the returned values are the global - * indices of those degrees of freedom that are located locally on the - * current cell, face or edge. + * The cells needs to be an active cell (and not artificial in a + * parallel distributed computation). + * + * The vector has to have the right size before being passed to this + * function. + * + * The last argument denotes the finite element index. For the + * standard ::DoFHandler class, this value must be equal to its + * default value since that class only supports the same finite + * element on all cells anyway. + * + * However, for hp objects (i.e. the hp::DoFHandler class), + * different finite element objects may be used on different + * cells. On faces between two cells, as well as vertices, there may + * therefore be two sets of degrees of freedom, one for each of the + * finite elements used on the adjacent cells. In order to specify + * which set of degrees of freedom to work on, the last argument is + * used to disambiguate. Finally, if this function is called for a + * cell object, there can only be a single set of degrees of + * freedom, and fe_index has to match the result of + * active_fe_index(). + * + * For cells, there is only a single possible finite element index + * (namely the one for that cell, returned by + * cell-@>active_fe_index. Consequently, the derived + * DoFCellAccessor class has an overloaded version of this function + * that calls the present function with + * cell-@>active_fe_index as last argument. + * */ - void get_dof_indices (std::vector &dof_indices, + void get_dof_indices (std::vector &dof_indices, const unsigned int fe_index = DH::default_fe_index) const; /** @@@ -1072,35 -1070,64 +1070,64 @@@ public */ /** - * Return the indices of the dofs of this - * object in the standard ordering: dofs - * on vertex 0, dofs on vertex 1, etc, - * dofs on line 0, dofs on line 1, etc, - * dofs on quad 0, etc. + * Return the global indices of the degrees of freedom located on + * this object in the standard ordering defined by the finite element (i.e., + * dofs on vertex 0, dofs on vertex 1, etc, dofs on line 0, dofs on line 1, + * etc, dofs on quad 0, etc.) This function is only available on + * active objects (see @ref GlossActive "this glossary entry"). * - * @param[out] dof_indices The vector into which the indices will be - * written. It has to have the right size (namely, - * fe.dofs_per_cell, fe.dofs_per_face, - * or fe.dofs_per_line, depending on which kind of - * object this function is called) before being passed to this - * function. - * @param[in] fe_index The finite element index. For the - * standard ::DoFHandler class, this value must be equal to its default - * value since that class only supports the same finite element on all - * cells anyway. However, for hp objects (i.e. the hp::DoFHandler - * class), different finite element objects may be used on different - * cells. On faces between two cells, as well as vertices, there may - * therefore be two sets of degrees of freedom, one for each of the - * finite elements used on the adjacent cells. In order to specify which - * set of degrees of freedom to work on, the last argument is used to - * disambiguate. Finally, if this function is called for a cell object, - * there can only be a single set of degrees of freedom, and fe_index - * has to match the result of active_fe_index(). (Consequently, - * the derived DoFCellAccessor class has an overloaded version of this - * function that calls the present function with - * cell-@>active_fe_index as last argument.) + * The cells needs to be an active cell (and not artificial in a + * parallel distributed computation). + * + * The vector has to have the + * right size before being passed + * to this function. + * + * The last argument denotes the + * finite element index. For the + * standard ::DoFHandler class, + * this value must be equal to + * its default value since that + * class only supports the same + * finite element on all cells + * anyway. + * + * However, for hp objects + * (i.e. the hp::DoFHandler + * class), different finite + * element objects may be used on + * different cells. On faces + * between two cells, as well as + * vertices, there may therefore + * be two sets of degrees of + * freedom, one for each of the + * finite elements used on the + * adjacent cells. In order to + * specify which set of degrees + * of freedom to work on, the + * last argument is used to + * disambiguate. Finally, if this + * function is called for a cell + * object, there can only be a + * single set of degrees of + * freedom, and fe_index has to + * match the result of + * active_fe_index(). + * + * For cells, there is only a + * single possible finite element + * index (namely the one for that + * cell, returned by + * cell-@>active_fe_index. Consequently, + * the derived DoFCellAccessor + * class has an overloaded + * version of this function that + * calls the present function + * with + * cell-@>active_fe_index + * as last argument. */ - void get_dof_indices (std::vector &dof_indices, + void get_dof_indices (std::vector &dof_indices, const unsigned int fe_index = AccessorData::default_fe_index) const; /** @@@ -2027,40 -2054,42 +2054,42 @@@ public * * Examples for this use are in the implementation of DoFRenumbering. */ - void get_active_or_mg_dof_indices (std::vector &dof_indices) const; + void get_active_or_mg_dof_indices (std::vector &dof_indices) const; /** - * Return the indices of the dofs of this - * quad in the standard ordering: dofs - * on vertex 0, dofs on vertex 1, etc, - * dofs on line 0, dofs on line 1, etc, - * dofs on quad 0, etc. + * Return the global indices of the degrees of freedom located on + * this object in the standard ordering defined by the finite element (i.e., + * dofs on vertex 0, dofs on vertex 1, etc, dofs on line 0, dofs on line 1, + * etc, dofs on quad 0, etc.) This function is only available on + * active objects (see @ref GlossActive "this glossary entry"). + * + * @param[out] dof_indices The vector into which the indices will be + * written. It has to have the right size (namely, + * fe.dofs_per_cell, fe.dofs_per_face, + * or fe.dofs_per_line, depending on which kind of + * object this function is called) before being passed to this + * function. * - * It is assumed that the vector already - * has the right size beforehand. - * - * This function reimplements the - * same function in the base - * class. The functions in the - * base classes are available for - * all geometric objects, - * i.e. even in 3d they can be - * used to access the dof indices - * of edges, for example. On the - * other hand, the most common - * case is clearly the use on - * cells, which is why we cache - * the array for each cell, but - * not edge. To retrieve the - * cached values, rather than - * collect the necessary - * information every time, this - * function overwrites the one in - * the base class. + * This function reimplements the same function in the base class. + * In contrast to the function in the base class, we do not need the + * fe_index here because there is always a unique finite + * element index on cells. * + * This is a function which requires that the cell is active. + * * Also see get_active_or_mg_dof_indices(). + * + * @note In many places in the tutorial and elsewhere in the library, + * the argument to this function is called local_dof_indices + * by convention. The name is not meant to indicate the local + * numbers of degrees of freedom (which are always between zero and + * fe.dofs_per_cell) but instead that the returned values + * are the global indices of those degrees of freedom that + * are located locally on the current cell. + * + * @deprecated Currently, this function can also be called for non-active cells, if all degrees of freedom of the FiniteElement are located in vertices. This functionality will vanish in a future release. */ - void get_dof_indices (std::vector &dof_indices) const; + void get_dof_indices (std::vector &dof_indices) const; /** * @deprecated Use get_active_or_mg_dof_indices() with level_cell_iterator returned from begin_mg(). diff --cc deal.II/include/deal.II/dofs/dof_accessor.templates.h index 83ef24d839,259eccedac..30132e99bd --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@@ -2760,17 -2738,11 +2760,11 @@@ namespace interna { AssertDimension (dof_indices.size(), accessor.get_fe().dofs_per_cell); - // check as in documentation that - // cell is either active, or dofs - // are only in vertices - Assert (!accessor.has_children() - || - (accessor.get_fe().dofs_per_cell == - accessor.get_fe().dofs_per_vertex * GeometryInfo::vertices_per_cell), - ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); + Assert (!accessor.has_children(), + ExcMessage ("Cell must be active.")); - unsigned int *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell]; + types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] + ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell]; for (unsigned int i=0; i::vertices_per_cell), - ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); + Assert (!accessor.has_children(), + ExcMessage ("Cell must be active.")); - unsigned int *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * - accessor.get_fe().dofs_per_cell]; + types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] + ->cell_dof_indices_cache[accessor.present_index * + accessor.get_fe().dofs_per_cell]; for ( ; local_values_begin != local_values_end; ++local_values_begin, ++cache) *local_values_begin = values(*cache); } @@@ -2895,18 -2861,12 +2883,12 @@@ Assert (values.size() == accessor.get_dof_handler().n_dofs(), typename BaseClass::ExcVectorDoesNotMatch()); - // check as in documentation that - // cell is either active, or dofs - // are only in vertices - Assert (!accessor.has_children() - || - (accessor.get_fe().dofs_per_cell == - accessor.get_fe().dofs_per_vertex * GeometryInfo::vertices_per_cell), - ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); + Assert (!accessor.has_children(), + ExcMessage ("Cell must be active.")); - unsigned int *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * - accessor.get_fe().dofs_per_cell]; + types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] + ->cell_dof_indices_cache[accessor.present_index * + accessor.get_fe().dofs_per_cell]; constraints.get_dof_values(values, *cache, local_values_begin, local_values_end); } @@@ -2961,17 -2921,11 +2943,11 @@@ Assert (values.size() == accessor.get_dof_handler().n_dofs(), typename BaseClass::ExcVectorDoesNotMatch()); - // check as in documentation that - // cell is either active, or dofs - // are only in vertices - Assert (!accessor.has_children() - || - (accessor.get_fe().dofs_per_cell == - accessor.get_fe().dofs_per_vertex * GeometryInfo::vertices_per_cell), - ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); + Assert (!accessor.has_children(), + ExcMessage ("Cell must be active.")); - unsigned int *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell]; + types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] + ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell]; for (unsigned int i=0; in_dofs() == global_vector.size(), typename BaseClass::ExcVectorDoesNotMatch()); - // check as in documentation that - // cell is either active, or dofs - // are only in vertices - Assert (!accessor.has_children() - || - (accessor.get_fe().dofs_per_cell == - accessor.get_fe().dofs_per_vertex * GeometryInfo::vertices_per_cell), - ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); + Assert (!accessor.has_children(), + ExcMessage ("Cell must be active.")); const unsigned int n_dofs = accessor.get_fe().dofs_per_cell; - unsigned int *dofs = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index *n_dofs]; + types::global_dof_index *dofs = &accessor.dof_handler->levels[accessor.level()] + ->cell_dof_indices_cache[accessor.present_index *n_dofs]; // distribute cell matrices for (unsigned int i=0; i::face (const un template inline void -DoFCellAccessor::get_dof_indices (std::vector &dof_indices) const +DoFCellAccessor::get_dof_indices (std::vector &dof_indices) const { + Assert (this->active(), ExcMessage ("get_dof_indices() only works on active cells.")); Assert (this->is_artificial() == false, ExcMessage ("Can't ask for DoF indices on artificial cells.")); AssertDimension (dof_indices.size(), this->get_fe().dofs_per_cell); diff --cc deal.II/include/deal.II/dofs/dof_renumbering.h index 59c659c31e,0b750d627a..ae80171850 --- a/deal.II/include/deal.II/dofs/dof_renumbering.h +++ b/deal.II/include/deal.II/dofs/dof_renumbering.h @@@ -817,11 -817,12 +817,12 @@@ namespace DoFRenumberin * the renumbering vector. */ template - unsigned int - compute_component_wise (std::vector &new_dof_indices, + types::global_dof_index + compute_component_wise (std::vector &new_dof_indices, const ITERATOR &start, const ENDITERATOR &end, - const std::vector &target_component); + const std::vector &target_component, + bool is_level_operation); /** * @} diff --cc deal.II/source/dofs/dof_renumbering.cc index 420ad7843f,f7d9e8796e..979cd02e91 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@@ -559,10 -558,10 +559,10 @@@ namespace DoFRenumberin typename DH::level_cell_iterator start =dof_handler.begin(level); typename DH::level_cell_iterator end = dof_handler.end(level); - const unsigned int result = + const types::global_dof_index result = compute_component_wise - (renumbering, start, end, component_order_arg); + (renumbering, start, end, component_order_arg, true); if (result == 0) return; @@@ -576,11 -575,12 +576,12 @@@ template - unsigned int - compute_component_wise (std::vector &new_indices, + types::global_dof_index + compute_component_wise (std::vector &new_indices, const ITERATOR &start, const ENDITERATOR &end, - const std::vector &component_order_arg) + const std::vector &component_order_arg, + bool is_level_operation) { const hp::FECollection fe_collection (start->get_dof_handler().get_fe ()); @@@ -658,23 -658,37 +659,37 @@@ // dof indices are entered // multiply, so we will have to // take care of that - std::vector > + std::vector > component_to_dof_map (fe_collection.n_components()); for (ITERATOR cell=start; cell!=end; ++cell) - if (cell->is_locally_owned()) - { - // on each cell: get dof indices - // and insert them into the global - // list using their component - const unsigned int fe_index = cell->active_fe_index(); - const unsigned int dofs_per_cell = fe_collection[fe_index].dofs_per_cell; - local_dof_indices.resize (dofs_per_cell); - cell->get_active_or_mg_dof_indices (local_dof_indices); - for (unsigned int i=0; iget_dof_handler().locally_owned_dofs().is_element(local_dof_indices[i])) - component_to_dof_map[component_list[fe_index][i]]. - push_back (local_dof_indices[i]); - } + { + if (is_level_operation) + { + //we are dealing with mg dofs, skip foreign level cells: + if ((start->get_dof_handler().get_tria().locally_owned_subdomain() != numbers::invalid_subdomain_id) + && + (cell->level_subdomain_id()!=start->get_dof_handler().get_tria().locally_owned_subdomain())) + continue; + } + else + { + //we are dealing with active dofs, skip the loop if not locally + // owned: + if (!cell->active() || !cell->is_locally_owned()) + continue; + } + // on each cell: get dof indices + // and insert them into the global + // list using their component + const unsigned int fe_index = cell->active_fe_index(); + const unsigned int dofs_per_cell = fe_collection[fe_index].dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); + cell->get_active_or_mg_dof_indices (local_dof_indices); + for (unsigned int i=0; iget_dof_handler().locally_owned_dofs().is_element(local_dof_indices[i])) + component_to_dof_map[component_list[fe_index][i]]. + push_back (local_dof_indices[i]); + } // now we've got all indices sorted // into buckets labeled by their diff --cc deal.II/source/lac/slepc_solver.cc index 638f7b0f9d,89d8b900ef..2703bc964c --- a/deal.II/source/lac/slepc_solver.cc +++ b/deal.II/source/lac/slepc_solver.cc @@@ -218,8 -218,8 +218,8 @@@ namespace SLEPcWrapper } void - SolverBase::get_eigenpair (const unsigned int index, + SolverBase::get_eigenpair (const size_type index, - double &eigenvalues, + PetscScalar &eigenvalues, PETScWrappers::VectorBase &eigenvectors) { AssertThrow (solver_data.get() != 0, ExcSLEPcWrappersUsageError()); diff --cc deal.II/source/multigrid/mg_transfer_prebuilt.cc index 94b5cf7b32,0d54ca3de8..6525146ac6 --- a/deal.II/source/multigrid/mg_transfer_prebuilt.cc +++ b/deal.II/source/multigrid/mg_transfer_prebuilt.cc @@@ -247,10 -247,9 +247,9 @@@ void MGTransferPrebuilt::build_ copy_indices_to_me.resize(n_levels); IndexSet globally_relevant; DoFTools::extract_locally_relevant_dofs(mg_dof, globally_relevant); - std::vector dof_touched(globally_relevant.n_elements(), false); - std::vector global_dof_indices (dofs_per_cell); - std::vector level_dof_indices (dofs_per_cell); + std::vector global_dof_indices (dofs_per_cell); + std::vector level_dof_indices (dofs_per_cell); // for (int level=mg_dof.get_tria().n_levels()-1; level>=0; --level) for (unsigned int level=0; level::cell_iterator - cell = dofh.begin(lvl), - endc = dofh.end(lvl); - - for (;cell!=endc;++cell) - { - std::vector dofs(fe.n_dofs_per_cell()); - cell->get_mg_dof_indices(dofs); - - for (unsigned int i=0;i::cell_iterator + cell = dofh.begin(lvl), + endc = dofh.end(lvl); + + for (;cell!=endc;++cell) + { - std::vector dofs(fe.n_dofs_per_cell()); ++ std::vector dofs(fe.n_dofs_per_cell()); + cell->get_mg_dof_indices(dofs); + + for (unsigned int i=0;i::cell_iterator - cell = dofh.begin(lvl), - endc = dofh.end(lvl); - - for (;cell!=endc;++cell) - { - std::vector dofs(fe.n_dofs_per_cell()); - cell->get_mg_dof_indices(dofs); - - for (unsigned int i=0;i::cell_iterator + cell = dofh.begin(lvl), + endc = dofh.end(lvl); + + for (;cell!=endc;++cell) + { - std::vector dofs(fe.n_dofs_per_cell()); ++ std::vector dofs(fe.n_dofs_per_cell()); + cell->get_mg_dof_indices(dofs); + + for (unsigned int i=0;i