--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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();
+ }
+}
--- /dev/null
+
+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
+