1 // --------------------------------------------------------------------- 2 // 3 // Copyright (C) 2016 - 2020 by the deal.II authors 4 // 5 // This file is part of the deal.II library. 6 // 7 // The deal.II library is free software; you can use it, redistribute 8 // it, and/or modify it under the terms of the GNU Lesser General 9 // Public License as published by the Free Software Foundation; either 10 // version 2.1 of the License, or (at your option) any later version. 11 // The full text of the license can be found in the file LICENSE.md at 12 // the top level directory of deal.II. 13 // 14 // --------------------------------------------------------------------- 15 16 17 #ifndef dealii_mg_transfer_internal_h 18 #define dealii_mg_transfer_internal_h 19 20 #include <deal.II/base/config.h> 21 22 #include <deal.II/base/mg_level_object.h> 23 24 #include <deal.II/dofs/dof_handler.h> 25 26 #include <deal.II/lac/la_parallel_vector.h> 27 28 #include <deal.II/multigrid/mg_constrained_dofs.h> 29 30 DEAL_II_NAMESPACE_OPEN 31 32 namespace internal 33 { 34 namespace MGTransfer 35 { 36 /** 37 * Internal function for filling the copy indices from global to level 38 * indices 39 * 40 * If @p skip_interface_dofs is false, the mapping will also contain 41 * DoFs at the interface between levels. This is desirable when 42 * transferring solution vectors instead of residuals. 43 */ 44 template <int dim, int spacedim> 45 void 46 fill_copy_indices( 47 const DoFHandler<dim, spacedim> &dof_handler, 48 const MGConstrainedDoFs * mg_constrained_dofs, 49 std::vector<std::vector< 50 std::pair<types::global_dof_index, types::global_dof_index>>> 51 ©_indices, 52 std::vector<std::vector< 53 std::pair<types::global_dof_index, types::global_dof_index>>> 54 ©_indices_global_mine, 55 std::vector<std::vector< 56 std::pair<types::global_dof_index, types::global_dof_index>>> 57 & copy_indices_level_mine, 58 const bool skip_interface_dofs = true); 59 60 61 62 /** 63 * Given the collection of child cells in lexicographic ordering as seen 64 * from the parent, this function computes the first index of the given 65 * child 66 */ 67 template <int dim> 68 unsigned int 69 compute_shift_within_children(const unsigned int child, 70 const unsigned int fe_shift_1d, 71 const unsigned int fe_degree); 72 73 /** 74 * A structure that stores data related to the finite element contained in 75 * the DoFHandler. Used only for the initialization using 76 * <tt>setup_transfer</tt>. 77 */ 78 template <typename Number> 79 struct ElementInfo 80 { 81 /** 82 * A variable storing the degree of the finite element. The selection of 83 * the computational kernel is based on this number. 84 */ 85 unsigned int fe_degree; 86 87 /** 88 * A variable storing whether the element is continuous and there is a 89 * joint degree of freedom in the center of the 1D line. 90 */ 91 bool element_is_continuous; 92 93 /** 94 * A variable storing the number of components in the finite element. 95 */ 96 unsigned int n_components; 97 98 /** 99 * A variable storing the number of degrees of freedom on all child cells. 100 * It is <tt>2<sup>dim</sup>*fe.n_dofs_per_cell()</tt> for DG elements and 101 * somewhat less for continuous elements. 102 */ 103 unsigned int n_child_cell_dofs; 104 105 /** 106 * An array that holds the numbering between the numbering of degrees of 107 * freedom in the finite element and the lexicographic numbering needed 108 * for the tensor product application. 109 */ 110 std::vector<unsigned int> lexicographic_numbering; 111 112 /** 113 * This variable holds the one-dimensional embedding (prolongation) matrix 114 * from mother element to all the children. 115 */ 116 std::vector<Number> prolongation_matrix_1d; 117 }; 118 119 /** 120 * Set up most of the internal data structures of MGTransferMatrixFree 121 */ 122 template <int dim, typename Number> 123 void 124 setup_transfer( 125 const DoFHandler<dim> & dof_handler, 126 const MGConstrainedDoFs *mg_constrained_dofs, 127 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 128 & external_partitioners, 129 ElementInfo<Number> & elem_info, 130 std::vector<std::vector<unsigned int>> &level_dof_indices, 131 std::vector<std::vector<std::pair<unsigned int, unsigned int>>> 132 & parent_child_connect, 133 std::vector<unsigned int> &n_owned_level_cells, 134 std::vector<std::vector<std::vector<unsigned short>>> &dirichlet_indices, 135 std::vector<std::vector<Number>> & weights_on_refined, 136 std::vector<Table<2, unsigned int>> ©_indices_global_mine, 137 MGLevelObject<std::shared_ptr<const Utilities::MPI::Partitioner>> 138 &vector_partitioners); 139 140 } // namespace MGTransfer 141 } // namespace internal 142 143 DEAL_II_NAMESPACE_CLOSE 144 145 #endif 146