From 4b27eef0f49a25f5bd90ae7469b7704cdbf32bb9 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 25 May 2018 13:35:17 -0500 Subject: [PATCH] RCM: Update dofs, part 2: dof_tools TODO: Complexify make_periodicity_constraints --- include/deal.II/dofs/dof_tools.h | 152 ++++++++-------- source/dofs/dof_tools.cc | 9 +- source/dofs/dof_tools.inst.in | 21 ++- source/dofs/dof_tools_constraints.cc | 198 ++++++++++----------- source/dofs/dof_tools_constraints.inst.in | 22 +-- source/dofs/dof_tools_sparsity.cc | 83 +++++---- source/dofs/dof_tools_sparsity.inst.in | 200 ++++++++++++---------- 7 files changed, 358 insertions(+), 327 deletions(-) diff --git a/include/deal.II/dofs/dof_tools.h b/include/deal.II/dofs/dof_tools.h index 2bcbe24247..09434fae1a 100644 --- a/include/deal.II/dofs/dof_tools.h +++ b/include/deal.II/dofs/dof_tools.h @@ -29,7 +29,7 @@ #include -#include +#include #include #include @@ -492,23 +492,24 @@ namespace DoFTools * entries. * * @param[in] constraints The process for generating entries described above - * is purely local to each cell. Consequently, the sparsity pattern does not - * provide for matrix entries that will only be written into during the - * elimination of hanging nodes or other constraints. They have to be taken - * care of by a subsequent call to ConstraintMatrix::condense(). - * Alternatively, the constraints on degrees of freedom can already be taken - * into account at the time of creating the sparsity pattern. For this, pass - * the ConstraintMatrix object as the third argument to the current - * function. No call to ConstraintMatrix::condense() is then necessary. This - * process is explained in step-6, step-27, and other tutorial programs. + * is purely local to each cell. Consequently, the sparsity pattern does + * not provide for matrix entries that will only be written into during + * the elimination of hanging nodes or other constraints. They have to be + * taken care of by a subsequent call to AffineConstraints::condense(). + * Alternatively, the constraints on degrees of freedom can already be + * taken into account at the time of creating the sparsity pattern. For + * this, pass the AffineConstraints object as the third argument to the + * current function. No call to AffineConstraints::condense() is then + * necessary. This process is explained in step-6, step-27, and other + * tutorial programs. * * @param[in] keep_constrained_dofs In case the constraints are already - * taken care of in this function by passing in a ConstraintMatrix object, + * taken care of in this function by passing in a AffineConstraints object, * it is possible to abandon some off-diagonal entries in the sparsity * pattern if these entries will also not be written into during the actual * assembly of the matrix this sparsity pattern later serves. Specifically, * when using an assembly method that uses - * ConstraintMatrix::distribute_local_to_global(), no entries will ever be + * AffineConstraints::distribute_local_to_global(), no entries will ever be * written into those matrix rows or columns that correspond to constrained * degrees of freedom. In such cases, you can set the argument @p * keep_constrained_dofs to @p false to avoid allocating these entries in @@ -548,13 +549,15 @@ namespace DoFTools * * @ingroup constraints */ - template + template void make_sparsity_pattern( - const DoFHandlerType & dof_handler, - SparsityPatternType & sparsity_pattern, - const ConstraintMatrix & constraints = ConstraintMatrix(), - const bool keep_constrained_dofs = true, + const DoFHandlerType & dof_handler, + SparsityPatternType & sparsity_pattern, + const AffineConstraints &constraints = AffineConstraints(), + const bool keep_constrained_dofs = true, const types::subdomain_id subdomain_id = numbers::invalid_subdomain_id); /** @@ -622,14 +625,16 @@ namespace DoFTools * * @ingroup constraints */ - template + template void make_sparsity_pattern( - const DoFHandlerType & dof_handler, - const Table<2, Coupling> &coupling, - SparsityPatternType & sparsity_pattern, - const ConstraintMatrix & constraints = ConstraintMatrix(), - const bool keep_constrained_dofs = true, + const DoFHandlerType & dof_handler, + const Table<2, Coupling> & coupling, + SparsityPatternType & sparsity_pattern, + const AffineConstraints &constraints = AffineConstraints(), + const bool keep_constrained_dofs = true, const types::subdomain_id subdomain_id = numbers::invalid_subdomain_id); /** @@ -716,15 +721,18 @@ namespace DoFTools * * @ingroup constraints */ - template + template void make_flux_sparsity_pattern( - const DoFHandlerType & dof_handler, - SparsityPatternType & sparsity_pattern, - const ConstraintMatrix & constraints, - const bool keep_constrained_dofs = true, + const DoFHandlerType & dof_handler, + SparsityPatternType & sparsity_pattern, + const AffineConstraints &constraints, + const bool keep_constrained_dofs = true, const types::subdomain_id subdomain_id = numbers::invalid_subdomain_id); + /** * This function does essentially the same as the other * make_flux_sparsity_pattern() function but allows the specification of @@ -752,6 +760,8 @@ namespace DoFTools const Table<2, Coupling> &cell_integrals_mask, const Table<2, Coupling> &face_integrals_mask, const types::subdomain_id subdomain_id = numbers::invalid_subdomain_id); + + /** * This function does essentially the same as the previous * make_flux_sparsity_pattern() function but allows the application of @@ -760,11 +770,13 @@ namespace DoFTools * constraints to be imposed on the continuous part while also building * the flux terms needed for the discontinuous part. */ - template + template void - make_flux_sparsity_pattern(const DoFHandlerType & dof, - SparsityPatternType & sparsity, - const ConstraintMatrix & constraints, + make_flux_sparsity_pattern(const DoFHandlerType & dof, + SparsityPatternType & sparsity, + const AffineConstraints &constraints, const bool keep_constrained_dofs, const Table<2, Coupling> &couplings, const Table<2, Coupling> &face_couplings, @@ -846,7 +858,7 @@ namespace DoFTools * This function does not clear the constraint matrix object before use, in * order to allow adding constraints from different sources to the same * object. You therefore need to make sure it contains only constraints you - * still want; otherwise call the ConstraintMatrix::clear() function. + * still want; otherwise call the AffineConstraints::clear() function. * Since this function does not check if it would add cycles in * @p constraints, it is recommended to call this function prior to other * functions that constrain DoFs with respect to others such as @@ -865,10 +877,10 @@ namespace DoFTools * * @ingroup constraints */ - template + template void - make_hanging_node_constraints(const DoFHandlerType &dof_handler, - ConstraintMatrix & constraints); + make_hanging_node_constraints(const DoFHandlerType & dof_handler, + AffineConstraints &constraints); /** * This function is used when different variables in a problem are @@ -891,7 +903,7 @@ namespace DoFTools * functions $v\in {\cal V}_1$. In other words, every function $v_h=\sum_j * V_j \varphi_j^{(1)} \in {\cal V}_1$ that also satisfies $v_h\in {\cal * V}_0$ automatically satisfies $CV=0$. This function computes the matrix - * $C$ in the form of a ConstraintMatrix object. + * $C$ in the form of a AffineConstraints object. * * The construction of these constraints is done as follows: for each of the * degrees of freedom (i.e. shape functions) on the coarse grid, we compute @@ -935,7 +947,7 @@ namespace DoFTools * it as an argument. * * The computed constraints are entered into a variable of type - * ConstraintMatrix; previous contents are not deleted. + * AffineConstraints; previous contents are not deleted. */ template void @@ -945,7 +957,7 @@ namespace DoFTools const DoFHandler & fine_grid, const unsigned int fine_component, const InterGridMap> &coarse_to_fine_grid_map, - ConstraintMatrix & constraints); + AffineConstraints & constraints); /** @@ -987,7 +999,7 @@ namespace DoFTools /** * Insert the (algebraic) constraints due to periodic boundary conditions - * into a ConstraintMatrix @p constraint_matrix. + * into an AffineConstraints object @p constraints. * * Given a pair of not necessarily active boundary faces @p face_1 and @p * face_2, this functions constrains all DoFs associated with the boundary @@ -995,7 +1007,7 @@ namespace DoFTools * by @p face_2. More precisely: * * If @p face_1 and @p face_2 are both active faces it adds the DoFs of @p - * face_1 to the list of constrained DoFs in @p constraint_matrix and adds + * face_1 to the list of constrained DoFs in @p constraints and adds * entries to constrain them to the corresponding values of the DoFs on @p * face_2. This happens on a purely algebraic level, meaning, the global DoF * with (local face) index i on @p face_1 gets constraint to the @@ -1130,7 +1142,7 @@ namespace DoFTools * interpolation matrix with size no_face_dofs $\times$ no_face_dofs. * * This function makes sure that identity constraints don't create cycles - * in @p constraint_matrix. + * in @p constraints. * * Detailed information can be found in the see * @ref GlossPeriodicConstraints "Glossary entry on periodic boundary conditions". @@ -1142,7 +1154,7 @@ namespace DoFTools make_periodicity_constraints( const FaceIterator & face_1, const typename identity::type &face_2, - dealii::ConstraintMatrix & constraint_matrix, + AffineConstraints & constraints, const ComponentMask & component_mask = ComponentMask(), const bool face_orientation = true, const bool face_flip = false, @@ -1155,7 +1167,7 @@ namespace DoFTools /** * Insert the (algebraic) constraints due to periodic boundary conditions - * into a ConstraintMatrix @p constraint_matrix. + * into an AffineConstraints object @p constraints. * * This is the main high level interface for above low level variant of * make_periodicity_constraints(). It takes a std::vector @p periodic_faces @@ -1180,7 +1192,7 @@ namespace DoFTools const std::vector< GridTools::PeriodicFacePair> & periodic_faces, - dealii::ConstraintMatrix & constraint_matrix, + AffineConstraints & constraints, const ComponentMask & component_mask = ComponentMask(), const std::vector &first_vector_components = std::vector()); @@ -1189,7 +1201,7 @@ namespace DoFTools /** * Insert the (algebraic) constraints due to periodic boundary conditions - * into a ConstraintMatrix @p constraint_matrix. + * into a AffineConstraints @p constraints. * * This function serves as a high level interface for the * make_periodicity_constraints() function. @@ -1220,12 +1232,12 @@ namespace DoFTools template void make_periodicity_constraints( - const DoFHandlerType & dof_handler, - const types::boundary_id b_id1, - const types::boundary_id b_id2, - const int direction, - dealii::ConstraintMatrix &constraint_matrix, - const ComponentMask & component_mask = ComponentMask()); + const DoFHandlerType & dof_handler, + const types::boundary_id b_id1, + const types::boundary_id b_id2, + const int direction, + AffineConstraints &constraints, + const ComponentMask & component_mask = ComponentMask()); @@ -1256,11 +1268,11 @@ namespace DoFTools template void make_periodicity_constraints( - const DoFHandlerType & dof_handler, - const types::boundary_id b_id, - const int direction, - dealii::ConstraintMatrix &constraint_matrix, - const ComponentMask & component_mask = ComponentMask()); + const DoFHandlerType & dof_handler, + const types::boundary_id b_id, + const int direction, + AffineConstraints &constraints, + const ComponentMask & component_mask = ComponentMask()); /** * @} @@ -1549,22 +1561,22 @@ namespace DoFTools * Essentially, the question this functions answers is the following: * Given a subdomain with associated DoFs, what is the largest subset of * these DoFs that are allowed to be non-zero such that after calling - * ConstraintMatrix::distribute() the resulting solution vector will have - * support only within the given domain. Here @p cm is the ConstraintMatrix - * containing hanging nodes constraints. + * AffineConstraints::distribute() the resulting solution vector will have + * support only within the given domain. Here, @p constraints is the + * AffineConstraints container containing hanging nodes constraints. * * In case of parallel::distributed::Triangulation @p predicate will be called * only for locally owned and ghost cells. The resulting index set may contain * DoFs that are associated with the locally owned or ghost cells, but are not * owned by the current MPI core. */ - template + template IndexSet extract_dofs_with_support_contained_within( const DoFHandlerType &dof_handler, const std::function< bool(const typename DoFHandlerType::active_cell_iterator &)> &predicate, - const ConstraintMatrix &cm = ConstraintMatrix()); + const AffineConstraints &constraints = AffineConstraints()); /** * Extract a vector that represents the constant modes of the DoFHandler for @@ -2389,7 +2401,7 @@ namespace DoFTools * results, which can then be further processed, e.g. for output. You should * note that the resulting field will not be continuous at hanging nodes. * This can, however, easily be arranged by calling the appropriate @p - * distribute function of a ConstraintMatrix object created for this + * distribute function of an AffineConstraints object created for this * DoFHandler object, after the vector has been fully assembled. * * It is assumed that the number of elements in @p cell_data equals the @@ -2539,12 +2551,15 @@ namespace DoFTools * @see * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" */ - template class DoFHandlerType> + template class DoFHandlerType, + typename number> void make_zero_boundary_constraints( const DoFHandlerType &dof, const types::boundary_id boundary_id, - ConstraintMatrix & zero_boundary_constraints, + AffineConstraints & zero_boundary_constraints, const ComponentMask & component_mask = ComponentMask()); /** @@ -2557,11 +2572,14 @@ namespace DoFTools * * @ingroup constraints */ - template class DoFHandlerType> + template class DoFHandlerType, + typename number> void make_zero_boundary_constraints( const DoFHandlerType &dof, - ConstraintMatrix & zero_boundary_constraints, + AffineConstraints & zero_boundary_constraints, const ComponentMask & component_mask = ComponentMask()); /** diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 3b64d1e16a..755df33152 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -42,8 +42,8 @@ #include #include +#include #include -#include #include #include #include @@ -810,13 +810,13 @@ namespace DoFTools - template + template IndexSet extract_dofs_with_support_contained_within( const DoFHandlerType &dof_handler, const std::function< bool(const typename DoFHandlerType::active_cell_iterator &)> &predicate, - const ConstraintMatrix & cm) + const AffineConstraints & cm) { const std::function @@ -888,8 +888,7 @@ namespace DoFTools // if halo DoF is constrained, add all DoFs to which it's constrained // because after resolving constraints, the support of the DoFs that // constrain the current DoF will extend to the halo cells. - if (const std::vector> - *line_ptr = cm.get_constraint_entries(*it)) + if (const auto *line_ptr = cm.get_constraint_entries(*it)) { const unsigned int line_size = line_ptr->size(); for (unsigned int j = 0; j < line_size; ++j) diff --git a/source/dofs/dof_tools.inst.in b/source/dofs/dof_tools.inst.in index ac454fe118..3d55ba3e55 100644 --- a/source/dofs/dof_tools.inst.in +++ b/source/dofs/dof_tools.inst.in @@ -176,14 +176,6 @@ for (deal_II_dimension : DIMENSIONS) std::vector &, const std::set &); - template IndexSet DoFTools::extract_dofs_with_support_contained_within< - DoFHandler>( - const DoFHandler &, - const std::function::active_cell_iterator &)> - &, - const ConstraintMatrix &); - template void DoFTools::extract_hanging_node_dofs( const DoFHandler &dof_handler, std::vector & selected_dofs); @@ -658,6 +650,19 @@ for (deal_II_dimension : DIMENSIONS) } +for (deal_II_dimension : DIMENSIONS; S : REAL_AND_COMPLEX_SCALARS) + { + template IndexSet DoFTools::extract_dofs_with_support_contained_within< + DoFHandler, + S>( + const DoFHandler &, + const std::function::active_cell_iterator &)> + &, + const AffineConstraints &); + } + + for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index b5dcccdb98..d9d06f5eab 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -35,7 +35,7 @@ #include #include -#include +#include #include #ifdef DEAL_II_WITH_MPI @@ -480,12 +480,13 @@ namespace DoFTools * It also suppresses very small entries in the constraint matrix to * avoid making the sparsity pattern fuller than necessary. */ + template void filter_constraints( const std::vector &master_dofs, const std::vector &slave_dofs, - const FullMatrix & face_constraints, - ConstraintMatrix & constraints) + const FullMatrix & face_constraints, + AffineConstraints & constraints) { Assert(face_constraints.n() == master_dofs.size(), ExcDimensionMismatch(master_dofs.size(), face_constraints.n())); @@ -525,7 +526,7 @@ namespace DoFTools { // add up the absolute values of all constraints in this // line to get a measure of their absolute size - double abs_sum = 0; + number abs_sum = 0; for (unsigned int i = 0; i < n_master_dofs; ++i) abs_sum += std::abs(face_constraints(row, i)); @@ -552,29 +553,30 @@ namespace DoFTools } // namespace - + template void make_hp_hanging_node_constraints(const dealii::DoFHandler<1> &, - ConstraintMatrix &) + AffineConstraints &) { // nothing to do for regular dof handlers in 1d } - + template void make_oldstyle_hanging_node_constraints(const dealii::DoFHandler<1> &, - ConstraintMatrix &, + AffineConstraints &, std::integral_constant) { // nothing to do for regular dof handlers in 1d } + template void make_hp_hanging_node_constraints( const dealii::hp::DoFHandler<1> & /*dof_handler*/, - ConstraintMatrix & /*constraints*/) + AffineConstraints & /*constraints*/) { // we may have to compute constraints for vertices. gotta think about // that a bit more @@ -583,11 +585,11 @@ namespace DoFTools } - + template void make_oldstyle_hanging_node_constraints( const dealii::hp::DoFHandler<1> & /*dof_handler*/, - ConstraintMatrix & /*constraints*/, + AffineConstraints & /*constraints*/, std::integral_constant) { // we may have to compute constraints for vertices. gotta think about @@ -597,86 +599,51 @@ namespace DoFTools } + template void make_hp_hanging_node_constraints(const dealii::DoFHandler<1, 2> &, - ConstraintMatrix &) + AffineConstraints &) { // nothing to do for regular dof handlers in 1d } - + template void make_oldstyle_hanging_node_constraints(const dealii::DoFHandler<1, 2> &, - ConstraintMatrix &, + AffineConstraints &, std::integral_constant) { // nothing to do for regular dof handlers in 1d } + template void make_hp_hanging_node_constraints(const dealii::DoFHandler<1, 3> &, - ConstraintMatrix &) + AffineConstraints &) { // nothing to do for regular dof handlers in 1d } + + template void make_oldstyle_hanging_node_constraints(const dealii::DoFHandler<1, 3> &, - ConstraintMatrix &, + AffineConstraints &, std::integral_constant) { // nothing to do for regular dof handlers in 1d } - // currently not used but may be in the future: - - // void - // make_hp_hanging_node_constraints (const dealii::MDoFHandler<1,2> &, - // ConstraintMatrix &) - // { - // // nothing to do for regular - // // dof handlers in 1d - // } - - - - // void - // make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> - // &, - // ConstraintMatrix &, - // std::integral_constant) - // { - // // nothing to do for regular - // // dof handlers in 1d - // } - - - // void - // make_oldstyle_hanging_node_constraints (const - // dealii::hp::DoFHandler<1,2> &/*dof_handler*/, - // ConstraintMatrix - // &/*constraints*/, - // std::integral_constant) - // { - // // we may have to compute - // // constraints for - // // vertices. gotta think about - // // that a bit more - // - // //TODO[WB]: think about what to do here... - // } - //#endif - - - template + template void - make_oldstyle_hanging_node_constraints(const DoFHandlerType &dof_handler, - ConstraintMatrix & constraints, - std::integral_constant) + make_oldstyle_hanging_node_constraints( + const DoFHandlerType & dof_handler, + AffineConstraints &constraints, + std::integral_constant) { const unsigned int dim = 2; @@ -823,11 +790,12 @@ namespace DoFTools - template + template void - make_oldstyle_hanging_node_constraints(const DoFHandlerType &dof_handler, - ConstraintMatrix & constraints, - std::integral_constant) + make_oldstyle_hanging_node_constraints( + const DoFHandlerType & dof_handler, + AffineConstraints &constraints, + std::integral_constant) { const unsigned int dim = 3; @@ -1064,10 +1032,10 @@ namespace DoFTools - template + template void - make_hp_hanging_node_constraints(const DoFHandlerType &dof_handler, - ConstraintMatrix & constraints) + make_hp_hanging_node_constraints(const DoFHandlerType & dof_handler, + AffineConstraints &constraints) { // note: this function is going to be hard to understand if you // haven't read the hp paper. however, we try to follow the notation @@ -1082,7 +1050,7 @@ namespace DoFTools // a matrix to be used for constraints below. declared here and // simply resized down below to avoid permanent re-allocation of // memory - FullMatrix constraint_matrix; + FullMatrix constraint_matrix; // similarly have arrays that will hold master and slave dof numbers, // as well as a scratch array needed for the complicated case below @@ -1094,9 +1062,9 @@ namespace DoFTools // different (or the same) finite elements. we compute them only // once, namely the first time they are needed, and then just reuse // them - Table<2, std::unique_ptr>> face_interpolation_matrices( + Table<2, std::unique_ptr>> face_interpolation_matrices( n_finite_elements(dof_handler), n_finite_elements(dof_handler)); - Table<3, std::unique_ptr>> + Table<3, std::unique_ptr>> subface_interpolation_matrices( n_finite_elements(dof_handler), n_finite_elements(dof_handler), @@ -1107,7 +1075,7 @@ namespace DoFTools // these two matrices are derived from the face interpolation matrix // as described in the @ref hp_paper "hp paper" Table<2, - std::unique_ptr, FullMatrix>>> + std::unique_ptr, FullMatrix>>> split_face_interpolation_matrices(n_finite_elements(dof_handler), n_finite_elements(dof_handler)); @@ -1381,13 +1349,13 @@ namespace DoFTools split_face_interpolation_matrices [dominating_fe_index][cell->active_fe_index()]); - const FullMatrix + const FullMatrix &restrict_mother_to_virtual_master_inv = (split_face_interpolation_matrices [dominating_fe_index][cell->active_fe_index()] ->first); - const FullMatrix + const FullMatrix &restrict_mother_to_virtual_slave = (split_face_interpolation_matrices [dominating_fe_index][cell->active_fe_index()] @@ -1472,7 +1440,7 @@ namespace DoFTools subface_interpolation_matrices [dominating_fe_index][subface_fe_index][sf]); - const FullMatrix + const FullMatrix &restrict_subface_to_virtual = *( subface_interpolation_matrices [dominating_fe_index][subface_fe_index][sf]); @@ -1691,13 +1659,13 @@ namespace DoFTools [dominating_fe_index][cell->active_fe_index()]); const FullMatrix< - double> &restrict_mother_to_virtual_master_inv = + number> &restrict_mother_to_virtual_master_inv = (split_face_interpolation_matrices [dominating_fe_index][cell->active_fe_index()] ->first); const FullMatrix< - double> &restrict_mother_to_virtual_slave = + number> &restrict_mother_to_virtual_slave = (split_face_interpolation_matrices [dominating_fe_index][cell->active_fe_index()] ->second); @@ -1756,7 +1724,7 @@ namespace DoFTools [dominating_fe_index] [neighbor->active_fe_index()]); - const FullMatrix + const FullMatrix &restrict_secondface_to_virtual = *(face_interpolation_matrices [dominating_fe_index] @@ -1800,10 +1768,10 @@ namespace DoFTools - template + template void - make_hanging_node_constraints(const DoFHandlerType &dof_handler, - ConstraintMatrix & constraints) + make_hanging_node_constraints(const DoFHandlerType & dof_handler, + AffineConstraints &constraints) { // Decide whether to use the new or old make_hanging_node_constraints // function. If all the FiniteElement or all elements in a FECollection @@ -1827,9 +1795,9 @@ namespace DoFTools * * Internally used in make_periodicity_constraints. * - * enter constraints for periodicity into the given ConstraintMatrix object. - * this function is called when at least one of the two face iterators - * corresponds to an active object without further children + * enter constraints for periodicity into the given AffineConstraints + * object. this function is called when at least one of the two face + * iterators corresponds to an active object without further children * * @param transformation A matrix that maps degrees of freedom from one face * to another. If the DoFs on the two faces are supposed to match exactly, @@ -1851,7 +1819,7 @@ namespace DoFTools const FaceIterator & face_1, const typename identity::type &face_2, const FullMatrix & transformation, - dealii::ConstraintMatrix & constraint_matrix, + AffineConstraints & constraint_matrix, const ComponentMask & component_mask, const bool face_orientation, const bool face_flip, @@ -2360,7 +2328,7 @@ namespace DoFTools make_periodicity_constraints( const FaceIterator & face_1, const typename identity::type &face_2, - dealii::ConstraintMatrix & constraint_matrix, + AffineConstraints & constraint_matrix, const ComponentMask & component_mask, const bool face_orientation, const bool face_flip, @@ -2590,7 +2558,7 @@ namespace DoFTools const std::vector< GridTools::PeriodicFacePair> & periodic_faces, - dealii::ConstraintMatrix & constraint_matrix, + AffineConstraints & constraints, const ComponentMask & component_mask, const std::vector &first_vector_components) { @@ -2617,7 +2585,7 @@ namespace DoFTools // every matching pair: make_periodicity_constraints(face_1, face_2, - constraint_matrix, + constraints, component_mask, it->orientation[0], it->orientation[1], @@ -2633,12 +2601,12 @@ namespace DoFTools template void - make_periodicity_constraints(const DoFHandlerType & dof_handler, - const types::boundary_id b_id1, - const types::boundary_id b_id2, - const int direction, - dealii::ConstraintMatrix &constraint_matrix, - const ComponentMask & component_mask) + make_periodicity_constraints(const DoFHandlerType & dof_handler, + const types::boundary_id b_id1, + const types::boundary_id b_id2, + const int direction, + dealii::AffineConstraints &constraints, + const ComponentMask &component_mask) { static const int space_dim = DoFHandlerType::space_dimension; (void)space_dim; @@ -2658,18 +2626,18 @@ namespace DoFTools dof_handler, b_id1, b_id2, direction, matched_faces); make_periodicity_constraints( - matched_faces, constraint_matrix, component_mask); + matched_faces, constraints, component_mask); } template void - make_periodicity_constraints(const DoFHandlerType & dof_handler, - const types::boundary_id b_id, - const int direction, - dealii::ConstraintMatrix &constraint_matrix, - const ComponentMask & component_mask) + make_periodicity_constraints(const DoFHandlerType & dof_handler, + const types::boundary_id b_id, + const int direction, + AffineConstraints &constraints, + const ComponentMask & component_mask) { static const int dim = DoFHandlerType::dimension; static const int space_dim = DoFHandlerType::space_dimension; @@ -2690,7 +2658,7 @@ namespace DoFTools dof_handler, b_id, direction, matched_faces); make_periodicity_constraints( - matched_faces, constraint_matrix, component_mask); + matched_faces, constraints, component_mask); } @@ -3231,7 +3199,7 @@ namespace DoFTools const DoFHandler & fine_grid, const unsigned int fine_component, const InterGridMap> &coarse_to_fine_grid_map, - ConstraintMatrix & constraints) + AffineConstraints & constraints) { // store the weights with which a dof on the parameter grid contributes // to a dof on the fine grid. see the long doc below for more info @@ -3342,7 +3310,7 @@ namespace DoFTools // note for people that want to optimize this function: the largest // part of the computing time is spent in the following, rather // innocent block of code. basically, it must be the - // ConstraintMatrix::add_entry call which takes the bulk of the time, + // AffineConstraints::add_entry call which takes the bulk of the time, // but it is not known to the author how to make it faster... std::vector> constraint_line; for (types::global_dof_index global_dof = 0; global_dof < n_fine_dofs; @@ -3501,12 +3469,16 @@ namespace DoFTools - template class DoFHandlerType> + template class DoFHandlerType, + typename number> void - make_zero_boundary_constraints(const DoFHandlerType &dof, - const types::boundary_id boundary_id, - ConstraintMatrix & zero_boundary_constraints, - const ComponentMask &component_mask) + make_zero_boundary_constraints( + const DoFHandlerType &dof, + const types::boundary_id boundary_id, + AffineConstraints & zero_boundary_constraints, + const ComponentMask & component_mask) { Assert(component_mask.represents_n_components(dof.get_fe(0).n_components()), ExcMessage("The number of components in the mask has to be either " @@ -3587,11 +3559,15 @@ namespace DoFTools - template class DoFHandlerType> + template class DoFHandlerType, + typename number> void - make_zero_boundary_constraints(const DoFHandlerType &dof, - ConstraintMatrix & zero_boundary_constraints, - const ComponentMask &component_mask) + make_zero_boundary_constraints( + const DoFHandlerType &dof, + AffineConstraints & zero_boundary_constraints, + const ComponentMask & component_mask) { make_zero_boundary_constraints(dof, numbers::invalid_boundary_id, diff --git a/source/dofs/dof_tools_constraints.inst.in b/source/dofs/dof_tools_constraints.inst.in index 3de6fe397e..2a6443182c 100644 --- a/source/dofs/dof_tools_constraints.inst.in +++ b/source/dofs/dof_tools_constraints.inst.in @@ -19,20 +19,21 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) #if deal_II_dimension < deal_II_space_dimension template void DoFTools::make_hanging_node_constraints( const DoFHandler &, - ConstraintMatrix &); + AffineConstraints &); #endif } for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) { template void DoFTools::make_hanging_node_constraints( - const DH &, ConstraintMatrix &); + const DH &, + AffineConstraints &); #if deal_II_dimension != 1 template void DoFTools::make_periodicity_constraints( const DH::face_iterator &, const DH::face_iterator &, - dealii::ConstraintMatrix &, + AffineConstraints &, const ComponentMask &, bool, bool, @@ -43,7 +44,7 @@ for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) template void DoFTools::make_periodicity_constraints>( const std::vector< GridTools::PeriodicFacePair::cell_iterator>> &, - dealii::ConstraintMatrix &, + AffineConstraints &, const ComponentMask &, const std::vector &); @@ -53,31 +54,32 @@ for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) const types::boundary_id, const types::boundary_id, const int, - dealii::ConstraintMatrix &, + AffineConstraints &, const ComponentMask &); template void DoFTools::make_periodicity_constraints( const DH &, const types::boundary_id, const int, - dealii::ConstraintMatrix &, + AffineConstraints &, const ComponentMask &); #endif } for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; - deal_II_space_dimension : SPACE_DIMENSIONS) + deal_II_space_dimension : SPACE_DIMENSIONS; + S : REAL_AND_COMPLEX_SCALARS) { #if deal_II_dimension <= deal_II_space_dimension template void DoFTools::make_zero_boundary_constraints( const DH &, - ConstraintMatrix &, + AffineConstraints &, const ComponentMask &); template void DoFTools::make_zero_boundary_constraints( const DH &, const types::boundary_id, - ConstraintMatrix &, + AffineConstraints &, const ComponentMask &); #endif } @@ -93,7 +95,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) const unsigned int, const InterGridMap> &, - ConstraintMatrix &); + AffineConstraints &); template void DoFTools::compute_intergrid_transfer_representation( diff --git a/source/dofs/dof_tools_sparsity.cc b/source/dofs/dof_tools_sparsity.cc index a6af8f0dc8..109ed2578a 100644 --- a/source/dofs/dof_tools_sparsity.cc +++ b/source/dofs/dof_tools_sparsity.cc @@ -36,8 +36,8 @@ #include #include +#include #include -#include #include #include #include @@ -54,13 +54,15 @@ DEAL_II_NAMESPACE_OPEN namespace DoFTools { - template + template void - make_sparsity_pattern(const DoFHandlerType & dof, - SparsityPatternType & sparsity, - const ConstraintMatrix & constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id) + make_sparsity_pattern(const DoFHandlerType & dof, + SparsityPatternType & sparsity, + const AffineConstraints &constraints, + const bool keep_constrained_dofs, + const types::subdomain_id subdomain_id) { const types::global_dof_index n_dofs = dof.n_dofs(); (void)n_dofs; @@ -110,14 +112,16 @@ namespace DoFTools - template + template void - make_sparsity_pattern(const DoFHandlerType & dof, - const Table<2, Coupling> &couplings, - SparsityPatternType & sparsity, - const ConstraintMatrix & constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id) + make_sparsity_pattern(const DoFHandlerType & dof, + const Table<2, Coupling> & couplings, + SparsityPatternType & sparsity, + const AffineConstraints &constraints, + const bool keep_constrained_dofs, + const types::subdomain_id subdomain_id) { const types::global_dof_index n_dofs = dof.n_dofs(); (void)n_dofs; @@ -477,11 +481,13 @@ namespace DoFTools - template + template void - make_flux_sparsity_pattern(const DoFHandlerType & dof, - SparsityPatternType & sparsity, - const ConstraintMatrix & constraints, + make_flux_sparsity_pattern(const DoFHandlerType & dof, + SparsityPatternType & sparsity, + const AffineConstraints &constraints, const bool keep_constrained_dofs, const types::subdomain_id subdomain_id) @@ -651,8 +657,8 @@ namespace DoFTools make_flux_sparsity_pattern(const DoFHandlerType &dof, SparsityPatternType & sparsity) { - ConstraintMatrix constraints; - make_flux_sparsity_pattern(dof, sparsity, constraints); + AffineConstraints dummy; + make_flux_sparsity_pattern(dof, sparsity, dummy); } template @@ -718,12 +724,14 @@ namespace DoFTools { // implementation of the same function in namespace DoFTools for // non-hp DoFHandlers - template + template void - make_flux_sparsity_pattern(const DoFHandlerType & dof, - SparsityPatternType & sparsity, - const ConstraintMatrix &constraints, - const bool keep_constrained_dofs, + make_flux_sparsity_pattern(const DoFHandlerType & dof, + SparsityPatternType & sparsity, + const AffineConstraints &constraints, + const bool keep_constrained_dofs, const Table<2, Coupling> &int_mask, const Table<2, Coupling> &flux_mask, const types::subdomain_id subdomain_id) @@ -1007,12 +1015,15 @@ namespace DoFTools // implementation of the same function in namespace DoFTools for hp // DoFHandlers - template + template void make_flux_sparsity_pattern( const dealii::hp::DoFHandler &dof, SparsityPatternType & sparsity, - const ConstraintMatrix & constraints, + const AffineConstraints & constraints, const bool keep_constrained_dofs, const Table<2, Coupling> & int_mask, const Table<2, Coupling> & flux_mask, @@ -1271,22 +1282,26 @@ namespace DoFTools const Table<2, Coupling> &flux_mask, const types::subdomain_id subdomain_id) { - ConstraintMatrix constraints; - const bool keep_constrained_dofs = true; + AffineConstraints dummy; + + const bool keep_constrained_dofs = true; + make_flux_sparsity_pattern(dof, sparsity, - constraints, + dummy, keep_constrained_dofs, int_mask, flux_mask, subdomain_id); } - template + template void - make_flux_sparsity_pattern(const DoFHandlerType & dof, - SparsityPatternType & sparsity, - const ConstraintMatrix & constraints, + make_flux_sparsity_pattern(const DoFHandlerType & dof, + SparsityPatternType & sparsity, + const AffineConstraints &constraints, const bool keep_constrained_dofs, const Table<2, Coupling> &int_mask, const Table<2, Coupling> &flux_mask, diff --git a/source/dofs/dof_tools_sparsity.inst.in b/source/dofs/dof_tools_sparsity.inst.in index 48c0660baa..33dd80096c 100644 --- a/source/dofs/dof_tools_sparsity.inst.in +++ b/source/dofs/dof_tools_sparsity.inst.in @@ -149,13 +149,14 @@ for (scalar : COMPLEX_SCALARS; SP : SPARSITY_PATTERNS; #endif } -for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) +for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS; + S : REAL_AND_COMPLEX_SCALARS) { template void DoFTools::make_sparsity_pattern< DoFHandler, SP>(const DoFHandler &dof, SP & sparsity, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -163,7 +164,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) hp::DoFHandler, SP>(const hp::DoFHandler &dof, SP & sparsity, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -172,7 +173,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) SP>(const DoFHandler &, const Table<2, Coupling> &, SP &, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -181,56 +182,15 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) SP>(const hp::DoFHandler &, const Table<2, Coupling> &, SP &, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); - template void DoFTools::make_sparsity_pattern< - DoFHandler, - SP>(const DoFHandler &dof_row, - const DoFHandler &dof_col, - SP & sparsity); - - template void DoFTools::make_sparsity_pattern< - hp::DoFHandler, - SP>(const hp::DoFHandler &dof_row, - const hp::DoFHandler &dof_col, - SP & sparsity); - - template void - DoFTools::make_boundary_sparsity_pattern, SP>( - const DoFHandler &dof, - const std::vector &, - SP &); - - template void - DoFTools::make_boundary_sparsity_pattern, - SP>( - const hp::DoFHandler &dof, - const std::vector &, - SP &); - - template void - DoFTools::make_flux_sparsity_pattern, SP>( - const DoFHandler &dof, SP &sparsity); - - template void - DoFTools::make_flux_sparsity_pattern, SP>( - const hp::DoFHandler &dof, SP &sparsity); - - template void - DoFTools::make_flux_sparsity_pattern, SP>( - const DoFHandler &dof, - SP & sparsity, - const Table<2, Coupling> &, - const Table<2, Coupling> &, - const types::subdomain_id); - template void DoFTools::make_flux_sparsity_pattern, SP>( const DoFHandler &dof, SP & sparsity, - const ConstraintMatrix & constraints, + const AffineConstraints &, const bool, const Table<2, Coupling> &, const Table<2, Coupling> &, @@ -240,7 +200,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) DoFTools::make_flux_sparsity_pattern, SP>( const DoFHandler &dof, SP & sparsity, - const ConstraintMatrix & constraints, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -248,7 +208,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) DoFTools::make_flux_sparsity_pattern, SP>( const hp::DoFHandler &dof, SP & sparsity, - const ConstraintMatrix & constraints, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -258,15 +218,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) DoFTools::make_flux_sparsity_pattern, SP>( const hp::DoFHandler &dof, SP & sparsity, - const Table<2, Coupling> &, - const Table<2, Coupling> &, - const types::subdomain_id); - - template void - DoFTools::make_flux_sparsity_pattern, SP>( - const hp::DoFHandler &dof, - SP & sparsity, - const ConstraintMatrix & constraints, + const AffineConstraints &, const bool, const Table<2, Coupling> &, const Table<2, Coupling> &, @@ -280,7 +232,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) DoFHandler, SP>(const DoFHandler &dof, SP & sparsity, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -288,7 +240,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) hp::DoFHandler, SP>(const hp::DoFHandler &dof, SP &sparsity, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -297,7 +249,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) SP>(const DoFHandler &, const Table<2, Coupling> &, SP &, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -306,51 +258,25 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) SP>(const hp::DoFHandler &, const Table<2, Coupling> &, SP &, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); - template void DoFTools::make_sparsity_pattern< - DoFHandler, - SP>(const DoFHandler &dof_row, - const DoFHandler &dof_col, - SP & sparsity); - - template void DoFTools::make_sparsity_pattern< - hp::DoFHandler, - SP>( - const hp::DoFHandler &dof_row, - const hp::DoFHandler &dof_col, - SP & sparsity); - - template void DoFTools::make_boundary_sparsity_pattern< - DoFHandler, - SP>(const DoFHandler &dof, - const std::vector &, - SP &); - - // template void - // DoFTools::make_boundary_sparsity_pattern,SP> - //(const hp::DoFHandler& dof, - // const std::vector &, - // SP &); - #endif - #if deal_II_dimension == 3 template void DoFTools::make_sparsity_pattern, SP>( const DoFHandler<1, 3> &dof, SP & sparsity, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); template void DoFTools::make_sparsity_pattern, SP>( const hp::DoFHandler<1, 3> &dof, SP & sparsity, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -358,7 +284,7 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) const DoFHandler<1, 3> &, const Table<2, Coupling> &, SP &, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); @@ -366,10 +292,100 @@ for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) const hp::DoFHandler<1, 3> &, const Table<2, Coupling> &, SP &, - const ConstraintMatrix &, + const AffineConstraints &, const bool, const types::subdomain_id); +#endif + } + +for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) + { + template void DoFTools::make_sparsity_pattern< + DoFHandler, + SP>(const DoFHandler &dof_row, + const DoFHandler &dof_col, + SP & sparsity); + + template void DoFTools::make_sparsity_pattern< + hp::DoFHandler, + SP>(const hp::DoFHandler &dof_row, + const hp::DoFHandler &dof_col, + SP & sparsity); + + template void + DoFTools::make_boundary_sparsity_pattern, SP>( + const DoFHandler &dof, + const std::vector &, + SP &); + + template void + DoFTools::make_boundary_sparsity_pattern, + SP>( + const hp::DoFHandler &dof, + const std::vector &, + SP &); + + template void + DoFTools::make_flux_sparsity_pattern, SP>( + const DoFHandler &dof, SP &sparsity); + + template void + DoFTools::make_flux_sparsity_pattern, SP>( + const hp::DoFHandler &dof, SP &sparsity); + + template void + DoFTools::make_flux_sparsity_pattern, SP>( + const DoFHandler &dof, + SP & sparsity, + const Table<2, Coupling> &, + const Table<2, Coupling> &, + const types::subdomain_id); + +#if deal_II_dimension > 1 + + template void + DoFTools::make_flux_sparsity_pattern, SP>( + const hp::DoFHandler &dof, + SP & sparsity, + const Table<2, Coupling> &, + const Table<2, Coupling> &, + const types::subdomain_id); + +#endif + +#if deal_II_dimension < 3 + + template void DoFTools::make_sparsity_pattern< + DoFHandler, + SP>(const DoFHandler &dof_row, + const DoFHandler &dof_col, + SP & sparsity); + + template void DoFTools::make_sparsity_pattern< + hp::DoFHandler, + SP>( + const hp::DoFHandler &dof_row, + const hp::DoFHandler &dof_col, + SP & sparsity); + + template void DoFTools::make_boundary_sparsity_pattern< + DoFHandler, + SP>(const DoFHandler &dof, + const std::vector &, + SP &); + + // template void + // DoFTools::make_boundary_sparsity_pattern,SP> + //(const hp::DoFHandler& dof, + // const std::vector &, + // SP &); + +#endif + + +#if deal_II_dimension == 3 + template void DoFTools::make_sparsity_pattern, SP>( const DoFHandler<1, 3> &dof_row, const DoFHandler<1, 3> &dof_col, -- 2.39.5