rebl-AMR
templateForest.h
Go to the documentation of this file.
1 #ifndef _TEMPLATEFOREST_H_
2 #define _TEMPLATEFOREST_H_
3 #include "communicate.h"
4 #include "definitions.h"
5 #include "tree.h"
6 #include "typedefs.h"
7 
13 template <class T>
14 using treeList = std::list<T>;
16 template <size_t M>
17 using seed = std::unordered_map<morton<M>, uint>;
18 
19 
20 //template <size_t N, typename Nvalue, size_t M, typename Mvalue, template< size_t L, typename Lvalue> class T=Tree >
21 template <size_t N, typename Nvalue, size_t M, typename Mvalue, class T >
23 {
24  protected:
31  private:
33  int duplicated=0;
36  bitlist<M> seeds; /*maybe in the future add this to class tree*/
39  vector<uint> destination;
40  vector<uint> sendtag;
41  vector<uint> recvtag;
42  vector <uint> nbrsOfNbrs;
43  vector<bitset<M + N>> *message=nullptr;
44  struct Zoltan_Struct *zz=nullptr; /*<Zoltan structure to be used for partitioning */
46  MPI_Comm graphComm;
47  MPI_Request *request=nullptr;
48  MPI_Request *request1=nullptr;
49  char nameAppendix[80];
50  unsigned long long meshSize;
51 
55  // seed<M> seeds; /*!< look up the tree that need to be transfered to other procs */
56  // may be use tuple in the future*/
57  // std::tuple<morton<M>,Tree<N,Nvalue>> lookup();
58 
59  public:
60 // TemplateForest<N, Nvalue, M, Mvalue, T>( T &proc, real *length, real *coords, uint nx, uint ny, uint nz ); /*!<constructor */
61 
63  TemplateForest<N, Nvalue, M, Mvalue, T>(int argcs,char *pArgs[], T &proc, real *length, real *coords, uint nx, uint ny, uint nz );
64  void construct(int argcs,char *pArgs[], T &proc, real *length, real *coords, uint nx, uint ny, uint nz );
66  void assignSeeds( real *length,T &proc);
67 // void formProcTop(Tree<M, Mvalue> &proc ,uint proclevel,real *geom_xyz,int geom_nn);
68  void assignGeom( T &proc,real *geom_xyz, uint geom_nn );
69  void encodeGeometry();
70  void refineEachTree( uint nlevel );
71  void moveGeom( T &proc, real *geom_xyz,uint n, real x[3]);
72  void getListEachTree();
73  bool isInSeed( morton<M> &key, uint *counter );
74  void flipAll( morton<N> &key, uint *mylevel, uint *direction );
75  void getDirections( morton<N + M> &key, uint combinedlevel, vector<uint> &directions );
76  void recoverAllZeroSingularity(morton<N+M> &key, const uint &combinedlevel);
77  void combinedLevel(const morton<N+M> &key, uint *level );
78  void findSeedLevelForRcvdMessage(const morton<N+M> &key, uint *mylevel, Tree<M,Mvalue> & proc);
79  void findSeedLevelForRcvdMessage(const morton<N+M> &key, uint *mylevel, FullTree<M,Mvalue> & proc);
80  void constructSeedKeyForRcvdMessage(const morton<N+M> &key,const uint &seedlevel, morton<M> &seedkey);
81  void constructElementKeyForRcvdMessage(const morton<N+M> &key,const uint &seedlevel, morton<N> &elementkey);
82  void removeAllZeroSingularity(morton<N+M> &key,const uint &combinedlevel);
83  void getMaxSeedsLevel(T &proc);
84  void findFlipLevel( morton<N + M> key, uint *mylevel, uint *changedirectionlevel,
85  uint *direction );
86  void flipForNbr( morton<N + M> &key, uint *mylevel, uint *changedirectionlevel,
87  uint *direction );
89  void getTotalMeshSize();
90  void getNbrSeedLevel( morton<N + M> &combinedkey, uint topologylevel, uint *nbrseedleve, Tree<M,Mvalue> &proc );
91  void getNbrSeedLevel( morton<N + M> &combinedkey, uint topologylevel, uint *nbrseedleve, FullTree<M,Mvalue> &proc );
92  uint forestsize();
93  void getElemNbrs(Tree<M, Mvalue> &proc,const morton<M> key, bitvector<M> &nbr );
94  void comPatternConstruct( Tree<M, Mvalue> &proc ); // might be a bug in here
95  void comPatternConstruct( FullTree<M, Mvalue> &proc, vector<uint> &Nbrs);
96  void fourToOneBalance( T &proc );
97  void refineForestBalanced( uint nlevel,T &proc );
98  void nonCollectiveNbrComm( );
99 
100  // composite morton code functions
101  // void flipForNbr( morton<M> &key, uint *mylevel, uint *changedirectionlevel, uint *direction );
102  // typename bitlist<M>::iterator find( morton<M> key );
103 
104  void pushToDerefineEachTree( uint nlevel, Tree<M, uint> &proc );
105  void retainFourToOneBalance( Tree<M, uint> &proc );
110  void createCommGraph(uint Nnbr); // works for both of the objects if we use the proper getElemNbrs
111  void createNbrsOfNbrs( ); // this one uses neighbor connectivity
112  void checkGraphConsistency();
113  void filterRefineList();
114  void setMaxProcLevel(const uint refinelevel );
115 
116  //uint findIndexInSeed( Tree<M,uint> &proc, morton<M> &seedkey );
117  uint findIndexInSeed( T &proc, morton<M> &seedkey );
118 
119 // void appendToMessage(Tree<M, uint> &proc,const uint seednbrlevel , morton<M+N> &seednbrkey ,morton<M+N> &combinedkey,const uint combinedlevel);
120 
121  void appendToMessage( T &proc, morton<M> &seednbrkey ,morton<M+N> &combinedkey,const uint combinedlevel );
122 
123 
124 #if(0)
125 // derefine routines
126  void zoltanGeomrepart( Tree<M,Mvalue>& proc,uint setmethod );
127 // debug routnes
128  void debug( Tree<M, Mvalue> &proc );
129  void debugDerefine( Tree<M, Mvalue> &proc );
130  void checkNbrsOfNbrsConsistency();
131  bool checkWithNbrs(bool *sendbuf,bool *recvbuf);
132  void rcvrMessageSize(int *sendbuf, int *recvbuf);
133  void constructCommWeak(const vector<int>Nbr);
134 // graph communication trial
135 #endif
136  void MPIStartUp();
137  void checkInputParams(int argcs,char *pArgs[]);
138  void runInfo();
139  void currentDateTime();
140  template <size_t N1, typename Nvalue1, size_t M1, typename Mvalue1,class T1 >
141  friend class templatePhdf5;
142 
143  ~TemplateForest();
144  // ~TemplateForest(){}; /*!< Destructor of the object*/
145 
146 };
147 
148 
149 #endif
std::list< morton< M > > bitlist
Definition: definitions.h:99
void refineEachTree(uint nlevel)
Definition: templateForest.cpp:328
MPI_Request * request
Definition: templateForest.h:47
uint npx
Definition: templateForest.h:27
void flipAll(morton< N > &key, uint *mylevel, uint *direction)
Definition: templateForest.cpp:600
void getListEachTree()
Definition: templateForest.cpp:515
This Class is specifically designed for weak analysis to operate on the fulltree topology in this cla...
Definition: tree.h:182
void nonCollectiveNbrComm()
Definition: templateForest.cpp:5183
void checkZoltanPartConsistency(Tree< M, Mvalue > &proc)
Definition: templateForest.cpp:5922
void constructElementKeyForRcvdMessage(const morton< N+M > &key, const uint &seedlevel, morton< N > &elementkey)
Definition: templateForest.cpp:766
void findSeedLevelForRcvdMessage(const morton< N+M > &key, uint *mylevel, Tree< M, Mvalue > &proc)
Definition: templateForest.cpp:695
void findFlipLevel(morton< N+M > key, uint *mylevel, uint *changedirectionlevel, uint *direction)
Definition: templateForest.cpp:820
Tree< M, real > geom
Definition: templateForest.h:38
void refineForestBalanced(uint nlevel, T &proc)
Definition: templateForest.cpp:4476
void retainFourToOneBalance(Tree< M, uint > &proc)
Definition: templateForest.cpp:5344
real ancestorlength[3]
Definition: templateForest.h:25
void getNbrSeedLevel(morton< N+M > &combinedkey, uint topologylevel, uint *nbrseedleve, Tree< M, Mvalue > &proc)
Definition: templateForest.cpp:984
uint getTotalSize()
Definition: templateForest.cpp:277
void currentDateTime()
Definition: templateForest.cpp:7136
std::vector< morton< N > > bitvector
Definition: definitions.h:102
vector< uint > recvtag
Definition: templateForest.h:41
Zoltan_Out zoltan_out
Definition: templateForest.h:45
struct Zoltan_Struct * zz
Definition: templateForest.h:44
uint npy
Definition: templateForest.h:28
vector< bitset< M+N > > * message
Definition: templateForest.h:43
std::list< T > treeList
Definition: templateForest.h:14
void recoverAllZeroSingularity(morton< N+M > &key, const uint &combinedlevel)
Definition: templateForest.cpp:653
bool isInSeed(morton< M > &key, uint *counter)
Definition: templateForest.cpp:575
void encodeGeometry()
Definition: templateForest.cpp:291
void fourToOneBalance(T &proc)
Definition: templateForest.cpp:1412
void checkGraphConsistency()
Definition: templateForest.cpp:6166
void pushToDerefineEachTree(uint nlevel, Tree< M, uint > &proc)
Definition: templateForest.cpp:5327
void assignSeeds(real *length, T &proc)
Definition: templateForest.cpp:242
void removeAllZeroSingularity(morton< N+M > &key, const uint &combinedlevel)
Definition: templateForest.cpp:778
~TemplateForest()
Definition: templateForest.cpp:193
void filterRefineList()
Template Class designed to unify tree and full_tree topologies.
Definition: templateForest.h:22
MpiCom Com
Definition: templateForest.h:32
void appendToMessage(T &proc, morton< M > &seednbrkey, morton< M+N > &combinedkey, const uint combinedlevel)
Definition: templateForest.cpp:7014
void constructSeedKeyForRcvdMessage(const morton< N+M > &key, const uint &seedlevel, morton< M > &seedkey)
Definition: templateForest.cpp:755
uint forestsize()
Definition: templateForest.cpp:1042
void createCommGraph(uint Nnbr)
Definition: templateForest.cpp:5972
void combinedLevel(const morton< N+M > &key, uint *level)
Definition: templateForest.cpp:663
treeList< Tree< N, Nvalue > > trees
Definition: templateForest.h:34
void construct(int argcs, char *pArgs[], T &proc, real *length, real *coords, uint nx, uint ny, uint nz)
Definition: templateForest.cpp:89
void moveGeom(T &proc, real *geom_xyz, uint n, real x[3])
Definition: templateForest.cpp:347
int duplicated
Definition: templateForest.h:33
uint maxseedlevel
Definition: templateForest.h:37
void comPatternConstruct(Tree< M, Mvalue > &proc)
Definition: templateForest.cpp:1282
void createNbrsOfNbrs()
Definition: templateForest.cpp:6091
vector< uint > nbrsOfNbrs
Definition: templateForest.h:42
real ancestorcoords[3]
Definition: templateForest.h:26
vector< uint > destination
Definition: templateForest.h:39
void checkInputParams(int argcs, char *pArgs[])
Definition: templateForest.cpp:165
void flipForNbr(morton< N+M > &key, uint *mylevel, uint *changedirectionlevel, uint *direction)
Definition: templateForest.cpp:856
std::bitset< N > morton
Definition: definitions.h:45
void getTotalMeshSize()
Definition: templateForest.cpp:897
vector< uint > sendtag
Definition: templateForest.h:40
double real
Definition: definitions.h:37
uint findIndexInSeed(T &proc, morton< M > &seedkey)
Definition: templateForest.cpp:6984
unsigned int uint
Definition: definitions.h:38
uint npz
Definition: templateForest.h:29
void getElemNbrs(Tree< M, Mvalue > &proc, const morton< M > key, bitvector< M > &nbr)
Definition: templateForest.cpp:1054
void setMaxProcLevel(const uint refinelevel)
Definition: templateForest.cpp:814
bitlist< M > seeds
Definition: templateForest.h:36
void getMaxSeedsLevel(T &proc)
Definition: templateForest.cpp:796
void assignGeom(T &proc, real *geom_xyz, uint geom_nn)
Definition: templateForest.cpp:390
MPI_Request * request1
Definition: templateForest.h:48
unsigned long long meshSize
Definition: templateForest.h:50
This structure is an interface to store the output from Zoltan.
Definition: typedefs.h:29
Definition: templatePhdf5.h:15
class for embedding data related to the communicator
Definition: communicate.h:10
MPI_Comm graphComm
Definition: templateForest.h:46
std::unordered_map< morton< M >, uint > seed
Definition: forest.h:26
char nameAppendix[80]
Definition: templateForest.h:49
void MPIStartUp()
Definition: templateForest.cpp:7056
void getDirections(morton< N+M > &key, uint combinedlevel, vector< uint > &directions)
Definition: templateForest.cpp:613
void runInfo()
Definition: templateForest.cpp:7149
uint maxProcLevel
Definition: templateForest.h:35