00001
00002 #ifndef ELEMENT_H
00003 #define ELEMENT_H
00004
00005 #include <vector.h>
00006 #include "ref.h"
00007 #include "PMAF.decl.h"
00008
00009 extern CProxy_chunk mesh;
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class element {
00029 double targetVolume, currentVolume;
00030 elemRef myRef;
00031 chunk *C;
00032 public:
00033 int present;
00034 nodeRef nodes[4];
00035 elemRef faceElements[4];
00036 element() { targetVolume = currentVolume = -1.0; present = 1; C = NULL; }
00037 element(nodeRef *n) {
00038 targetVolume=currentVolume=-1.0; present = 1; C = NULL; set(n);
00039 }
00040 void set(int cid, int idx, chunk *cptr) { myRef.set(cid, idx); C = cptr; }
00041 void set(nodeRef *n) { for (int i=0; i<4; i++) nodes[i] = n[i]; }
00042 void update(nodeRef& oldval, nodeRef& newval);
00043 int hasNode(nodeRef n);
00044 int hasNode(node n);
00045 int hasNodes(nodeRef n1, nodeRef n2, nodeRef n3);
00046 int hasNodes(double nodeCoords[3][3]);
00047 elemRef getFace(int face[3]) {
00048 return(faceElements[face[0]+face[1]+face[2]-3]);
00049 }
00050 elemRef getFace(int a, int b, int c) { return(faceElements[a+b+c-3]); }
00051 void setFace(int a, int b, int c, elemRef er) { faceElements[a+b+c-3] = er; }
00052 void setFace(int idx, elemRef er) { faceElements[idx] = er; }
00053 int hasFace(elemRef face);
00054 int checkFace(node n1, node n2, node n3, elemRef nbr);
00055 void updateFace(int cid, int idx) {
00056 faceElements[0].cid = cid; faceElements[0].idx = idx;
00057 }
00058 void updateFace(elemRef oldElem, elemRef newElem) {
00059 for (int i=0; i<4; i++)
00060 if (faceElements[i] == oldElem) {
00061 faceElements[i] = newElem;
00062 return;
00063 }
00064 }
00065 nodeRef& getNode(int nodeIdx) { return nodes[nodeIdx]; }
00066 int getNodeIdx(nodeRef n);
00067 int getNode(node n);
00068 elemRef& getMyRef() { return myRef; }
00069 void clear() { present = 0; }
00070 int isPresent() { return present; }
00071 double getVolume();
00072 void calculateVolume();
00073 double getArea(int n1, int n2, int n3);
00074 void resetTargetVolume(double volume) { targetVolume = volume; }
00075 void setTargetVolume(double volume);
00076 double getTargetVolume() { return targetVolume; }
00077 double getCachedVolume() { return currentVolume; }
00078 double findLongestEdge(int *le1, int *le2, int *nl1, int *nl2);
00079
00080
00081 void flip23(int face[3]);
00082 flip23response *flip23remote(flip23request *fr);
00083
00084 void flip32(int edge[2]);
00085 flip32response *flip32remote(flip32request *fr);
00086 flip32response *remove32element(flip32request *fr);
00087
00088
00089 int test23(int face[3]);
00090
00091
00092 int test32(int edge[2]);
00093 int connectTest();
00094
00095
00096
00097 void refineLF();
00098 int lockLF(node n1, node n2, node n3, node n4, elemRef requester,
00099 double prio);
00100 splitResponse *element::splitLF(node in1, node in2, node in3, node in4,
00101 elemRef requester);
00102
00103 void refineLE();
00104 LEsplitResult *LEsplit(elemRef root, elemRef parent, nodeRef newNodeRef,
00105 node newNode, elemRef newRootElem, elemRef newElem,
00106 elemRef targetElem, double targetVol,
00107 node aIn, node bIn);
00108 lockResult *lockArc(elemRef prioRef, elemRef parentRef, double prio,
00109 elemRef destRef, node aNode, node bNode);
00110 void unlockArc1(int prio, elemRef parentRef, elemRef destRef, node aNode,
00111 node bNode);
00112 void unlockArc2(int prio, elemRef parentRef, elemRef destRef, node aNode,
00113 node bNode);
00114
00115 void refineCP();
00116
00117
00118
00119 void coarsen();
00120
00121
00122 void improveElement();
00123 void improveInternalNode(int n);
00124 void improveSurfaceNode(int n);
00125 void improveSurfaceNodeHelp(int n, int ot1, int ot2);
00126
00127
00128 int LEtest();
00129 int LFtest();
00130 int CPtest();
00131 };
00132
00133 #endif