Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add another test. #16430

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 94 additions & 0 deletions tests/trilinos/sparse_matrix_iterator_02.cc
Original file line number Diff line number Diff line change
@@ -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 <deal.II/base/index_set.h>
#include <deal.II/base/utilities.h>

#include <deal.II/distributed/grid_refinement.h>
#include <deal.II/distributed/tria.h>

#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_renumbering.h>
#include <deal.II/dofs/dof_tools.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/lac/trilinos_sparse_matrix.h>
#include <deal.II/lac/trilinos_sparsity_pattern.h>
#include <deal.II/lac/trilinos_vector.h>

#include <iostream>

#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;
}
2 changes: 2 additions & 0 deletions tests/trilinos/sparse_matrix_iterator_02.mpirun=1.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

DEAL::OK
2 changes: 2 additions & 0 deletions tests/trilinos/sparse_matrix_iterator_02.mpirun=2.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

DEAL::OK