accu.template
par_geom.h
Go to the documentation of this file.
1 #ifndef PAR_GEOM_FILE
2 #define PAR_GEOM_FILE
3 #include "geom.h"
4 #include "vdop.h"
5 #include <array>
6 #include <functional> // function; C++11
7 #include <iostream>
8 #include <map>
9 #include <memory> // shared_ptr
10 #include <mpi.h> // MPI
11 #include <string>
12 #include <vector>
13 
14 class ParMesh: public Mesh
15 {
16 public:
26  explicit ParMesh(int ndim, int nvert_e = 0, int ndof_e = 0, int nedge_e = 0, MPI_Comm const &icomm = MPI_COMM_WORLD);
27 
28  ParMesh(ParMesh const &) = default;
29 
30  ParMesh &operator=(ParMesh const &) = delete;
31 
32 
39  virtual ~ParMesh();
40 
48  explicit ParMesh(std::string const &sname, MPI_Comm const &icomm = MPI_COMM_WORLD);
49 
50  void VecAccu(std::vector<double> &w) const;
51 
57  double dscapr(std::vector<double> const &x, std::vector<double> const &y) const
58  {
59  return par_scalar(x, y, _icomm);
60  }
61 
62 private:
70  std::vector<int> ReadElementSubdomains(std::string const &dname);
71 
72 
79  void Transform_Local2Global_Vertex(int myrank, std::vector<int> const &t2d);
80 
81 
85  void Generate_VectorAdd();
86 
87  bool CheckInterfaceExchange_InPlace() const;
88  bool CheckInterfaceExchange() const;
89  bool CheckInterfaceAdd_InPlace() const;
90  bool CheckInterfaceAdd() const;
91 
92 
93 public:
98  int MyRank() const
99  {
100  return _myrank;
101  }
102 
107  int NumProcs() const
108  {
109  return _numprocs;
110  }
111 
115  MPI_Comm GetCommunicator() const
116  {
117  return _icomm;
118  }
119 
120 private:
121  // Don't use &_icomm ==> Error
122  MPI_Comm const _icomm;
123  int _numprocs;
124  int _myrank;
125  std::vector<int> _v_l2g;
126  std::vector<int> _t_l2g;
127  std::map<int, int> _v_g2l;
128  std::map<int, int> _t_g2l;
129 
130  //std::vector<int> e_l2g; //!< edges: local to global mapping
131 
132  std::vector<int> _valence;
133  // MPI_Alltoallv needs:
134  mutable std::vector<double> _sendbuf;
135  std::vector<int> _sendcounts;
136  std::vector<int> _sdispls;
137  //
138  // We need to map the interface vertices onto the sendbuffer:
139  std::vector<int> _loc_itf;
140  std::vector<int> _gloc_itf;
141  std::vector<int> _buf2loc;
142 
143 
144 };
145 
146 
147 #endif
ParMesh::ReadElementSubdomains
std::vector< int > ReadElementSubdomains(std::string const &dname)
Definition: par_geom.cpp:75
ParMesh::_sdispls
std::vector< int > _sdispls
offset of data to send to each MPI rank wrt. _senbuffer (the same as for recv)
Definition: par_geom.h:136
ParMesh::CheckInterfaceExchange
bool CheckInterfaceExchange() const
Definition: par_geom.cpp:406
ParMesh::_icomm
const MPI_Comm _icomm
MPI communicator for the group of processes.
Definition: par_geom.h:122
ParMesh::CheckInterfaceExchange_InPlace
bool CheckInterfaceExchange_InPlace() const
Definition: par_geom.cpp:377
ParMesh::_valence
std::vector< int > _valence
valence of local vertices, i.e. number of subdomains they belong to
Definition: par_geom.h:132
ParMesh::_sendcounts
std::vector< int > _sendcounts
number of data to send to each MPI rank (the same as for recv)
Definition: par_geom.h:135
ParMesh::dscapr
double dscapr(std::vector< double > const &x, std::vector< double > const &y) const
Definition: par_geom.h:57
Mesh
Definition: geom.h:13
ParMesh::_t_g2l
std::map< int, int > _t_g2l
triangles: global to local mapping
Definition: par_geom.h:128
ParMesh::GetCommunicator
MPI_Comm GetCommunicator() const
Definition: par_geom.h:115
ParMesh::_loc_itf
std::vector< int > _loc_itf
local index of interface vertex lk
Definition: par_geom.h:139
ParMesh::_t_l2g
std::vector< int > _t_l2g
triangles: local to global mapping
Definition: par_geom.h:126
ParMesh::NumProcs
int NumProcs() const
Definition: par_geom.h:107
par_scalar
double par_scalar(vector< double > const &x, vector< double > const &y, MPI_Comm const &icomm)
Definition: vdop.cpp:90
ParMesh::_v_g2l
std::map< int, int > _v_g2l
vertices: global to local mapping
Definition: par_geom.h:127
ParMesh::_gloc_itf
std::vector< int > _gloc_itf
global index of interface vertex lk
Definition: par_geom.h:140
vdop.h
ParMesh::CheckInterfaceAdd
bool CheckInterfaceAdd() const
Definition: par_geom.cpp:474
ParMesh::_numprocs
int _numprocs
number of MPI processes
Definition: par_geom.h:123
ndim
ndim
Definition: ascii_read_meshvector.m:23
geom.h
ParMesh::_buf2loc
std::vector< int > _buf2loc
local indices of sendbuffer positions (the same as for recv)
Definition: par_geom.h:141
ParMesh::VecAccu
void VecAccu(std::vector< double > &w) const
Definition: par_geom.cpp:517
ParMesh::_myrank
int _myrank
my MPI rank
Definition: par_geom.h:124
ParMesh::_v_l2g
std::vector< int > _v_l2g
vertices: local to global mapping
Definition: par_geom.h:125
ParMesh::operator=
ParMesh & operator=(ParMesh const &)=delete
ParMesh::MyRank
int MyRank() const
Definition: par_geom.h:98
ParMesh::Transform_Local2Global_Vertex
void Transform_Local2Global_Vertex(int myrank, std::vector< int > const &t2d)
Definition: par_geom.cpp:106
ParMesh
Definition: par_geom.h:14
ParMesh::Generate_VectorAdd
void Generate_VectorAdd()
Definition: par_geom.cpp:192
ParMesh::CheckInterfaceAdd_InPlace
bool CheckInterfaceAdd_InPlace() const
Definition: par_geom.cpp:438
nvert_e
nvert_e
Definition: ascii_write_mesh.m:26
ParMesh::ParMesh
ParMesh(int ndim, int nvert_e=0, int ndof_e=0, int nedge_e=0, MPI_Comm const &icomm=MPI_COMM_WORLD)
Definition: par_geom.cpp:21
ParMesh::_sendbuf
std::vector< double > _sendbuf
send buffer a n d receiving buffer (MPI_IN_PLACE)
Definition: par_geom.h:134
ParMesh::~ParMesh
virtual ~ParMesh()
Definition: par_geom.cpp:32