12 #ifndef DENDRO_5_ODA_H 13 #define DENDRO_5_ODA_H 22 #include "asyncExchangeContex.h" 25 #include "matRecord.h" 28 #ifdef BUILD_WITH_PETSC 32 #include "petscdmda.h" 35 #define VECType DendroScalar 36 #define MATType DendroScalar 65 enum LoopType {ALL,WRITABLE,INDEPENDENT,W_DEPENDENT,W_BOUNDARY,LOCAL_ELEMENTS,PREGHOST_ELEMENTS,POSTGHOST_ELEMENTS};
77 enum BdyType {X_MIN,X_MAX,Y_MIN,Y_MAX,Z_MIN,Z_MAX};
86 enum Refine {DA_NO_CHANGE,DA_REFINE,DA_COARSEN};
88 enum WriteMode{SET_VALUES=0,ADD_VALUES};
121 unsigned int indexBegin;
122 unsigned int indexEnd;
133 double m_uiOctreeLowerBound[m_uiDim];
136 double m_uiOctreeUpperBound[m_uiDim];
144 std::vector<unsigned int> m_uiOctantFlags;
151 unsigned int m_uiTotalNodalSz;
153 unsigned int m_uiLocalNodalSz;
156 unsigned int m_uiTotalElementSz;
159 unsigned int m_uiLocalElementSz;
162 std::vector<ot::AsyncExchangeContex> m_uiMPIContexts;
165 unsigned int m_uiCommTag;
168 std::vector<DendroIntL> m_uiLocalToGlobalNodalMap;
171 DendroIntL m_uiGlobalNodeSz;
178 std::vector<ot::TreeNode> getLocalOctants();
181 const std::vector<ot::TreeNode>& getBlocks();
190 DA(std::vector<ot::TreeNode> &balOct,MPI_Comm comm,
unsigned int order,
unsigned int grainSz=100,
double sfc_tol=0.3,
SM_TYPE smType=SM_TYPE::FEM_CG);
211 DA(std::function<
void(T,T,T,T*)>func,
unsigned int dofSz,MPI_Comm comm,
unsigned int order,
double interp_tol,
unsigned int grainSz=100,
double sfc_tol=0.3,
SM_TYPE smType=SM_TYPE::FEM_CG);
226 DA(
const Point* pts,
unsigned int numPts,
Point pt_min,
Point pt_max, MPI_Comm comm,
unsigned int order,
unsigned int grainSz=100,
double sfc_tol=0.3,
SM_TYPE smType=SM_TYPE::FEM_CG);
272 inline const std::vector<unsigned int>
getOctFlags()
const {
return m_uiOctantFlags; }
280 return MPI_COMM_NULL;
311 bool isBoundaryOctant(
unsigned int eleID)
const;
329 void getElementalCoords(
unsigned int eleID,
double* coords)
const ;
395 void computeTreeNodeOwnerProc(
const ot::TreeNode * pNodes,
unsigned int n,
int* ownerranks);
406 int createVector(T*& local,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
416 int createVector(std::vector<T>& local,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
422 template <
typename T>
423 void destroyVector(T*& local)
const;
425 template <
typename T>
426 void destroyVector(std::vector<T>& local)
const;
431 template<ot::DA_FLAGS::LoopType type>
439 template<ot::DA_FLAGS::LoopType type>
443 template<ot::DA_FLAGS::LoopType type>
450 void readFromGhostBegin(T* vec,
unsigned int dof=1);
456 void readFromGhostEnd(T* vec,
unsigned int dof=1);
461 void writeToGhostsBegin(T* vec,
unsigned int dof=1) ;
469 void writeToGhostsEnd(T* vec, DA_FLAGS::WriteMode mode,
unsigned int dof=1) ;
480 void nodalVecToGhostedNodal(
const T* in,T*& out,
bool isAllocated=
false,
unsigned int dof=1)
const;
492 void ghostedNodalToNodalVec(
const T* gVec,T*& local,
bool isAllocated=
false,
unsigned int dof=1)
const;
503 template <
typename T>
504 void getElementNodalValues(
const T*in, T* eleVecOut,
unsigned int eleID,
unsigned int dof=1)
const;
513 template <
typename T>
514 void eleVecToVecAccumilation(T*out,
const T* eleVecIn,
unsigned int eleID,
unsigned int dof=1)
const;
521 void getOctreeBoundaryNodeIndices(std::vector<unsigned int >& bdyIndex,std::vector<double>& coords,
bool isGhosted=
false);
528 int getNodeIndices(DendroIntL* nodeIdx,
unsigned int ele,
bool isGhosted)
const;
535 int getGlobalNodeIndices(DendroIntL* nodeIdx,
unsigned int ele)
const ;
546 template <
typename T>
547 void setVectorByFunction(T* local,std::function<
void(T,T,T,T*)>func,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
560 template <
typename T>
561 void setVectorByScalar(T* local,
const T* value,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
571 template <
typename T>
572 void vecTopvtu(T* local,
const char * fPrefix,
char** nodalVarNames=NULL,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1);
595 T* getVecPointerToDof(T* in ,
unsigned int dofInex,
bool isElemental=
false,
bool isGhosted=
false)
const;
607 void copyVectors(T* dest,
const T* source,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
617 void copyVector(T* dest,
const T* source,
bool isElemental=
false,
bool isGhosted=
false)
const;
629 ot::DA* remesh(
const DA_FLAGS::Refine * flags,
unsigned int sz,
unsigned int grainSz=100,
double ld_bal=0.3,
unsigned int sfK=2,
unsigned int (*getWeight)(
const ot::TreeNode *)=NULL)
const;
640 void intergridTransfer(
const T* varIn, T* & varOut,
const ot::DA* newDA,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1);
656 int getFaceNeighborValues(
unsigned int eleID,
const T* in, T* out, T* coords,
unsigned int * neighID,
unsigned int face, NeighbourLevel & level,
unsigned int dof)
const;
669 #ifdef BUILD_WITH_PETSC 679 PetscErrorCode petscCreateVector(Vec &local,
bool isElemental,
bool isGhosted,
unsigned int dof)
const;
688 PetscErrorCode createMatrix(Mat &M, MatType mtype,
unsigned int dof=1)
const;
699 PetscErrorCode petscNodalVecToGhostedNodal(
const Vec& in,Vec& out,
bool isAllocated=
false,
unsigned int dof=1)
const;
710 PetscErrorCode petscGhostedNodalToNodalVec(
const Vec& gVec,Vec& local,
bool isAllocated=
false,
unsigned int dof=1)
const;
719 void petscReadFromGhostBegin(PetscScalar * vecArry,
unsigned int dof=1) ;
727 void petscReadFromGhostEnd(PetscScalar * vecArry,
unsigned int dof=1) ;
740 void petscSetVectorByFunction(Vec& local,std::function<
void(T,T,T,T*)>func,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
753 template <
typename T>
754 void petscSetVectorByScalar(Vec& local,
const T* value,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1)
const;
764 void petscVecTopvtu(
const Vec& local,
const char * fPrefix,
char** nodalVarNames=NULL,
bool isElemental=
false,
bool isGhosted=
false,
unsigned int dof=1) ;
779 PetscErrorCode petscSetValuesInMatrix(Mat mat, std::vector<ot::MatRecord>& records,
unsigned int dof, InsertMode mode)
const;
790 PetscErrorCode petscChangeVecToMatBased(Vec& v1,
bool isElemental,
bool isGhosted,
unsigned int dof=1)
const;
798 PetscErrorCode petscChangeVecToMatFree(Vec& v1,
bool isElemental,
bool isGhosted,
unsigned int dof=1)
const;
809 void petscIntergridTransfer(
const Vec &varIn, Vec &varOut,
const ot::DA *newDA,
bool isElemental =
false,
bool isGhosted =
false,
unsigned int dof = 1);
815 PetscErrorCode petscDestroyVec(Vec & vec);
unsigned int getNumNodesPerElement() const
get number of nodes per element
Definition: oda.h:257
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 getTotalElemSz() const
returns the local elemental size (includes the ghost elements as well)
Definition: oda.h:251
LoopType
loop flags, ALL : Loop over all the elements (note here we loop only on the local + level 1 ghost ele...
Definition: oda.h:65
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
MPI_Comm getCommActive() const
: returns the active MPI sub com of the global communicator
Definition: oda.h:275
unsigned int getPreAndPostGhostNodeSize() const
: get the number of pre and post ghost elements
Definition: oda.h:346
unsigned int getGhostedElementSize() const
: get the number of pre and post ghost elements
Definition: oda.h:352
unsigned int getLocalElemSz() const
returns the local elemental size
Definition: oda.h:248
unsigned int getLevel(unsigned int ele) const
return the level of current octant
Definition: oda.h:578
A class to manage octants.
Definition: TreeNode.h:35
unsigned int getNumLayer1GhostEleSz() const
number of layer 1 ghost elements.
Definition: oda.h:349
Refine
contains the refine flags. DA_NO_CHANGE : no change needed for the octant DA_REFINE : refine the octa...
Definition: oda.h:86
unsigned int getMortonchildNum(unsigned int eleID) const
returns the morton child number
Definition: mesh.h:1167
unsigned int getPostGhostElementSize() const
: get the number of post-ghost element size
Definition: oda.h:343
ot::TreeNode getMinTreeNode() const
get min local node (nodal)
Definition: oda.h:361
const std::vector< DendroIntL > getNodeLocalToGlobalMap() const
: returns node local to node global map
Definition: oda.h:266
A point class.
Definition: point.h:36
unsigned int getRankActive() const
: rank w.r.t active comm.
Definition: oda.h:299
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
A set of parallel utilities.
unsigned int getNumPreGhostElements() const
Definition: mesh.h:1014
BdyType
Definition: oda.h:77
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 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 getMPIRank() const
returns the rank
Definition: mesh.h:1108
: Simple structure to keep the loop counters
Definition: oda.h:117
unsigned int getMaxDepth() const
: get the max depth of the octree
Definition: oda.h:356
unsigned int getElementOrder() const
get element order
Definition: oda.h:260
DAType
: DA type OCT: uses Dendro DA and PETSC uses petsc based DA
Definition: oda.h:105
unsigned int currentIndex
: current Index
Definition: oda.h:120
unsigned int getPostNodalSz() const
returns the post nodal size
Definition: oda.h:242
MVECType
: denotes the type of the matvec being computed, MESH_BASED - denotes the MatVec computation using me...
Definition: oda.h:111
unsigned int getPreGhostElementSize() const
: get the number of pre-ghost element size
Definition: oda.h:340
SM_TYPE
type of the scatter map, based on numerical computation method
Definition: mesh.h:114
unsigned int getLocalNodalSz() const
returns the local nodal size
Definition: oda.h:236
const RefElement * getReferenceElement() const
get a constant pointer for the reference element
Definition: oda.h:333
bool isActive() const
returns true if mesh is active
Definition: mesh.h:1173
unsigned int getDimension() const
: get the dimensionality of the octree
Definition: oda.h:358
unsigned int getMPIRankGlobal() const
returns the rank w.r.t. global comm
Definition: mesh.h:1102
A Set of utilities to test octrees.
unsigned int getRankAll() const
: rank with respect to the global comm.
Definition: oda.h:296
bool isActive() const
see if the current DA is active
Definition: oda.h:254
unsigned int getNumLocalMeshElements() const
Definition: mesh.h:1012
unsigned int getNpesActive() const
: number of processors active
Definition: oda.h:287
unsigned int getMortonChildNum(unsigned int eleID) const
computes the child number of the given octant
Definition: oda.h:663
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
unsigned int getPreNodalSz() const
returns the pre ghost nodal size
Definition: oda.h:239
ot::TreeNode getMaxTreeNode() const
get max localnode (nodal)
Definition: oda.h:375
unsigned int getElementLocalEnd() const
return the end location of element local
Definition: mesh.h:1032
unsigned int getNpesAll() const
: global mpi com. size
Definition: oda.h:284
const std::vector< unsigned int > getOctFlags() const
: Returns octDA flags
Definition: oda.h:272
ot::TreeNode getOctant(unsigned int ele) const
return the TreeNode of the current octnat.
Definition: oda.h:584
MPI_Comm getGlobalComm() const
: returns the global MPI communicator
Definition: oda.h:263
unsigned int getElementSize() const
: get the number of local elements.
Definition: oda.h:337
const ot::Mesh * getMesh() const
returns the mesh
Definition: oda.h:269
unsigned int getTotalNodalSz() const
returns the total nodal size (this includes the ghosted region as well.)
Definition: oda.h:245
unsigned int getMPICommSize() const
returns the comm size:
Definition: mesh.h:1111