--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Check GridTools::affine_cell_approximation
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_in.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/tria.h>
+
+#include "../tests.h"
+
+
+template <int dim, int spacedim>
+void
+do_test(const Triangulation<dim, spacedim> &tria)
+{
+ for (const auto &cell : tria.cell_iterators())
+ {
+ std::array<Point<spacedim>, GeometryInfo<dim>::vertices_per_cell>
+ vertices;
+ for (const unsigned int v : cell->vertex_indices())
+ vertices[v] = cell->vertex(v);
+ deallog << "Cell " << cell->id() << " with center " << cell->center()
+ << ": A = [";
+ const auto A =
+ GridTools::affine_cell_approximation<dim, spacedim>(vertices).first;
+ for (unsigned int d = 0; d < spacedim; ++d)
+ {
+ for (unsigned int e = 0; e < dim; ++e)
+ deallog << A[d][e] << (e < dim - 1 ? " " : "");
+ deallog << (d < spacedim - 1 ? ", " : "");
+ }
+ deallog
+ << "] b = "
+ << GridTools::affine_cell_approximation<dim, spacedim>(vertices).second
+ << std::endl;
+ }
+}
+
+
+
+template <int dim>
+void
+test1()
+{
+ Triangulation<dim> tria;
+ GridGenerator::hyper_cube(tria, -1, 1);
+ tria.refine_global(1);
+ do_test(tria);
+}
+
+
+
+template <int dim>
+void
+test2()
+{
+ Triangulation<dim> tria;
+ GridGenerator::hyper_ball(tria);
+ do_test(tria);
+}
+
+
+
+template <int dim, int spacedim>
+void
+test3()
+{
+ Triangulation<dim, spacedim> triangulation;
+ GridIn<dim, spacedim> grid_in;
+ grid_in.attach_triangulation(triangulation);
+ if (dim == 1)
+ {
+ std::ifstream fname(SOURCE_DIR "/../codim_one/grids/circle_1.inp");
+ grid_in.read_ucd(fname);
+ }
+ else
+ {
+ std::ifstream fname(SOURCE_DIR "/../codim_one/grids/sphere_0.inp");
+ grid_in.read_ucd(fname);
+ }
+
+ do_test(triangulation);
+}
+
+
+int
+main()
+{
+ initlog();
+
+ test1<1>();
+ test1<2>();
+ test1<3>();
+
+ test2<2>();
+ test2<3>();
+
+ test3<1, 2>();
+ test3<2, 3>();
+}
--- /dev/null
+
+DEAL::Cell 0_0: with center 0.00000: A = [2.00000] b = -1.00000
+DEAL::Cell 0_1:0 with center -0.500000: A = [1.00000] b = -1.00000
+DEAL::Cell 0_1:1 with center 0.500000: A = [1.00000] b = 0.00000
+DEAL::Cell 0_0: with center 0.00000 0.00000: A = [2.00000 0.00000, 0.00000 2.00000] b = -1.00000 -1.00000
+DEAL::Cell 0_1:0 with center -0.500000 -0.500000: A = [1.00000 0.00000, 0.00000 1.00000] b = -1.00000 -1.00000
+DEAL::Cell 0_1:1 with center 0.500000 -0.500000: A = [1.00000 0.00000, 0.00000 1.00000] b = 0.00000 -1.00000
+DEAL::Cell 0_1:2 with center -0.500000 0.500000: A = [1.00000 0.00000, 0.00000 1.00000] b = -1.00000 0.00000
+DEAL::Cell 0_1:3 with center 0.500000 0.500000: A = [1.00000 0.00000, 0.00000 1.00000] b = 0.00000 0.00000
+DEAL::Cell 0_0: with center 0.00000 0.00000 0.00000: A = [2.00000 0.00000 0.00000, 0.00000 2.00000 0.00000, 0.00000 0.00000 2.00000] b = -1.00000 -1.00000 -1.00000
+DEAL::Cell 0_1:0 with center -0.500000 -0.500000 -0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = -1.00000 -1.00000 -1.00000
+DEAL::Cell 0_1:1 with center 0.500000 -0.500000 -0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = 0.00000 -1.00000 -1.00000
+DEAL::Cell 0_1:2 with center -0.500000 0.500000 -0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = -1.00000 0.00000 -1.00000
+DEAL::Cell 0_1:3 with center 0.500000 0.500000 -0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = 0.00000 0.00000 -1.00000
+DEAL::Cell 0_1:4 with center -0.500000 -0.500000 0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = -1.00000 -1.00000 0.00000
+DEAL::Cell 0_1:5 with center 0.500000 -0.500000 0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = 0.00000 -1.00000 0.00000
+DEAL::Cell 0_1:6 with center -0.500000 0.500000 0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = -1.00000 0.00000 0.00000
+DEAL::Cell 0_1:7 with center 0.500000 0.500000 0.500000: A = [1.00000 0.00000 0.00000, 0.00000 1.00000 0.00000, 0.00000 0.00000 1.00000] b = 0.00000 0.00000 0.00000
+DEAL::Cell 0_0: with center 0.00000 -0.500000: A = [1.00000 0.00000, 0.00000 0.414214] b = -0.500000 -0.707107
+DEAL::Cell 1_0: with center -0.500000 -1.38778e-17: A = [0.414214 2.77556e-17, 0.00000 1.00000] b = -0.707107 -0.500000
+DEAL::Cell 2_0: with center 0.00000 0.00000: A = [0.585786 0.00000, 0.00000 0.585786] b = -0.292893 -0.292893
+DEAL::Cell 3_0: with center 0.500000 0.00000: A = [0.00000 -0.414214, 1.00000 0.00000] b = 0.707107 -0.500000
+DEAL::Cell 4_0: with center -1.38778e-17 0.500000: A = [0.00000 1.00000, -0.414214 -2.77556e-17] b = -0.500000 0.707107
+DEAL::Cell 0_0: with center 0.00000 0.00000 -6.93889e-18: A = [0.422650 0.00000 0.00000, 0.00000 0.422650 0.00000, 0.00000 0.00000 0.422650] b = -0.211325 -0.211325 -0.211325
+DEAL::Cell 1_0: with center 0.00000 0.00000 -0.394338: A = [0.788675 0.00000 0.00000, 0.00000 0.788675 0.00000, 0.00000 0.00000 0.366025] b = -0.394338 -0.394338 -0.577350
+DEAL::Cell 2_0: with center 0.394338 0.00000 2.08167e-17: A = [0.00000 -0.366025 4.16334e-17, 0.788675 0.00000 0.00000, 0.00000 1.38778e-17 0.788675] b = 0.577350 -0.394338 -0.394338
+DEAL::Cell 3_0: with center 0.00000 2.08167e-17 0.394338: A = [0.788675 0.00000 0.00000, 0.00000 1.38778e-17 0.788675, 0.00000 -0.366025 4.16334e-17] b = -0.394338 -0.394338 0.577350
+DEAL::Cell 4_0: with center -0.394338 3.46945e-18 1.73472e-17: A = [0.366025 -6.93889e-18 -3.46945e-17, 6.93889e-18 0.788675 6.93889e-18, 6.93889e-18 6.93889e-18 0.788675] b = -0.577350 -0.394338 -0.394338
+DEAL::Cell 5_0: with center 0.00000 -0.394338 2.08167e-17: A = [0.788675 0.00000 0.00000, 0.00000 0.366025 -4.16334e-17, 0.00000 1.38778e-17 0.788675] b = -0.394338 -0.577350 -0.394338
+DEAL::Cell 6_0: with center 3.46945e-18 0.394338 1.73472e-17: A = [6.93889e-18 0.788675 6.93889e-18, -0.366025 6.93889e-18 3.46945e-17, 6.93889e-18 6.93889e-18 0.788675] b = -0.394338 0.577350 -0.394338
+DEAL::Cell 0_0: with center 0.293893 0.904508: A = [0.587785, -0.190983] b = 0.00000 1.00000
+DEAL::Cell 1_0: with center 0.769421 0.559017: A = [0.363271, -0.500000] b = 0.587785 0.809017
+DEAL::Cell 2_0: with center 0.951057 0.00000: A = [0.00000, -0.618034] b = 0.951057 0.309017
+DEAL::Cell 3_0: with center 0.769421 -0.559017: A = [-0.363271, -0.500000] b = 0.951057 -0.309017
+DEAL::Cell 4_0: with center 0.293893 -0.904508: A = [-0.587785, -0.190983] b = 0.587785 -0.809017
+DEAL::Cell 5_0: with center -0.293893 -0.904508: A = [-0.587785, 0.190983] b = 0.00000 -1.00000
+DEAL::Cell 6_0: with center -0.769421 -0.559017: A = [-0.363271, 0.500000] b = -0.587785 -0.809017
+DEAL::Cell 7_0: with center -0.951057 0.00000: A = [0.00000, 0.618034] b = -0.951057 -0.309017
+DEAL::Cell 8_0: with center -0.769421 0.559017: A = [0.363271, 0.500000] b = -0.951057 0.309017
+DEAL::Cell 9_0: with center -0.293893 0.904508: A = [0.587785, 0.190983] b = -0.587785 0.809017
+DEAL::Cell 0_0: with center 0.00000 0.00000 -0.577350: A = [-1.15470 0.00000, 0.00000 1.15470, 0.00000 0.00000] b = 0.577350 -0.577350 -0.577350
+DEAL::Cell 1_0: with center 0.00000 0.00000 0.577350: A = [0.00000 -1.15470, 1.15470 0.00000, 0.00000 0.00000] b = 0.577350 -0.577350 0.577350
+DEAL::Cell 2_0: with center 0.00000 -0.577350 0.00000: A = [-1.15470 0.00000, 0.00000 0.00000, 0.00000 -1.15470] b = 0.577350 -0.577350 0.577350
+DEAL::Cell 3_0: with center 0.00000 0.577350 0.00000: A = [0.00000 -1.15470, 0.00000 0.00000, -1.15470 0.00000] b = 0.577350 0.577350 0.577350
+DEAL::Cell 4_0: with center -0.577350 0.00000 0.00000: A = [0.00000 0.00000, 1.15470 0.00000, 0.00000 -1.15470] b = -0.577350 -0.577350 0.577350
+DEAL::Cell 5_0: with center 0.577350 0.00000 0.00000: A = [0.00000 0.00000, 0.00000 1.15470, -1.15470 0.00000] b = 0.577350 -0.577350 0.577350