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     
00131         adjElem *adjElemList;     
00132         adjNode() { 
00133             sharedWithPartition = NULL;
00134             adjElemList = new adjElem(0); 
00135                                           
00136             adjElemList->elemID = -1;
00137             adjElemList->next = NULL;
00138             adjElemCount = 0; 
00139             numSharedPartitions=0;
00140         }
00141         ~adjNode() { 
00142             
00143             
00144         }
00145 };
00146 
00147 class adjRequest{
00148  public:
00149   int elemID,chunkID,elemType,nodeSetID;
00150   int translatedNodeSet[MAX_NODESET_SIZE];
00151  adjRequest():
00152   elemID(-1), 
00153     chunkID(-1), 
00154     elemType(-1){};
00155  adjRequest(int _elemID,int _chunkID,int _nodeSetID,int _elemType ): 
00156   elemID(_elemID),
00157     chunkID(_chunkID),
00158     elemType(_elemType),
00159     nodeSetID(_nodeSetID) {};
00160   adjRequest(const adjRequest &rhs){
00161     *this = rhs;
00162   }
00163   inline adjRequest& operator=(const adjRequest &rhs) {
00164     elemID = rhs.elemID;
00165     chunkID = rhs.chunkID;
00166     elemType = rhs.elemType;
00167     nodeSetID = rhs.nodeSetID;
00168     memcpy(&translatedNodeSet[0],&(rhs.translatedNodeSet[0]),
00169        MAX_NODESET_SIZE*sizeof(int));
00170     return *this;
00171   }
00172   void pup(PUP::er &p){
00173     p | elemID;
00174     p | chunkID;
00175     p | elemType;
00176     p | nodeSetID;
00177     p(translatedNodeSet,MAX_NODESET_SIZE);
00178   }
00179 };
00180 
00181 class adjReply {
00182  public:
00183   int requestingElemID,requestingNodeSetID;
00184   adaptAdj replyingElem;
00185  adjReply(): 
00186   requestingElemID(-1),
00187     requestingNodeSetID(-1), 
00188     replyingElem(){};
00189   adjReply(const adjReply &rhs){
00190     *this = rhs;
00191   }
00192   inline adjReply& operator=(const adjReply &rhs){
00193     requestingElemID = rhs.requestingElemID;
00194     requestingNodeSetID = rhs.requestingNodeSetID;
00195     replyingElem = rhs.replyingElem;
00196     return *this;
00197   }
00198   void pup(PUP::er &p){
00199     p | requestingElemID;
00200     p | requestingNodeSetID;
00201     replyingElem.pup(p);
00202   }
00203 };
00204 
00205 
00206 typedef ElemList<adjRequest> AdjRequestList;
00207 typedef MSA::MSA1D<AdjRequestList, DefaultListEntry<AdjRequestList,true>,MSA_DEFAULT_ENTRIES_PER_PAGE> MSA1DREQLIST;
00208 
00209 typedef ElemList<adjReply> AdjReplyList;
00210 typedef MSA::MSA1D<AdjReplyList, DefaultListEntry<AdjReplyList,true>, MSA_DEFAULT_ENTRIES_PER_PAGE> MSA1DREPLYLIST;
00211 
00213 void CreateAdaptAdjacencies(int meshid, int elemType);
00214 
00215 
00216 adaptAdj* lookupAdaptAdjacencies(
00217         const FEM_Mesh* const mesh,
00218         const int elemType,
00219         int* numAdjacencies);
00220 adaptAdj* lookupAdaptAdjacencies(
00221         const int meshid,
00222         const int elemType,
00223         int* numAdjacencies);
00224 CkVec<adaptAdj>** lookupEdgeAdaptAdjacencies(
00225         const FEM_Mesh* const mesh,
00226         const int elemType,
00227         int* numAdjacencies);
00228 CkVec<adaptAdj>** lookupEdgeAdaptAdjacencies(
00229         const int meshID,
00230         const int elemType,
00231         int* numAdjacencies);
00232 
00233 
00234 
00235 
00236 adaptAdj *getAdaptAdj(
00237         const int meshID, 
00238         const int localID, 
00239         const int elemType,
00240         const int edgeID);
00241 adaptAdj *getAdaptAdj(
00242         const FEM_Mesh* const meshPtr, 
00243         const int localID,
00244         const int elemType, 
00245         const int faceID);
00246 adaptAdj *getAdaptAdj(
00247         const int meshID, 
00248         const int localID,
00249         const int elemType, 
00250         const int* const vertexList);
00251 
00252 
00253 CkVec<adaptAdj>* getEdgeAdaptAdj(
00254         const int meshid, 
00255         const int localID,
00256         const int elemType,
00257         const int edgeID);
00258 CkVec<adaptAdj>* getEdgeAdaptAdj(
00259         const FEM_Mesh* const meshPtr, 
00260         const int localID,
00261         const int elemType,
00262         int edgeID);
00263 CkVec<adaptAdj>* getEdgeAdaptAdj(
00264         const int meshID, 
00265         const int localID,
00266         const int elemType, 
00267         const int* const vertexList);
00268 
00269 adaptAdj* getFaceAdaptAdj(
00270         const int meshID,
00271         const int localID,
00272         const int elemType, 
00273         int faceID);
00274 adaptAdj* getFaceAdaptAdj(
00275         const FEM_Mesh* const meshPtr,
00276         const int localID,
00277         const int elemType,
00278         int faceID);
00279 adaptAdj* getFaceAdaptAdj(
00280         const int meshID, 
00281         const int localID,
00282         const int elemType, 
00283         const int* const vertexList);
00284 
00285 
00286 void clearEdgeAdjacency(
00287         const FEM_Mesh* const meshPtr,
00288         const int localID,
00289         const int elemType,
00290         const int edgeID);
00291 void clearEdgeAdjacency(
00292         const int meshID,
00293         const int localID,
00294         const int elemType,
00295         const int edgeID);
00296 void addEdgeAdjacency(
00297         const FEM_Mesh* const meshPtr,
00298         const int localID,
00299         const int elemType,
00300         const int edgeID,
00301         const adaptAdj adj);
00302 void addEdgeAdjacency(
00303         const int meshID,
00304         const int localID,
00305         const int elemType,
00306         const int edgeID,
00307         const adaptAdj adj);
00308 
00311 void GetVertices(int meshid, adaptAdj elem, int edgeFaceID, int *vertexList);
00312 
00315 int getElemFace(
00316         const int meshID, 
00317         const int type, 
00318         const int* vertexList);
00319 int getElemEdge(
00320         const int meshID, 
00321         const int type, 
00322         const int* vertexList);
00323 
00324 
00327 void setAdaptAdj(
00328         const int meshid, 
00329         const adaptAdj elem, 
00330         const int faceID, 
00331         const adaptAdj nbr);
00332 
00333 void setAdaptAdj(
00334         const FEM_Mesh* meshPtr, 
00335         const adaptAdj elem, 
00336         const int faceID, 
00337         const adaptAdj nbr);
00338 
00341 void addToAdaptAdj(
00342         const int meshid, 
00343         const adaptAdj elem, 
00344         const int edgeID, 
00345         const adaptAdj nbr);
00346 void addToAdaptAdj(
00347         const FEM_Mesh* meshPtr, 
00348         const adaptAdj elem, 
00349         const int edgeID, 
00350         const adaptAdj nbr);
00353 void removeFromAdaptAdj(
00354         const int meshid, 
00355         const adaptAdj elem, 
00356         const int edgeID, 
00357         const adaptAdj nbr);
00358 
00361 void copyAdaptAdj(
00362         const int meshid, 
00363         const adaptAdj* const srcElem, 
00364         const adaptAdj* const destElem);
00365 void copyAdaptAdj(
00366         const FEM_Mesh* const meshPtr, 
00367         const adaptAdj* const srcElem, 
00368         const adaptAdj* const destElem);
00369 
00370 void copyEdgeAdaptAdj(
00371         const int meshid, 
00372         const adaptAdj* const srcElem, 
00373         const adaptAdj* const destElem);
00374 void copyEdgeAdaptAdj(
00375         const FEM_Mesh* const meshPtr, 
00376         const adaptAdj* const srcElem, 
00377         const adaptAdj* const destElem);
00378 
00379 
00382 void replaceAdaptAdj(
00383         const int meshID, 
00384         const adaptAdj elem, 
00385         const adaptAdj originalNbr, 
00386         const adaptAdj newNbr);
00387 void replaceAdaptAdj(
00388         const FEM_Mesh* const meshPtr, 
00389         const adaptAdj elem, 
00390         const adaptAdj originalNbr,
00391         const adaptAdj newNbr);
00394 void replaceAdaptAdjOnEdge(
00395         const int meshID, 
00396         const adaptAdj elem, 
00397         const adaptAdj originalNbr, 
00398         const adaptAdj newNbr,
00399         const int edgeID);
00400 void replaceAdaptAdjOnEdge(
00401         const FEM_Mesh* const meshPtr, 
00402         const adaptAdj elem, 
00403         const adaptAdj originalNbr, 
00404         const adaptAdj newNbr,
00405         const int edgeID);
00406 
00410 void guessElementShape(
00411         const int dim,
00412         const int nodesPerElem,
00413         int* faceSize, 
00414         int *faceMapSize, 
00415         int* edgeMapSize,
00416         int faceMap[MAX_ADJELEMS][MAX_FACE_SIZE],
00417         int edgeMap[MAX_EDGES][2]);
00418 void getAndDumpAdaptAdjacencies(
00419         const int meshid, 
00420         const int numElems, 
00421         const int elemType, 
00422         const int myRank);
00423 
00424 void fillLocalAdaptAdjacencies(
00425         const int numNodes, 
00426         FEM_Node* node, 
00427         adjNode* faceTable, 
00428         adjNode* edgeTable, 
00429         const int faceMapSize,
00430         const int edgeMapSize,
00431         adaptAdj* adaptFaceAdjacencies,
00432         CkVec<adaptAdj>** adaptEdgeAdjacencies, 
00433         const int myRank, 
00434         const int elemType);
00435 
00436 void makeAdjacencyRequests(
00437         const int numNodes, 
00438         FEM_Node* node, 
00439         adjNode* adaptAdjTable,
00440         MSA1DREQLIST::Accum &requestTable, 
00441         const int nodeSetSize, 
00442         const int myRank,
00443         int elemType);
00444 void replyAdjacencyRequests(
00445         CkVec<adjRequest> *requests, 
00446         MSA1DREPLYLIST::Accum &replyTable,
00447         FEM_Node* node, 
00448         adjNode* adaptAdjTable, 
00449         adaptAdj* adaptFaceAdjacencies, 
00450         CkVec<adaptAdj>** adaptEdgeAdjacencies, 
00451         const int nodeSetSize,
00452         const int numAdjElems, 
00453         const int myRank, 
00454         const int elemType,
00455         bool isEdgeRequest);
00456 
00457 #endif