76 int nBadVol=0, nBadFace=0;
77 double minVolRatio=1.0;
79 CkSample edgeStats, volumeStats, volRatioStats, faceRatioStats;
84 enum {nCorners=8,nEdges=12,nFaces=6};
92 for (k=0;k<2;k++)
for (j=0;j<2;j++)
for (i=0;i<2;i++)
100 double minEdge=1.0e30;
103 const static int edges[nEdges][2]={
104 {0,1}, {1,3}, {3,2}, {2,0},
105 {4,5}, {5,7}, {7,6}, {6,4},
106 {0,4}, {1,5}, {3,7}, {2,6}
108 for (e=0;e<nEdges;e++) {
109 double l=c[edges[e][0]].
dist(c[edges[e][1]]);
110 if (l<minEdge) minEdge=l;
115 const static int faces[nFaces][4]={
116 {0,4,6,2}, {1,3,7,5},
117 {0,1,5,4}, {2,6,7,3},
122 for (f=0;f<nFaces;f++)
124 vector3d diagA=c[faces[f][2]]-c[faces[f][0]];
125 vector3d diagB=c[faces[f][3]]-c[faces[f][1]];
126 normals[f]=0.5*diagA.
cross(diagB);
127 center[f]=0.25*(c[faces[f][0]]+c[faces[f][1]]+
128 c[faces[f][2]]+c[faces[f][3]]);
133 normals[0]+normals[1]+
134 normals[2]+normals[3]+
135 normals[4]+normals[5];
136 double faceRatio=faceVecSum.
max()/(minEdge*minEdge);
144 for (f=0;f<nFaces;f++)
145 volume+=(1.0/3.0)*normals[f].dot(center[f]);
147 double volRatio=volume/(minEdge*minEdge*minEdge);
150 if (volRatio<minVolRatio) {
151 minVolRatio=volRatio;
157 faceRatioStats.
add(faceRatio);
158 volumeStats.
add(volume);
159 volRatioStats.
add(volRatio);
165 printf(
" volume ratio (fullness): "); volRatioStats.
printMinAveMax(stdout);
166 printf(
" face ratio (skewness): "); faceRatioStats.
printMinAveMax(stdout);
169 printf(
"WARNING: detected %d bad-volume cells in original block %d: \n"
170 " the worst of which is cell (%d,%d,%d), with ratio %.3f\n",
172 1+aBadVol[0],1+aBadVol[1],1+aBadVol[2], minVolRatio);
CkSampleT represents a statistical "sample" of some data values.
int getOriginalNumber(void) const
vector3d cross(const vector3d &b) const
real dist(const vector3d &b) const
void printMinAveMax(FILE *dest)
Print a terse textual description of this sample to this FILE.
#define BLOCKSPAN_FOR(i, span)
int volume(const block *b)
void checkQuality(const block &b)
const blockDim & getDim(void) const
void add(real r)
Add this value to the sample set.
const vector3d & getLoc(const blockLoc &l) const