7 #include "refine.decl.h"
11 int pending
, newNodeIdx
;
15 int incidentNode
, fixNode
;
17 edgeRef newEdgeRef
; // half of this edge: from newNode to incidentNode
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();
35 for (int i
=0; i
<2; i
++) elements
[i
] = e
.elements
[i
];
37 newNodeIdx
= e
.newNodeIdx
;
39 waitingFor
= e
.waitingFor
;
41 incidentNode
= e
.incidentNode
;
43 newEdgeRef
= e
.newEdgeRef
;
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
;}
60 edge
& operator=(const edge
& e
) {
61 for (int i
=0; i
<2; i
++) elements
[i
] = e
.elements
[i
];
63 newNodeIdx
= e
.newNodeIdx
;
65 waitingFor
= e
.waitingFor
;
67 incidentNode
= e
.incidentNode
;
69 newEdgeRef
= e
.newEdgeRef
;
72 boundary
= e
.boundary
;
73 nodes
[0] = e
.nodes
[0];
74 nodes
[1] = e
.nodes
[1];
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));
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
,
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
;
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
);