]> https://gitweb.dealii.org/ - dealii.git/commitdiff
MatrixFree: Templatify reinit functions
authorMatthias Maier <tamiko@43-1.org>
Mon, 28 May 2018 00:25:06 +0000 (19:25 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 6 Jun 2018 15:19:38 +0000 (10:19 -0500)
Unfortunately, we have a bit of a clashing ideology here:

 - The MatrixFree container is motivated by the old ConstraintMatrix
   object. Meaning it expects constraints to be expressed in double.

 - AffineConstraints<number>, however, should be matched with the
   underlying number type. And the rest of the library now assumes that
   this is the case (in particular project_matrix_free and variants...)

In order to facilitate both approaches, we have to slab another "number"
template aorund the reinit functions. That's a bit unfortunate but
cannot be avoided. :-/

include/deal.II/matrix_free/matrix_free.h
include/deal.II/matrix_free/matrix_free.templates.h
source/matrix_free/matrix_free.inst.in

index 4048a4fbb564e1587a9fdd73c5f60ae219aa3af8..8231d0b11c93d754d33b4174e6612437e5716c0d 100644 (file)
@@ -486,24 +486,24 @@ public:
    * not allowed. In that case, use the initialization function with
    * several DoFHandler arguments.
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   void
-  reinit(const Mapping<dim> &             mapping,
-         const DoFHandlerType &           dof_handler,
-         const AffineConstraints<double> &constraint,
-         const QuadratureType &           quad,
-         const AdditionalData             additional_data = AdditionalData());
+  reinit(const Mapping<dim> &              mapping,
+         const DoFHandlerType &            dof_handler,
+         const AffineConstraints<number2> &constraint,
+         const QuadratureType &            quad,
+         const AdditionalData              additional_data = AdditionalData());
 
   /**
    * Initializes the data structures. Same as above, but using a $Q_1$
    * mapping.
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   void
-  reinit(const DoFHandlerType &           dof_handler,
-         const AffineConstraints<double> &constraint,
-         const QuadratureType &           quad,
-         const AdditionalData             additional_data = AdditionalData());
+  reinit(const DoFHandlerType &            dof_handler,
+         const AffineConstraints<number2> &constraint,
+         const QuadratureType &            quad,
+         const AdditionalData              additional_data = AdditionalData());
 
   /**
    * Same as above.
@@ -512,14 +512,14 @@ public:
    * more. Use the reinit function without index set argument to choose the
    * one provided by DoFHandler::locally_owned_dofs().
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   DEAL_II_DEPRECATED void
-  reinit(const Mapping<dim> &             mapping,
-         const DoFHandlerType &           dof_handler,
-         const AffineConstraints<double> &constraint,
-         const IndexSet &                 locally_owned_dofs,
-         const QuadratureType &           quad,
-         const AdditionalData             additional_data = AdditionalData());
+  reinit(const Mapping<dim> &              mapping,
+         const DoFHandlerType &            dof_handler,
+         const AffineConstraints<number2> &constraint,
+         const IndexSet &                  locally_owned_dofs,
+         const QuadratureType &            quad,
+         const AdditionalData              additional_data = AdditionalData());
 
   /**
    * Extracts the information needed to perform loops over cells. The
@@ -541,23 +541,23 @@ public:
    * can be sets independently from the number of DoFHandlers, when several
    * elements are always integrated with the same quadrature formula.
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   void
-  reinit(const Mapping<dim> &                                  mapping,
-         const std::vector<const DoFHandlerType *> &           dof_handler,
-         const std::vector<const AffineConstraints<double> *> &constraint,
-         const std::vector<QuadratureType> &                   quad,
+  reinit(const Mapping<dim> &                                   mapping,
+         const std::vector<const DoFHandlerType *> &            dof_handler,
+         const std::vector<const AffineConstraints<number2> *> &constraint,
+         const std::vector<QuadratureType> &                    quad,
          const AdditionalData additional_data = AdditionalData());
 
   /**
    * Initializes the data structures. Same as above, but  using a $Q_1$
    * mapping.
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   void
-  reinit(const std::vector<const DoFHandlerType *> &           dof_handler,
-         const std::vector<const AffineConstraints<double> *> &constraint,
-         const std::vector<QuadratureType> &                   quad,
+  reinit(const std::vector<const DoFHandlerType *> &            dof_handler,
+         const std::vector<const AffineConstraints<number2> *> &constraint,
+         const std::vector<QuadratureType> &                    quad,
          const AdditionalData additional_data = AdditionalData());
 
   /**
@@ -567,11 +567,11 @@ public:
    * more. Use the reinit function without index set argument to choose the
    * one provided by DoFHandler::locally_owned_dofs().
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   DEAL_II_DEPRECATED void
-  reinit(const Mapping<dim> &                                  mapping,
-         const std::vector<const DoFHandlerType *> &           dof_handler,
-         const std::vector<const AffineConstraints<double> *> &constraint,
+  reinit(const Mapping<dim> &                                   mapping,
+         const std::vector<const DoFHandlerType *> &            dof_handler,
+         const std::vector<const AffineConstraints<number2> *> &constraint,
          const std::vector<IndexSet> &      locally_owned_set,
          const std::vector<QuadratureType> &quad,
          const AdditionalData               additional_data = AdditionalData());
@@ -583,23 +583,23 @@ public:
    * as might be necessary when several components in a vector-valued problem
    * are integrated together based on the same quadrature formula.
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   void
-  reinit(const Mapping<dim> &                                  mapping,
-         const std::vector<const DoFHandlerType *> &           dof_handler,
-         const std::vector<const AffineConstraints<double> *> &constraint,
-         const QuadratureType &                                quad,
+  reinit(const Mapping<dim> &                                   mapping,
+         const std::vector<const DoFHandlerType *> &            dof_handler,
+         const std::vector<const AffineConstraints<number2> *> &constraint,
+         const QuadratureType &                                 quad,
          const AdditionalData additional_data = AdditionalData());
 
   /**
    * Initializes the data structures. Same as above, but  using a $Q_1$
    * mapping.
    */
-  template <typename DoFHandlerType, typename QuadratureType>
+  template <typename DoFHandlerType, typename QuadratureType, typename number2>
   void
-  reinit(const std::vector<const DoFHandlerType *> &           dof_handler,
-         const std::vector<const AffineConstraints<double> *> &constraint,
-         const QuadratureType &                                quad,
+  reinit(const std::vector<const DoFHandlerType *> &            dof_handler,
+         const std::vector<const AffineConstraints<number2> *> &constraint,
+         const QuadratureType &                                 quad,
          const AdditionalData additional_data = AdditionalData());
 
   /**
@@ -1578,26 +1578,28 @@ private:
    * This is the actual reinit function that sets up the indices for the
    * DoFHandler case.
    */
+  template <typename number2>
   void
   internal_reinit(
-    const Mapping<dim> &                                  mapping,
-    const std::vector<const DoFHandler<dim> *> &          dof_handler,
-    const std::vector<const AffineConstraints<double> *> &constraint,
-    const std::vector<IndexSet> &                         locally_owned_set,
-    const std::vector<hp::QCollection<1>> &               quad,
-    const AdditionalData &                                additional_data);
+    const Mapping<dim> &                                   mapping,
+    const std::vector<const DoFHandler<dim> *> &           dof_handler,
+    const std::vector<const AffineConstraints<number2> *> &constraint,
+    const std::vector<IndexSet> &                          locally_owned_set,
+    const std::vector<hp::QCollection<1>> &                quad,
+    const AdditionalData &                                 additional_data);
 
   /**
    * Same as before but for hp::DoFHandler instead of generic DoFHandler type.
    */
+  template <typename number2>
   void
   internal_reinit(
-    const Mapping<dim> &                                  mapping,
-    const std::vector<const hp::DoFHandler<dim> *> &      dof_handler,
-    const std::vector<const AffineConstraints<double> *> &constraint,
-    const std::vector<IndexSet> &                         locally_owned_set,
-    const std::vector<hp::QCollection<1>> &               quad,
-    const AdditionalData &                                additional_data);
+    const Mapping<dim> &                                   mapping,
+    const std::vector<const hp::DoFHandler<dim> *> &       dof_handler,
+    const std::vector<const AffineConstraints<number2> *> &constraint,
+    const std::vector<IndexSet> &                          locally_owned_set,
+    const std::vector<hp::QCollection<1>> &                quad,
+    const AdditionalData &                                 additional_data);
 
   /**
    * Initializes the fields in DoFInfo together with the constraint pool that
@@ -1605,11 +1607,12 @@ private:
    * because several DoFInfo classes can have the same weights which
    * consequently only need to be stored once).
    */
+  template <typename number2>
   void
   initialize_indices(
-    const std::vector<const AffineConstraints<double> *> &constraint,
-    const std::vector<IndexSet> &                         locally_owned_set,
-    const AdditionalData &                                additional_data);
+    const std::vector<const AffineConstraints<number2> *> &constraint,
+    const std::vector<IndexSet> &                          locally_owned_set,
+    const AdditionalData &                                 additional_data);
 
   /**
    * Initializes the DoFHandlers based on a DoFHandler<dim> argument.
@@ -2425,17 +2428,17 @@ namespace internal
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const DoFHandlerType &                                 dof_handler,
-  const AffineConstraints<double> &                      constraints_in,
+  const AffineConstraints<number2> &                     constraints_in,
   const QuadratureType &                                 quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
 {
-  std::vector<const DoFHandlerType *>            dof_handlers;
-  std::vector<const AffineConstraints<double> *> constraints;
-  std::vector<QuadratureType>                    quads;
+  std::vector<const DoFHandlerType *>             dof_handlers;
+  std::vector<const AffineConstraints<number2> *> constraints;
+  std::vector<QuadratureType>                     quads;
 
   dof_handlers.push_back(&dof_handler);
   constraints.push_back(&constraints_in);
@@ -2459,17 +2462,17 @@ MatrixFree<dim, Number>::reinit(
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const Mapping<dim> &                                   mapping,
   const DoFHandlerType &                                 dof_handler,
-  const AffineConstraints<double> &                      constraints_in,
+  const AffineConstraints<number2> &                     constraints_in,
   const QuadratureType &                                 quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
 {
-  std::vector<const DoFHandlerType *>            dof_handlers;
-  std::vector<const AffineConstraints<double> *> constraints;
+  std::vector<const DoFHandlerType *>             dof_handlers;
+  std::vector<const AffineConstraints<number2> *> constraints;
 
   dof_handlers.push_back(&dof_handler);
   constraints.push_back(&constraints_in);
@@ -2492,11 +2495,11 @@ MatrixFree<dim, Number>::reinit(
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const std::vector<const DoFHandlerType *> &            dof_handler,
-  const std::vector<const AffineConstraints<double> *> & constraint,
+  const std::vector<const AffineConstraints<number2> *> &constraint,
   const std::vector<QuadratureType> &                    quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
 {
@@ -2517,11 +2520,11 @@ MatrixFree<dim, Number>::reinit(
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const std::vector<const DoFHandlerType *> &            dof_handler,
-  const std::vector<const AffineConstraints<double> *> & constraint,
+  const std::vector<const AffineConstraints<number2> *> &constraint,
   const QuadratureType &                                 quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
 {
@@ -2541,12 +2544,12 @@ MatrixFree<dim, Number>::reinit(
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const Mapping<dim> &                                   mapping,
   const std::vector<const DoFHandlerType *> &            dof_handler,
-  const std::vector<const AffineConstraints<double> *> & constraint,
+  const std::vector<const AffineConstraints<number2> *> &constraint,
   const QuadratureType &                                 quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
 {
@@ -2566,12 +2569,12 @@ MatrixFree<dim, Number>::reinit(
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const Mapping<dim> &                                   mapping,
   const std::vector<const DoFHandlerType *> &            dof_handler,
-  const std::vector<const AffineConstraints<double> *> & constraint,
+  const std::vector<const AffineConstraints<number2> *> &constraint,
   const std::vector<QuadratureType> &                    quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
 {
@@ -2592,12 +2595,12 @@ MatrixFree<dim, Number>::reinit(
 
 
 template <int dim, typename Number>
-template <typename DoFHandlerType, typename QuadratureType>
+template <typename DoFHandlerType, typename QuadratureType, typename number2>
 void
 MatrixFree<dim, Number>::reinit(
   const Mapping<dim> &                                   mapping,
   const std::vector<const DoFHandlerType *> &            dof_handler,
-  const std::vector<const AffineConstraints<double> *> & constraint,
+  const std::vector<const AffineConstraints<number2> *> &constraint,
   const std::vector<IndexSet> &                          locally_owned_set,
   const std::vector<QuadratureType> &                    quad,
   const typename MatrixFree<dim, Number>::AdditionalData additional_data)
index 8c4074dfabdbb308d7047638ef8bc92f53c0019b..13cd40785058ba21a425f64fcaf0094e104d6856 100644 (file)
@@ -225,11 +225,12 @@ MatrixFree<dim, Number>::copy_from(const MatrixFree<dim, Number> &v)
 
 
 template <int dim, typename Number>
+template <typename number2>
 void
 MatrixFree<dim, Number>::internal_reinit(
   const Mapping<dim> &                                    mapping,
   const std::vector<const DoFHandler<dim> *> &            dof_handler,
-  const std::vector<const AffineConstraints<double> *> &  constraint,
+  const std::vector<const AffineConstraints<number2> *> & constraint,
   const std::vector<IndexSet> &                           locally_owned_set,
   const std::vector<hp::QCollection<1>> &                 quad,
   const typename MatrixFree<dim, Number>::AdditionalData &additional_data)
@@ -384,11 +385,12 @@ MatrixFree<dim, Number>::internal_reinit(
 
 
 template <int dim, typename Number>
+template <typename number2>
 void
 MatrixFree<dim, Number>::internal_reinit(
   const Mapping<dim> &                                    mapping,
   const std::vector<const hp::DoFHandler<dim> *> &        dof_handler,
-  const std::vector<const AffineConstraints<double> *> &  constraint,
+  const std::vector<const AffineConstraints<number2> *> & constraint,
   const std::vector<IndexSet> &                           locally_owned_set,
   const std::vector<hp::QCollection<1>> &                 quad,
   const typename MatrixFree<dim, Number>::AdditionalData &additional_data)
@@ -737,11 +739,12 @@ MatrixFree<dim, Number>::initialize_dof_handlers(
 
 
 template <int dim, typename Number>
+template <typename number2>
 void
 MatrixFree<dim, Number>::initialize_indices(
-  const std::vector<const AffineConstraints<double> *> &constraint,
-  const std::vector<IndexSet> &                         locally_owned_set,
-  const AdditionalData &                                additional_data)
+  const std::vector<const AffineConstraints<number2> *> &constraint,
+  const std::vector<IndexSet> &                          locally_owned_set,
+  const AdditionalData &                                 additional_data)
 {
   // insert possible ghost cells and construct face topology
   const bool do_face_integrals =
index fddb7f18b3dedd0ad9ec11bfb185e50b868088f5..694b7904dfdca36346ad1fe44b73113a51d772be 100644 (file)
@@ -30,9 +30,42 @@ for (deal_II_dimension : DIMENSIONS)
     MatrixFree<deal_II_dimension,
                float>::print_memory_consumption<std::ostream>(std::ostream &)
       const;
+
     template void MatrixFree<deal_II_dimension, float>::
       print_memory_consumption<ConditionalOStream>(ConditionalOStream &) const;
 
+    template void MatrixFree<deal_II_dimension, double>::internal_reinit<double>(
+      const Mapping<deal_II_dimension> &,
+      const std::vector<const DoFHandler<deal_II_dimension> *> &,
+      const std::vector<const AffineConstraints<double> *> &,
+      const std::vector<IndexSet> &,
+      const std::vector<hp::QCollection<1>> &,
+      const AdditionalData &);
+
+    template void MatrixFree<deal_II_dimension, double>::internal_reinit<double>(
+      const Mapping<deal_II_dimension> &,
+      const std::vector<const hp::DoFHandler<deal_II_dimension> *> &,
+      const std::vector<const AffineConstraints<double> *> &,
+      const std::vector<IndexSet> &,
+      const std::vector<hp::QCollection<1>> &,
+      const AdditionalData &);
+
+    template void MatrixFree<deal_II_dimension, float>::internal_reinit<double>(
+      const Mapping<deal_II_dimension> &,
+      const std::vector<const DoFHandler<deal_II_dimension> *> &,
+      const std::vector<const AffineConstraints<double> *> &,
+      const std::vector<IndexSet> &,
+      const std::vector<hp::QCollection<1>> &,
+      const AdditionalData &);
+
+    template void MatrixFree<deal_II_dimension, float>::internal_reinit<double>(
+      const Mapping<deal_II_dimension> &,
+      const std::vector<const hp::DoFHandler<deal_II_dimension> *> &,
+      const std::vector<const AffineConstraints<double> *> &,
+      const std::vector<IndexSet> &,
+      const std::vector<hp::QCollection<1>> &,
+      const AdditionalData &);
+
 #ifndef DEAL_II_MSVC
     template void
     internal::MatrixFreeFunctions::ShapeInfo<double>::reinit<deal_II_dimension>(

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.