]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bug in weighting_callback for uninitialized DoFHandlers. 12041/head
authorMarc Fehling <mafehling.git@gmail.com>
Tue, 13 Apr 2021 21:38:59 +0000 (15:38 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Tue, 13 Apr 2021 21:38:59 +0000 (15:38 -0600)
include/deal.II/distributed/cell_weights.h
source/distributed/cell_weights.cc

index e8c16491789ee78ec7191524c577d578f6ab7929..3ea742ddf14d8857f915986d8a76d147a510f7f9 100644 (file)
@@ -40,6 +40,9 @@ namespace parallel
    * a DoFHandler. One can choose from predefined weighting algorithms provided
    * by this class or provide a custom one.
    *
+   * If the associated DoFHandler has not been initialized yet, i.e., its
+   * hp::FECollection is empty, all cell weights will be evaluated as zero.
+   *
    * This class offers two different ways of connecting the chosen weighting
    * function to the corresponding signal of the linked
    * parallel::TriangulationBase. The recommended way involves creating an
@@ -282,7 +285,8 @@ namespace parallel
      * A callback function that will be connected to the cell_weight signal of
      * the @p triangulation, to which the @p dof_handler is attached. Ultimately
      * returns the weight for each cell, determined by the @p weighting_function
-     * provided as a parameter.
+     * provided as a parameter. Returns zero if @p dof_handler has not been
+     * initialized yet.
      */
     static unsigned int
     weighting_callback(
index d493728065ba6a943082cd309ae6be9cd713c061..a6441a314f49c1c02cc42bd4d12eacb5b7e1b392 100644 (file)
@@ -176,6 +176,10 @@ namespace parallel
              "Triangulation associated with the DoFHandler has changed!"));
     (void)triangulation;
 
+    // Skip if the DoFHandler has not been initialized yet.
+    if (dof_handler.get_fe_collection().size() == 0)
+      return 0;
+
     // Convert cell type from Triangulation to DoFHandler to be able
     // to access the information about the degrees of freedom.
     const typename DoFHandler<dim, spacedim>::cell_iterator cell(*cell_,

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.