-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14057 from kronbichler/fix_reinit_mf
Fix bug in MatrixFree::reinit for MG levels with empty process
- Loading branch information
Showing
3 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// 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. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
// Verify that MatrixFree::reinit works without errors also when we have | ||
// processes without any cells on a larger mesh (we need 17 processes to have | ||
// a 8x8 mesh with one process not having a cell on level 1). | ||
|
||
|
||
#include <deal.II/distributed/tria.h> | ||
|
||
#include <deal.II/fe/fe_q.h> | ||
|
||
#include <deal.II/grid/grid_generator.h> | ||
|
||
#include <deal.II/lac/affine_constraints.h> | ||
|
||
#include <deal.II/matrix_free/matrix_free.h> | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
|
||
#include "../tests.h" | ||
|
||
|
||
|
||
template <int dim> | ||
void | ||
do_test(const unsigned int n_refinements) | ||
{ | ||
parallel::distributed::Triangulation<dim> tria( | ||
MPI_COMM_WORLD, | ||
Triangulation<dim>::limit_level_difference_at_vertices, | ||
parallel::distributed::Triangulation<dim>::construct_multigrid_hierarchy); | ||
|
||
GridGenerator::hyper_cube(tria); | ||
tria.refine_global(n_refinements); | ||
|
||
FE_Q<dim> fe(1); | ||
DoFHandler<dim> dof_handler(tria); | ||
|
||
dof_handler.distribute_dofs(fe); | ||
dof_handler.distribute_mg_dofs(); | ||
|
||
deallog << "Number of degrees of freedom: " << dof_handler.n_dofs() | ||
<< std::endl; | ||
|
||
AffineConstraints<double> constraints; | ||
constraints.close(); | ||
|
||
MappingQ1<dim> mapping; | ||
|
||
for (unsigned int level = 0; level <= tria.n_global_levels(); ++level) | ||
{ | ||
typename MatrixFree<dim, double>::AdditionalData data; | ||
data.initialize_mapping = false; | ||
if (level < tria.n_global_levels()) | ||
data.mg_level = level; | ||
|
||
MatrixFree<dim, double> matrix_free; | ||
matrix_free.reinit(mapping, dof_handler, constraints, QGauss<1>(2), data); | ||
|
||
deallog << "Level " << data.mg_level << " OK" << std::endl; | ||
} | ||
} | ||
|
||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, 1); | ||
mpi_initlog(); | ||
|
||
do_test<2>(2); | ||
do_test<2>(3); | ||
do_test<2>(4); | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/matrix_free/reinit_matrix_free_mg.with_p4est=ture.mpirun=17.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
DEAL::Number of degrees of freedom: 25 | ||
DEAL::Level 0 OK | ||
DEAL::Level 1 OK | ||
DEAL::Level 2 OK | ||
DEAL::Level 4294967295 OK | ||
DEAL::Number of degrees of freedom: 81 | ||
DEAL::Level 0 OK | ||
DEAL::Level 1 OK | ||
DEAL::Level 2 OK | ||
DEAL::Level 3 OK | ||
DEAL::Level 4294967295 OK | ||
DEAL::Number of degrees of freedom: 289 | ||
DEAL::Level 0 OK | ||
DEAL::Level 1 OK | ||
DEAL::Level 2 OK | ||
DEAL::Level 3 OK | ||
DEAL::Level 4 OK | ||
DEAL::Level 4294967295 OK |