00001 #ifndef REF_H
00002 #define REF_H
00003 #include <charm++.h>
00004 #include "charm-api.h"
00005 #include "ckvector3d.h"
00006 #include "pup_mpi.h"
00007 #include "tcharm.h"
00008 #include "fem.h"
00009 #include "fem_mesh.h"
00010
00011
00012
00013
00014 class objRef {
00015 public:
00016 int cid, idx;
00017 objRef() { cid = -1; idx = -1; }
00018 objRef(int chunkId, int objIdx) { cid = chunkId; idx = objIdx; }
00019 void set(int chunkId, int objIdx) { cid = chunkId; idx = objIdx; }
00020 void reset() { cid = -1; idx = -1; }
00021 void pup(PUP::er &p) { p(cid); p(idx); }
00022 int isNull() { return ((cid == -1) && (idx == -1)); }
00023 bool operator==(const objRef& o) const {
00024 return((cid == o.cid) && (idx == o.idx)); }
00025 bool operator>(const objRef& o) const {
00026 return((idx > o.idx) || ((idx == o.idx) && (cid > o.cid))); }
00027 bool operator<(const objRef& o) const {
00028 return((idx < o.idx) || ((idx == o.idx) && (cid < o.cid))); }
00029 objRef& operator=(const objRef& o) { cid=o.cid; idx=o.idx; return *this; }
00030 void sanityCheck() { CkAssert((cid >= -1) && (idx >= -1)); }
00031 };
00032
00033 class node;
00034 class elemRef;
00035 class edgeRef : public objRef {
00036 public:
00037 edgeRef() { }
00038 edgeRef(int chunkId, int objIdx) { cid = chunkId; idx = objIdx; }
00039 void update(elemRef& oldval, elemRef& newval, int b);
00040 elemRef getNbr(elemRef m);
00041 void remove();
00042 int split(int *m, edgeRef *e_prime, int oIdx, int fIdx,
00043 elemRef requester, int *local, int *first, int *nullNbr);
00044 void collapse(elemRef requester, int kIdx, int dIdx, elemRef kNbr,
00045 elemRef dNbr, edgeRef kEdge, edgeRef dEdge, node newN,
00046 double frac);
00047 int flipPrevent(elemRef requester, int kIdx, int dIdx, elemRef kNbr,
00048 elemRef dNbr, edgeRef kEdge, edgeRef dEdge, node newN);
00049 void resetEdge();
00050 int isPending(elemRef e);
00051 int getBoundary();
00052 void checkPending(elemRef e);
00053 void checkPending(elemRef e, elemRef ne);
00054 };
00055
00056 class elemRef : public objRef {
00057 public:
00058 elemRef() { }
00059 elemRef(int chunkId, int objIdx) { cid = chunkId; idx = objIdx; }
00060 void update(edgeRef& oldval, edgeRef& newval);
00061 double getArea();
00062 void setTargetArea(double ta);
00063 void resetTargetArea(double ta);
00064 void remove();
00065
00066 };
00067
00068 static elemRef nullRef(-1,-1);
00069
00070 #endif