00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef __ADAPT_ADJ_H__
00060 #define __ADAPT_ADJ_H__
00061
00062
00063 #include <set>
00064 #include <algorithm>
00065
00066 #define MAX_ADJELEMS 6
00067 #define MAX_FACE_SIZE 4
00068 #define MAX_EDGES 12
00069
00070 #define MAX_NODESET_SIZE 4
00071
00072
00073
00074 class adaptAdj{
00075 public:
00076 int partID;
00077 int localID;
00078 int elemType;
00079 adaptAdj():partID(-1),localID(-1),elemType(-1){};
00080 adaptAdj(int _partID,int _localID,int _elemType) :
00081 partID(_partID),
00082 localID(_localID),
00083 elemType(_elemType){};
00084 inline adaptAdj &operator=(const adaptAdj &rhs){
00085 partID = rhs.partID;
00086 localID = rhs.localID;
00087 elemType = rhs.elemType;
00088 return *this;
00089 }
00090 inline bool operator==(const adaptAdj &rhs) const{
00091 return (partID==rhs.partID &&
00092 localID==rhs.localID &&
00093 elemType==rhs.elemType);
00094 }
00095 inline bool operator!=(const adaptAdj &rhs) const{
00096 return (partID!=rhs.partID ||
00097 localID!=rhs.localID ||
00098 elemType!=rhs.elemType);
00099 }
00100 void pup(PUP::er &p){
00101 p | partID;
00102 p | localID;
00103 p | elemType;
00104 }
00105 };
00106
00107
00108
00109
00110 class adjElem {
00111 public:
00112 int elemID;
00113 int nodeSetID;
00114 CkVec<int> nodeSet;
00115 adjElem *next;
00116 adjElem(int nodeSetSize):
00117 nodeSet(nodeSetSize){};
00118 };
00119
00120 class adjNode {
00121 public:
00122 int *sharedWithPartition;
00123
00124
00125 int *sharedWithLocalIdx;
00126
00127 int numSharedPartitions;
00128 int adjElemCount;
00129
00130 adjElem *adjElemList;
00131 adjNode() {
00132 sharedWithPartition = NULL;
00133 adjElemList = new adjElem(0);
00134
00135 adjElemList->elemID = -1;
00136 adjElemList->next = NULL;
00137 adjElemCount = 0;
00138 numSharedPartitions=0;
00139 }
00140 ~adjNode() {
00141
00142
00143 }
00144 };
00145
00146 class adjRequest{
00147 public:
00148 int elemID,chunkID,elemType,nodeSetID;
00149 int translatedNodeSet[MAX_NODESET_SIZE];
00150 adjRequest():
00151 elemID(-1),
00152 chunkID(-1),
00153 elemType(-1){};
00154 adjRequest(int _elemID,int _chunkID,int _nodeSetID,int _elemType ):
00155 elemID(_elemID),
00156 chunkID(_chunkID),
00157 elemType(_elemType),
00158 nodeSetID(_nodeSetID) {};
00159 adjRequest(const adjRequest &rhs){
00160 *this = rhs;
00161 }
00162 inline adjRequest& operator=(const adjRequest &rhs) {
00163 elemID = rhs.elemID;
00164 chunkID = rhs.chunkID;
00165 elemType = rhs.elemType;
00166 nodeSetID = rhs.nodeSetID;
00167 memcpy(&translatedNodeSet[0],&(rhs.translatedNodeSet[0]),
00168 MAX_NODESET_SIZE*sizeof(int));
00169 return *this;
00170 }
00171 void pup(PUP::er &p){
00172 p | elemID;
00173 p | chunkID;
00174 p | elemType;
00175 p | nodeSetID;
00176 p(translatedNodeSet,MAX_NODESET_SIZE);
00177 }
00178 };
00179
00180 class adjReply {
00181 public:
00182 int requestingElemID,requestingNodeSetID;
00183 adaptAdj replyingElem;
00184 adjReply():
00185 requestingElemID(-1),
00186 requestingNodeSetID(-1),
00187 replyingElem(){};
00188 adjReply(const adjReply &rhs){
00189 *this = rhs;
00190 }
00191 inline adjReply& operator=(const adjReply &rhs){
00192 requestingElemID = rhs.requestingElemID;
00193 requestingNodeSetID = rhs.requestingNodeSetID;
00194 replyingElem = rhs.replyingElem;
00195 return *this;
00196 }
00197 void pup(PUP::er &p){
00198 p | requestingElemID;
00199 p | requestingNodeSetID;
00200 replyingElem.pup(p);
00201 }
00202 };
00203
00204
00205 typedef ElemList<adjRequest> AdjRequestList;
00206 typedef MSA::MSA1D<AdjRequestList, DefaultListEntry<AdjRequestList,true>,MSA_DEFAULT_ENTRIES_PER_PAGE> MSA1DREQLIST;
00207
00208 typedef ElemList<adjReply> AdjReplyList;
00209 typedef MSA::MSA1D<AdjReplyList, DefaultListEntry<AdjReplyList,true>, MSA_DEFAULT_ENTRIES_PER_PAGE> MSA1DREPLYLIST;
00210
00212 void CreateAdaptAdjacencies(int meshid, int elemType);
00213
00214
00215 adaptAdj* lookupAdaptAdjacencies(
00216 const FEM_Mesh* const mesh,
00217 const int elemType,
00218 int* numAdjacencies);
00219 adaptAdj* lookupAdaptAdjacencies(
00220 const int meshid,
00221 const int elemType,
00222 int* numAdjacencies);
00223 CkVec<adaptAdj>** lookupEdgeAdaptAdjacencies(
00224 const FEM_Mesh* const mesh,
00225 const int elemType,
00226 int* numAdjacencies);
00227 CkVec<adaptAdj>** lookupEdgeAdaptAdjacencies(
00228 const int meshID,
00229 const int elemType,
00230 int* numAdjacencies);
00231
00232
00233
00234
00235 adaptAdj *getAdaptAdj(
00236 const int meshID,
00237 const int localID,
00238 const int elemType,
00239 const int edgeID);
00240 adaptAdj *getAdaptAdj(
00241 const FEM_Mesh* const meshPtr,
00242 const int localID,
00243 const int elemType,
00244 const int faceID);
00245 adaptAdj *getAdaptAdj(
00246 const int meshID,
00247 const int localID,
00248 const int elemType,
00249 const int* const vertexList);
00250
00251
00252 CkVec<adaptAdj>* getEdgeAdaptAdj(
00253 const int meshid,
00254 const int localID,
00255 const int elemType,
00256 const int edgeID);
00257 CkVec<adaptAdj>* getEdgeAdaptAdj(
00258 const FEM_Mesh* const meshPtr,
00259 const int localID,
00260 const int elemType,
00261 int edgeID);
00262 CkVec<adaptAdj>* getEdgeAdaptAdj(
00263 const int meshID,
00264 const int localID,
00265 const int elemType,
00266 const int* const vertexList);
00267
00268 adaptAdj* getFaceAdaptAdj(
00269 const int meshID,
00270 const int localID,
00271 const int elemType,
00272 int faceID);
00273 adaptAdj* getFaceAdaptAdj(
00274 const FEM_Mesh* const meshPtr,
00275 const int localID,
00276 const int elemType,
00277 int faceID);
00278 adaptAdj* getFaceAdaptAdj(
00279 const int meshID,
00280 const int localID,
00281 const int elemType,
00282 const int* const vertexList);
00283
00284
00285 void clearEdgeAdjacency(
00286 const FEM_Mesh* const meshPtr,
00287 const int localID,
00288 const int elemType,
00289 const int edgeID);
00290 void clearEdgeAdjacency(
00291 const int meshID,
00292 const int localID,
00293 const int elemType,
00294 const int edgeID);
00295 void addEdgeAdjacency(
00296 const FEM_Mesh* const meshPtr,
00297 const int localID,
00298 const int elemType,
00299 const int edgeID,
00300 const adaptAdj adj);
00301 void addEdgeAdjacency(
00302 const int meshID,
00303 const int localID,
00304 const int elemType,
00305 const int edgeID,
00306 const adaptAdj adj);
00307
00310 void GetVertices(int meshid, adaptAdj elem, int edgeFaceID, int *vertexList);
00311
00314 int getElemFace(
00315 const int meshID,
00316 const int type,
00317 const int* vertexList);
00318 int getElemEdge(
00319 const int meshID,
00320 const int type,
00321 const int* vertexList);
00322
00323
00326 void setAdaptAdj(
00327 const int meshid,
00328 const adaptAdj elem,
00329 const int faceID,
00330 const adaptAdj nbr);
00331
00332 void setAdaptAdj(
00333 const FEM_Mesh* meshPtr,
00334 const adaptAdj elem,
00335 const int faceID,
00336 const adaptAdj nbr);
00337
00340 void addToAdaptAdj(
00341 const int meshid,
00342 const adaptAdj elem,
00343 const int edgeID,
00344 const adaptAdj nbr);
00345 void addToAdaptAdj(
00346 const FEM_Mesh* meshPtr,
00347 const adaptAdj elem,
00348 const int edgeID,
00349 const adaptAdj nbr);
00352 void removeFromAdaptAdj(
00353 const int meshid,
00354 const adaptAdj elem,
00355 const int edgeID,
00356 const adaptAdj nbr);
00357
00360 void copyAdaptAdj(
00361 const int meshid,
00362 const adaptAdj* const srcElem,
00363 const adaptAdj* const destElem);
00364 void copyAdaptAdj(
00365 const FEM_Mesh* const meshPtr,
00366 const adaptAdj* const srcElem,
00367 const adaptAdj* const destElem);
00368
00369 void copyEdgeAdaptAdj(
00370 const int meshid,
00371 const adaptAdj* const srcElem,
00372 const adaptAdj* const destElem);
00373 void copyEdgeAdaptAdj(
00374 const FEM_Mesh* const meshPtr,
00375 const adaptAdj* const srcElem,
00376 const adaptAdj* const destElem);
00377
00378
00381 void replaceAdaptAdj(
00382 const int meshID,
00383 const adaptAdj elem,
00384 const adaptAdj originalNbr,
00385 const adaptAdj newNbr);
00386 void replaceAdaptAdj(
00387 const FEM_Mesh* const meshPtr,
00388 const adaptAdj elem,
00389 const adaptAdj originalNbr,
00390 const adaptAdj newNbr);
00393 void replaceAdaptAdjOnEdge(
00394 const int meshID,
00395 const adaptAdj elem,
00396 const adaptAdj originalNbr,
00397 const adaptAdj newNbr,
00398 const int edgeID);
00399 void replaceAdaptAdjOnEdge(
00400 const FEM_Mesh* const meshPtr,
00401 const adaptAdj elem,
00402 const adaptAdj originalNbr,
00403 const adaptAdj newNbr,
00404 const int edgeID);
00405
00409 void guessElementShape(
00410 const int dim,
00411 const int nodesPerElem,
00412 int* faceSize,
00413 int *faceMapSize,
00414 int* edgeMapSize,
00415 int faceMap[MAX_ADJELEMS][MAX_FACE_SIZE],
00416 int edgeMap[MAX_EDGES][2]);
00417 void getAndDumpAdaptAdjacencies(
00418 const int meshid,
00419 const int numElems,
00420 const int elemType,
00421 const int myRank);
00422
00423 void fillLocalAdaptAdjacencies(
00424 const int numNodes,
00425 FEM_Node* node,
00426 adjNode* faceTable,
00427 adjNode* edgeTable,
00428 const int faceMapSize,
00429 const int edgeMapSize,
00430 adaptAdj* adaptFaceAdjacencies,
00431 CkVec<adaptAdj>** adaptEdgeAdjacencies,
00432 const int myRank,
00433 const int elemType);
00434
00435 void makeAdjacencyRequests(
00436 const int numNodes,
00437 FEM_Node* node,
00438 adjNode* adaptAdjTable,
00439 MSA1DREQLIST::Accum &requestTable,
00440 const int nodeSetSize,
00441 const int myRank,
00442 int elemType);
00443 void replyAdjacencyRequests(
00444 CkVec<adjRequest> *requests,
00445 MSA1DREPLYLIST::Accum &replyTable,
00446 FEM_Node* node,
00447 adjNode* adaptAdjTable,
00448 adaptAdj* adaptFaceAdjacencies,
00449 CkVec<adaptAdj>** adaptEdgeAdjacencies,
00450 const int nodeSetSize,
00451 const int numAdjElems,
00452 const int myRank,
00453 const int elemType,
00454 bool isEdgeRequest);
00455
00456 #endif