LRTS Comm Thread Tracing in message recieve
[charm.git] / src / libs / ck-libs / TMRC2D / edge.h
blobcc3cd0b3791ef18dd6f49c0d5a3dcb88b52d04cc
1 #ifndef EDGE_H
2 #define EDGE_H
4 #include "charm++.h"
5 #include "node.h"
6 #include "ref.h"
7 #include "refine.decl.h"
9 class edge {
10 public:
11 int pending, newNodeIdx;
12 double length;
13 elemRef waitingFor;
14 node newNode;
15 int incidentNode, fixNode;
16 int boundary;
17 edgeRef newEdgeRef; // half of this edge: from newNode to incidentNode
18 chunk *C;
19 edgeRef myRef;
20 elemRef elements[2]; // the elements on either side of the edge
21 int nodes[2]; // the nodes on either end of the edge on the edge's chunk
22 int present; // indicates this is an edge present in the mesh
23 edge() { unsetPending(); present = 0; }
24 edge(int idx, int cid, chunk *myChk) {
25 unsetPending(); myRef.set(cid, idx); C = myChk; present = 1;
26 nodes[0] = nodes[1] = -1;
28 edge(elemRef e1, elemRef e2, int p) {
29 elements[0] = e1; elements[1] = e2; pending = p;
31 edge(elemRef e1, elemRef e2) {
32 elements[0] = e1; elements[1] = e2; unsetPending();
34 edge(const edge& e) {
35 for (int i=0; i<2; i++) elements[i] = e.elements[i];
36 pending = e.pending;
37 newNodeIdx = e.newNodeIdx;
38 C = e.C;
39 waitingFor = e.waitingFor;
40 newNode = e.newNode;
41 incidentNode = e.incidentNode;
42 fixNode = e.fixNode;
43 newEdgeRef = e.newEdgeRef;
44 myRef = e.myRef;
45 present = e.present;
46 length = e.length;
47 boundary = e.boundary;
48 nodes[0] = e.nodes[0];
49 nodes[1] = e.nodes[1];
51 void set(int idx, int cid, chunk *myChk) {
52 unsetPending(); myRef.set(cid, idx); C = myChk; present = 1;
54 void set(elemRef e1, elemRef e2) { elements[0] = e1; elements[1] = e2; }
55 void set(elemRef *e) { elements[0] = e[0]; elements[1] = e[1]; }
56 void setNodes(int n1, int n2) { nodes[0] = n1; nodes[1] = n2; CkAssert(n1!=n2);}
57 void setBoundary(int b) { boundary = b;}
58 int getBoundary() { return boundary;}
59 void reset();
60 edge& operator=(const edge& e) {
61 for (int i=0; i<2; i++) elements[i] = e.elements[i];
62 pending = e.pending;
63 newNodeIdx = e.newNodeIdx;
64 C = e.C;
65 waitingFor = e.waitingFor;
66 newNode = e.newNode;
67 incidentNode = e.incidentNode;
68 fixNode = e.fixNode;
69 newEdgeRef = e.newEdgeRef;
70 myRef = e.myRef;
71 present = e.present;
72 boundary = e.boundary;
73 nodes[0] = e.nodes[0];
74 nodes[1] = e.nodes[1];
75 return *this;
77 int isPresent() { return present; }
78 void update(elemRef oldval, elemRef newval) {
79 CkAssert((elements[0] == oldval) || (elements[1] == oldval));
80 if (elements[0] == oldval) elements[0] = newval;
81 else /* (elements[1] == oldval) */ elements[1] = newval;
83 void updateNode(int oldval, int newval) {
84 CkAssert((nodes[0] == oldval) || (nodes[1] == oldval));
85 if (nodes[0] == oldval) nodes[0] = newval;
86 else /* (nodes[1] == oldval) */ nodes[1] = newval;
88 elemRef& getElement(int idx) {
89 CkAssert((idx==0) || (idx==1));
90 return elements[idx];
92 elemRef& getNot(elemRef er) {
93 CkAssert((elements[0] == er) || (elements[1] == er));
94 if (elements[0] == er) return elements[1];
95 else return elements[0];
97 void setPending() { pending = 1; }
98 void unsetPending() { pending = 0; }
99 int isPending(elemRef e);
100 void checkPending(elemRef e);
101 void checkPending(elemRef e, elemRef ne);
102 int split(int *m, edgeRef *e_prime, int oIdx, int fIdx,
103 elemRef requester, int *local, int *first, int *nullNbr);
104 void collapse(elemRef requester, int kIdx, int dIdx, elemRef kNbr,
105 elemRef dNbr, edgeRef kEdge, edgeRef dEdge, node newN,
106 double frac);
107 int flipPrevent(elemRef requester, int kIdx, int dIdx, elemRef kNbr,
108 elemRef dNbr, edgeRef kEdge, edgeRef dEdge, node newN);
109 int existsOn(FEM_Comm_Rec *cl, int chunkID) {
110 int count = cl->getShared();
111 for (int i=0; i<count; i++) {
112 if (chunkID == cl->getChk(i)) return i;
114 return -1;
116 void translateSharedNodeIDs(int *kIdx, int *dIdx, elemRef req);
117 void unlockCloudRemoveEdge(int dIdxlShared, int kIdxlShared,
118 FEM_Comm_Rec *dNodeRec, FEM_Comm_Rec *kNodeRec);
119 void localCollapse(int kIdx, int dIdx, elemRef *req, node *newNode,
120 double frac, elemRef *keepNbr, elemRef *delNbr,
121 edgeRef *kEdge, edgeRef *dEdge, int local, int first);
122 void updateCloud(int kIdx, int dIdx, node newNode, int *dIdxl, int *kIdxl,
123 FEM_Comm_Rec **dNodeRec, FEM_Comm_Rec **kNodeRec);
124 int buildLockingCloud(int kIdx, int dIdx, elemRef *req, elemRef *nbr);
125 void sanityCheck(chunk *c, edgeRef shouldRef);
126 void sanityCheck(int node1, int node2, int eIdx);
129 #endif