00001
00004 #ifndef __BULK_ADAPT_OPS_H
00005 #define __BULK_ADAPT_OPS_H
00006
00007 #include "charm++.h"
00008 #include "ParFUM.h"
00009 #include "ParFUM_internals.h"
00010 #include "ParFUM_SA.h"
00011
00013
00015 class BulkAdapt {
00016 private:
00018 int partitionID;
00019 int meshID;
00021 FEM_Mesh *meshPtr;
00023 CProxy_ParFUMShadowArray shadowProxy;
00025 ParFUMShadowArray *localShadow;
00026
00028 adaptAdj *elemPairs[10];
00029 int freeTable[10];
00030 int numGathered[10];
00031 int firstFree;
00032 public:
00034 BulkAdapt(int meshid, FEM_Mesh *mPtr, int partID, CProxy_ParFUMShadowArray sa_proxy);
00036 ~BulkAdapt();
00037
00039 void pup(PUP::er &p);
00040
00041
00042
00044 int getPartition() { return partitionID; }
00046 FEM_Mesh *getMeshPtr() { return meshPtr; }
00047
00048 int getTableID() {
00049 int x = firstFree;
00050 freeTable[x]=0;
00051 numGathered[x] = 0;
00052 firstFree++;
00053 while (!freeTable[firstFree]) {
00054 firstFree++;
00055 if (firstFree == 10) {
00056 CkPrintf("ERROR: elemPairs table is full!\n");
00057 break;
00058 }
00059 }
00060 return x;
00061 }
00062 void freeTableID(int x) {
00063 freeTable[x]=1;
00064 free(elemPairs[x]);
00065 if (x<firstFree) firstFree = x;
00066 }
00067
00068
00069
00070
00072
00077 bool edge_bisect(int elemID, int elemType, int edgeID, int dim, RegionID lockRegionID);
00078 bool edge_bisect_2D(int elemID, int elemType, int edgeID);
00079 bool edge_bisect_3D(int elemID, int elemType, int edgeID, RegionID lockRegionID);
00080
00081
00083
00088 int edge_flip(int elemID, int edgeID);
00089
00091
00096 int flip_23(int elemID, int faceID);
00097
00099
00104 int flip_32(int elemID, int edgeID);
00105
00107
00112 int edge_collapse(int elemID, int edgeID);
00113
00115 void one_side_split_2D(adaptAdj &startElem, adaptAdj &splitElem, int edgeID,
00116 int *node1idx, int *node2idx, int *newNodeID,
00117 bool startSide);
00118
00119
00120 adaptAdj remote_edge_bisect_2D(adaptAdj nbrElem, adaptAdj splitElem,
00121 int new_idxl, int n1_idxl, int n2_idxl,
00122 int remotePartID);
00123
00124 void remote_adaptAdj_replace(adaptAdj elem, adaptAdj oldElem,
00125 adaptAdj newElem);
00126 void remote_edgeAdj_replace(int remotePartID, adaptAdj adj, adaptAdj elem,
00127 adaptAdj splitElem, int n1_idxl, int n2_idxl);
00128 void remote_edgeAdj_add(int remotePartID, adaptAdj adj, adaptAdj splitElem,
00129 int n1_idxl, int n2_idxl);
00130
00131 adaptAdj remote_edge_bisect_3D(adaptAdj nbrElem, adaptAdj splitElem,
00132 int new_idxl, int n1_idxl, int n2_idxl,
00133 int remotePartID);
00134
00135 void handle_split_3D(int remotePartID, int pos, int tableID, adaptAdj elem, RegionID lockRegionID,
00136 int n1_idxl, int n2_idxl, int n5_idxl);
00137 void recv_split_3D(int pos, int tableID, adaptAdj elem, adaptAdj splitElem);
00138 bool all_splits_received(int tableID, int expectedSplits);
00139 void update_asterisk_3D(int remotePartID, int i, adaptAdj elem,
00140 int numElemPairs, adaptAdj *elemPairs, RegionID lockRegionID,
00141 int n1_idxl, int n2_idxl, int n5_idxl);
00142
00143 bool isLongest(int elem, int elemType, double len);
00144
00145
00146
00147 int lock_3D_region(int elemID, int elemType, int edgeID, double prio, RegionID *lockRegionID);
00148 void unlock_3D_region(RegionID lockRegionID);
00149 void unpend_3D_region(RegionID lockRegionID);
00150
00155 int add_element(int elemType,int nodesPerElem,int *conn,double sizing);
00156
00158 void update_element_conn(int elemType,int elemID,int nodesPerElem,int *conn);
00159
00164 int add_node(int dim,double *coords);
00165
00167 void update_node_coord(int nodeID,int dim,double *coords);
00168
00169 void make_node_shared(int nodeID,int numSharedChunks,int *sharedChunks);
00170
00171 int get_idxl_for_node(int nodeID, int partID);
00172 int get_node_from_idxl(int node_idxl, int partID);
00173 bool is_node_in_idxl(int node_idxl, int partID);
00174
00176 void get_elemsToLock(adaptAdj startElem, adaptAdj **elemsToLock, int edgeID, int *count);
00177
00179 adaptAdj *local_split_3D(const adaptAdj elem, int n1, int n2, int n5);
00180
00181 void local_update_asterisk_3D(int i, adaptAdj elem, int numElemPairs,
00182 adaptAdj *elemPairs, int n1,
00183 int n2, int n5);
00185 void update_local_face_adj(const adaptAdj elem, const adaptAdj splitElem, int n1, int n2, int n5);
00187 void update_local_edge_adj(const adaptAdj elem, const adaptAdj splitElem, int n1, int n2, int n5);
00188 double length(int n1, int n2, int dim);
00189 double length(double *n1, double *n2, int dim);
00190 void dumpConn();
00191 };
00192
00193
00194
00196 void midpoint(double *n1, double *n2, int dim, double *result);
00197
00198 int getRelNode(int nodeIdx, int *conn, int nodesPerElem);
00199 void getRelNodes(int edgeID, int nodesPerElem, int *r1, int *r2);
00200 int getEdgeID(int node1, int node2, int nodePerElem, int dim);
00201 int getFaceID(int node1, int node2, int node3, int nodesPerElem);
00202
00204 void fillNodes(int *relNode, int *nodeIDs, int *conn);
00205 void fillNodes(int *relNode, int n1, int n2, int *conn);
00206
00207 #endif