--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2023 - 2023 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// Test mapping centers with simplices
+
+#include <deal.II/base/function.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_simplex_p.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/mapping_fe.h>
+#include <deal.II/fe/mapping_fe_field.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/numerics/vector_tools.h>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+template <int dim>
+class Position : public Function<dim>
+{
+public:
+ Position()
+ : Function<dim>(dim)
+ {}
+
+ double
+ value(const Point<dim> &point, const unsigned int component) const
+ {
+ if (component == 0)
+ return point[component] + std::sin(point[dim - 1] * numbers::PI);
+ return point[component];
+ }
+};
+
+void
+test(const unsigned int mapping_degree)
+{
+ const int dim = 3;
+
+ Triangulation<dim> tria;
+ GridGenerator::subdivided_hyper_cube_with_simplices(tria, 2);
+
+ FE_SimplexP<dim> fe(mapping_degree);
+ FESystem<dim> position_fe(fe, dim);
+
+ DoFHandler<dim> dof_handler(tria);
+ dof_handler.distribute_dofs(fe);
+
+ DoFHandler<dim> position_dof_handler(tria);
+ position_dof_handler.distribute_dofs(position_fe);
+
+ Vector<double> position_vector(position_dof_handler.n_dofs());
+ MappingFE<dim> mapping_interpolation(FE_SimplexP<dim>(1));
+ VectorTools::interpolate(mapping_interpolation,
+ position_dof_handler,
+ Position<dim>(),
+ position_vector);
+
+ MappingFEField<dim> mapping(position_dof_handler, position_vector);
+
+ for (const auto &cell : tria.active_cell_iterators())
+ {
+ deallog << "cell = " << cell << std::endl;
+ deallog << "mapped barycenter = " << mapping.get_center(cell, true)
+ << std::endl;
+ Point<dim> manually_mapped_center;
+ for (unsigned int d = 0; d < dim; ++d)
+ manually_mapped_center[d] =
+ Position<dim>().value(cell->barycenter(), d);
+ deallog << "exact mapped barycenter = " << manually_mapped_center
+ << std::endl;
+ deallog << "mapped vertex mean = " << mapping.get_center(cell, false)
+ << std::endl;
+ }
+}
+
+int
+main()
+{
+ initlog();
+
+ test(1); // linear mapping
+
+ deallog << std::endl << "quadratic mapping" << std::endl << std::endl;
+
+ test(2); // quadratic mapping
+}
--- /dev/null
+
+DEAL::cell = 0.0
+DEAL::mapped barycenter = 0.375000 0.125000 0.125000
+DEAL::exact mapped barycenter = 0.507683 0.125000 0.125000
+DEAL::mapped vertex mean = 0.375000 0.125000 0.125000
+DEAL::cell = 0.1
+DEAL::mapped barycenter = 0.625000 0.375000 0.125000
+DEAL::exact mapped barycenter = 0.757683 0.375000 0.125000
+DEAL::mapped vertex mean = 0.625000 0.375000 0.125000
+DEAL::cell = 0.2
+DEAL::mapped barycenter = 1.12500 0.125000 0.375000
+DEAL::exact mapped barycenter = 1.29888 0.125000 0.375000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.375000
+DEAL::cell = 0.3
+DEAL::mapped barycenter = 0.875000 0.375000 0.375000
+DEAL::exact mapped barycenter = 1.04888 0.375000 0.375000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.375000
+DEAL::cell = 0.4
+DEAL::mapped barycenter = 0.750000 0.250000 0.250000
+DEAL::exact mapped barycenter = 0.957107 0.250000 0.250000
+DEAL::mapped vertex mean = 0.750000 0.250000 0.250000
+DEAL::cell = 0.5
+DEAL::mapped barycenter = 1.12500 0.125000 0.125000
+DEAL::exact mapped barycenter = 1.25768 0.125000 0.125000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.125000
+DEAL::cell = 0.6
+DEAL::mapped barycenter = 0.875000 0.375000 0.125000
+DEAL::exact mapped barycenter = 1.00768 0.375000 0.125000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.125000
+DEAL::cell = 0.7
+DEAL::mapped barycenter = 1.37500 0.125000 0.375000
+DEAL::exact mapped barycenter = 1.54888 0.125000 0.375000
+DEAL::mapped vertex mean = 1.37500 0.125000 0.375000
+DEAL::cell = 0.8
+DEAL::mapped barycenter = 1.62500 0.375000 0.375000
+DEAL::exact mapped barycenter = 1.79888 0.375000 0.375000
+DEAL::mapped vertex mean = 1.62500 0.375000 0.375000
+DEAL::cell = 0.9
+DEAL::mapped barycenter = 1.25000 0.250000 0.250000
+DEAL::exact mapped barycenter = 1.45711 0.250000 0.250000
+DEAL::mapped vertex mean = 1.25000 0.250000 0.250000
+DEAL::cell = 0.10
+DEAL::mapped barycenter = 0.625000 0.625000 0.125000
+DEAL::exact mapped barycenter = 0.757683 0.625000 0.125000
+DEAL::mapped vertex mean = 0.625000 0.625000 0.125000
+DEAL::cell = 0.11
+DEAL::mapped barycenter = 0.375000 0.875000 0.125000
+DEAL::exact mapped barycenter = 0.507683 0.875000 0.125000
+DEAL::mapped vertex mean = 0.375000 0.875000 0.125000
+DEAL::cell = 0.12
+DEAL::mapped barycenter = 0.875000 0.625000 0.375000
+DEAL::exact mapped barycenter = 1.04888 0.625000 0.375000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.375000
+DEAL::cell = 0.13
+DEAL::mapped barycenter = 1.12500 0.875000 0.375000
+DEAL::exact mapped barycenter = 1.29888 0.875000 0.375000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.375000
+DEAL::cell = 0.14
+DEAL::mapped barycenter = 0.750000 0.750000 0.250000
+DEAL::exact mapped barycenter = 0.957107 0.750000 0.250000
+DEAL::mapped vertex mean = 0.750000 0.750000 0.250000
+DEAL::cell = 0.15
+DEAL::mapped barycenter = 0.875000 0.625000 0.125000
+DEAL::exact mapped barycenter = 1.00768 0.625000 0.125000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.125000
+DEAL::cell = 0.16
+DEAL::mapped barycenter = 1.12500 0.875000 0.125000
+DEAL::exact mapped barycenter = 1.25768 0.875000 0.125000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.125000
+DEAL::cell = 0.17
+DEAL::mapped barycenter = 1.62500 0.625000 0.375000
+DEAL::exact mapped barycenter = 1.79888 0.625000 0.375000
+DEAL::mapped vertex mean = 1.62500 0.625000 0.375000
+DEAL::cell = 0.18
+DEAL::mapped barycenter = 1.37500 0.875000 0.375000
+DEAL::exact mapped barycenter = 1.54888 0.875000 0.375000
+DEAL::mapped vertex mean = 1.37500 0.875000 0.375000
+DEAL::cell = 0.19
+DEAL::mapped barycenter = 1.25000 0.750000 0.250000
+DEAL::exact mapped barycenter = 1.45711 0.750000 0.250000
+DEAL::mapped vertex mean = 1.25000 0.750000 0.250000
+DEAL::cell = 0.20
+DEAL::mapped barycenter = 1.12500 0.125000 0.625000
+DEAL::exact mapped barycenter = 1.29888 0.125000 0.625000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.625000
+DEAL::cell = 0.21
+DEAL::mapped barycenter = 0.875000 0.375000 0.625000
+DEAL::exact mapped barycenter = 1.04888 0.375000 0.625000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.625000
+DEAL::cell = 0.22
+DEAL::mapped barycenter = 0.375000 0.125000 0.875000
+DEAL::exact mapped barycenter = 0.507683 0.125000 0.875000
+DEAL::mapped vertex mean = 0.375000 0.125000 0.875000
+DEAL::cell = 0.23
+DEAL::mapped barycenter = 0.625000 0.375000 0.875000
+DEAL::exact mapped barycenter = 0.757683 0.375000 0.875000
+DEAL::mapped vertex mean = 0.625000 0.375000 0.875000
+DEAL::cell = 0.24
+DEAL::mapped barycenter = 0.750000 0.250000 0.750000
+DEAL::exact mapped barycenter = 0.957107 0.250000 0.750000
+DEAL::mapped vertex mean = 0.750000 0.250000 0.750000
+DEAL::cell = 0.25
+DEAL::mapped barycenter = 1.37500 0.125000 0.625000
+DEAL::exact mapped barycenter = 1.54888 0.125000 0.625000
+DEAL::mapped vertex mean = 1.37500 0.125000 0.625000
+DEAL::cell = 0.26
+DEAL::mapped barycenter = 1.62500 0.375000 0.625000
+DEAL::exact mapped barycenter = 1.79888 0.375000 0.625000
+DEAL::mapped vertex mean = 1.62500 0.375000 0.625000
+DEAL::cell = 0.27
+DEAL::mapped barycenter = 1.12500 0.125000 0.875000
+DEAL::exact mapped barycenter = 1.25768 0.125000 0.875000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.875000
+DEAL::cell = 0.28
+DEAL::mapped barycenter = 0.875000 0.375000 0.875000
+DEAL::exact mapped barycenter = 1.00768 0.375000 0.875000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.875000
+DEAL::cell = 0.29
+DEAL::mapped barycenter = 1.25000 0.250000 0.750000
+DEAL::exact mapped barycenter = 1.45711 0.250000 0.750000
+DEAL::mapped vertex mean = 1.25000 0.250000 0.750000
+DEAL::cell = 0.30
+DEAL::mapped barycenter = 0.875000 0.625000 0.625000
+DEAL::exact mapped barycenter = 1.04888 0.625000 0.625000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.625000
+DEAL::cell = 0.31
+DEAL::mapped barycenter = 1.12500 0.875000 0.625000
+DEAL::exact mapped barycenter = 1.29888 0.875000 0.625000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.625000
+DEAL::cell = 0.32
+DEAL::mapped barycenter = 0.625000 0.625000 0.875000
+DEAL::exact mapped barycenter = 0.757683 0.625000 0.875000
+DEAL::mapped vertex mean = 0.625000 0.625000 0.875000
+DEAL::cell = 0.33
+DEAL::mapped barycenter = 0.375000 0.875000 0.875000
+DEAL::exact mapped barycenter = 0.507683 0.875000 0.875000
+DEAL::mapped vertex mean = 0.375000 0.875000 0.875000
+DEAL::cell = 0.34
+DEAL::mapped barycenter = 0.750000 0.750000 0.750000
+DEAL::exact mapped barycenter = 0.957107 0.750000 0.750000
+DEAL::mapped vertex mean = 0.750000 0.750000 0.750000
+DEAL::cell = 0.35
+DEAL::mapped barycenter = 1.62500 0.625000 0.625000
+DEAL::exact mapped barycenter = 1.79888 0.625000 0.625000
+DEAL::mapped vertex mean = 1.62500 0.625000 0.625000
+DEAL::cell = 0.36
+DEAL::mapped barycenter = 1.37500 0.875000 0.625000
+DEAL::exact mapped barycenter = 1.54888 0.875000 0.625000
+DEAL::mapped vertex mean = 1.37500 0.875000 0.625000
+DEAL::cell = 0.37
+DEAL::mapped barycenter = 0.875000 0.625000 0.875000
+DEAL::exact mapped barycenter = 1.00768 0.625000 0.875000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.875000
+DEAL::cell = 0.38
+DEAL::mapped barycenter = 1.12500 0.875000 0.875000
+DEAL::exact mapped barycenter = 1.25768 0.875000 0.875000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.875000
+DEAL::cell = 0.39
+DEAL::mapped barycenter = 1.25000 0.750000 0.750000
+DEAL::exact mapped barycenter = 1.45711 0.750000 0.750000
+DEAL::mapped vertex mean = 1.25000 0.750000 0.750000
+DEAL::
+DEAL::quadratic mapping
+DEAL::
+DEAL::cell = 0.0
+DEAL::mapped barycenter = 0.530330 0.125000 0.125000
+DEAL::exact mapped barycenter = 0.507683 0.125000 0.125000
+DEAL::mapped vertex mean = 0.375000 0.125000 0.125000
+DEAL::cell = 0.1
+DEAL::mapped barycenter = 0.780330 0.375000 0.125000
+DEAL::exact mapped barycenter = 0.757683 0.375000 0.125000
+DEAL::mapped vertex mean = 0.625000 0.375000 0.125000
+DEAL::cell = 0.2
+DEAL::mapped barycenter = 1.28033 0.125000 0.375000
+DEAL::exact mapped barycenter = 1.29888 0.125000 0.375000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.375000
+DEAL::cell = 0.3
+DEAL::mapped barycenter = 1.03033 0.375000 0.375000
+DEAL::exact mapped barycenter = 1.04888 0.375000 0.375000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.375000
+DEAL::cell = 0.4
+DEAL::mapped barycenter = 0.957107 0.250000 0.250000
+DEAL::exact mapped barycenter = 0.957107 0.250000 0.250000
+DEAL::mapped vertex mean = 0.750000 0.250000 0.250000
+DEAL::cell = 0.5
+DEAL::mapped barycenter = 1.28033 0.125000 0.125000
+DEAL::exact mapped barycenter = 1.25768 0.125000 0.125000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.125000
+DEAL::cell = 0.6
+DEAL::mapped barycenter = 1.03033 0.375000 0.125000
+DEAL::exact mapped barycenter = 1.00768 0.375000 0.125000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.125000
+DEAL::cell = 0.7
+DEAL::mapped barycenter = 1.53033 0.125000 0.375000
+DEAL::exact mapped barycenter = 1.54888 0.125000 0.375000
+DEAL::mapped vertex mean = 1.37500 0.125000 0.375000
+DEAL::cell = 0.8
+DEAL::mapped barycenter = 1.78033 0.375000 0.375000
+DEAL::exact mapped barycenter = 1.79888 0.375000 0.375000
+DEAL::mapped vertex mean = 1.62500 0.375000 0.375000
+DEAL::cell = 0.9
+DEAL::mapped barycenter = 1.45711 0.250000 0.250000
+DEAL::exact mapped barycenter = 1.45711 0.250000 0.250000
+DEAL::mapped vertex mean = 1.25000 0.250000 0.250000
+DEAL::cell = 0.10
+DEAL::mapped barycenter = 0.780330 0.625000 0.125000
+DEAL::exact mapped barycenter = 0.757683 0.625000 0.125000
+DEAL::mapped vertex mean = 0.625000 0.625000 0.125000
+DEAL::cell = 0.11
+DEAL::mapped barycenter = 0.530330 0.875000 0.125000
+DEAL::exact mapped barycenter = 0.507683 0.875000 0.125000
+DEAL::mapped vertex mean = 0.375000 0.875000 0.125000
+DEAL::cell = 0.12
+DEAL::mapped barycenter = 1.03033 0.625000 0.375000
+DEAL::exact mapped barycenter = 1.04888 0.625000 0.375000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.375000
+DEAL::cell = 0.13
+DEAL::mapped barycenter = 1.28033 0.875000 0.375000
+DEAL::exact mapped barycenter = 1.29888 0.875000 0.375000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.375000
+DEAL::cell = 0.14
+DEAL::mapped barycenter = 0.957107 0.750000 0.250000
+DEAL::exact mapped barycenter = 0.957107 0.750000 0.250000
+DEAL::mapped vertex mean = 0.750000 0.750000 0.250000
+DEAL::cell = 0.15
+DEAL::mapped barycenter = 1.03033 0.625000 0.125000
+DEAL::exact mapped barycenter = 1.00768 0.625000 0.125000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.125000
+DEAL::cell = 0.16
+DEAL::mapped barycenter = 1.28033 0.875000 0.125000
+DEAL::exact mapped barycenter = 1.25768 0.875000 0.125000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.125000
+DEAL::cell = 0.17
+DEAL::mapped barycenter = 1.78033 0.625000 0.375000
+DEAL::exact mapped barycenter = 1.79888 0.625000 0.375000
+DEAL::mapped vertex mean = 1.62500 0.625000 0.375000
+DEAL::cell = 0.18
+DEAL::mapped barycenter = 1.53033 0.875000 0.375000
+DEAL::exact mapped barycenter = 1.54888 0.875000 0.375000
+DEAL::mapped vertex mean = 1.37500 0.875000 0.375000
+DEAL::cell = 0.19
+DEAL::mapped barycenter = 1.45711 0.750000 0.250000
+DEAL::exact mapped barycenter = 1.45711 0.750000 0.250000
+DEAL::mapped vertex mean = 1.25000 0.750000 0.250000
+DEAL::cell = 0.20
+DEAL::mapped barycenter = 1.28033 0.125000 0.625000
+DEAL::exact mapped barycenter = 1.29888 0.125000 0.625000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.625000
+DEAL::cell = 0.21
+DEAL::mapped barycenter = 1.03033 0.375000 0.625000
+DEAL::exact mapped barycenter = 1.04888 0.375000 0.625000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.625000
+DEAL::cell = 0.22
+DEAL::mapped barycenter = 0.530330 0.125000 0.875000
+DEAL::exact mapped barycenter = 0.507683 0.125000 0.875000
+DEAL::mapped vertex mean = 0.375000 0.125000 0.875000
+DEAL::cell = 0.23
+DEAL::mapped barycenter = 0.780330 0.375000 0.875000
+DEAL::exact mapped barycenter = 0.757683 0.375000 0.875000
+DEAL::mapped vertex mean = 0.625000 0.375000 0.875000
+DEAL::cell = 0.24
+DEAL::mapped barycenter = 0.957107 0.250000 0.750000
+DEAL::exact mapped barycenter = 0.957107 0.250000 0.750000
+DEAL::mapped vertex mean = 0.750000 0.250000 0.750000
+DEAL::cell = 0.25
+DEAL::mapped barycenter = 1.53033 0.125000 0.625000
+DEAL::exact mapped barycenter = 1.54888 0.125000 0.625000
+DEAL::mapped vertex mean = 1.37500 0.125000 0.625000
+DEAL::cell = 0.26
+DEAL::mapped barycenter = 1.78033 0.375000 0.625000
+DEAL::exact mapped barycenter = 1.79888 0.375000 0.625000
+DEAL::mapped vertex mean = 1.62500 0.375000 0.625000
+DEAL::cell = 0.27
+DEAL::mapped barycenter = 1.28033 0.125000 0.875000
+DEAL::exact mapped barycenter = 1.25768 0.125000 0.875000
+DEAL::mapped vertex mean = 1.12500 0.125000 0.875000
+DEAL::cell = 0.28
+DEAL::mapped barycenter = 1.03033 0.375000 0.875000
+DEAL::exact mapped barycenter = 1.00768 0.375000 0.875000
+DEAL::mapped vertex mean = 0.875000 0.375000 0.875000
+DEAL::cell = 0.29
+DEAL::mapped barycenter = 1.45711 0.250000 0.750000
+DEAL::exact mapped barycenter = 1.45711 0.250000 0.750000
+DEAL::mapped vertex mean = 1.25000 0.250000 0.750000
+DEAL::cell = 0.30
+DEAL::mapped barycenter = 1.03033 0.625000 0.625000
+DEAL::exact mapped barycenter = 1.04888 0.625000 0.625000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.625000
+DEAL::cell = 0.31
+DEAL::mapped barycenter = 1.28033 0.875000 0.625000
+DEAL::exact mapped barycenter = 1.29888 0.875000 0.625000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.625000
+DEAL::cell = 0.32
+DEAL::mapped barycenter = 0.780330 0.625000 0.875000
+DEAL::exact mapped barycenter = 0.757683 0.625000 0.875000
+DEAL::mapped vertex mean = 0.625000 0.625000 0.875000
+DEAL::cell = 0.33
+DEAL::mapped barycenter = 0.530330 0.875000 0.875000
+DEAL::exact mapped barycenter = 0.507683 0.875000 0.875000
+DEAL::mapped vertex mean = 0.375000 0.875000 0.875000
+DEAL::cell = 0.34
+DEAL::mapped barycenter = 0.957107 0.750000 0.750000
+DEAL::exact mapped barycenter = 0.957107 0.750000 0.750000
+DEAL::mapped vertex mean = 0.750000 0.750000 0.750000
+DEAL::cell = 0.35
+DEAL::mapped barycenter = 1.78033 0.625000 0.625000
+DEAL::exact mapped barycenter = 1.79888 0.625000 0.625000
+DEAL::mapped vertex mean = 1.62500 0.625000 0.625000
+DEAL::cell = 0.36
+DEAL::mapped barycenter = 1.53033 0.875000 0.625000
+DEAL::exact mapped barycenter = 1.54888 0.875000 0.625000
+DEAL::mapped vertex mean = 1.37500 0.875000 0.625000
+DEAL::cell = 0.37
+DEAL::mapped barycenter = 1.03033 0.625000 0.875000
+DEAL::exact mapped barycenter = 1.00768 0.625000 0.875000
+DEAL::mapped vertex mean = 0.875000 0.625000 0.875000
+DEAL::cell = 0.38
+DEAL::mapped barycenter = 1.28033 0.875000 0.875000
+DEAL::exact mapped barycenter = 1.25768 0.875000 0.875000
+DEAL::mapped vertex mean = 1.12500 0.875000 0.875000
+DEAL::cell = 0.39
+DEAL::mapped barycenter = 1.45711 0.750000 0.750000
+DEAL::exact mapped barycenter = 1.45711 0.750000 0.750000
+DEAL::mapped vertex mean = 1.25000 0.750000 0.750000