rebl-AMR
forest.h
Go to the documentation of this file.
1 #ifndef _FOREST_H_
2 #define _FOREST_H_
3 #include "communicate.h"
4 #include "definitions.h"
5 #include "tree.h"
6 #include "typedefs.h"
7 
22 template <size_t N, typename value>
23 using treelist = std::list<Tree<N, value>>;
24 
25 template <size_t M> /*This map is defined to find the reference of the tree in the list that corresponds to the seed */
26 using seed = std::unordered_map<morton<M>, uint>;
27 
28 template <size_t N, typename Nvalue, size_t M, typename Mvalue>
29 class Forest
30 {
31  protected:
38  private:
41  bitlist<M> seeds; /*maybe in the future add this to class tree*/
44  vector<uint> destination;
45  vector <uint> nbrsOfNbrs;
46  struct Zoltan_Struct *zz=nullptr;
48  MPI_Comm graphComm;
52  // seed<M> seeds; /*!< look up the tree that need to be transfered to other procs */
53  // may be use tuple in the future*/
54  // std::tuple<morton<M>,Tree<N,Nvalue>> lookup();
55 
56  public:
57  Forest<N, Nvalue, M, Mvalue>( real *length, real *coords, Tree<M, Mvalue> &proc,const int fixedlevel, uint nx, uint ny, uint nz );
58  void assignSeeds( real *length, Tree<M, Mvalue> &proc,const int ficedlevel);
60 // void formProcTop(Tree<M, Mvalue> &proc ,uint proclevel,real *geom_xyz,int geom_nn);
61  void refineEachTreeVoxel( uint nlevel );
63  void assignGeom( Tree<M, Mvalue> &proc,const uint fixedlevel ,real *geom_xyz, uint geom_nn );
64  void refineEachTree( uint nlevel );
65  void getListEachTree();
66  void fourToOneBalance( Tree<M, uint> &proc );
67  bool isInSeed( morton<M> &key, uint *counter );
68  void flipAll( morton<N> &key, uint *mylevel, uint *direction );
69  // composite morton code functions
70  void findFlipLevel( morton<N + M> key, uint *mylevel, uint *changedirectionlevel,
71  uint *direction );
72  void flipForNbr( morton<N + M> &key, uint *mylevel, uint *changedirectionlevel,
73  uint *direction );
74  // bool getNbrSeedLevel(morton<N+M> &combinedkey,uint topologylevel,uint *nbrseedleve,Tree<M,uint>& proc);
75  // void flipForNbr( morton<M> &key, uint *mylevel, uint *changedirectionlevel, uint *direction );
76 // void combine(const morton<N> &key,const morton<M> &seed, morton<M+N> &combinedkey); /*!<combined seed key with element key*/
77  void getNbrSeedLevel( morton<N + M> &combinedkey, uint topologylevel, uint *nbrseedleve, Tree<M, uint> &proc );
78  void debug( Tree<M, Mvalue> &proc );
79  // typename bitlist<M>::iterator find( morton<M> key );
80  void getElemNbrs(Tree<M, Mvalue> &proc,const morton<M> key, bitvector<M> &nbr );
82  void getDirections( morton<N + M> &key, uint combinedlevel, vector<uint> &directions );
83  void encodeGeometry();
84  void removeAllZeroSingularity(morton<N+M> &key,const uint &combinedlevel);
85  void getMaxSeedsLevel(Tree<M,Mvalue>& proc);
86  void findSeedLevelForRcvdMessage(const morton<N+M> &key, uint *mylevel, Tree<M,Mvalue> & proc);
87  void recoverAllZeroSingularity(morton<N+M> &key, const uint &combinedlevel);
88  void constructSeedKeyForRcvdMessage(const morton<N+M> &key,const uint &seedlevel, morton<M> &seedkey);
89  void constructElementKeyForRcvdMessage(const morton<N+M> &key,const uint &seedlevel, morton<N> &elementkey);
90  // void refine();
91  void refineForestBalanced( uint nlevel,Tree<M,Mvalue>& proc );
92  void combinedLevel(const morton<N+M> &key, uint *level );
93  void zoltanGeomrepart( Tree<M,Mvalue>& proc,uint setmethod );
94  // void EncodeGeomEachTree( Tree<M, Mvalue> &proc, real *geom_xyz, uint n );
95  uint forestsize();
97  void moveGeom( Tree<M, Mvalue> &proc, const uint fixedlevel, real *geom_xyz,uint n, real x[3]);
98  void pushToDerefineEachTree( uint nlevel, Tree<M, uint> &proc );
99  void convertBitsToDouble( morton<N+M> key, double *val);
100  void convertDoubleToBits( morton<N+M> &key, const double val);
101  void createCommGraph(uint Nnbr);
102  void createNbrsOfNbrs( );
103  // debug routines
104  void debugDerefine( Tree<M, Mvalue> &proc );
105  void checkGraphConsistency();
107  bool checkWithNbrs(bool *sendbuf,bool *recvbuf);
108  void rcvrMessageSize(int *sendbuf, int *recvbuf);
109  void getTotalMeshSize();
111 // friends and such
112  void constructCommWeak(const vector<int>Nbr);
113 
114  template <size_t N1, typename Nvalue1, size_t M1, typename Mvalue1>
115  friend class Phdf5;
116 
117 /*
118  template <size_t N2>
119  friend class Scale;
120 */
121 
122 // destructor
123 
124  ~Forest() {};
125 };
126 
127 #endif
void getMaxSeedsLevel(Tree< M, Mvalue > &proc)
std::list< morton< M > > bitlist
Definition: definitions.h:99
This Writes out Tree data in hdf5 format in parallel with *.xmf as metadata suitable for paraview and...
Definition: phdf5.h:15
struct Zoltan_Struct * zz
Definition: forest.h:46
void retainFourToOneBalance(Tree< M, uint > &proc)
~Forest()
Definition: forest.h:124
void debugDerefine(Tree< M, Mvalue > &proc)
void assignGeom(Tree< M, Mvalue > &proc, const uint fixedlevel, real *geom_xyz, uint geom_nn)
void fourToOneBalance(Tree< M, uint > &proc)
void refineEachTreeVoxel(uint nlevel)
vector< uint > nbrsOfNbrs
Definition: forest.h:45
void combinedLevel(const morton< N+M > &key, uint *level)
bool isInSeed(morton< M > &key, uint *counter)
void getElemNbrs(Tree< M, Mvalue > &proc, const morton< M > key, bitvector< M > &nbr)
void getTotalMeshSize()
void assignSeeds(real *length, Tree< M, Mvalue > &proc, const int ficedlevel)
void zoltanGeomrepart(Tree< M, Mvalue > &proc, uint setmethod)
void findSeedLevelForRcvdMessage(const morton< N+M > &key, uint *mylevel, Tree< M, Mvalue > &proc)
void recoverAllZeroSingularity(morton< N+M > &key, const uint &combinedlevel)
std::vector< morton< N > > bitvector
Definition: definitions.h:102
void createNbrsOfNbrs()
void rcvrMessageSize(int *sendbuf, int *recvbuf)
vector< uint > destination
Definition: forest.h:44
uint maxseedlevel
Definition: forest.h:42
void comPatternConstruct(Tree< M, Mvalue > &proc)
void constructSeedKeyForRcvdMessage(const morton< N+M > &key, const uint &seedlevel, morton< M > &seedkey)
bool checkWithNbrs(bool *sendbuf, bool *recvbuf)
void refineEachTree(uint nlevel)
void convertBitsToDouble(morton< N+M > key, double *val)
void debug(Tree< M, Mvalue > &proc)
void removeAllZeroSingularity(morton< N+M > &key, const uint &combinedlevel)
MpiCom Com
Definition: forest.h:39
void moveGeom(Tree< M, Mvalue > &proc, const uint fixedlevel, real *geom_xyz, uint n, real x[3])
MPI_Comm graphComm
Definition: forest.h:48
void pushToDerefineEachTree(uint nlevel, Tree< M, uint > &proc)
void getListEachTree()
void constructElementKeyForRcvdMessage(const morton< N+M > &key, const uint &seedlevel, morton< N > &elementkey)
uint npx
Definition: forest.h:34
std::list< Tree< N, value > > treelist
Definition: forest.h:23
void checkZoltanPartConsistency(Tree< M, Mvalue > &proc)
std::bitset< N > morton
Definition: definitions.h:45
Tree< M, real > geom
Definition: forest.h:43
real ancestorcoords[3]
Definition: forest.h:33
double real
Definition: definitions.h:37
unsigned int uint
Definition: definitions.h:38
template class that is a forest of octrees with semi-structured process topology
Definition: forest.h:29
uint npz
Definition: forest.h:36
Zoltan_Out zoltan_out
Definition: forest.h:47
void refineForestBalanced(uint nlevel, Tree< M, Mvalue > &proc)
real ancestorlength[3]
Definition: forest.h:32
void flipForNbr(morton< N+M > &key, uint *mylevel, uint *changedirectionlevel, uint *direction)
void flipAll(morton< N > &key, uint *mylevel, uint *direction)
void checkGraphConsistency()
This structure is an interface to store the output from Zoltan.
Definition: typedefs.h:29
bitlist< M > seeds
Definition: forest.h:41
class for embedding data related to the communicator
Definition: communicate.h:10
void getDirections(morton< N+M > &key, uint combinedlevel, vector< uint > &directions)
void findFlipLevel(morton< N+M > key, uint *mylevel, uint *changedirectionlevel, uint *direction)
void constructCommWeak(const vector< int >Nbr)
void encodeGeometry()
std::unordered_map< morton< M >, uint > seed
Definition: forest.h:26
treelist< N, Nvalue > trees
Definition: forest.h:40
void createCommGraph(uint Nnbr)
uint npy
Definition: forest.h:35
uint forestsize()
uint getTotalSize()
void getNbrSeedLevel(morton< N+M > &combinedkey, uint topologylevel, uint *nbrseedleve, Tree< M, uint > &proc)
void checkNbrsOfNbrsConsistency()
void convertDoubleToBits(morton< N+M > &key, const double val)