From a4c00363be24dd51db78546f6925e8dbb6b76440 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 7 Jan 2024 10:18:28 -0700 Subject: [PATCH] Add a test. --- .../trilinos_sparsity_pattern_iterators_03.cc | 92 +++++++++++++++++++ ...rsity_pattern_iterators_03.mpirun=1.output | 2 + ...rsity_pattern_iterators_03.mpirun=2.output | 2 + 3 files changed, 96 insertions(+) create mode 100644 tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc create mode 100644 tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=1.output create mode 100644 tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=2.output diff --git a/tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc new file mode 100644 index 0000000000..1a75c45a1f --- /dev/null +++ b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc @@ -0,0 +1,92 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2024 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 Trilinos sparsity pattern iterators in a parallel +// context. One used to get errors when walking off the locally-owned +// set of rows of a sparsity pattern. + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include + +#include "../tests.h" + + +namespace dealiiLA +{ + using namespace dealii::TrilinosWrappers; +} + +int +main(int argc, char *argv[]) +{ + initlog(); + + dealii::Utilities::MPI::MPI_InitFinalize mpiInitialization(argc, argv, 1); + const MPI_Comm &mpiCommunicator(MPI_COMM_WORLD); + + dealii::parallel::distributed::Triangulation<3> tria(mpiCommunicator); + dealii::GridGenerator::hyper_cube(tria); + tria.refine_global(2); + + dealii::DoFHandler<3> dofHandler(tria); + dealii::FE_Q<3> fe(1); + dofHandler.distribute_dofs(fe); + + dealii::DoFRenumbering::component_wise(dofHandler); + + dealii::IndexSet locallyOwnedDofs = dofHandler.locally_owned_dofs(); + + dealiiLA::SparsityPattern sparsityPattern; + sparsityPattern.reinit(locallyOwnedDofs, mpiCommunicator); + dealii::DoFTools::make_sparsity_pattern( + dofHandler, + sparsityPattern, + dealii::AffineConstraints(), + false, + dealii::Utilities::MPI::this_mpi_process(mpiCommunicator)); + sparsityPattern.compress(); + + for (unsigned int i = 0; i < dofHandler.n_dofs(); ++i) + if (sparsityPattern.row_is_stored_locally(i)) + { + auto it = sparsityPattern.begin(i); + + // sparsityPattern.end(i) does not work for i=74, + // because i=75 is not locally owned + auto itend = sparsityPattern.end(i); + } + + deallog << "OK" << std::endl; +} diff --git a/tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=1.output b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=1.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=1.output @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=2.output b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=2.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=2.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5