* 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
* 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(
"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_,