Reference documentation for deal.II version GIT 35969cdc9b 2023-12-09 01:10:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
petsc_communication_pattern.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2023 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_petsc_communication_pattern_h
17 #define dealii_petsc_communication_pattern_h
18 
19 #include <deal.II/base/config.h>
20 
21 #ifdef DEAL_II_WITH_PETSC
22 
23 # include <deal.II/base/array_view.h>
25 # include <deal.II/base/index_set.h>
26 
28 
29 # include <petscsf.h>
30 
31 # include <vector>
32 
34 
39 namespace PETScWrappers
40 {
50  {
51  public:
56 
60  virtual ~CommunicationPattern() override;
61 
62  virtual void
63  reinit(const IndexSet &locally_owned_indices,
64  const IndexSet &ghost_indices,
65  const MPI_Comm communicator) override;
66 
80  void
81  reinit(const std::vector<types::global_dof_index> &indices_locally_owned,
82  const std::vector<types::global_dof_index> &indices_want,
83  const MPI_Comm communicator);
84 
98  void
99  reinit(const types::global_dof_index local_size,
100  const IndexSet &ghost_indices,
101  const MPI_Comm communicator);
102 
107  template <typename Number>
108  void
109  export_to_ghosted_array(const ArrayView<const Number> &locally_owned_array,
110  const ArrayView<Number> &ghost_array) const;
111 
117  template <typename Number>
118  void
120  const ArrayView<const Number> &locally_owned_array,
121  const ArrayView<Number> &ghost_array) const;
122 
128  template <typename Number>
129  void
131  const ArrayView<const Number> &locally_owned_array,
132  const ArrayView<Number> &ghost_array) const;
133 
138  template <typename Number>
139  void
141  const VectorOperation::values op,
142  const ArrayView<const Number> &ghost_array,
143  const ArrayView<Number> &locally_owned_array) const;
144 
151  template <typename Number>
152  void
154  const VectorOperation::values op,
155  const ArrayView<const Number> &ghost_array,
156  const ArrayView<Number> &locally_owned_array) const;
157 
164  template <typename Number>
165  void
167  const VectorOperation::values op,
168  const ArrayView<const Number> &ghost_array,
169  const ArrayView<Number> &locally_owned_array) const;
170 
174  MPI_Comm
175  get_mpi_communicator() const override;
176 
180  operator const PetscSF &() const
181  {
182  return sf;
183  }
184 
188  void
189  clear();
190 
191  protected:
195  PetscSF sf;
196 
200  void
201  do_reinit(const std::vector<PetscInt> &inidx,
202  const std::vector<PetscInt> &inloc,
203  const std::vector<PetscInt> &outidx,
204  const std::vector<PetscInt> &outloc,
205  const MPI_Comm communicator);
206  };
207 
221  {
222  public:
227 
231  virtual ~Partitioner() override = default;
232 
238  virtual void
239  reinit(const IndexSet &locally_owned_indices,
240  const IndexSet &ghost_indices,
241  const MPI_Comm communicator) override;
242 
250  void
251  reinit(const IndexSet &locally_owned_indices,
252  const IndexSet &ghost_indices,
253  const IndexSet &larger_ghost_indices,
254  const MPI_Comm communicator);
255 
259  unsigned int
261  {
262  return n_ghost_indices_data;
263  }
264 
268  const IndexSet &
270  {
271  return ghost_indices_data;
272  }
273 
278  template <typename Number>
279  void
281  const ArrayView<Number> &ghost_array) const;
282 
291  template <typename Number>
292  void
294  const ArrayView<const Number> &locally_owned_array,
295  const ArrayView<Number> &ghost_array) const;
296 
305  template <typename Number>
306  void
308  const ArrayView<const Number> &locally_owned_array,
309  const ArrayView<Number> &ghost_array) const;
310 
315  template <typename Number>
316  void
318  const VectorOperation::values op,
319  const ArrayView<const Number> &ghost_array,
320  const ArrayView<Number> &locally_owned_array) const;
321 
331  template <typename Number>
332  void
334  const VectorOperation::values op,
335  const ArrayView<const Number> &ghost_array,
336  const ArrayView<Number> &locally_owned_array) const;
337 
347  template <typename Number>
348  void
350  const VectorOperation::values op,
351  const ArrayView<const Number> &ghost_array,
352  const ArrayView<Number> &locally_owned_array) const;
353 
357  MPI_Comm
358  get_mpi_communicator() const override;
359 
360  protected:
365  };
366 
367 } // namespace PETScWrappers
368 
372 
373 #endif
374 
375 #endif
void import_from_ghosted_array(const VectorOperation::values op, const ArrayView< const Number > &ghost_array, const ArrayView< Number > &locally_owned_array) const
void export_to_ghosted_array_start(const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &ghost_array) const
void export_to_ghosted_array(const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &ghost_array) const
void export_to_ghosted_array_finish(const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &ghost_array) const
void import_from_ghosted_array_finish(const VectorOperation::values op, const ArrayView< const Number > &ghost_array, const ArrayView< Number > &locally_owned_array) const
void do_reinit(const std::vector< PetscInt > &inidx, const std::vector< PetscInt > &inloc, const std::vector< PetscInt > &outidx, const std::vector< PetscInt > &outloc, const MPI_Comm communicator)
virtual void reinit(const IndexSet &locally_owned_indices, const IndexSet &ghost_indices, const MPI_Comm communicator) override
void import_from_ghosted_array_start(const VectorOperation::values op, const ArrayView< const Number > &ghost_array, const ArrayView< Number > &locally_owned_array) const
types::global_dof_index n_ghost_indices_data
virtual void reinit(const IndexSet &locally_owned_indices, const IndexSet &ghost_indices, const MPI_Comm communicator) override
void import_from_ghosted_array(const VectorOperation::values op, const ArrayView< const Number > &ghost_array, const ArrayView< Number > &locally_owned_array) const
void export_to_ghosted_array_finish(const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &ghost_array) const
MPI_Comm get_mpi_communicator() const override
void reinit(const IndexSet &locally_owned_indices, const IndexSet &ghost_indices, const IndexSet &larger_ghost_indices, const MPI_Comm communicator)
virtual ~Partitioner() override=default
const IndexSet & ghost_indices() const
void export_to_ghosted_array(const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &ghost_array) const
void export_to_ghosted_array_start(const ArrayView< const Number > &locally_owned_array, const ArrayView< Number > &ghost_array) const
void import_from_ghosted_array_start(const VectorOperation::values op, const ArrayView< const Number > &ghost_array, const ArrayView< Number > &locally_owned_array) const
void import_from_ghosted_array_finish(const VectorOperation::values op, const ArrayView< const Number > &ghost_array, const ArrayView< Number > &locally_owned_array) const
types::global_dof_index n_ghost_indices_larger
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
unsigned int global_dof_index
Definition: types.h:82