]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add DataPostprocessors::BoundaryIds.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 27 Apr 2022 19:26:26 +0000 (13:26 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 27 Apr 2022 23:02:01 +0000 (17:02 -0600)
include/deal.II/numerics/data_postprocessor.h
source/numerics/data_postprocessor.cc
source/numerics/data_postprocessor.inst.in

index ee82201f56cdc5395c6d2885458a72a9646aff47..40710dcfa997dd070d2cfd3d03950262d3df1bf3 100644 (file)
@@ -1274,6 +1274,48 @@ private:
 
 
 
+/**
+ * A namespace that contains concrete implementations of data
+ * postprocessors, i.e., non-abstract classes based on DataPostprocessor
+ * or on the intermediate classes DataPostprocessorScalar,
+ * DataPostprocessorVector, or DataPostprocessorTensor.
+ */
+namespace DataPostprocessors
+{
+  /**
+   * A concrete data postprocessor class that can be used to output the
+   * boundary ids of all faces. This is often useful to identify bugs in
+   * the assignment of boundary indicators when reading meshes from input
+   * files. See the usage example in the
+   * @ref GlossBoundaryIndicator "glossary entry on boundary ids"
+   * to see how this class can be used.
+   *
+   * @note This class is intended for use with DataOutFaces, not DataOut.
+   *   This is because it provides information about the *faces* of a
+   *   triangulation, not about cell-based information.
+   */
+  template <int dim>
+  class BoundaryIds : public DataPostprocessorScalar<dim>
+  {
+  public:
+    /**
+     * Constructor.
+     */
+    BoundaryIds();
+
+    /**
+     * The principal function of this class. It puts the boundary id
+     * of each face into the appropriate output fields.
+     */
+    virtual void
+    evaluate_scalar_field(
+      const DataPostprocessorInputs::Scalar<dim> &inputs,
+      std::vector<Vector<double>> &computed_quantities) const override;
+  };
+} // namespace DataPostprocessors
+
+
+
 #ifndef DOXYGEN
 // -------------------- template functions ----------------------
 
index 61fa1fd222e3df1f83ab19e99e00ade24bdcb667..946be4b1ed047fc87d98cd4632a57770ad2cde9a 100644 (file)
@@ -196,6 +196,36 @@ DataPostprocessorTensor<dim>::get_needed_update_flags() const
 
 
 
+namespace DataPostprocessors
+{
+  template <int dim>
+  BoundaryIds<dim>::BoundaryIds()
+    : DataPostprocessorScalar<dim>("boundary_id", update_quadrature_points)
+  {}
+
+
+  template <int dim>
+  void
+  BoundaryIds<dim>::evaluate_scalar_field(
+    const DataPostprocessorInputs::Scalar<dim> &inputs,
+    std::vector<Vector<double>> &               computed_quantities) const
+  {
+    AssertDimension(computed_quantities.size(), inputs.solution_values.size());
+
+    const typename DoFHandler<dim>::active_cell_iterator cell =
+      inputs.template get_cell<dim>();
+    const unsigned int face = inputs.get_face_number();
+
+    for (auto &output : computed_quantities)
+      {
+        AssertDimension(output.size(), 1);
+        output(0) = cell->face(face)->boundary_id();
+      }
+  }
+} // namespace DataPostprocessors
+
+
+
 // explicit instantiation
 #include "data_postprocessor.inst"
 
index 55dbded5e149b9eab4453492443206534c690edb..5ce5e140ebe4d6f3cb509e6478f42b9e149ca682 100644 (file)
@@ -24,4 +24,9 @@ for (deal_II_dimension : DIMENSIONS)
     template class DataPostprocessorScalar<deal_II_dimension>;
     template class DataPostprocessorVector<deal_II_dimension>;
     template class DataPostprocessorTensor<deal_II_dimension>;
+
+    namespace DataPostprocessors
+    \{
+      template class BoundaryIds<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.