Reference documentation for deal.II version GIT f8d87ffe95 2022-08-04 17:30: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\}}\)
Public Member Functions | Private Attributes | List of all members
Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType > Class Template Referenceabstract

#include <deal.II/base/mpi_consensus_algorithms.h>

Inheritance diagram for Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >:
[legend]

Public Member Functions

 Interface ()
 
 Interface (Process< RequestType, AnswerType > &process, const MPI_Comm &comm)
 
virtual ~Interface ()=default
 
std::vector< unsigned int > run ()
 
std::vector< unsigned int > run (Process< RequestType, AnswerType > &process, const MPI_Comm &comm)
 
virtual std::vector< unsigned int > run (const std::vector< unsigned int > &targets, const std::function< RequestType(const unsigned int)> &create_request, const std::function< AnswerType(const unsigned int, const RequestType &)> &answer_request, const std::function< void(const unsigned int, const AnswerType &)> &process_answer, const MPI_Comm &comm)=0
 

Private Attributes

Process< RequestType, AnswerType > * process
 
MPI_Comm comm
 

Detailed Description

template<typename RequestType, typename AnswerType>
class Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >

A base class for algorithms that implement consensus algorithms, see the documentation of the surrounding namespace for more information.

This base class only introduces a basic interface to achieve these goals, while derived classes implement different algorithms to actually compute such communication patterns and perform the communication.

Template Parameters
RequestTypeThe type of the elements of the vector to be sent.
AnswerTypeThe type of the elements of the vector to be received.

Definition at line 233 of file mpi_consensus_algorithms.h.

Constructor & Destructor Documentation

◆ Interface() [1/2]

template<typename RequestType , typename AnswerType >
Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::Interface ( )

Default constructor.

◆ Interface() [2/2]

template<typename RequestType , typename AnswerType >
Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::Interface ( Process< RequestType, AnswerType > &  process,
const MPI_Comm &  comm 
)

Constructor. process is an object that provides information about what processes the current process wants to communicate with, and the data to be sent/received. comm is the communicator on which this communication is to happen.

Deprecated:
This constructor stores the Process object and the communicator so that one can later call the run() function without arguments. This approach is deprecated. Instead, use the default constructor of this class along with the run() function that takes an argument.

◆ ~Interface()

template<typename RequestType , typename AnswerType >
virtual Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::~Interface ( )
virtualdefault

Destructor. Made virtual to ensure that one can work with derived classes.

Member Function Documentation

◆ run() [1/3]

template<typename RequestType , typename AnswerType >
std::vector<unsigned int> Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::run ( )

Run the consensus algorithm and return a vector of process ranks that have requested answers from the current process.

Deprecated:
This function is deprecated. It can be called if the Process object and communicator to be used have previously been provided to the non-default constructor. Use the run() functions taking arguments instead.

◆ run() [2/3]

template<typename RequestType , typename AnswerType >
std::vector<unsigned int> Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::run ( Process< RequestType, AnswerType > &  process,
const MPI_Comm &  comm 
)

Run the consensus algorithm and return a vector of process ranks that have requested answers from the current process.

This version of the run() function simply unpacks the functions packaged in process and calls the version of the run() function that takes a number of std::function arguments.

◆ run() [3/3]

template<typename RequestType , typename AnswerType >
virtual std::vector<unsigned int> Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::run ( const std::vector< unsigned int > &  targets,
const std::function< RequestType(const unsigned int)> &  create_request,
const std::function< AnswerType(const unsigned int, const RequestType &)> &  answer_request,
const std::function< void(const unsigned int, const AnswerType &)> &  process_answer,
const MPI_Comm &  comm 
)
pure virtual

Run the consensus algorithm and return a vector of process ranks that have requested answers from the current process.

Parameters
[in]targetsA vector that contains the ranks of processes to which requests should be sent and from which answers need to be received.
[in]create_requestA function object that takes the rank of a target process as argument and returns the message that forms the request to this target.
[in]answer_requestA function that takes as arguments the rank of the process that has sent a request to us, along with the message of the request, and returns the message that forms the answer that should be sent back to the requesting process.
[in]process_answerA function object that takes as argument the rank of a process from which we have received an answer to a previously sent request, along with the message that forms this answer. This function is used to describe what the caller of the consensus algorithm wants to do with the received answer.
[in]commThe MPI communicator on which the whole algorithm is to be performed.

Implemented in Utilities::MPI::ConsensusAlgorithms::Selector< RequestType, AnswerType >, Utilities::MPI::ConsensusAlgorithms::Serial< RequestType, AnswerType >, Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >, and Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >.

Member Data Documentation

◆ process

template<typename RequestType , typename AnswerType >
Process<RequestType, AnswerType>* Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::process
private

Reference to the process provided by the user.

This member variable is only used in the deprecated constructor and the run() function without argument. It is a nullptr otherwise

Definition at line 329 of file mpi_consensus_algorithms.h.

◆ comm

template<typename RequestType , typename AnswerType >
MPI_Comm Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::comm
private

MPI communicator.

This member variable is only used in the deprecated constructor and the run() function without argument.

Definition at line 338 of file mpi_consensus_algorithms.h.


The documentation for this class was generated from the following file: