00001
00002
00003
00004 #ifndef __UIUC_CHARM_PRISMMESH_H
00005 #define __UIUC_CHARM_PRISMMESH_H
00006
00007 #include <stdio.h>
00008 #include "ckvector3d.h"
00009 #include <vector>
00010
00011 #define OSL_TETMESH_DEBUG 0
00012
00013
00014 class PrismMesh {
00015 public:
00016 enum {nodePer=6};
00017
00019 class conn_t {
00020 public:
00021 int nodes[PrismMesh::nodePer];
00022 conn_t() {nodes[0]=-1;}
00023 conn_t(int a,int b,int c,int d, int e, int f)
00024 {nodes[0]=a; nodes[1]=b; nodes[2]=c; nodes[3]=d;nodes[4]=e;nodes[5]=f;}
00025 };
00026
00028 PrismMesh() { }
00030 PrismMesh(int nt,int np) { allocate(nt,np); }
00031 virtual ~PrismMesh() { }
00032
00034 virtual void allocate(int nt,int np) {
00035 prism.resize(nt);
00036 pts.resize(np);
00037 }
00038
00040 inline int getPrisms(void) const {return prism.size();}
00042 inline int *getPrism(int t) {return &(prism[t].nodes[0]);}
00043 inline const int *getPrism(int t) const {return &(prism[t].nodes[0]);}
00044 inline int *getPrismConn(void) {return getPrism(0);}
00045 inline const int *getPrismConn(void) const {return getPrism(0);}
00046
00048 inline int getPoints(void) const {return pts.size();}
00050 inline CkVector3d &getPoint(int p) {return pts[p];}
00051 inline const CkVector3d &getPoint(int p) const {return pts[p];}
00052 CkVector3d *getPointArray(void);
00053 const CkVector3d *getPointArray(void) const;
00054
00055 void cleanup() {
00056 pts.erase(pts.begin(), pts.end());
00057 std::vector<CkVector3d>(pts).swap(pts);
00058 prism.erase(prism.begin(), prism.end());
00059 std::vector<conn_t>(prism).swap(prism);
00060 }
00061
00063 int addPrism(const conn_t &c) {prism.push_back(c); nonGhostPrism++; return prism.size()-1;}
00064 int addPoint(const CkVector3d &pt) {pts.push_back(pt); nonGhostPt++; return pts.size()-1;}
00065
00066 int nonGhostPrism, nonGhostPt;
00067 void writeToTecplot(char *fname) {
00068 FILE *file = fopen(fname, "w");
00069
00070 fprintf (file, "TITLE=\"%s\"\n", fname);
00071 fprintf (file, "ZONE N=%d E=%d ET=BRICK F=FEPOINT\n",
00072 pts.size(), prism.size());
00073
00074 int i,n;
00075 n=pts.size();
00076 for (i=0; i<n; ++i) {
00077 fprintf(file,"%lf %lf %lf\n",pts[i][0],pts[i][1],pts[i][2]);
00078 }
00079
00080 n=prism.size();
00081 for (i=0; i<n; ++i) {
00082 fprintf(file,"%d %d %d %d %d %d %d %d\n", prism[i].nodes[0]+1,
00083 prism[i].nodes[1]+1, prism[i].nodes[2]+1, prism[i].nodes[2]+1,
00084 prism[i].nodes[3]+1, prism[i].nodes[4]+1, prism[i].nodes[5]+1,
00085 prism[i].nodes[5]+1);
00086 }
00087 fclose(file);
00088 }
00089
00090
00091 private:
00092 std::vector<conn_t> prism;
00093 std::vector<CkVector3d> pts;
00094 };
00095 #endif