21 #ifndef SFCSORTBENCH_MESH_H 22 #define SFCSORTBENCH_MESH_H 27 #include "treenode2vtk.h" 30 #include "sfcSearch.h" 34 #include <fdCoefficient.h> 42 #include "asyncExchangeContex.h" 45 #include "dendroProfileParams.h" 52 extern double t_e2e_g[3];
53 extern double t_e2n_g[3];
54 extern double t_sm_g[3];
55 extern double t_blk_g[3];
57 #include "dendroProfileParams.h" 102 #define KS_MAX 31 // maximum number of points in any direction that wavelet DA supports. 103 #define KEY_DIR_OFFSET 7 104 #define CHAINED_GHOST_OFFSET 5u 106 #define OCT_NO_CHANGE 0u 108 #define OCT_COARSE 2u 157 NodeTuple(
unsigned int xi,
unsigned int yj,
unsigned int zk,
unsigned int owner)
164 inline unsigned int getX()
const {
return i; }
165 inline unsigned int getY()
const {
return j; }
166 inline unsigned int getZ()
const {
return k; }
167 inline unsigned int getLevel()
const {
return e; }
184 std::vector<unsigned int> m_uiE2EMapping;
186 std::vector<unsigned int> m_uiE2NMapping_CG;
188 std::vector<unsigned int> m_uiE2NMapping_DG;
190 std::vector<unsigned int> m_uiCG2DG;
192 std::vector<unsigned int> m_uiDG2CG;
195 std::vector<ot::TreeNode> m_uiLocalSplitterElements;
203 std::vector<ot::TreeNode> m_uiPreGhostOctants;
205 std::vector<ot::TreeNode> m_uiPostGhostOctants;
209 std::vector<Key> m_uiKeys;
212 std::vector<Key> m_uiGhostKeys;
215 std::vector<Key> m_uiKeysDiag;
218 std::vector<ot::TreeNode> m_uiEmbeddedOctree;
221 std::vector<ot::TreeNode> m_uiGhostOctants;
229 std::vector<unsigned int> m_uiGhostElementRound1Index;
232 std::vector<ot::TreeNode> m_uiAllElements;
234 std::vector<ot::TreeNode> m_uiAllLocalNode;
237 std::vector<ot::Block> m_uiLocalBlockList;
240 unsigned int m_uiDmin;
242 unsigned int m_uiDmax;
245 unsigned int m_uiElementPreGhostBegin = 0;
247 unsigned int m_uiElementPreGhostEnd;
249 unsigned int m_uiElementLocalBegin;
251 unsigned int m_uiElementLocalEnd;
253 unsigned int m_uiElementPostGhostBegin;
255 unsigned int m_uiElementPostGhostEnd;
257 unsigned int m_uiFElementPreGhostBegin;
259 unsigned int m_uiFElementPreGhostEnd;
261 unsigned int m_uiFElementLocalBegin;
263 unsigned int m_uiFElementLocalEnd;
265 unsigned int m_uiFElementPostGhostBegin;
267 unsigned int m_uiFElementPostGhostEnd;
270 unsigned int m_uiMeshDomain_min;
272 unsigned int m_uiMeshDomain_max;
275 unsigned int m_uiNumLocalElements;
277 unsigned int m_uiNumPreGhostElements;
279 unsigned int m_uiNumPostGhostElements;
282 unsigned int m_uiNumTotalElements;
285 unsigned int m_uiNumActualNodes;
288 DendroIntL m_uiUnZippedVecSz;
291 unsigned int m_uiNumFakeNodes;
294 unsigned int m_uiNodePreGhostBegin;
296 unsigned int m_uiNodePreGhostEnd;
298 unsigned int m_uiNodeLocalBegin;
300 unsigned int m_uiNodeLocalEnd;
302 unsigned int m_uiNodePostGhostBegin;
304 unsigned int m_uiNodePostGhostEnd;
315 MPI_Comm m_uiCommActive;
318 MPI_Comm m_uiCommGlobal;
329 unsigned int *m_uiSendKeyCount;
331 unsigned int *m_uiRecvKeyCount;
333 unsigned int *m_uiSendKeyOffset;
335 unsigned int *m_uiRecvKeyOffset;
338 unsigned int *m_uiSendKeyDiagCount;
340 unsigned int *m_uiRecvKeyDiagCount;
342 unsigned int *m_uiSendKeyDiagOffset;
344 unsigned int *m_uiRecvKeyDiagOffset;
348 unsigned int *m_uiSendOctCountRound1;
350 unsigned int *m_uiRecvOctCountRound1;
352 unsigned int *m_uiSendOctOffsetRound1;
354 unsigned int *m_uiRecvOctOffsetRound1;
356 unsigned int *m_uiSendOctCountRound1Diag;
358 unsigned int *m_uiRecvOctCountRound1Diag;
360 unsigned int *m_uiSendOctOffsetRound1Diag;
362 unsigned int *m_uiRecvOctOffsetRound1Diag;
366 unsigned int *m_uiSendOctCountRound2;
368 unsigned int *m_uiRecvOctCountRound2;
370 unsigned int *m_uiSendOctOffsetRound2;
372 unsigned int *m_uiRecvOctOffsetRound2;
375 std::vector<unsigned int> m_uiSendNodeCount;
377 std::vector<unsigned int> m_uiRecvNodeCount;
379 std::vector<unsigned int> m_uiSendNodeOffset;
381 std::vector<unsigned int> m_uiRecvNodeOffset;
384 std::vector<unsigned int> m_uiSendProcList;
387 std::vector<unsigned int> m_uiRecvProcList;
390 std::vector<unsigned int> m_uiGhostElementIDsToBeSent;
392 std::vector<unsigned int> m_uiGhostElementIDsToBeRecv;
395 std::vector<unsigned int> m_uiPreGhostHangingNodeCGID;
398 std::vector<unsigned int> m_uiPostGhostHangingNodeCGID;
401 std::vector<ot::TreeNode> m_uiSendBufferElement;
404 std::vector<double> m_uiSendBufferNodes;
406 std::vector<double> m_uiRecvBufferNodes;
412 std::vector<unsigned int> m_uiScatterMapElementRound1;
415 std::vector<unsigned int> m_uiScatterMapActualNodeSend;
418 std::vector<unsigned int> m_uiScatterMapActualNodeRecv;
422 unsigned int m_uiEL_i;
425 unsigned int m_uiElementOrder;
428 unsigned int m_uiNpE;
431 unsigned int m_uiStensilSz;
434 unsigned int m_uiNumDirections;
440 std::vector<unsigned int> m_uiFEMGhostLev1IDs;
445 std::vector<unsigned int> m_uiF2EMap;
448 bool m_uiIsBlockSetup;
457 std::vector<AsyncExchangeContex> m_uiMPIContexts;
460 unsigned int m_uiCommTag=0;
463 std::vector<bool> m_uiIsNodalMapValid;
470 std::vector<ot::Key> m_uiUnzip_3pt_keys;
472 std::vector<ot::Key> m_uiUnzip_3pt_ele;
474 std::vector<ot::Key> m_uiUnzip_3pt_recv_keys;
477 std::vector<unsigned int> m_uiSendCountRePt;
480 std::vector<unsigned int> m_uiSendOffsetRePt;
483 std::vector<unsigned int> m_uiRecvCountRePt;
486 std::vector<unsigned int> m_uiRecvOffsetRePt;
489 std::vector<unsigned int> m_uiReqSendProcList;
492 std::vector<unsigned int> m_uiReqRecvProcList;
495 std::vector<unsigned int> m_uiSendNodeReqPtSM;
507 void generateSearchKeys();
514 void generateGhostElementSearchKeys();
520 void generateBdyElementDiagonalSearchKeys();
529 void buildE2EMap(std::vector<ot::TreeNode> &in, MPI_Comm comm);
531 void computeElementOwnerRanks(std::vector<unsigned int> &elementOwner);
539 void buildE2EMap(std::vector<ot::TreeNode> &in);
557 void shrinkE2EAndE2N();
566 void generateFakeElementsAndUpdateE2EAndE2N();
579 inline bool computeOveralppingNodes(
const ot::TreeNode &parent,
const ot::TreeNode &child,
int *idx,
int *idy,
int *idz);
590 void computeNodeScatterMaps(MPI_Comm comm);
596 void computeNodalScatterMap(MPI_Comm comm);
603 void computeNodalScatterMap1(MPI_Comm comm);
610 void computeNodalScatterMap2(MPI_Comm comm);
617 void computeNodalScatterMap3(MPI_Comm comm);
624 void computeNodalScatterMap4(MPI_Comm comm);
644 inline void OCT_DIR_LEFT_INTERNAL_EDGE_MAP(
unsigned int child,
unsigned int parent,
bool parentChildLevEqual, std::vector<unsigned int> &edgeChildIndex, std::vector<unsigned int> &edgeOwnerIndex);
653 inline void OCT_DIR_RIGHT_INTERNAL_EDGE_MAP(
unsigned int child,
unsigned int parent,
bool parentChildLevEqual, std::vector<unsigned int> &edgeChildIndex, std::vector<unsigned int> &edgeOwnerIndex);
662 inline void OCT_DIR_DOWN_INTERNAL_EDGE_MAP(
unsigned int child,
unsigned int parent,
bool parentChildLevEqual, std::vector<unsigned int> &edgeChildIndex, std::vector<unsigned int> &edgeOwnerIndex);
671 inline void OCT_DIR_UP_INTERNAL_EDGE_MAP(
unsigned int child,
unsigned int parent,
bool parentChildLevEqual, std::vector<unsigned int> &edgeChildIndex, std::vector<unsigned int> &edgeOwnerIndex);
680 inline void OCT_DIR_FRONT_INTERNAL_EDGE_MAP(
unsigned int child,
unsigned int parent,
bool parentChildLevEqual, std::vector<unsigned int> &edgeChildIndex, std::vector<unsigned int> &edgeOwnerIndex);
689 inline void OCT_DIR_BACK_INTERNAL_EDGE_MAP(
unsigned int child,
unsigned int parent,
bool parentChildLevEqual, std::vector<unsigned int> &edgeChildIndex, std::vector<unsigned int> &edgeOwnerIndex);
699 void SET_FACE_TO_ELEMENT_MAP(
unsigned int ele,
unsigned int dir,
unsigned int dirOp,
unsigned int dir1,
unsigned int dir2);
705 inline void CORNER_NODE_MAP(
unsigned int child);
710 inline void OCT_DIR_DIAGONAL_E2E(
unsigned int elementID,
unsigned int face1,
unsigned int face2,
unsigned int &lookUp)
const;
720 template <
typename pKey,
typename pNode>
721 void searchKeys(std::vector<pKey> &pKeys, std::vector<pNode> &pNodes);
726 inline unsigned int getDIROfANode(
unsigned int ii_x,
unsigned int jj_y,
unsigned int kk_z);
732 inline void directionToIJK(
unsigned int direction, std::vector<unsigned int> &ii_x, std::vector<unsigned int> &jj_y, std::vector<unsigned int> &kk_z);
748 template <
typename T>
749 inline void interpUpWind(
const double *upWind,
const unsigned int element,
const unsigned int lookup, T *vecLookUp,
const unsigned int cnum,
const T *parentInterpIn, T *parentInterpOut,
const unsigned int padDir,
const unsigned int padWidth,
const T *zippedVec, T *out);
765 template <
typename T>
766 inline void interpDownWind(
const double *downWind,
const unsigned int element,
const unsigned int lookup, T *vecLookUp,
const unsigned int cnum,
const T *parentInterpIn, T *parentInterpOut,
const unsigned int padDir,
const unsigned int padWidth,
const T *zippedVec, T *out);
773 template <
typename T>
774 void blockDiagonalUnZip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
781 template <
typename T>
782 void blockVertexUnZip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
789 template <
typename T>
790 void OCT_DIR_LEFT_DOWN_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
797 template <
typename T>
798 void OCT_DIR_LEFT_UP_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
805 template <
typename T>
806 void OCT_DIR_LEFT_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
813 template <
typename T>
814 void OCT_DIR_LEFT_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
821 template <
typename T>
822 void OCT_DIR_RIGHT_DOWN_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
829 template <
typename T>
830 void OCT_DIR_RIGHT_UP_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
837 template <
typename T>
838 void OCT_DIR_RIGHT_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
845 template <
typename T>
846 void OCT_DIR_RIGHT_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
853 template <
typename T>
854 void OCT_DIR_UP_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
861 template <
typename T>
862 void OCT_DIR_UP_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
869 template <
typename T>
870 void OCT_DIR_DOWN_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
877 template <
typename T>
878 void OCT_DIR_DOWN_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
885 template <
typename T>
886 void OCT_DIR_LEFT_DOWN_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
893 template <
typename T>
894 void OCT_DIR_RIGHT_DOWN_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
901 template <
typename T>
902 void OCT_DIR_LEFT_UP_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
909 template <
typename T>
910 void OCT_DIR_RIGHT_UP_BACK_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
917 template <
typename T>
918 void OCT_DIR_LEFT_DOWN_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
925 template <
typename T>
926 void OCT_DIR_RIGHT_DOWN_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
933 template <
typename T>
934 void OCT_DIR_LEFT_UP_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
941 template <
typename T>
942 void OCT_DIR_RIGHT_UP_FRONT_Unzip(
const ot::Block &blk,
const T *zippedVec, T *unzippedVec);
950 void computeSMSpecialPts();
957 template <
typename T>
958 void readSpecialPtsBegin(
const T *in);
960 template <
typename T>
961 void readSpecialPtsEnd(
const T *in, T* out);
973 Mesh(std::vector<ot::TreeNode> &in,
unsigned int k_s,
unsigned int pOrder,
unsigned int activeNpes, MPI_Comm comm,
bool pBlockSetup =
true,
SM_TYPE smType = SM_TYPE::FDM,
unsigned int grainSz = DENDRO_DEFAULT_GRAIN_SZ,
double ld_tol = DENDRO_DEFAULT_LB_TOL,
unsigned int sf_k = DENDRO_DEFAULT_SF_K);
984 Mesh(std::vector<ot::TreeNode> &in,
unsigned int k_s,
unsigned int pOrder, MPI_Comm comm,
bool pBlockSetup =
true,
SM_TYPE smType = SM_TYPE::FDM,
unsigned int grainSz = DENDRO_DEFAULT_GRAIN_SZ,
double ld_tol = DENDRO_DEFAULT_LB_TOL,
unsigned int sf_k = DENDRO_DEFAULT_SF_K);
993 void performBlocksSetup();
1058 inline const std::vector<ot::TreeNode> &
getAllElements()
const {
return m_uiAllElements; }
1070 inline const std::vector<unsigned int> &
getE2EMapping()
const {
return m_uiE2EMapping; }
1073 inline const std::vector<unsigned int> &
getE2NMapping()
const {
return m_uiE2NMapping_CG; }
1076 inline const std::vector<unsigned int> &
getDG2CGMap()
const {
return m_uiDG2CG; }
1079 inline const std::vector<unsigned int> &
getCG2DGMap()
const {
return m_uiCG2DG; }
1108 inline unsigned int getMPIRank()
const {
return m_uiActiveRank; }
1135 inline const std::vector<unsigned int> &
getSendProcList()
const {
return m_uiSendProcList; }
1138 inline const std::vector<unsigned int> &
getRecvProcList()
const {
return m_uiRecvProcList; }
1141 inline const std::vector<unsigned int> &
getSendNodeSM()
const {
return m_uiScatterMapActualNodeSend; }
1144 inline const std::vector<unsigned int> &
getRecvNodeSM()
const {
return m_uiScatterMapActualNodeRecv; }
1147 inline void dg2eijk(
unsigned int dg_index,
unsigned int &e,
unsigned int &i,
unsigned int &j,
unsigned int &k)
const 1149 e = dg_index / m_uiNpE;
1155 if (dg_index > e * m_uiNpE)
1156 k = (dg_index - e * m_uiNpE) / ((m_uiElementOrder + 1) * (m_uiElementOrder + 1));
1158 if ((dg_index + k * ((m_uiElementOrder + 1) * (m_uiElementOrder + 1))) > (e * m_uiNpE))
1159 j = (dg_index - e * m_uiNpE - k * ((m_uiElementOrder + 1) * (m_uiElementOrder + 1))) / (m_uiElementOrder + 1);
1161 if ((dg_index + k * ((m_uiElementOrder + 1) * (m_uiElementOrder + 1)) + j * (m_uiElementOrder + 1)) > (e * m_uiNpE))
1162 i = (dg_index - e * m_uiNpE - k * ((m_uiElementOrder + 1) * (m_uiElementOrder + 1)) - j * (m_uiElementOrder + 1));
1169 return m_uiAllElements[eleID].getMortonIndex();
1176 inline void waitAll()
const { MPI_Barrier(m_uiCommGlobal); }
1185 void setOctreeRefineFlags(
unsigned int *flags,
unsigned int sz);
1194 void getElementalFaceNeighbors(
const unsigned int eID,
const unsigned int dir,
unsigned int *lookup)
const;
1202 void getElementalEdgeNeighbors(
const unsigned int eID,
const unsigned int dir,
unsigned int *lookup)
const;
1209 void getElementalVertexNeighbors(
const unsigned int eID,
const unsigned int dir,
unsigned int *lookup)
const;
1217 void getElementQMat(
unsigned int currentId,
double *&qMat,
bool isAllocated =
true)
const;
1230 template<
typename T>
1231 void getUnzipElementalNodalValues(
const T* uzipVec,
unsigned int blkID,
unsigned int ele, T*out,
bool isPadded=
true)
const;
1237 template <ot::WaveletDA::LoopType type>
1244 template <ot::WaveletDA::LoopType type>
1245 bool nextAvailable();
1251 template <ot::WaveletDA::LoopType type>
1262 inline unsigned int currentIndex();
1268 inline void currentElementNeighbourIndexList(
unsigned int *neighList);
1275 inline void currentElementNodeList(
unsigned int *nodeList);
1282 inline void currentElementNodeList_DG(
unsigned int *nodeList);
1294 inline void faceNodesIndex(
unsigned int elementID,
unsigned int face, std::vector<unsigned int> &index,
1295 bool isInternal)
const;
1306 inline void edgeNodeIndex(
unsigned int elementID,
unsigned int face1,
unsigned int face2, std::vector<unsigned int> &index,
bool isInternal)
const;
1315 inline void cornerNodeIndex(
unsigned int elementID,
unsigned int mortonIndex,
unsigned int &index)
const;
1326 inline void elementNodeIndex(
unsigned int elementID, std::vector<unsigned int> &index,
bool isInternal)
const;
1333 bool isEdgeHanging(
unsigned int elementId,
unsigned int edgeId,
unsigned int &cnum)
const;
1340 bool isFaceHanging(
unsigned int elementId,
unsigned int faceId,
unsigned int &cnum)
const;
1349 bool isNodeHanging(
unsigned int eleID,
unsigned int ix,
unsigned int jy,
unsigned int kz)
const;
1358 inline bool isNodeLocal(
unsigned int eleID,
unsigned int ix,
unsigned int jy,
unsigned int kz)
const 1360 return ((m_uiE2NMapping_CG[eleID * m_uiNpE + kz * (m_uiElementOrder + 1) * (m_uiElementOrder + 1) + jy * (m_uiElementOrder + 1) + ix] >= m_uiNodeLocalBegin) && (m_uiE2NMapping_CG[eleID * m_uiNpE + kz * (m_uiElementOrder + 1) * (m_uiElementOrder + 1) + jy * (m_uiElementOrder + 1) + ix] < m_uiNodeLocalEnd));
1363 inline bool isBoundaryOctant(
unsigned int ele)
const 1365 assert(ele < m_uiAllElements.size() );
1366 return (m_uiAllElements[ele].minX() ==0 || m_uiAllElements[ele].minY() ==0 || m_uiAllElements[ele].minZ()==0 || m_uiAllElements[ele].maxX() == 1u<<(m_uiMaxDepth) || m_uiAllElements[ele].maxY() == 1u<<(m_uiMaxDepth) || m_uiAllElements[ele].maxZ() == 1u<<(m_uiMaxDepth) );
1369 inline DendroIntL getGhostExcgTotalSendNodeCount()
const 1371 if (m_uiGlobalNpes == 1)
1375 return (m_uiSendNodeOffset[m_uiActiveNpes - 1] + m_uiSendNodeCount[m_uiActiveNpes - 1]);
1380 inline DendroIntL getGhostExcgTotalRecvNodeCount()
const 1382 if (m_uiGlobalNpes == 1)
1386 return (m_uiRecvNodeOffset[m_uiActiveNpes - 1] + m_uiRecvNodeCount[m_uiActiveNpes - 1]);
1396 template <
typename T>
1397 T *createVector()
const;
1400 template <
typename T>
1401 void createVector(std::vector<T> &vec)
const;
1406 template <
typename T>
1407 T *createVector(
const T initValue)
const;
1412 template <
typename T>
1413 T *createVector(std::function<T(T, T, T)> func)
const;
1419 template <
typename T>
1420 void createVector(std::vector<T> &vec,
const T initValue)
const;
1427 template <
typename T>
1428 void createVector(std::vector<T> &vec, std::function<T(T, T, T)> func)
const;
1435 template <
typename T>
1436 void createUnZippedVector(std::vector<T> &uvec)
const;
1443 template <
typename T>
1444 T *createUnZippedVector()
const;
1450 template <
typename T>
1451 void createUnZippedVector(std::vector<T> &uvec,
const T initValue)
const;
1457 template <
typename T>
1458 T *createUnZippedVector(
const T initValue)
const;
1469 inline void parent2ChildInterpolation(
const double *in,
double *out,
unsigned int cnum,
unsigned int dim = 3)
const;
1480 inline void child2ParentInterpolation(
const double *in,
double *out,
unsigned int cnum,
unsigned int dim = 3)
const;
1489 inline void child2ParentInjection(
double *in,
double *out,
bool *isHanging)
const;
1498 template <
typename T>
1499 void unzip(
const T *zippedVec, T *unzippedVec);
1507 template <
typename T>
1508 void unzip_async(T *zippedVec, T *unzippedVec, MPI_Request *send_reqs, MPI_Request *recv_reqs, MPI_Status *send_sts, MPI_Status *recv_sts);
1515 template <
typename T>
1516 void zip(
const T *unzippedVec, T *zippedVec);
1527 template <
typename T,
unsigned int length,
unsigned int offsetCentered,
unsigned int offsetBackward,
unsigned int offsetForward>
1528 void applyStencil(
const std::vector<T> &in, std::vector<T> &out,
1537 template <
typename T>
1538 void performGhostExchange(std::vector<T> &vec);
1544 template <
typename T>
1545 void performGhostExchange(T *vec);
1552 template <
typename T>
1553 void ghostExchangeStart(T *vec, T *sendNodeBuffer, T *recvNodeBuffer, MPI_Request *send_reqs, MPI_Request *recv_reqs);
1561 template <
typename T>
1562 void ghostExchangeRecvSync(T *vec, T *recvNodeBuffer, MPI_Request *recv_reqs, MPI_Status *recv_sts);
1572 MPI_Waitall(m_uiSendProcList.size(), send_reqs, send_sts);
1580 template <
typename T>
1581 void vectorToVTK(
const std::vector<T> &vec,
char *fprefix,
double pTime = 0.0,
unsigned int nCycle = 0)
const;
1594 template <
typename T>
1595 bool isReMesh(
const T **vec,
const unsigned int *varIds,
const unsigned int numVars,
double tol,
double amr_coarse_fac = DENDRO_AMR_COARSEN_FAC);
1607 template <
typename T>
1608 bool isReMeshUnzip(
const T **unzippedVec,
const unsigned int *varIds,
const unsigned int numVars, std::function<
double(
double,
double,
double)> wavelet_tol,
double amr_coarse_fac = DENDRO_AMR_COARSEN_FAC,
double coarsen_hx = DENDRO_REMESH_UNZIP_SCALE_FAC);
1619 ot::Mesh *ReMesh(
unsigned int grainSz = DENDRO_DEFAULT_GRAIN_SZ,
double ld_tol = DENDRO_DEFAULT_LB_TOL,
unsigned int sfK = DENDRO_DEFAULT_SF_K,
unsigned int (*getWeight)(
const ot::TreeNode *)=NULL);
1627 template <
typename T>
1628 void interGridTransfer(std::vector<T> &vec,
const ot::Mesh *pMesh);
1636 template <
typename T>
1637 void interGridTransfer(T *&vec,
const ot::Mesh *pMesh);
1647 template<
typename T>
1648 void interGridTransferUnzip(T*& unzip, T*& vec,
const ot::Mesh *pMesh);
1657 template <
typename T>
1658 void getElementNodalValues(
const T *vec, T *nodalValues,
unsigned int elementID)
const;
1672 template <
typename T>
1673 void computeElementalContribution(
const T *in, T *out,
unsigned int elementID)
const;
1682 void getElementCoordinates(
unsigned int eleID,
double *coords)
const;
1695 template <
typename T>
1696 int getFaceNeighborValues(
unsigned int eleID,
const T *in, T *out, T *coords,
unsigned int *neighID,
unsigned int face, NeighbourLevel &level)
const;
1700 EType getElementType(
unsigned int eleID);
1712 int getBlkBdyParentNodeIndices(
unsigned int blkId,
unsigned int eleId,
unsigned int dir,
unsigned int* nid,
unsigned int* child,
unsigned int* fid,
unsigned int* cid);
1717 inline void Mesh::init<WaveletDA::LoopType ::ALL>()
1719 m_uiEL_i = m_uiElementPreGhostBegin;
1723 inline void Mesh::init<WaveletDA::INDEPENDENT>()
1725 m_uiEL_i = m_uiElementLocalBegin;
1729 inline void Mesh::init<WaveletDA::DEPENDENT>()
1731 m_uiEL_i = m_uiElementPreGhostBegin;
1735 inline bool Mesh::nextAvailable<WaveletDA::ALL>()
1737 return (m_uiEL_i < m_uiElementPostGhostEnd);
1741 inline bool Mesh::nextAvailable<WaveletDA::INDEPENDENT>()
1743 return (m_uiEL_i < m_uiElementLocalEnd);
1747 inline bool Mesh::nextAvailable<WaveletDA::DEPENDENT>()
1749 return (m_uiEL_i < m_uiElementPreGhostEnd) || ((m_uiEL_i > m_uiElementLocalEnd) && m_uiEL_i < m_uiElementPostGhostEnd);
1753 inline void Mesh::next<WaveletDA::ALL>()
1760 inline void Mesh::next<WaveletDA::INDEPENDENT>()
1767 inline void Mesh::next<WaveletDA::DEPENDENT>()
1771 if (m_uiEL_i == m_uiElementPreGhostEnd)
1772 m_uiEL_i = m_uiElementPostGhostBegin;
1777 return m_uiAllElements[m_uiEL_i];
1787 for (
unsigned int k = 0; k < m_uiNumDirections; k++)
1788 neighList[k] = m_uiE2EMapping[m_uiEL_i * m_uiNumDirections + k];
1796 for (
unsigned int k = 0; k < m_uiNpE; k++)
1798 nodeList[k] = m_uiE2NMapping_CG[m_uiEL_i * m_uiNpE + k];
1807 for (
unsigned int k = 0; k < m_uiNpE; k++)
1809 nodeList[k] = m_uiE2NMapping_DG[m_uiEL_i * m_uiNpE + k];
1816 dendro::timer::t_unzip_p2c.start();
1818 m_uiRefEl.I3D_Parent2Child(in, out, cnum);
1820 m_uiRefEl.I2D_Parent2Child(in, out, cnum);
1822 m_uiRefEl.I1D_Parent2Child(in, out, cnum);
1823 dendro::timer::t_unzip_p2c.stop();
1830 m_uiRefEl.I3D_Child2Parent(in, out, cnum);
1832 m_uiRefEl.I2D_Child2Parent(in, out, cnum);
1834 m_uiRefEl.I1D_Child2Parent(in, out, cnum);
1840 assert(m_uiElementOrder % 2 == 0 || m_uiElementOrder == 1);
1841 if (m_uiElementOrder == 1)
1843 for (
unsigned int child = 0; child < NUM_CHILDREN; child++)
1845 for (
unsigned int k = 0; k < (m_uiElementOrder + 1); k++)
1846 for (
unsigned int j = 0; j < (m_uiElementOrder + 1); j++)
1847 for (
unsigned int i = 0; i < (m_uiElementOrder + 1); i++)
1848 out[k * (m_uiElementOrder + 1) * (m_uiElementOrder + 1) + j * (m_uiElementOrder + 1) + i] = in[child * m_uiNpE + k * (m_uiElementOrder + 1) + j * (m_uiElementOrder + 1) + i];
1854 for (
unsigned int child = 0; child < NUM_CHILDREN; child++)
1857 for (
unsigned int k = 0; k < (m_uiElementOrder + 1); k++)
1858 for (
unsigned int j = 0; j < (m_uiElementOrder + 1); j++)
1859 for (
unsigned int i = 0; i < (m_uiElementOrder + 1); i++)
1861 if ((i % 2 == 0) && (j % 2 == 0) && (k % 2 == 0) && isHanging[k * (m_uiElementOrder + 1) * (m_uiElementOrder + 1) + j * (m_uiElementOrder + 1) + i])
1863 out[((((child & 4u) >> 2u) * m_uiElementOrder + k) >> 1) * (m_uiElementOrder + 1) * (m_uiElementOrder + 1) + ((((child & 2u) >> 1u) * m_uiElementOrder + j) >> 1) * (m_uiElementOrder + 1) + (((((child & (1u))) * m_uiElementOrder + i) >> 1))] = in[child * m_uiNpE + k * (m_uiElementOrder + 1) * (m_uiElementOrder + 1) + j * (m_uiElementOrder + 1) + i];
1871 inline bool Mesh::computeOveralppingNodes(
const ot::TreeNode &parent,
const ot::TreeNode &child,
int *idx,
int *idy,
int *idz)
1874 unsigned int Lp = 1u << (m_uiMaxDepth - parent.
getLevel());
1875 unsigned int Lc = 1u << (m_uiMaxDepth - child.
getLevel());
1878 unsigned int dp, dc;
1879 dp = (m_uiElementOrder);
1880 dc = m_uiElementOrder;
1882 assert(Lp % dp == 0);
1883 assert(Lc % dc == 0);
1885 for (
unsigned int k = 0; k < (m_uiElementOrder + 1); k++)
1892 bool stateX =
false;
1893 bool stateY =
false;
1894 bool stateZ =
false;
1895 if (parent == child)
1897 for (
unsigned int k = 0; k < (m_uiElementOrder + 1); k++)
1905 else if (parent.isAncestor(child))
1911 unsigned int index[3];
1912 for (
unsigned int k = 0; k < (m_uiElementOrder + 1); k++)
1915 index[0] = (m_uiElementOrder + 1);
1916 index[1] = (m_uiElementOrder + 1);
1917 index[2] = (m_uiElementOrder + 1);
1919 if (!(((child.
getX() - parent.
getX()) * dp * dc + k * Lc * dp) % (Lp * dc)))
1920 index[0] = ((child.
getX() - parent.
getX()) * dp * dc + k * Lc * dp) / (Lp * dc);
1922 if (!(((child.getY() - parent.getY()) * dp * dc + k * Lc * dp) % (Lp * dc)))
1923 index[1] = ((child.getY() - parent.getY()) * dp * dc + k * Lc * dp) / (Lp * dc);
1925 if (!(((child.getZ() - parent.getZ()) * dp * dc + k * Lc * dp) % (Lp * dc)))
1926 index[2] = ((child.getZ() - parent.getZ()) * dp * dc + k * Lc * dp) / (Lp * dc);
1928 if (!stateX && index[0] < (m_uiElementOrder + 1))
1931 if (!stateY && index[1] < (m_uiElementOrder + 1))
1934 if (!stateZ && index[2] < (m_uiElementOrder + 1))
1937 if (index[0] < (m_uiElementOrder + 1))
1940 assert((parent.
getX() + idx[k] * Lp / dp) == (child.
getX() + k * Lc / dc));
1942 if (index[1] < (m_uiElementOrder + 1))
1945 assert((parent.getY() + idy[k] * Lp / dp) == (child.getY() + k * Lc / dc));
1947 if (index[2] < (m_uiElementOrder + 1))
1950 assert((parent.getZ() + idz[k] * Lp / dp) == (child.getZ() + k * Lc / dc));
1953 state = stateX & stateY & stateZ;
1966 #include "meshE2NUtils.tcc" 1968 #endif //SFCSORTBENCH_MESH_H void currentElementNodeList(unsigned int *nodeList)
: Returns the node index list belongs to current element. NodeList size should be m_uiNpE; ...
Definition: mesh.h:1791
MPI_Comm getMPIGlobalCommunicator() const
returns the global communicator
Definition: mesh.h:1099
Simple class to manage async data transfer in the ODA class.
Definition: asyncExchangeContex.h:16
unsigned int getNodePreGhostEnd() const
return the end location of pre ghost nodes
Definition: mesh.h:1041
const std::vector< unsigned int > & getSendNodeSM() const
return Scatter map for node send
Definition: mesh.h:1141
bool isBlockSetep()
: returns if the block setup has performed or not
Definition: mesh.h:1005
unsigned int getNumPostMeshNodes() const
return the number of post ghost mesh nodes
Definition: mesh.h:1024
const std::vector< unsigned int > & getLevel1GhostElementIndices() const
returns the Level 1 ghost element indices.
Definition: mesh.h:1061
unsigned int getElementPreGhostEnd() const
return the end location of element pre ghost
Definition: mesh.h:1028
const std::vector< unsigned int > & getNodalSendCounts() const
returns the nodal send counts
Definition: mesh.h:1123
void child2ParentInjection(double *in, double *out, bool *isHanging) const
Performs child to parent injection.
Definition: mesh.h:1837
const std::vector< ot::TreeNode > & getSplitterElements() const
returns the splitter elements of the mesh local elements.
Definition: mesh.h:1064
A class to manage octants.
Definition: TreeNode.h:35
unsigned int getMortonchildNum(unsigned int eleID) const
returns the morton child number
Definition: mesh.h:1167
void currentElementNeighbourIndexList(unsigned int *neighList)
Returns the current neighbour list (Element) information. Note that for 3D it is 8 neighbours for eac...
Definition: mesh.h:1782
unsigned int getNumDirections() const
return the number of directions in the E2E mapping.
Definition: mesh.h:1087
const std::vector< unsigned int > & getE2NMapping_DG() const
Definition: mesh.h:1082
unsigned int getNodeLocalBegin() const
return the location of local node begin
Definition: mesh.h:1043
bool isNodeLocal(unsigned int eleID, unsigned int ix, unsigned int jy, unsigned int kz) const
: Returns true if the specified node (e,i,j,k) is local.
Definition: mesh.h:1358
unsigned int getMPICommSizeGlobal() const
returns the comm size w.r.t. global comm
Definition: mesh.h:1105
unsigned int getElementLocalBegin() const
return the begin location of element local
Definition: mesh.h:1030
const std::vector< unsigned int > & getNodalRecvOffsets() const
returns the nodal recv offsets
Definition: mesh.h:1132
const unsigned int getSendProcListSize() const
returns the send proc list size
Definition: mesh.h:1117
unsigned int getElementPostGhostEnd() const
return the end location of element post ghost
Definition: mesh.h:1036
void waitAll() const
waiting for all the mesh instances both active and inactive. This should not be called if not needed...
Definition: mesh.h:1176
unsigned int getNumPreGhostElements() const
Definition: mesh.h:1014
void currentElementNodeList_DG(unsigned int *nodeList)
Returns the node index list belogns to the currentl element in DG indexing. NodeList size should be m...
Definition: mesh.h:1802
const std::vector< unsigned int > & getRecvProcList() const
returns the recv proc. list
Definition: mesh.h:1138
unsigned int getNumPreMeshNodes() const
return the number of pre ghost mesh nodes
Definition: mesh.h:1022
const std::vector< ot::TreeNode > & getAllElements() const
returns the pointer to All elements array.
Definition: mesh.h:1058
unsigned int getNumLocalMeshNodes() const
return the number of nodes local to the mesh
Definition: mesh.h:1020
unsigned int getNumPostGhostElements() const
Returns the number of post-ghost elements.
Definition: mesh.h:1016
unsigned int getNumNodesPerElement() const
return the number of nodes per element.
Definition: mesh.h:1090
const RefElement * getReferenceElement() const
returns const pointer to reference element
Definition: mesh.h:1114
unsigned int getNodePostGhostBegin() const
return the location of post node begin
Definition: mesh.h:1047
const std::vector< unsigned int > & getCG2DGMap() const
returns cg to dg map
Definition: mesh.h:1079
const std::vector< unsigned int > & getDG2CGMap() const
returns dg to cg map
Definition: mesh.h:1076
unsigned int getNodePreGhostBegin() const
return the begin location of pre ghost nodes
Definition: mesh.h:1039
unsigned int getDegOfFreedom() const
returns the dof for a partition
Definition: mesh.h:1052
unsigned int getMPIRank() const
returns the rank
Definition: mesh.h:1108
unsigned int getLevel() const
return the level of the of the octant
Definition: TreeNode.h:387
SM_TYPE getScatterMapType()
: returns if the scatter map typed set
Definition: mesh.h:1008
const unsigned int getRecvProcListSize() const
returns the recv proc list size
Definition: mesh.h:1120
const ot::TreeNode & currentOctant()
Return the current element as an octant.
Definition: mesh.h:1775
unsigned int getElementPreGhostBegin() const
return the begin location of element pre ghost
Definition: mesh.h:1026
SM_TYPE
type of the scatter map, based on numerical computation method
Definition: mesh.h:114
unsigned int currentIndex()
Returns the current element index.
Definition: mesh.h:1780
const std::vector< unsigned int > & getSendProcList() const
returns the send proc. list
Definition: mesh.h:1135
const std::vector< unsigned int > & getE2NMapping() const
Definition: mesh.h:1073
bool isActive() const
returns true if mesh is active
Definition: mesh.h:1173
void ghostExchangeSendSync(MPI_Request *send_reqs, MPI_Status *send_sts)
Perform the wait on the recv requests.
Definition: mesh.h:1570
const std::vector< unsigned int > & getNodalRecvCounts() const
returns the nodal recv counts
Definition: mesh.h:1129
unsigned int getMPIRankGlobal() const
returns the rank w.r.t. global comm
Definition: mesh.h:1102
A Set of utilities to test octrees.
const std::vector< unsigned int > & getRecvNodeSM() const
return Scatter map for node send
Definition: mesh.h:1144
void parent2ChildInterpolation(const double *in, double *out, unsigned int cnum, unsigned int dim=3) const
Performs all parent to child interpolations for the m_uiEl_i element in order to apply the stencil...
Definition: mesh.h:1813
unsigned int getX() const
get integer values of the octree coordinates.
Definition: TreeNode.h:366
unsigned int getNodeLocalEnd() const
return the location of local node end
Definition: mesh.h:1045
const std::vector< ot::Block > & getLocalBlockList() const
returns const list of local blocks (regular grids) for the consdering mesh.
Definition: mesh.h:1084
const std::vector< unsigned int > & getE2EMapping() const
returns const e2e mapping instance.
Definition: mesh.h:1070
unsigned int getNumLocalMeshElements() const
Definition: mesh.h:1012
void child2ParentInterpolation(const double *in, double *out, unsigned int cnum, unsigned int dim=3) const
performs the child to parent contribution (only from a single child).
Definition: mesh.h:1826
unsigned int getNodePostGhostEnd() const
return the location of post node end
Definition: mesh.h:1049
const ot::TreeNode * getNodalSplitterNodes() const
get plitter nodes for each processor.
Definition: mesh.h:1392
void dg2eijk(unsigned int dg_index, unsigned int &e, unsigned int &i, unsigned int &j, unsigned int &k) const
: Decompose the DG index to element id and it's i,j,k values.
Definition: mesh.h:1147
unsigned int getElementOrder() const
returns the order of an element
Definition: mesh.h:1093
MPI_Comm getMPICommunicator() const
returns the communicator (acitve)
Definition: mesh.h:1096
const std::vector< unsigned int > & getNodalSendOffsets() const
returns the nodal send offsets
Definition: mesh.h:1126
unsigned int getElementLocalEnd() const
return the end location of element local
Definition: mesh.h:1032
unsigned int getElementPostGhostBegin() const
return the begin location of element post ghost
Definition: mesh.h:1034
unsigned int getMPICommSize() const
returns the comm size:
Definition: mesh.h:1111
const std::vector< ot::TreeNode > & getAllLocalNodes() const
returns all local nodes(vertices)
Definition: mesh.h:1067
unsigned int getDegOfFreedomUnZip() const
returns the dof for a partition
Definition: mesh.h:1055