--- /dev/null
+Removed: The class parallel::distributed::ErrorPredictor has been
+removed. Use the function hp::Refinement::predict_error() in combination
+with parallel::distributed::CellDataTransfer instead. Please consult the
+documentation of hp::Refinement::predict_error() for instructions.
+<br>
+(Marc Fehling, 2021/04/21)
* $\gamma_\text{p}^2 = 0.4$, $\gamma_\text{h}^2 = 4$,
* $\gamma_\text{n}^2 = 1$.
*
+ * If you are working with parallel::distributed::Triangulation objects, you
+ * need to pay special attention. Here, p4est determines the details of grid
+ * refinement, and consequently, it yields more reliable and trustworthy
+ * results when we determine the predicted errors during the adaptation
+ * process. We can do exactly this by attaching this function to the signal
+ * Triangulation::Signals::post_p4est_refinement, which is triggered after
+ * p4est got refined, but before data is prepared for transfer. Refinement
+ * and coarsening flags of the Triangulation object need to be matched with
+ * the already refined p4est oracle using
+ * internal::parallel::distributed::TemporarilyMatchRefineFlags.
+ * Thus, a construct like the following is necessary to correctly predict
+ * errors in parallel distributed applications.
+ * @code
+ * Vector<float> predicted_errors;
+ * triangulation.signals.post_p4est_refinement.connect([&]() {
+ * const internal::parallel::distributed::TemporarilyMatchRefineFlags<dim>
+ * refine_modifier(triangulation);
+ * predicted_errors.reinit(triangulation.n_active_cells());
+ * hp::Refinement::predict_error(dof_handler,
+ * error_indicators,
+ * predicted_errors);
+ * });
+ * @endcode
+ * The container <code>predicted_errors</code> then needs to follow the
+ * usual parallel::distributed::CellDataTransfer workflow.
+ *
* @note We want to predict the error by how adaptation will actually happen.
* Thus, this function needs to be called after
* Triangulation::prepare_coarsening_and_refinement() and
// This tests is based on hp/error_prediction.cc
-#include <deal.II/distributed/error_predictor.h>
+#include <deal.II/distributed/cell_data_transfer.h>
#include <deal.II/distributed/tria.h>
#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/dofs/dof_tools.h>
#include <deal.II/fe/fe_q.h>
+#include <deal.II/hp/refinement.h>
+
#include <deal.II/lac/vector.h>
#include "../tests.h"
for (unsigned int i = 0; i < error_indicators.size(); ++i)
error_indicators(i) = 10.;
+ // ----- connect error predictor -----
+ Vector<float> predicted_errors;
+ tria.signals.post_p4est_refinement.connect([&]() {
+ const internal::parallel::distributed::TemporarilyMatchRefineFlags<dim>
+ refine_modifier(tria);
+ predicted_errors.reinit(tria.n_active_cells());
+ hp::Refinement::predict_error(dh,
+ error_indicators,
+ predicted_errors,
+ /*gamma_p=*/0.5,
+ /*gamma_h=*/1.,
+ /*gamma_n=*/1.);
+ });
+
// ----- verify ------
deallog << "pre_adaptation" << std::endl;
for (const auto &cell : dh.active_cell_iterators())
}
// ----- execute adaptation -----
- parallel::distributed::ErrorPredictor<dim> predictor(dh);
+ parallel::distributed::CellDataTransfer<dim, dim, Vector<float>>
+ data_transfer(tria,
+ /*transfer_variable_size_data=*/false,
+ &AdaptationStrategies::Refinement::l2_norm<dim, dim, float>,
+ &AdaptationStrategies::Coarsening::l2_norm<dim, dim, float>);
- predictor.prepare_for_coarsening_and_refinement(error_indicators,
- /*gamma_p=*/0.5,
- /*gamma_h=*/1.,
- /*gamma_n=*/1.);
+ data_transfer.prepare_for_coarsening_and_refinement(predicted_errors);
tria.execute_coarsening_and_refinement();
- Vector<float> predicted_errors(tria.n_active_cells());
- predictor.unpack(predicted_errors);
+ predicted_errors.reinit(tria.n_active_cells());
+ data_transfer.unpack(predicted_errors);
// ------ verify ------
deallog << "post_adaptation" << std::endl;
// This tests is based on hp/error_prediction.cc
-#include <deal.II/distributed/error_predictor.h>
+#include <deal.II/distributed/cell_data_transfer.h>
#include <deal.II/distributed/tria.h>
#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/dofs/dof_tools.h>
#include <deal.II/fe/fe_q.h>
+#include <deal.II/hp/refinement.h>
+
#include <deal.II/lac/vector.h>
#include "../tests.h"
for (unsigned int i = 0; i < error_indicators.size(); ++i)
error_indicators(i) = 10.;
+ // ----- connect error predictor -----
+ Vector<float> predicted_errors;
+ tria.signals.post_p4est_refinement.connect([&]() {
+ const internal::parallel::distributed::TemporarilyMatchRefineFlags<dim>
+ refine_modifier(tria);
+ predicted_errors.reinit(tria.n_active_cells());
+ hp::Refinement::predict_error(dh,
+ error_indicators,
+ predicted_errors,
+ /*gamma_p=*/0.5,
+ /*gamma_h=*/1.,
+ /*gamma_n=*/1.);
+ });
+
// ----- verify ------
deallog << "pre_adaptation" << std::endl;
for (const auto &cell : dh.active_cell_iterators())
}
// ----- execute adaptation -----
- parallel::distributed::ErrorPredictor<dim> predictor(dh);
+ parallel::distributed::CellDataTransfer<dim, dim, Vector<float>>
+ data_transfer(tria,
+ /*transfer_variable_size_data=*/false,
+ &AdaptationStrategies::Refinement::l2_norm<dim, dim, float>,
+ &AdaptationStrategies::Coarsening::l2_norm<dim, dim, float>);
- predictor.prepare_for_coarsening_and_refinement(error_indicators,
- /*gamma_p=*/0.5,
- /*gamma_h=*/1.,
- /*gamma_n=*/1.);
+ data_transfer.prepare_for_coarsening_and_refinement(predicted_errors);
tria.execute_coarsening_and_refinement();
- Vector<float> predicted_errors(tria.n_active_cells());
- predictor.unpack(predicted_errors);
+ predicted_errors.reinit(tria.n_active_cells());
+ data_transfer.unpack(predicted_errors);
// ------ verify ------
deallog << "post_adaptation" << std::endl;