Chi-Tech
vector_ghost_communicator.h
Go to the documentation of this file.
1#ifndef CHITECH_VECTOR_GHOST_COMMUNICATOR_H
2#define CHITECH_VECTOR_GHOST_COMMUNICATOR_H
3
4#include <vector>
5#include <cstdint>
6#include <map>
7
8#include <mpi.h>
9
10namespace chi_math
11{
12
13/**Vector with allocation space for ghosts.*/
15{
16
17public:
18 VectorGhostCommunicator(uint64_t local_size,
19 uint64_t global_size,
20 const std::vector<int64_t>& ghost_ids,
21 MPI_Comm communicator);
22
23 /**Copy constructor.*/
25
26 /**Move constructor.*/
28
29 uint64_t LocalSize() const { return local_size_; }
30 uint64_t GlobalSize() const { return global_size_; }
31
32 uint64_t NumGhosts() const { return ghost_ids_.size(); }
33 const std::vector<int64_t>& GhostIndices() const { return ghost_ids_; }
34
35 MPI_Comm Communicator() const { return comm_; }
36
37 int64_t MapGhostToLocal(int64_t ghost_id) const;
38
39 void CommunicateGhostEntries(std::vector<double>& ghosted_vector) const;
40
41 std::vector<double> MakeGhostedVector() const;
42 std::vector<double>
43 MakeGhostedVector(const std::vector<double>& local_vector) const;
44
45protected:
46 const uint64_t local_size_;
47 const uint64_t global_size_;
48 const std::vector<int64_t> ghost_ids_;
49 const MPI_Comm comm_;
50
51 const int location_id_;
52 const int process_count_;
53 const std::vector<uint64_t> extents_;
54
56 {
57 std::vector<int> sendcounts_;
58 std::vector<int> senddispls_;
59 std::vector<int> recvcounts_;
60 std::vector<int> recvdispls_;
61
62 std::vector<int64_t> local_ids_to_send_;
63 std::map<int64_t, size_t> ghost_to_recv_map_;
64 };
65
67
68private:
69 int FindOwnerPID(int64_t global_id) const;
71};
72
73}//namespace chi_math
74
75#endif //CHITECH_VECTOR_GHOST_COMMUNICATOR_H
int64_t MapGhostToLocal(int64_t ghost_id) const
const std::vector< uint64_t > extents_
std::vector< double > MakeGhostedVector() const
const std::vector< int64_t > & GhostIndices() const
const std::vector< int64_t > ghost_ids_
const CachedParallelData cached_parallel_data_
void CommunicateGhostEntries(std::vector< double > &ghosted_vector) const
int FindOwnerPID(int64_t global_id) const
VectorGhostCommunicator(uint64_t local_size, uint64_t global_size, const std::vector< int64_t > &ghost_ids, MPI_Comm communicator)