preCICE v3.1.1
Loading...
Searching...
No Matches
ParallelMatrixOperations.cpp
Go to the documentation of this file.
2#ifndef PRECICE_NO_MPI
3
5#include "utils/IntraComm.hpp"
6
8
9void ParallelMatrixOperations::initialize(const bool needCyclicComm)
10{
12
13 if (needCyclicComm && utils::IntraComm::isParallel()) {
14 _needCyclicComm = true;
16 } else {
17 _needCyclicComm = false;
18 }
19}
20
29
31{
35
38
39 const auto size = utils::IntraComm::getSize();
40 const auto rank = utils::IntraComm::getRank();
41 com::connectCircularComm("IQNIMVJCyclicComm", "", rank, size, *cyclicCommLeft, *cyclicCommRight);
42
43 _cyclicCommLeft = std::move(cyclicCommLeft);
44 _cyclicCommRight = std::move(cyclicCommRight);
45}
46
48{
49 // Enforce consistency
50 PRECICE_ASSERT(static_cast<bool>(_cyclicCommLeft) == static_cast<bool>(_cyclicCommRight));
52
53 if ((utils::IntraComm::getRank() % 2) == 0) {
54 _cyclicCommLeft->closeConnection();
55 _cyclicCommRight->closeConnection();
56 } else {
57 _cyclicCommRight->closeConnection();
58 _cyclicCommLeft->closeConnection();
59 }
60
61 _cyclicCommRight = nullptr;
62 _cyclicCommLeft = nullptr;
63}
64
65} // namespace precice::acceleration::impl
66
67#endif
#define PRECICE_TRACE(...)
Definition LogMacros.hpp:95
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
void initialize(const bool needCyclicComm)
Initializes the acceleration.
com::PtrCommunication _cyclicCommLeft
Communication between neighboring ranks, backwards.
com::PtrCommunication _cyclicCommRight
Communication between neighboring ranks, forward.
Provides connection methods based on MPI ports (part of MPI 2.0).
static int getSize()
Number of ranks. This includes ranks from both participants, e.g. minimal size is 2.
Definition IntraComm.cpp:47
static Rank getRank()
Current rank.
Definition IntraComm.cpp:42
static bool isParallel()
True if this process is running in parallel.
Definition IntraComm.cpp:62
std::shared_ptr< Communication > PtrCommunication
void connectCircularComm(std::string const &participantName, std::string const &tag, int rank, int size, com::Communication &left, com::Communication &right)