Reference documentation for deal.II version 9.2.0
\(\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::AnonymousProcess< T1, T2 > Class Template Reference

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

Inheritance diagram for Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >:
[legend]

Public Member Functions

 AnonymousProcess (const std::function< std::vector< unsigned int >()> &function_compute_targets, const std::function< void(const unsigned int, std::vector< T1 > &)> &function_create_request=[](const unsigned int, std::vector< T1 > &) {}, const std::function< void(const unsigned int, const std::vector< T1 > &, std::vector< T2 > &)> &function_answer_request=[](const unsigned int, const std::vector< T1 > &, std::vector< T2 > &) {}, const std::function< void(const unsigned int, std::vector< T2 > &)> &function_prepare_buffer_for_answer=[](const unsigned int, std::vector< T2 > &) {}, const std::function< void(const unsigned int, const std::vector< T2 > &)> &function_read_answer=[](const unsigned int, const std::vector< T2 > &) {})
 
std::vector< unsigned intcompute_targets () override
 
void create_request (const unsigned int other_rank, std::vector< T1 > &send_buffer) override
 
void answer_request (const unsigned int other_rank, const std::vector< T1 > &buffer_recv, std::vector< T2 > &request_buffer) override
 
void prepare_buffer_for_answer (const unsigned int other_rank, std::vector< T2 > &recv_buffer) override
 
void read_answer (const unsigned int other_rank, const std::vector< T2 > &recv_buffer) override
 
- Public Member Functions inherited from Utilities::MPI::ConsensusAlgorithms::Process< T1, T2 >
virtual ~Process ()=default
 

Private Attributes

const std::function< std::vector< unsigned int >)> function_compute_targets
 
const std::function< void(const int, std::vector< T1 > &)> function_create_request
 
const std::function< void(const unsigned int, const std::vector< T1 > &, std::vector< T2 > &)> function_answer_request
 
const std::function< void(const int, std::vector< T2 > &)> function_prepare_buffer_for_answer
 
const std::function< void(const int, const std::vector< T2 > &)> function_read_answer
 

Detailed Description

template<typename T1, typename T2>
class Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >

This class implements Utilities::MPI::ConsensusAlgorithms::Process, using user-provided function wrappers. The advantage of this class is that users do not have to write their own implementation but can register lambda functions directly.

Definition at line 500 of file mpi_consensus_algorithms.h.

Constructor & Destructor Documentation

◆ AnonymousProcess()

template<typename T1 , typename T2 >
Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::AnonymousProcess ( const std::function< std::vector< unsigned int >()> &  function_compute_targets,
const std::function< void(const unsigned int, std::vector< T1 > &)> &  function_create_request = [](const unsigned int, std::vector<T1> &) {},
const std::function< void(const unsigned int, const std::vector< T1 > &, std::vector< T2 > &)> &  function_answer_request = [](const unsigned int,                                          const std::vector<T1> &,                                          std::vector<T2> &) {},
const std::function< void(const unsigned int, std::vector< T2 > &)> &  function_prepare_buffer_for_answer = [](const unsigned int, std::vector<T2> &) {},
const std::function< void(const unsigned int, const std::vector< T2 > &)> &  function_read_answer = [](const unsigned int, const std::vector<T2> &) {} 
)

Register functions that should be called for implementing the interface of Process.

Parameters
function_compute_targetscalled during compute_targets.
function_create_requestcalled during create_request.
function_answer_requestcalled during answer_request.
function_prepare_buffer_for_answercalled during prepare_buffer_for_answer.
function_read_answercalled during read_answer.

Definition at line 585 of file mpi_consensus_algorithms.h.

Member Function Documentation

◆ compute_targets()

template<typename T1 , typename T2 >
std::vector< unsigned int > Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::compute_targets
overridevirtual

Returns
A vector of ranks this process wants to send a request to.
Note
This is the only method which has to be implemented since the payloads of the messages are optional.

Implements Utilities::MPI::ConsensusAlgorithms::Process< T1, T2 >.

Definition at line 608 of file mpi_consensus_algorithms.h.

◆ create_request()

template<typename T1 , typename T2 >
void Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::create_request ( const unsigned int  other_rank,
std::vector< T1 > &  send_buffer 
)
overridevirtual

Add to the request to the process with the specified rank a payload.

Parameters
[in]other_rankrank of the process
[out]send_bufferdata to be sent part of the request (optional)
Note
The buffer is empty. Before using it, you have to set its size.

Reimplemented from Utilities::MPI::ConsensusAlgorithms::Process< T1, T2 >.

Definition at line 617 of file mpi_consensus_algorithms.h.

◆ answer_request()

template<typename T1 , typename T2 >
void Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::answer_request ( const unsigned int  other_rank,
const std::vector< T1 > &  buffer_recv,
std::vector< T2 > &  request_buffer 
)
overridevirtual

Prepare the buffer where the payload of the answer of the request to the process with the specified rank is saved in.

Parameters
[in]other_rankrank of the process
[in]buffer_recvreceived payload (optional)
[out]request_bufferpayload to be sent as part of the request (optional)
Note
The request_buffer is empty. Before using it, you have to set its size.

Reimplemented from Utilities::MPI::ConsensusAlgorithms::Process< T1, T2 >.

Definition at line 627 of file mpi_consensus_algorithms.h.

◆ prepare_buffer_for_answer()

template<typename T1 , typename T2 >
void Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::prepare_buffer_for_answer ( const unsigned int  other_rank,
std::vector< T2 > &  recv_buffer 
)
overridevirtual

Prepare the buffer where the payload of the answer of the request to the process with the specified rank is saved in. The most obvious task is to resize the buffer, since it is empty when the function is called.

Parameters
[in]other_rankrank of the process
[out]recv_bufferdata to be sent part of the request (optional)

Reimplemented from Utilities::MPI::ConsensusAlgorithms::Process< T1, T2 >.

Definition at line 639 of file mpi_consensus_algorithms.h.

◆ read_answer()

template<typename T1 , typename T2 >
void Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::read_answer ( const unsigned int  other_rank,
const std::vector< T2 > &  recv_buffer 
)
overridevirtual

Process the payload of the answer of the request to the process with the specified rank.

Parameters
[in]other_rankrank of the process
[in]recv_bufferdata to be sent part of the request (optional)

Reimplemented from Utilities::MPI::ConsensusAlgorithms::Process< T1, T2 >.

Definition at line 650 of file mpi_consensus_algorithms.h.

Member Data Documentation

◆ function_compute_targets

template<typename T1 , typename T2 >
const std::function<std::vector<unsigned int>)> Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::function_compute_targets
private

Definition at line 570 of file mpi_consensus_algorithms.h.

◆ function_create_request

template<typename T1 , typename T2 >
const std::function<void(const int, std::vector<T1> &)> Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::function_create_request
private

Definition at line 572 of file mpi_consensus_algorithms.h.

◆ function_answer_request

template<typename T1 , typename T2 >
const std::function< void(const unsigned int, const std::vector<T1> &, std::vector<T2> &)> Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::function_answer_request
private

Definition at line 575 of file mpi_consensus_algorithms.h.

◆ function_prepare_buffer_for_answer

template<typename T1 , typename T2 >
const std::function<void(const int, std::vector<T2> &)> Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::function_prepare_buffer_for_answer
private

Definition at line 577 of file mpi_consensus_algorithms.h.

◆ function_read_answer

template<typename T1 , typename T2 >
const std::function<void(const int, const std::vector<T2> &)> Utilities::MPI::ConsensusAlgorithms::AnonymousProcess< T1, T2 >::function_read_answer
private

Definition at line 579 of file mpi_consensus_algorithms.h.


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