| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2016 - 2024 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
#ifndef dealii_trilinos_epetra_communication_pattern_h |
| 16 |
#define dealii_trilinos_epetra_communication_pattern_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#ifdef DEAL_II_WITH_TRILINOS |
| 22 |
|
| 23 |
# include <deal.II/base/communication_pattern_base.h> |
| 24 |
|
| 25 |
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS |
| 26 |
# include <Epetra_Import.h> |
| 27 |
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS |
| 28 |
|
| 29 |
# include <memory> |
| 30 |
|
| 31 |
DEAL_II_NAMESPACE_OPEN |
| 32 |
|
| 33 |
namespace LinearAlgebra |
| 34 |
{ |
| 35 |
namespace EpetraWrappers |
| 36 |
{ |
| 37 |
/** |
| 38 |
* This class implements a wrapper to a Trilinos Epetra_Import object, |
| 39 |
* for use in places where a Utilities::MPI::CommunicationPatternBase object |
| 40 |
* is required. |
| 41 |
*/ |
| 42 |
class CommunicationPattern : public Utilities::MPI::CommunicationPatternBase |
| 43 |
{ |
| 44 |
public: |
| 45 |
/** |
| 46 |
* Initialize the communication pattern. |
| 47 |
* |
| 48 |
* @param[in] locally_owned_indices The set of indices of elements |
| 49 |
* in the array mentioned in the class documentation that are |
| 50 |
* stored on the current process. |
| 51 |
* @param[in] ghost_indices The set of indices of elements in the |
| 52 |
* array mentioned in the class documentation that the current |
| 53 |
* process will need to be able to import. |
| 54 |
* @param[in] communicator The MPI communicator used to describe the |
| 55 |
* entire set of processes that participate in the storage and |
| 56 |
* access to elements of the array. |
| 57 |
*/ |
| 58 |
CommunicationPattern(const IndexSet &locally_owned_indices, |
| 59 |
const IndexSet &ghost_indices, |
| 60 |
const MPI_Comm communicator); |
| 61 |
|
| 62 |
/** |
| 63 |
* Reinitialize the communication pattern. |
| 64 |
* |
| 65 |
* @param[in] locally_owned_indices The set of indices of elements |
| 66 |
* in the array mentioned in the class documentation that are |
| 67 |
* stored on the current process. |
| 68 |
* @param[in] ghost_indices The set of indices of elements in the |
| 69 |
* array mentioned in the class documentation that the current |
| 70 |
* process will need to be able to import. |
| 71 |
* @param[in] communicator The MPI communicator used to describe the |
| 72 |
* entire set of processes that participate in the storage and |
| 73 |
* access to elements of the array. |
| 74 |
*/ |
| 75 |
virtual void |
| 76 |
reinit(const IndexSet &locally_owned_indices, |
| 77 |
const IndexSet &ghost_indices, |
| 78 |
const MPI_Comm communicator) override; |
| 79 |
|
| 80 |
/** |
| 81 |
* Return the underlying MPI communicator. |
| 82 |
*/ |
| 83 |
virtual MPI_Comm |
| 84 |
get_mpi_communicator() const override; |
| 85 |
|
| 86 |
/** |
| 87 |
* Return the underlying Epetra_Import object. |
| 88 |
*/ |
| 89 |
const Epetra_Import & |
| 90 |
get_epetra_import() const; |
| 91 |
|
| 92 |
private: |
| 93 |
/** |
| 94 |
* Shared pointer to the MPI communicator used. |
| 95 |
*/ |
| 96 |
std::shared_ptr<const MPI_Comm> comm; |
| 97 |
|
| 98 |
/** |
| 99 |
* Shared pointer to the Epetra_Import object used. |
| 100 |
*/ |
| 101 |
std::unique_ptr<Epetra_Import> importer; |
| 102 |
}; |
| 103 |
} // end of namespace EpetraWrappers |
| 104 |
} // end of namespace LinearAlgebra |
| 105 |
|
| 106 |
DEAL_II_NAMESPACE_CLOSE |
| 107 |
|
| 108 |
#else |
| 109 |
|
| 110 |
// Make sure the scripts that create the C++20 module input files have |
| 111 |
// something to latch on if the preprocessor #ifdef above would |
| 112 |
// otherwise lead to an empty content of the file. |
| 113 |
DEAL_II_NAMESPACE_OPEN |
| 114 |
DEAL_II_NAMESPACE_CLOSE |
| 115 |
|
| 116 |
#endif |
| 117 |
|
| 118 |
#endif |