]> https://gitweb.dealii.org/ - dealii.git/commitdiff
FEEvaluation + DG + hp: fix quadrature indexing 16619/head
authorPeter Munch <peterrmuench@gmail.com>
Fri, 9 Feb 2024 18:53:23 +0000 (19:53 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 9 Feb 2024 19:24:04 +0000 (20:24 +0100)
doc/news/changes/minor/20240209BergbauerMunchRitthalerSchreter [new file with mode: 0644]
include/deal.II/matrix_free/fe_evaluation.h
tests/matrix_free/hp_dg_01.cc [new file with mode: 0644]
tests/matrix_free/hp_dg_01.output [new file with mode: 0644]

diff --git a/doc/news/changes/minor/20240209BergbauerMunchRitthalerSchreter b/doc/news/changes/minor/20240209BergbauerMunchRitthalerSchreter
new file mode 100644 (file)
index 0000000..65a61f9
--- /dev/null
@@ -0,0 +1,3 @@
+Fixed: Fix initialization of FEFaceEvaluation for hp in 3D.
+<br>
+(Maximilian Bergbauer, Peter Munch, Andreas Ritthaler, Magdalena Schreter-Fleischhacker, 2024/02/09)
index 4cd421eaddedfb2360b2e4d06ec13406bce7760e..ad32c9e6230851a1774045589145453530b5404d 100644 (file)
@@ -2858,13 +2858,16 @@ namespace internal
         (active_fe_index_given != numbers::invalid_unsigned_int ?
            active_fe_index_given :
            0);
+
     init_data.active_quad_index =
       fe_degree == numbers::invalid_unsigned_int ?
         (active_quad_index_given != numbers::invalid_unsigned_int ?
            active_quad_index_given :
-           std::min<unsigned int>(init_data.active_fe_index,
-                                  init_data.mapping_data->descriptor.size() -
-                                    1)) :
+           std::min<unsigned int>(
+             init_data.active_fe_index,
+             init_data.mapping_data->descriptor.size() /
+                 (is_face ? std::max<unsigned int>(1, dim - 1) : 1) -
+               1)) :
         init_data.mapping_data->quad_index_from_n_q_points(n_q_points);
 
     init_data.shape_info = &matrix_free.get_shape_info(
diff --git a/tests/matrix_free/hp_dg_01.cc b/tests/matrix_free/hp_dg_01.cc
new file mode 100644 (file)
index 0000000..00fbc13
--- /dev/null
@@ -0,0 +1,98 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2022 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 if intialization of FEFaceEvaluation works for hp + DG in 3D.
+
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/mapping_q1.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+
+#include <deal.II/matrix_free/fe_evaluation.h>
+#include <deal.II/matrix_free/matrix_free.h>
+
+#include "../tests.h"
+
+template <int dim>
+void
+test()
+{
+  using VectorType = Vector<double>;
+
+  Triangulation<dim> tria;
+
+  std::vector<unsigned int> repetitions(dim, 1);
+  repetitions[0] = 2;
+
+  Point<dim> p1;
+  Point<dim> p2;
+
+  p2[0] = 2.0;
+  for (unsigned int i = 1; i < dim; ++i)
+    p2[i] = 1.0;
+
+  GridGenerator::subdivided_hyper_rectangle(tria, repetitions, p1, p2);
+
+
+  hp::FECollection<dim> fe;
+  fe.push_back(FE_DGQ<dim>(1));
+  fe.push_back(FE_DGQ<dim>(1));
+
+  hp::QCollection<dim> quad;
+  quad.push_back(QGauss<dim>(2));
+
+  MappingQ1<dim> mapping;
+
+  DoFHandler<dim> dof_handler(tria);
+
+  for (const auto &cell : dof_handler.active_cell_iterators())
+    cell->set_active_fe_index(cell->active_cell_index());
+
+  dof_handler.distribute_dofs(fe);
+
+  AffineConstraints<double> constraints;
+
+  typename MatrixFree<dim>::AdditionalData ad;
+
+  ad.mapping_update_flags_inner_faces = update_gradients;
+
+  MatrixFree<dim> matrix_free;
+  matrix_free.reinit(mapping, dof_handler, constraints, quad, ad);
+
+  VectorType dst(dof_handler.n_dofs());
+  VectorType src(dof_handler.n_dofs());
+
+  matrix_free.template loop<VectorType, VectorType>(
+    [](const auto &, auto &, const auto &, const auto) {},
+    [](const auto &matrix_free, auto &, const auto &, const auto range) {
+      FEFaceEvaluation<dim, -1, 0, 1, double> eval(matrix_free, range);
+    },
+    [](const auto &, auto &, const auto &, const auto) {},
+    dst,
+    src);
+}
+
+int
+main()
+{
+  initlog();
+
+  test<3>();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/matrix_free/hp_dg_01.output b/tests/matrix_free/hp_dg_01.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.