]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test for MatrixFree::reinit with empty procs 13728/head
authorSebastian Proell <sebastian.proell@tum.de>
Thu, 12 May 2022 08:44:41 +0000 (10:44 +0200)
committerSebastian Proell <sebastian.proell@tum.de>
Fri, 13 May 2022 08:38:37 +0000 (10:38 +0200)
tests/matrix_free/fe_nothing_01.cc [new file with mode: 0644]
tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output [new file with mode: 0644]

diff --git a/tests/matrix_free/fe_nothing_01.cc b/tests/matrix_free/fe_nothing_01.cc
new file mode 100644 (file)
index 0000000..c821d85
--- /dev/null
@@ -0,0 +1,91 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test MatrixFree::reinit when some procs have only FE_Nothing and thus zero
+// dofs
+
+#include <deal.II/fe/fe_nothing.h>
+#include <deal.II/fe/fe_system.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/matrix_free/matrix_free.h>
+
+#include "../tests.h"
+
+
+template <int dim, int fe_degree>
+void
+test()
+{
+  parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
+  GridGenerator::subdivided_hyper_cube(tria, 2);
+
+  DoFHandler<dim> dof(tria);
+  {
+    std::vector<unsigned> active_indices(tria.n_active_cells());
+    for (unsigned i = 0; i < tria.n_active_cells() / 2; ++i)
+      active_indices[i] = 1;
+    dof.set_active_fe_indices(active_indices);
+
+    hp::FECollection<dim> fe{FE_Q<dim>(fe_degree), FE_Nothing<dim>(1)};
+    dof.distribute_dofs(fe);
+  }
+
+  AffineConstraints<double> constraints;
+  constraints.close();
+
+  deallog << "Testing reinit for FE_Nothing + " << dof.get_fe().get_name()
+          << std::endl;
+  deallog << "# local dofs: " << dof.n_locally_owned_dofs() << std::endl;
+
+  using number = double;
+  MatrixFree<dim, number> mf_data;
+  {
+    const QGauss<1>                                  quad(fe_degree + 1);
+    typename MatrixFree<dim, number>::AdditionalData data;
+    data.tasks_parallel_scheme = MatrixFree<dim, number>::AdditionalData::none;
+    data.mapping_update_flags =
+      (dealii::update_values | dealii::update_gradients |
+       dealii::update_JxW_values | dealii::update_quadrature_points);
+    mf_data.reinit(MappingQ<dim>(fe_degree),
+                   dof,
+                   constraints,
+                   hp::QCollection<dim>(quad, quad),
+                   data);
+  }
+}
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
+  MPILogInitAll                    log;
+
+  {
+    deallog.push("2d");
+    test<2, 1>();
+    test<2, 2>();
+    test<2, 3>();
+    test<2, 4>();
+    deallog.pop();
+    deallog.push("3d");
+    test<3, 1>();
+    test<3, 2>();
+    deallog.pop();
+  }
+}
diff --git a/tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output b/tests/matrix_free/fe_nothing_01.with_p4est=true.mpirun=3.output
new file mode 100644 (file)
index 0000000..734ed4f
--- /dev/null
@@ -0,0 +1,41 @@
+
+DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(1)
+DEAL:0:2d::# local dofs: 0
+DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(2)
+DEAL:0:2d::# local dofs: 0
+DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(3)
+DEAL:0:2d::# local dofs: 0
+DEAL:0:2d::Testing reinit for FE_Nothing + FE_Q<2>(4)
+DEAL:0:2d::# local dofs: 0
+DEAL:0:3d::Testing reinit for FE_Nothing + FE_Q<3>(1)
+DEAL:0:3d::# local dofs: 0
+DEAL:0:3d::Testing reinit for FE_Nothing + FE_Q<3>(2)
+DEAL:0:3d::# local dofs: 0
+
+DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(1)
+DEAL:1:2d::# local dofs: 0
+DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(2)
+DEAL:1:2d::# local dofs: 0
+DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(3)
+DEAL:1:2d::# local dofs: 0
+DEAL:1:2d::Testing reinit for FE_Nothing + FE_Q<2>(4)
+DEAL:1:2d::# local dofs: 0
+DEAL:1:3d::Testing reinit for FE_Nothing + FE_Q<3>(1)
+DEAL:1:3d::# local dofs: 8
+DEAL:1:3d::Testing reinit for FE_Nothing + FE_Q<3>(2)
+DEAL:1:3d::# local dofs: 27
+
+
+DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(1)
+DEAL:2:2d::# local dofs: 6
+DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(2)
+DEAL:2:2d::# local dofs: 15
+DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(3)
+DEAL:2:2d::# local dofs: 28
+DEAL:2:2d::Testing reinit for FE_Nothing + FE_Q<2>(4)
+DEAL:2:2d::# local dofs: 45
+DEAL:2:3d::Testing reinit for FE_Nothing + FE_Q<3>(1)
+DEAL:2:3d::# local dofs: 10
+DEAL:2:3d::Testing reinit for FE_Nothing + FE_Q<3>(2)
+DEAL:2:3d::# local dofs: 48
+

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.