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 #ifndef _FEM_REF_
00028 #define _FEM_REF_
00029 
00030 #include "tcharm.h"
00031 #include "charm++.h"
00032 #include "charm-api.h"
00033 #include "cklists.h"
00034 #include "mpi.h"
00035 #include "fem_mesh.h"
00036 #include "fem_adapt_new.h"
00037 #include "fem_adapt_lock.h"
00038 #include "fem_adapt_algs.h"
00039 #include "fem_interpolate.h"
00040 #include "fem_lock.h"
00041 #include "fem_lock_node.h"
00042 #include "fem_util.h"
00043 #include "idxl.h"
00044 #include "FEMMeshModify.decl.h"
00045 
00046 extern CProxy_femMeshModify meshMod;
00047 
00048 #define MAX_CHUNK 1000000000
00049 
00050 
00051 
00052 int FEM_add_node(FEM_Mesh *m, int* adjacent_nodes=0, int num_adjacent_nodes=0, int *chunks=0, int numChunks=0, int forceShared=0, int upcall=0);
00053 void FEM_remove_node(FEM_Mesh *m, int node);
00054 int FEM_remove_element(FEM_Mesh *m, int element, int elem_type=0, int permanent=-1);
00055 int FEM_purge_element(FEM_Mesh *m, int element, int elem_type=0);
00056 int FEM_add_element(FEM_Mesh *m, int* conn, int conn_size, int elem_type=0, int chunkNo=-1);
00057 int FEM_Modify_Lock(FEM_Mesh *m, int* affectedNodes=0, int numAffectedNodes=0, int* affectedElts=0, int numAffectedElts=0, int elemtype=0);
00058 int FEM_Modify_Unlock(FEM_Mesh *m);
00059 int FEM_Modify_LockN(FEM_Mesh *m, int nodeId, int readLock);
00060 int FEM_Modify_UnlockN(FEM_Mesh *m, int nodeId, int readLock);
00061 void FEM_Modify_LockAll(FEM_Mesh*m, int nodeId, bool lockall=true);
00062 void FEM_Modify_LockUpdate(FEM_Mesh*m, int nodeId, bool lockall=true);
00063 void FEM_Modify_correctLockN(FEM_Mesh *m, int nodeId);
00064 
00065 
00066 int FEM_add_node_local(FEM_Mesh *m, int addGhost=0);
00067 void FEM_remove_node_local(FEM_Mesh *m, int node);
00068 int FEM_add_element_local(FEM_Mesh *m, const int *conn, int connSize, int elemType, int addGhost);
00069 void FEM_remove_element_local(FEM_Mesh *m, int element, int etype);
00070 
00071 void FEM_Ghost_Essential_attributes(FEM_Mesh *m, int coord_attr, int bc_attr, int nodeid);
00072 
00073 void FEM_Mesh_dataP(FEM_Mesh *fem_mesh,int entity,int attr,void *data, int firstItem, int length, int datatype,int width);
00074 void FEM_Mesh_data_layoutP(FEM_Mesh *fem_mesh,int entity,int attr,void *data, int firstItem, int length, IDXL_Layout_t layout);
00075 void FEM_Mesh_data_layoutP(FEM_Mesh *fem_mesh,int entity,int attr,void *data, int firstItem,int length, const IDXL_Layout &layout);
00076 
00077 
00078 class femMeshModMsg : public CMessage_femMeshModMsg {
00079  public:
00080   int numChunks;
00081   int myChunk;
00082 
00083   femMeshModMsg() {}
00084   
00085   femMeshModMsg(int num, int idx) {
00086     numChunks = num;
00087     myChunk = idx;
00088   }
00089   
00090   ~femMeshModMsg() {}
00091 };
00092 
00093 class boolMsg : public CMessage_boolMsg {
00094  public:
00095   bool b;
00096 
00097   boolMsg(bool bo) {
00098     b = bo;
00099   }
00100 
00101   ~boolMsg() {}
00102 };
00103 
00104 class intMsg : public CMessage_intMsg {
00105  public:
00106   int i;
00107 
00108   intMsg(int n) {
00109     i = n;
00110   }
00111 
00112   ~intMsg(){}
00113 };
00114 
00115 class int2Msg : public CMessage_int2Msg {
00116  public:
00117   int i, j;
00118 
00119   int2Msg(int m, int n) {
00120     i = m;
00121     j = n;
00122   }
00123 
00124   ~int2Msg(){}
00125 };
00126 
00127 class double2Msg : public CMessage_double2Msg {
00128  public:
00129   double i,j;
00130 
00131   double2Msg(double m, double n) {
00132     i = m;
00133     j = n;
00134   }
00135 
00136   ~double2Msg() {}
00137 };
00138 
00139 class FEMMeshMsg : public CMessage_FEMMeshMsg {
00140  public:
00141   FEM_Mesh *m;
00142   int dimn;
00143 
00144   FEMMeshMsg(FEM_Mesh *mh, int dim) {
00145     m = mh;
00146     dimn = dim;
00147   }
00148 
00149   ~FEMMeshMsg() {}
00150 };
00151 
00152 class addNodeMsg : public CMessage_addNodeMsg {
00153  public:
00154   int chk;
00155   int nBetween;
00156   int *between;
00157   int *chunks;
00158   int numChunks;
00159   int forceShared;
00160   int upcall;
00161 
00162   ~addNodeMsg() {
00163     if(between) {
00164       
00165       
00166     }
00167   }
00168 };
00169 
00170 class sharedNodeMsg : public CMessage_sharedNodeMsg {
00171  public:
00172   int chk;
00173   int nBetween;
00174   int *between;
00175 
00176   
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185   ~sharedNodeMsg() {
00186     
00187     
00188     
00189   }
00190 };
00191 
00192 class removeSharedNodeMsg : public CMessage_removeSharedNodeMsg {
00193  public:
00194   int chk;
00195   int index;
00196 };
00197 
00198 class addGhostElemMsg : public CMessage_addGhostElemMsg {
00199  public:
00200   int chk;
00201   int elemType;
00202   int numGhostIndex;
00203   int *ghostIndices;
00204   int numSharedIndex;
00205   int *sharedIndices;
00206   int connSize;
00207 
00208   ~addGhostElemMsg() {
00209     if(ghostIndices) {
00210       
00211     }
00212     if(sharedIndices) {
00213       
00214     }
00215   }
00216 };
00217 
00218 class chunkListMsg : public CMessage_chunkListMsg {
00219  public:
00220   int numChunkList;
00221   int *chunkList;
00222   int *indexList;
00223 
00224   ~chunkListMsg() {
00225     if(numChunkList>0) {
00226       
00227       
00228     }
00229   }
00230 };
00231 
00232 class addElemMsg : public CMessage_addElemMsg {
00233  public:
00234   int chk;
00235   int elemtype;
00236   int connSize;
00237   int *conn;
00238   int numGhostIndex;
00239   int *ghostIndices;
00240 
00241   ~addElemMsg() {
00242     if(conn) {
00243       
00244     }
00245     if(ghostIndices) {
00246       
00247     }
00248   }
00249 };
00250 
00251 class removeGhostElemMsg : public CMessage_removeGhostElemMsg {
00252  public:
00253   int chk;
00254   int elemtype;
00255   int elementid;
00256   int numGhostIndex;
00257   int numGhostRNIndex;
00258   int numGhostREIndex;
00259   int numSharedIndex;
00260   int *ghostIndices;
00261   int *ghostRNIndices;
00262   int *ghostREIndices;
00263   int *sharedIndices;
00264 
00265   ~removeGhostElemMsg() {
00266     if(ghostIndices) {
00267       
00268       
00269       
00270       
00271     }
00272   }
00273 };
00274 
00275 class removeElemMsg : public CMessage_removeElemMsg {
00276  public:
00277   int chk;
00278   int elementid;
00279   int elemtype;
00280   int permanent;
00281 };
00282 
00283 class verifyghostsendMsg : public CMessage_verifyghostsendMsg {
00284  public:
00285   int fromChk;
00286   int sharedIdx;
00287   int numchks;
00288   int *chunks;
00289   
00290   ~verifyghostsendMsg() {
00291   }
00292 };
00293 
00294 class findgsMsg : public CMessage_findgsMsg {
00295  public:
00296   int numchks;
00297   int *chunks;
00298   
00299   ~findgsMsg() {
00300   }
00301 };
00302 
00303 class elemDataMsg : public CMessage_elemDataMsg {
00304  public:
00305   int datasize;
00306   char *data;
00307 
00308   elemDataMsg(int size) {
00309     datasize = size;
00310   }
00311 };
00312 
00313 class femMeshModify : public CBase_femMeshModify {
00314   friend class FEM_lock;
00315   friend class FEM_MUtil;
00316   friend class FEM_Mesh;
00317   friend class FEM_Interpolate;
00318   friend class FEM_Adapt;
00319   friend class FEM_AdaptL;
00320   friend class FEM_Adapt_Algs;
00321 
00322  public:
00323   int numChunks;
00324   int idx;
00325   FEM_Mesh *fmMesh;
00326   FEM_lock *fmLock;
00327   CkVec<FEM_lockN *> fmLockN;
00328   
00329   CkVec<bool> fmIdxlLock; 
00330   CkVec<int> fmfixedNodes; 
00331   FEM_MUtil *fmUtil;
00332   FEM_Interpolate *fmInp;
00333   FEM_Adapt *fmAdapt;
00334   FEM_AdaptL *fmAdaptL;
00335   FEM_Adapt_Algs *fmAdaptAlgs;
00336 
00337  public:
00338   femMeshModify(femMeshModMsg *fm);
00339   femMeshModify(CkMigrateMessage *m){};
00340   ~femMeshModify();
00341 
00342   intMsg *lockRemoteChunk(int2Msg *i2msg);
00343   intMsg *unlockRemoteChunk(int2Msg *i2msg);
00344   intMsg *lockRemoteNode(int sharedIdx, int fromChk, int isGhost, int readLock);
00345   intMsg *unlockRemoteNode(int sharedIdx, int fromChk, int isGhost, int readLock);
00346   void setFemMesh(FEMMeshMsg *fm);
00347   int getNumChunks(){return numChunks;}
00348   int getIdx(){return idx;}
00349   FEM_Mesh *getfmMesh(){return fmMesh;}
00350   FEM_lock *getfmLock(){return fmLock;}
00351   FEM_lockN *getfmLockN(int nodeid){
00352     
00353 
00354 
00355 
00356 
00357     CkAssert(nodeid < fmLockN.size());
00358     return fmLockN[nodeid];
00359   }
00360   FEM_MUtil *getfmUtil(){return fmUtil;}
00361   FEM_Adapt *getfmAdapt(){return fmAdapt;}
00362   FEM_AdaptL *getfmAdaptL(){return fmAdaptL;}
00363   FEM_Adapt_Algs *getfmAdaptAlgs(){return fmAdaptAlgs;}
00364   FEM_Interpolate *getfmInp(){return fmInp;}
00365 
00366   intMsg *addNodeRemote(addNodeMsg *fm);
00367   void addSharedNodeRemote(sharedNodeMsg *fm);
00368   void removeSharedNodeRemote(removeSharedNodeMsg *fm);
00369 
00370   void addGhostElem(addGhostElemMsg *fm);
00371   chunkListMsg *getChunksSharingGhostNode(int2Msg *);
00372   void addElementRemote(addElemMsg *fm);
00373 
00374   void removeGhostElem(removeGhostElemMsg *fm);
00375   void removeElementRemote(removeElemMsg *fm);
00376 
00377   void removeGhostNode(int fromChk, int sharedIdx);
00378 
00379   intMsg *eatIntoElement(int fromChk, int sharedIdx);
00380   intMsg *getLockOwner(int fromChk, int sharedIdx);
00381   boolMsg *knowsAbtNode(int fromChk, int toChk, int sharedIdx);
00382 
00383   void refine_flip_element_leb(int fromChk, int propElemT, int propNodeT,
00384                    int newNodeT, int nbrOpNodeT, int nbrghost,
00385                    double longEdgeLen);
00386 
00387   void addToSharedList(int fromChk, int sharedIdx);
00388   void updateNodeAttrs(int fromChk, int sharedIdx, double coordX, double coordY, int bound, bool isGhost);
00389   void updateghostsend(verifyghostsendMsg *vmsg);
00390   findgsMsg *findghostsend(int fromChk, int sharedIdx);
00391 
00392   double2Msg *getRemoteCoord(int fromChk, int ghostIdx);
00393   intMsg *getRemoteBound(int fromChk, int ghostIdx);
00394 
00395   intMsg *getIdxGhostSend(int fromChk, int idxshared, int toChk);
00396   void updateIdxlList(int fromChk, int idxTrans, int transChk);
00397   void removeIDXLRemote(int fromChk, int sharedIdx, int type);
00398   void addTransIDXLRemote(int fromChk, int sharedIdx, int type);
00399   void verifyIdxlList(int fromChk, int size, int type);
00400 
00401   void idxllockRemote(int fromChk, int type);
00402   void idxlunlockRemote(int fromChk, int type);
00403 
00404   intMsg *hasLockRemoteNode(int sharedIdx, int fromChk, int isGhost);
00405   void modifyLockAll(int fromChk, int sharedIdx);
00406   boolMsg *verifyLock(int fromChk, int sharedIdx, int isGhost);
00407   void verifyghostsend(verifyghostsendMsg *vmsg);
00408   boolMsg *shouldLoseGhost(int fromChk, int sharedIdx, int toChk);
00409 
00410   void addghostsendl(int fromChk, int sharedIdx, int toChk, int transIdx);
00411   void addghostsendl1(int fromChk, int transChk, int transIdx);
00412   void addghostsendr(int fromChk, int sharedIdx, int toChk, int transIdx);
00413   void addghostsendr1(int fromChk, int transChk, int transIdx);
00414   boolMsg *willItLose(int fromChk, int sharedIdx);
00415 
00416   void interpolateElemCopy(int fromChk, int sharedIdx1, int sharedIdx2);
00417   void cleanupIDXL(int fromChk, int sharedIdx);
00418   void purgeElement(int fromChk, int sharedIdx);
00419   elemDataMsg *packElemData(int fromChk, int sharedIdx);
00420 };
00421 
00422 
00423 #endif
00424