]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convenience routine from IndexSet to PETSc IS
authorStefano Zampini <stefano.zampini@gmail.com>
Tue, 24 Jan 2023 12:26:08 +0000 (15:26 +0300)
committerStefano Zampini <stefano.zampini@gmail.com>
Sat, 28 Jan 2023 08:17:56 +0000 (11:17 +0300)
include/deal.II/base/index_set.h
source/base/index_set.cc

index e50f58439e86f22480a4d8de8d8f25e8e47e4305..b17c18282ce191948743af8cd1e35294ca449d90 100644 (file)
@@ -37,6 +37,10 @@ DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
 #  endif
 #endif
 
+#ifdef DEAL_II_WITH_PETSC
+#  include <petscis.h>
+#endif
+
 DEAL_II_NAMESPACE_OPEN
 
 /**
@@ -498,6 +502,11 @@ public:
 #  endif
 #endif
 
+#ifdef DEAL_II_WITH_PETSC
+  IS
+  make_petsc_is(const MPI_Comm &communicator = MPI_COMM_WORLD) const;
+#endif
+
 
   /**
    * Determine an estimate for the memory consumption (in bytes) of this
index ef0a7c05e7f6cfdd9e1eff95f2af0413db437976..ecdad5d61f34ac3a2a7e0c00153ab253ff07d345 100644 (file)
@@ -17,6 +17,8 @@
 #include <deal.II/base/memory_consumption.h>
 #include <deal.II/base/mpi.h>
 
+#include <deal.II/lac/exceptions.h>
+
 #include <vector>
 
 #ifdef DEAL_II_WITH_TRILINOS
@@ -850,6 +852,26 @@ IndexSet::make_trilinos_map(const MPI_Comm &communicator,
 #endif
 
 
+#ifdef DEAL_II_WITH_PETSC
+IS
+IndexSet::make_petsc_is(const MPI_Comm &communicator) const
+{
+  std::vector<size_type> indices;
+  fill_index_vector(indices);
+
+  PetscInt              n = indices.size();
+  std::vector<PetscInt> pindices(indices.begin(), indices.end());
+
+  IS             is;
+  PetscErrorCode ierr =
+    ISCreateGeneral(communicator, n, pindices.data(), PETSC_COPY_VALUES, &is);
+  AssertThrow(ierr == 0, ExcPETScError(ierr));
+
+  return is;
+}
+#endif
+
+
 
 bool
 IndexSet::is_ascending_and_one_to_one(const MPI_Comm &communicator) const

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.