]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test.
authorWolfgang Bangerth <bangerth@colostate.edu>
Sun, 7 Jan 2024 17:18:28 +0000 (10:18 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sun, 7 Jan 2024 17:18:28 +0000 (10:18 -0700)
tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc [new file with mode: 0644]
tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=1.output [new file with mode: 0644]
tests/trilinos/trilinos_sparsity_pattern_iterators_03.mpirun=2.output [new file with mode: 0644]

diff --git a/tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc b/tests/trilinos/trilinos_sparsity_pattern_iterators_03.cc
new file mode 100644 (file)
index 0000000..1a75c45
--- /dev/null
@@ -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 <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();
+
+  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 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -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 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.