From: Wolfgang Bangerth Date: Wed, 27 Apr 2022 19:26:26 +0000 (-0600) Subject: Add DataPostprocessors::BoundaryIds. X-Git-Tag: v9.4.0-rc1~277^2~7 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0668dcd4df2594303db56053042493b9b137d087;p=dealii.git Add DataPostprocessors::BoundaryIds. --- diff --git a/include/deal.II/numerics/data_postprocessor.h b/include/deal.II/numerics/data_postprocessor.h index ee82201f56..40710dcfa9 100644 --- a/include/deal.II/numerics/data_postprocessor.h +++ b/include/deal.II/numerics/data_postprocessor.h @@ -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 + class BoundaryIds : public DataPostprocessorScalar + { + 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 &inputs, + std::vector> &computed_quantities) const override; + }; +} // namespace DataPostprocessors + + + #ifndef DOXYGEN // -------------------- template functions ---------------------- diff --git a/source/numerics/data_postprocessor.cc b/source/numerics/data_postprocessor.cc index 61fa1fd222..946be4b1ed 100644 --- a/source/numerics/data_postprocessor.cc +++ b/source/numerics/data_postprocessor.cc @@ -196,6 +196,36 @@ DataPostprocessorTensor::get_needed_update_flags() const +namespace DataPostprocessors +{ + template + BoundaryIds::BoundaryIds() + : DataPostprocessorScalar("boundary_id", update_quadrature_points) + {} + + + template + void + BoundaryIds::evaluate_scalar_field( + const DataPostprocessorInputs::Scalar &inputs, + std::vector> & computed_quantities) const + { + AssertDimension(computed_quantities.size(), inputs.solution_values.size()); + + const typename DoFHandler::active_cell_iterator cell = + inputs.template get_cell(); + 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" diff --git a/source/numerics/data_postprocessor.inst.in b/source/numerics/data_postprocessor.inst.in index 55dbded5e1..5ce5e140eb 100644 --- a/source/numerics/data_postprocessor.inst.in +++ b/source/numerics/data_postprocessor.inst.in @@ -24,4 +24,9 @@ for (deal_II_dimension : DIMENSIONS) template class DataPostprocessorScalar; template class DataPostprocessorVector; template class DataPostprocessorTensor; + + namespace DataPostprocessors + \{ + template class BoundaryIds; + \} }