From: Wolfgang Bangerth Date: Sun, 7 Jan 2024 17:53:57 +0000 (-0700) Subject: Add another test. X-Git-Tag: relicensing~190^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16430%2Fhead;p=dealii.git Add another test. --- diff --git a/tests/trilinos/sparse_matrix_iterator_02.cc b/tests/trilinos/sparse_matrix_iterator_02.cc new file mode 100644 index 0000000000..6f283c93d9 --- /dev/null +++ b/tests/trilinos/sparse_matrix_iterator_02.cc @@ -0,0 +1,94 @@ +// --------------------------------------------------------------------- +// +// 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 sparse matrix 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(); + + dealiiLA::SparseMatrix matrix(sparsityPattern); + + for (unsigned int i = 0; i < dofHandler.n_dofs(); ++i) + if (sparsityPattern.row_is_stored_locally(i)) + { + auto it = matrix.begin(i); + + // matrix.end(i) does not work for i=74, + // because i=75 is not locally owned + auto itend = matrix.end(i); + } + + deallog << "OK" << std::endl; +} diff --git a/tests/trilinos/sparse_matrix_iterator_02.mpirun=1.output b/tests/trilinos/sparse_matrix_iterator_02.mpirun=1.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/trilinos/sparse_matrix_iterator_02.mpirun=1.output @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/trilinos/sparse_matrix_iterator_02.mpirun=2.output b/tests/trilinos/sparse_matrix_iterator_02.mpirun=2.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/trilinos/sparse_matrix_iterator_02.mpirun=2.output @@ -0,0 +1,2 @@ + +DEAL::OK