]> https://gitweb.dealii.org/ - dealii.git/commitdiff
removed fe_enriched.templates.h and moved functions in internal namespace to fe_enric...
authornivesh <nidhinivesh.d@gmail.com>
Fri, 8 Jun 2018 14:31:36 +0000 (16:31 +0200)
committernivesh <nidhinivesh.d@gmail.com>
Wed, 20 Jun 2018 18:34:25 +0000 (20:34 +0200)
include/deal.II/fe/fe_enriched.h
include/deal.II/fe/fe_enriched.templates.h [deleted file]
source/fe/fe_enriched.cc
tests/fe/fe_enriched_color_01.cc
tests/fe/fe_enriched_color_02.cc
tests/fe/fe_enriched_color_03.cc
tests/fe/fe_enriched_color_04.cc
tests/fe/fe_enriched_color_05.cc

index 67335a223e1fc62be9d023e01228425fa9f47603..ecd651be019d8a50bb595641dccc7c66fba446d2 100644 (file)
@@ -721,6 +721,192 @@ namespace ColorEnriched
   using predicate_function = std::function<bool(
     const typename Triangulation<dim, spacedim>::cell_iterator &)>;
 
+  namespace internal
+  {
+    /**
+     * Returns true if there is a connection between subdomains in the mesh
+     * associated with @p hp::DoFHandler i.e., if the subdomains share at least
+     * a vertex. The two subdomains are defined by predicates provided by
+     * @p predicate_1 and @p predicate_2. A predicate is a function (or
+     * object of a type with an operator()) which takes in a cell iterator and
+     * gives a boolean. It is said to be active in a cell if it returns true.
+     *
+     * An example of a custom predicate is one that checks the distance from a
+     * fixed point. Note that the operator() takes in a cell iterator. Using the
+     * constructor, the fixed point and the distance can be chosen.
+     * @code
+     * <int dim>
+     * struct predicate
+     * {
+     *     predicate(const Point<dim> p, const int radius)
+     *     :p(p),radius(radius){}
+     *
+     *     template <class Iterator>
+     *     bool operator () (const Iterator &i)
+     *     {
+     *         return ( (i->center() - p).norm() < radius);
+     *     }
+     *
+     * private:
+     *     Point<dim> p;
+     *     int radius;
+     *
+     * };
+     * @endcode
+     * and then the function can be used as follows to find if the subdomains
+     * are connected.
+     * @code
+     * find_connection_between_subdomains
+     * (dof_handler,
+     *  predicate<dim>(Point<dim>(0,0), 1)
+     *  predicate<dim>(Point<dim>(2,2), 1));
+     * @endcode
+     *
+     * @param[in] hp::DoFHandler object
+     * @param[in] predicate_1 A function (or object of a type with an
+     * operator()) defining the subdomain 1. The function takes in a cell and
+     * returns a boolean.
+     * @param[in] predicate_2 Same as @p predicate_1 but defines subdomain 2.
+     * @return A boolean "true" if the subdomains share atleast a vertex.
+     */
+    template <int dim, int spacedim>
+    bool
+    find_connection_between_subdomains(
+      const hp::DoFHandler<dim, spacedim> &    dof_handler,
+      const predicate_function<dim, spacedim> &predicate_1,
+      const predicate_function<dim, spacedim> &predicate_2);
+
+    /**
+     * Assign colors to subdomains using Graph coloring algorithm where each
+     * subdomain is considered as a graph node. Subdomains which are
+     * connected i.e share atleast a vertex have different color. Each subdomain
+     * is defined using a predicate function of @p predicates.
+     *
+     * @param[in] dof_handler a hp::DoFHandler object
+     * @param[in] predicates predicates defining the subdomains
+     * @param[out] predicate_colors Colors (unsigned int) associated with each
+     * subdomain.
+     */
+    template <int dim, int spacedim>
+    unsigned int
+    color_predicates(
+      const hp::DoFHandler<dim, spacedim> &                 dof_handler,
+      const std::vector<predicate_function<dim, spacedim>> &predicates,
+      std::vector<unsigned int> &                           predicate_colors);
+
+    /**
+     * Used to construct data members @p cellwise_color_predicate_map and
+     * @p fe_sets of Helper class. Inputs are hp::DoFHandler object,
+     * vector of predicates and colors associated with them. Before calling
+     * this function, colors can be assigned to predicates (i.e subdomains)
+     * using the function color_predicates.
+     *
+     * Each active FE index has a set of colors associated with it.
+     * A cell with an active FE index i has a set of colors given by
+     * <code>fe_sets[i]</code>. An active FE index with color {a,b}
+     * means that the cell has two active predicates (i.e they return true
+     * for the cell) of color a and b.
+     *
+     * Eg: fe_sets = { {}, {1}, {2}, {1,2} } means
+     * Cells with active FE index 0 have no predicates associated.
+     * Cells with index 1 have a active predicate with color 1.
+     * Cells with index 2 have a active predicate with color 2.
+     * Cells with index 3 have active predicates with color 1 and color 2.
+     *
+     * A map of maps cellwise_color_predicate_map is used to associate
+     * predicate colors in cells with predicate ids. For this purpose, each
+     * cell is given a unique id which is stored in material id for now.
+     * When the grid is refined, material id is inherited to the children, so
+     * map which associates material id with color map will still be relevant.
+     *
+     * Now the color map can be explained with an example. If the cell with
+     * material id 100 has active predicates 4 (color = 1) and 5 (color = 2),
+     * the map will insert pairs (1, 4) and (2, 5) at key 100 (i.e unique id
+     * of cell is mapped with a map which associates color with predicate id).
+     *
+     * @param[in] dof_handler hp::DoFHandler object
+     * @param[in] predicates vector of predicates defining the subdomains.
+     * <code>@p predicates[i]</code> returns true for a cell if it
+     * belongs to subdomain with index i.
+     * @param[in] predicate_colors vector of colors (unsigned int) associated
+     * with each subdomain.
+     * @param[out] cellwise_color_predicate_map A map of maps used to associate
+     * predicate colors in cells with predicate ids.
+     * @param[out] fe_sets a vector of color lists
+     */
+    template <int dim, int spacedim>
+    void
+    set_cellwise_color_set_and_fe_index(
+      hp::DoFHandler<dim, spacedim> &                       dof_handler,
+      const std::vector<predicate_function<dim, spacedim>> &predicates,
+      const std::vector<unsigned int> &                     predicate_colors,
+      std::map<unsigned int, std::map<unsigned int, unsigned int>>
+        &                                  cellwise_color_predicate_map,
+      std::vector<std::set<unsigned int>> &fe_sets);
+
+    /**
+     * A function that returns a vector of enrichment functions corresponding
+     * to a color. The size of the vector is equal to total number of different
+     * colors associated with predicates (i.e subdomains).
+     *
+     * Assume that a cell has a active predicates with ids 4 (color = 1) and
+     * 5 (color = 2). cellwise_color_predicate_map has this information
+     * provided we know the material id.
+     *
+     * Now a call to color_enrichment[1](cell) should in turn call
+     * enrichments[4](cell).
+     *
+     * @param[in] num_colors number of colors for predicates
+     * @param[in] enrichments vector of enrichment functions
+     * @param[in] cellwise_color_predicate_map A map of maps used to associate
+     * predicate colors in cells with predicate ids.
+     * @param[out] color_enrichments A vector of functions that take in cell
+     * and return a function pointer.
+     */
+    template <int dim, int spacedim>
+    void
+    make_colorwise_enrichment_functions(
+      const unsigned int &                                    num_colors,
+      const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments,
+      const std::map<unsigned int, std::map<unsigned int, unsigned int>>
+        &cellwise_color_predicate_map,
+      std::vector<std::function<const Function<spacedim> *(
+        const typename Triangulation<dim, spacedim>::cell_iterator &)>>
+        &color_enrichments);
+
+
+    /**
+     * Creates a hp::FECollection object constructed using FE_Enriched
+     * elements which itself is constructed using color enrichment functions
+     * and is of size equal to number of colors.
+     *
+     * @param[in] fe_sets a vector of color lists
+     * @param[in] color_enrichments A vector of functions that take in cell
+     * and return a function pointer.
+     * @param[in] fe_base base FiniteElement
+     * @param[in] fe_enriched enriched FiniteElements
+     * @param[in] fe_nothing a finite element with zero degrees of freedom
+     * @param[out] fe_collection a collection of
+     * finite elements
+     */
+    template <int dim, int spacedim>
+    void
+    make_fe_collection_from_colored_enrichments(
+      const unsigned int &num_colors,
+      const std::vector<std::set<unsigned int>>
+        &fe_sets, // total list of color sets possible
+      const std::vector<std::function<const Function<spacedim> *(
+        const typename Triangulation<dim, spacedim>::cell_iterator &)>>
+        &color_enrichments,               // color wise enrichment functions
+      const FE_Q<dim, spacedim> &fe_base, // basic FE element
+      const FE_Q<dim, spacedim>
+        &fe_enriched, // FE element multiplied by enrichment function
+      const FE_Nothing<dim, spacedim> &fe_nothing,
+      hp::FECollection<dim, spacedim> &fe_collection);
+  } // namespace internal
+
+
+
   /**
    * ColorEnriched::Helper class creates a collection of FE_Enriched finite
    * elements (hp::FECollection) to be used with hp::DoFHandler in a domain
@@ -1005,7 +1191,7 @@ namespace ColorEnriched
     std::vector<std::set<unsigned int>> fe_sets;
   };
 } // namespace ColorEnriched
-//}
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif // dealii_fe_enriched_h
diff --git a/include/deal.II/fe/fe_enriched.templates.h b/include/deal.II/fe/fe_enriched.templates.h
deleted file mode 100644 (file)
index 674aebe..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2016 - 2017 by the deal.II authors
-//
-// This file is part of the deal.II library.
-//
-// The deal.II library is free software; you can use it, redistribute
-// it, and/or modify it under the terms of the GNU Lesser General
-// Public License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// The full text of the license can be found in the file LICENSE at
-// the top level of the deal.II distribution.
-//
-// ---------------------------------------------------------------------
-
-#ifndef dealii_fe_enriched_templates_h
-#define dealii_fe_enriched_templates_h
-
-#include <deal.II/fe/fe_enriched.h>
-
-DEAL_II_NAMESPACE_OPEN
-
-namespace ColorEnriched
-{
-  namespace internal
-  {
-    /**
-     * Returns true if there is a connection between subdomains in the mesh
-     * associated with @p hp::DoFHandler i.e., if the subdomains share at least
-     * a vertex. The two subdomains are defined by predicates provided by
-     * @p predicate_1 and @p predicate_2. A predicate is a function (or
-     * object of a type with an operator()) which takes in a cell iterator and
-     * gives a boolean. It is said to be active in a cell if it returns true.
-     *
-     * An example of a custom predicate is one that checks the distance from a
-     * fixed point. Note that the operator() takes in a cell iterator. Using the
-     * constructor, the fixed point and the distance can be chosen.
-     * @code
-     * <int dim>
-     * struct predicate
-     * {
-     *     predicate(const Point<dim> p, const int radius)
-     *     :p(p),radius(radius){}
-     *
-     *     template <class Iterator>
-     *     bool operator () (const Iterator &i)
-     *     {
-     *         return ( (i->center() - p).norm() < radius);
-     *     }
-     *
-     * private:
-     *     Point<dim> p;
-     *     int radius;
-     *
-     * };
-     * @endcode
-     * and then the function can be used as follows to find if the subdomains
-     * are connected.
-     * @code
-     * find_connection_between_subdomains
-     * (dof_handler,
-     *  predicate<dim>(Point<dim>(0,0), 1)
-     *  predicate<dim>(Point<dim>(2,2), 1));
-     * @endcode
-     *
-     * @param[in] hp::DoFHandler object
-     * @param[in] predicate_1 A function (or object of a type with an
-     * operator()) defining the subdomain 1. The function takes in a cell and
-     * returns a boolean.
-     * @param[in] predicate_2 Same as @p predicate_1 but defines subdomain 2.
-     * @return A boolean "true" if the subdomains share atleast a vertex.
-     */
-    template <int dim, int spacedim>
-    bool
-    find_connection_between_subdomains(
-      const hp::DoFHandler<dim, spacedim> &    dof_handler,
-      const predicate_function<dim, spacedim> &predicate_1,
-      const predicate_function<dim, spacedim> &predicate_2);
-
-    /**
-     * Assign colors to subdomains using Graph coloring algorithm where each
-     * subdomain is considered as a graph node. Subdomains which are
-     * connected i.e share atleast a vertex have different color. Each subdomain
-     * is defined using a predicate function of @p predicates.
-     *
-     * @param[in] dof_handler a hp::DoFHandler object
-     * @param[in] predicates predicates defining the subdomains
-     * @param[out] predicate_colors Colors (unsigned int) associated with each
-     * subdomain.
-     */
-    template <int dim, int spacedim>
-    unsigned int
-    color_predicates(
-      const hp::DoFHandler<dim, spacedim> &                 dof_handler,
-      const std::vector<predicate_function<dim, spacedim>> &predicates,
-      std::vector<unsigned int> &                           predicate_colors);
-
-    /**
-     * Used to construct data members @p cellwise_color_predicate_map and
-     * @p fe_sets of Helper class. Inputs are hp::DoFHandler object,
-     * vector of predicates and colors associated with them. Before calling
-     * this function, colors can be assigned to predicates (i.e subdomains)
-     * using the function color_predicates.
-     *
-     * Each active FE index has a set of colors associated with it.
-     * A cell with an active FE index i has a set of colors given by
-     * <code>fe_sets[i]</code>. An active FE index with color {a,b}
-     * means that the cell has two active predicates (i.e they return true
-     * for the cell) of color a and b.
-     *
-     * Eg: fe_sets = { {}, {1}, {2}, {1,2} } means
-     * Cells with active FE index 0 have no predicates associated.
-     * Cells with index 1 have a active predicate with color 1.
-     * Cells with index 2 have a active predicate with color 2.
-     * Cells with index 3 have active predicates with color 1 and color 2.
-     *
-     * A map of maps cellwise_color_predicate_map is used to associate
-     * predicate colors in cells with predicate ids. For this purpose, each
-     * cell is given a unique id which is stored in material id for now.
-     * When the grid is refined, material id is inherited to the children, so
-     * map which associates material id with color map will still be relevant.
-     *
-     * Now the color map can be explained with an example. If the cell with
-     * material id 100 has active predicates 4 (color = 1) and 5 (color = 2),
-     * the map will insert pairs (1, 4) and (2, 5) at key 100 (i.e unique id
-     * of cell is mapped with a map which associates color with predicate id).
-     *
-     * @param[in] dof_handler hp::DoFHandler object
-     * @param[in] predicates vector of predicates defining the subdomains.
-     * <code>@p predicates[i]</code> returns true for a cell if it
-     * belongs to subdomain with index i.
-     * @param[in] predicate_colors vector of colors (unsigned int) associated
-     * with each subdomain.
-     * @param[out] cellwise_color_predicate_map A map of maps used to associate
-     * predicate colors in cells with predicate ids.
-     * @param[out] fe_sets a vector of color lists
-     */
-    template <int dim, int spacedim>
-    void
-    set_cellwise_color_set_and_fe_index(
-      hp::DoFHandler<dim, spacedim> &                       dof_handler,
-      const std::vector<predicate_function<dim, spacedim>> &predicates,
-      const std::vector<unsigned int> &                     predicate_colors,
-      std::map<unsigned int, std::map<unsigned int, unsigned int>>
-        &                                  cellwise_color_predicate_map,
-      std::vector<std::set<unsigned int>> &fe_sets);
-
-    /**
-     * A function that returns a vector of enrichment functions corresponding
-     * to a color. The size of the vector is equal to total number of different
-     * colors associated with predicates (i.e subdomains).
-     *
-     * Assume that a cell has a active predicates with ids 4 (color = 1) and
-     * 5 (color = 2). cellwise_color_predicate_map has this information
-     * provided we know the material id.
-     *
-     * Now a call to color_enrichment[1](cell) should in turn call
-     * enrichments[4](cell).
-     *
-     * @param[in] num_colors number of colors for predicates
-     * @param[in] enrichments vector of enrichment functions
-     * @param[in] cellwise_color_predicate_map A map of maps used to associate
-     * predicate colors in cells with predicate ids.
-     * @param[out] color_enrichments A vector of functions that take in cell
-     * and return a function pointer.
-     */
-    template <int dim, int spacedim>
-    void
-    make_colorwise_enrichment_functions(
-      const unsigned int &                                    num_colors,
-      const std::vector<std::shared_ptr<Function<spacedim>>> &enrichments,
-      const std::map<unsigned int, std::map<unsigned int, unsigned int>>
-        &cellwise_color_predicate_map,
-      std::vector<std::function<const Function<spacedim> *(
-        const typename Triangulation<dim, spacedim>::cell_iterator &)>>
-        &color_enrichments);
-
-
-    /**
-     * Creates a hp::FECollection object constructed using FE_Enriched
-     * elements which itself is constructed using color enrichment functions
-     * and is of size equal to number of colors.
-     *
-     * @param[in] fe_sets a vector of color lists
-     * @param[in] color_enrichments A vector of functions that take in cell
-     * and return a function pointer.
-     * @param[in] fe_base base FiniteElement
-     * @param[in] fe_enriched enriched FiniteElements
-     * @param[in] fe_nothing a finite element with zero degrees of freedom
-     * @param[out] fe_collection a collection of
-     * finite elements
-     */
-    template <int dim, int spacedim>
-    void
-    make_fe_collection_from_colored_enrichments(
-      const unsigned int &num_colors,
-      const std::vector<std::set<unsigned int>>
-        &fe_sets, // total list of color sets possible
-      const std::vector<std::function<const Function<spacedim> *(
-        const typename Triangulation<dim, spacedim>::cell_iterator &)>>
-        &color_enrichments,               // color wise enrichment functions
-      const FE_Q<dim, spacedim> &fe_base, // basic FE element
-      const FE_Q<dim, spacedim>
-        &fe_enriched, // FE element multiplied by enrichment function
-      const FE_Nothing<dim, spacedim> &fe_nothing,
-      hp::FECollection<dim, spacedim> &fe_collection);
-  } // namespace internal
-} // namespace ColorEnriched
-
-DEAL_II_NAMESPACE_CLOSE
-
-#endif // dealii_fe_enriched_templates_h
index a6cf40b868f0350cb3720b86317ef197b083cca0..c634611fe4eb281a3aeecf4cadb8406c476037a0 100644 (file)
@@ -17,7 +17,6 @@
 #include <deal.II/base/std_cxx14/memory.h>
 
 #include <deal.II/fe/fe_enriched.h>
-#include <deal.II/fe/fe_enriched.templates.h>
 #include <deal.II/fe/fe_tools.h>
 
 #include <deal.II/lac/sparsity_tools.h>
@@ -1287,7 +1286,8 @@ namespace ColorEnriched
             // find active indices of neighboring cells
             if (!cell->at_boundary(face))
               {
-                unsigned int nbr_fe_index = cell->neighbor(face)->active_fe_index();
+                unsigned int nbr_fe_index =
+                  cell->neighbor(face)->active_fe_index();
                 // find corresponding fe set
                 auto nbr_fe_set = fe_sets[nbr_fe_index];
 
index ddee3960d30b2119df92b5393a17346be94e5dca..49d99eab7266f0579ddcfa1e4e8d4ed062599aeb 100644 (file)
@@ -18,7 +18,7 @@
 // function. Check if the function correctly finds if two subdomains
 // share an edge/node.
 
-#include <deal.II/fe/fe_enriched.templates.h>
+#include <deal.II/fe/fe_enriched.h>
 
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_out.h>
index f0657fd09554a38ad665a4b4e039f0e6b1d210a8..3ad1a224b3d16d707c65f3e91ca2e0d4b52d4f9d 100644 (file)
@@ -22,7 +22,7 @@
  * different predicates touch each other.
  */
 
-#include <deal.II/fe/fe_enriched.templates.h>
+#include <deal.II/fe/fe_enriched.h>
 
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_refinement.h>
index 24b69ad8b1dfe6b0e2f1e79649b1dfe358727a7a..ad0624573cafd580491432186148aadd3fa70104 100644 (file)
@@ -24,7 +24,7 @@
 #include <deal.II/dofs/dof_renumbering.h>
 #include <deal.II/dofs/dof_tools.h>
 
-#include <deal.II/fe/fe_enriched.templates.h>
+#include <deal.II/fe/fe_enriched.h>
 
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_refinement.h>
index ffd8c5a4db083a9ea6ff652de4f3ffc719b04263..58cd190d30f10333c86fdcca4352effc0093f961 100644 (file)
@@ -22,7 +22,7 @@
  * function if cell and color of the function are provided.
  */
 
-#include <deal.II/fe/fe_enriched.templates.h>
+#include <deal.II/fe/fe_enriched.h>
 
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_refinement.h>
index 339e4a35fe102d8a7408577bcbc85cc40219a968..cfc341bec9524021aec2d92725dfbc67931ec7f5 100644 (file)
@@ -23,7 +23,7 @@
 #include <deal.II/dofs/dof_renumbering.h>
 #include <deal.II/dofs/dof_tools.h>
 
-#include <deal.II/fe/fe_enriched.templates.h>
+#include <deal.II/fe/fe_enriched.h>
 #include <deal.II/fe/fe_nothing.h>
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_system.h>

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.