1 #ifndef __MESH_QUALITY__
2 #define __MESH_QUALITY__
160 for (
int a1=0; a1<DIM; a1++ )
161 for (
int a2=0; a2<DIM; a2++ )
164 Index Iv[3], &I1=Iv[0], &I2=Iv[1], &I3=Iv[2];
169 realArray & vertices = controlGrid[0].vertex();
173 ii[2] = I3.getBase();
175 dx[2] = dxa[2] = 0.0;
179 for ( axis=0; axis<DIM; axis++ )
181 controlBounds(0,axis) = vertices(I1.getBase(), I2.getBase(), I3.getBase(),axis);
182 controlBounds(1,axis) = vertices(I1.getBound(), I2.getBound(), I3.getBound(), axis);
183 dx[axis] = (controlBounds(1,axis) - controlBounds(0,axis))/
real(Iv[axis].getLength()-1);
184 ii[axis] = int( (midPt(axis)-controlBounds(0,axis))/dx[axis] );
188 for ( axis=0; axis<DIM; axis++ )
189 dxa[axis] = (midPt(axis) - vertices(ii[0],ii[1],ii[2],axis))/dx[axis];
194 for (
int ti=0; ti<DIM; ti++ )
195 for (
int tj=0; tj<DIM; tj++ )
196 T(ti,tj) = (( 1.0 -dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1],ii[2],ti,tj) +
197 ( dxa[0] ) * controlFunction[0](ii[0]+1,ii[1],ii[2],ti,tj) ) +
198 ( dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1]+1,ii[2],ti,tj) +
199 ( dxa[0] ) * controlFunction[0](ii[0]+1, ii[1]+1,ii[2],ti,tj) ) );
203 for (
int ti=0; ti<DIM; ti++ )
204 for (
int tj=0; tj<DIM; tj++ )
205 T(ti,tj) = ( (1.0-dxa[2])*( (( 1.0 -dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1],ii[2],ti,tj) +
206 ( dxa[0] ) * controlFunction[0](ii[0]+1,ii[1],ii[2],ti,tj) ) +
207 ( dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1]+1,ii[2],ti,tj) +
208 ( dxa[0] ) * controlFunction[0](ii[0]+1, ii[1]+1,ii[2],ti,tj) ) ) ) +
209 ( dxa[2])*( (( 1.0 -dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1],ii[2]+1,ti,tj) +
210 ( dxa[0] ) * controlFunction[0](ii[0]+1,ii[1],ii[2]+1,ti,tj) ) +
211 ( dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1]+1,ii[2]+1,ti,tj) +
212 ( dxa[0] ) * controlFunction[0](ii[0]+1, ii[1]+1,ii[2]+1,ti,tj) ) ) ));
225 for (
int a1=0; a1<DIM; a1++ )
226 for (
int a2=0; a2<DIM; a2++ )
229 Index Iv[3], &I1=Iv[0], &I2=Iv[1], &I3=Iv[2];
234 realArray & vertices = controlGrid[0].vertex();
238 ii[2] = I3.getBase();
240 dx[2] = dxa[2] = 0.0;
244 for ( axis=0; axis<DIM; axis++ )
246 controlBounds(0,axis) = vertices(I1.getBase(), I2.getBase(), I3.getBase(),axis);
247 controlBounds(1,axis) = vertices(I1.getBound(), I2.getBound(), I3.getBound(), axis);
248 dx[axis] = (controlBounds(1,axis) - controlBounds(0,axis))/
real(Iv[axis].getLength()-1);
249 ii[axis] =
min(Iv[axis].getBound(),
max(Iv[axis].getBase(),
int( (midPt(axis)-controlBounds(0,axis))/dx[axis] ) ));
253 for ( axis=0; axis<DIM; axis++ )
254 dxa[axis] = (midPt(axis) - vertices(ii[0],ii[1],ii[2],axis))/dx[axis];
256 for (
int ti=0; ti<DIM; ti++ )
257 for (
int tj=0; tj<DIM; tj++ )
258 T(ti,tj) = (( 1.0 -dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1],ii[2],ti,tj) +
259 ( dxa[0] ) * controlFunction[0](ii[0]+1,ii[1],ii[2],ti,tj) ) +
260 ( dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1]+1,ii[2],ti,tj) +
261 ( dxa[0] ) * controlFunction[0](ii[0]+1, ii[1]+1,ii[2],ti,tj) ) );
271 for (
int a1=0; a1<DIM; a1++ )
272 for (
int a2=0; a2<DIM; a2++ )
275 Index Iv[3], &I1=Iv[0], &I2=Iv[1], &I3=Iv[2];
280 realArray & vertices = controlGrid[0].vertex();
284 ii[2] = I3.getBase();
286 dx[2] = dxa[2] = 0.0;
290 for ( axis=0; axis<DIM; axis++ )
292 controlBounds(0,axis) = vertices(I1.getBase(), I2.getBase(), I3.getBase(),axis);
293 controlBounds(1,axis) = vertices(I1.getBound(), I2.getBound(), I3.getBound(), axis);
294 dx[axis] = (controlBounds(1,axis) - controlBounds(0,axis))/
real(Iv[axis].getLength()-1);
296 ii[axis] =
min(Iv[axis].getBound(),
max(Iv[axis].getBase(),
int( (midPt(axis)-controlBounds(0,axis))/dx[axis] ) ));
300 for ( axis=0; axis<DIM; axis++ )
301 dxa[axis] = (midPt(axis) - vertices(ii[0],ii[1],ii[2],axis))/dx[axis];
304 for (
int ti=0; ti<DIM; ti++ )
305 for (
int tj=0; tj<DIM; tj++ )
306 T(ti,tj) = ( (1.0-dxa[2])*( (( 1.0 -dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1],ii[2],ti,tj) +
307 ( dxa[0] ) * controlFunction[0](ii[0]+1,ii[1],ii[2],ti,tj) ) +
308 ( dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1]+1,ii[2],ti,tj) +
309 ( dxa[0] ) * controlFunction[0](ii[0]+1, ii[1]+1,ii[2],ti,tj) ) ) ) +
310 ( dxa[2])*( (( 1.0 -dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1],ii[2]+1,ti,tj) +
311 ( dxa[0] ) * controlFunction[0](ii[0]+1,ii[1],ii[2]+1,ti,tj) ) +
312 ( dxa[1] ) * ( ( 1.0-dxa[0] ) * controlFunction[0](ii[0],ii[1]+1,ii[2]+1,ti,tj) +
313 ( dxa[0] ) * controlFunction[0](ii[0]+1, ii[1]+1,ii[2]+1,ti,tj) ) ) ));
329 Jt(0,0) = xm[0]-x0[0];
330 Jt(0,1) = xmp1[0]-x0[0];
332 Jt(1,0) = xm[1]-x0[1];
333 Jt(1,1) = xmp1[1]-x0[1];
336 for ( r=0; r<2; r++ )
337 for ( c=0; c<2; c++ )
340 for ( r=0; r<2; r++ )
341 for ( c=0; c<2; c++ )
342 for ( cc=0; cc<2; cc++ )
343 J(r,c) += Jt(r,cc)*T(cc,c);
359 Jt(0,0) = 0.5*(x1[0]+x2[0]-x3[0]-x0[0]);
360 Jt(0,1) = 0.5*(x3[0]+x2[0]-x1[0]-x0[0]);
361 Jt(1,0) = 0.5*(x1[1]+x2[1]-x3[1]-x0[1]);
362 Jt(1,1) = 0.5*(x3[1]+x2[1]-x1[1]-x0[1]);
365 for ( r=0; r<2; r++ )
366 for ( c=0; c<2; c++ )
369 for ( r=0; r<2; r++ )
370 for ( c=0; c<2; c++ )
371 for ( cc=0; cc<2; cc++ )
372 J(r,c) += Jt(r,cc)*T(cc,c);
388 Jt(0,0) = x1[0]-x0[0];
389 Jt(0,1) = x2[0]-x0[0];
390 Jt(0,2) = x3[0]-x0[0];
392 Jt(1,0) = x1[1]-x0[1];
393 Jt(1,1) = x2[1]-x0[1];
394 Jt(1,2) = x3[1]-x0[1];
396 Jt(2,0) = x1[2]-x0[2];
397 Jt(2,1) = x2[2]-x0[2];
398 Jt(2,2) = x3[2]-x0[2];
401 for ( r=0; r<3; r++ )
402 for ( c=0; c<3; c++ )
405 for ( r=0; r<3; r++ )
406 for ( c=0; c<3; c++ )
407 for ( cc=0; cc<3; cc++ )
408 J(r,c) += Jt(r,cc)*T(cc,c);
424 Jt(0,0) = -( x0(0)+x3(0)+x4(0)-
425 (x1(0)+x2(0)+x4(0)))/3.;
426 Jt(1,0) = -( x0(1)+x3(1)+x4(1)-
427 (x1(1)+x2(1)+x4(1)))/3.;
428 Jt(2,0) = -( x0(2)+x3(2)+x4(2)-
429 (x1(2)+x2(2)+x4(2)))/3.;
431 Jt(0,1) = -( x0(0)+x1(0)+x4(0)-
432 (x2(0)+x3(0)+x4(0)))/3.;
433 Jt(1,1) = -( x0(1)+x1(1)+x4(1)-
434 (x2(1)+x3(1)+x4(1)))/3.;
435 Jt(2,1) = -( x0(2)+x1(2)+x4(2)-
436 (x2(2)+x3(2)+x4(2)))/3.;
438 Jt(0,2) = -2*( (x0(0)+x1(0)+
441 Jt(1,2) = -2*( (x0(1)+x1(1)+x2(1)+
444 Jt(2,2) = -2*( (x0(2)+x1(2)+x2(2)+
449 for ( r=0; r<3; r++ )
450 for ( c=0; c<3; c++ )
453 for ( r=0; r<3; r++ )
454 for ( c=0; c<3; c++ )
455 for ( cc=0; cc<3; cc++ )
456 J(r,c) += Jt(r,cc)*T(cc,c);
475 Jt(0,0) = -( x0(0)+x3(0)+x4(0)+x7(0)-
476 (x1(0)+x2(0)+x5(0)+x6(0)))/4.;
477 Jt(1,0) = -( x0(1)+x3(1)+x4(1)+x7(1)-
478 (x1(1)+x2(1)+x5(1)+x6(1)))/4.;
479 Jt(2,0) = -( x0(2)+x3(2)+x4(2)+x7(2)-
480 (x1(2)+x2(2)+x5(2)+x6(2)))/4.;
482 Jt(0,1) = -( x0(0)+x1(0)+x4(0)+x5(0)-
483 (x2(0)+x3(0)+x6(0)+x7(0)))/4.;
484 Jt(1,1) = -( x0(1)+x1(1)+x4(1)+x5(1)-
485 (x2(1)+x3(1)+x6(1)+x7(1)))/4.;
486 Jt(2,1) = -( x0(2)+x1(2)+x4(2)+x5(2)-
487 (x2(2)+x3(2)+x6(2)+x7(2)))/4.;
489 Jt(0,2) = -( x0(0)+x1(0)+x2(0)+x3(0)-
490 (x4(0)+x5(0)+x6(0)+x7(0)))/4.;
491 Jt(1,2) = -( x0(1)+x1(1)+x2(1)+x3(1)-
492 (x4(1)+x5(1)+x6(1)+x7(1)))/4.;
493 Jt(2,2) = -( x0(2)+x1(2)+x2(2)+x3(2)-
494 (x4(2)+x5(2)+x6(2)+x7(2)))/4.;
497 for ( r=0; r<3; r++ )
498 for ( c=0; c<3; c++ )
501 for ( r=0; r<3; r++ )
502 for ( c=0; c<3; c++ )
503 for ( cc=0; cc<3; cc++ )
504 J(r,c) += Jt(r,cc)*T(cc,c);
519 for ( r=0; r<2; r++ )
520 for ( c=0; c<2; c++ )
523 det = J(0,0)*J(1,1) - J(1,0)*J(0,1);
527 real normOfInverse = 0.;
529 normOfInverse += J(1,1)*J(1,1);
530 normOfInverse += J(1,0)*J(1,0);
531 normOfInverse += J(0,1)*J(0,1);
532 normOfInverse += J(0,0)*J(0,0);
534 normOfInverse = sqrt(normOfInverse)/det;
536 K = sqrt(N2)*normOfInverse;
553 for ( r=0; r<3; r++ )
554 for ( c=0; c<3; c++ )
558 J(0,0)*(J(1,1)*J(2,2)-J(1,2)*J(2,1)) -
559 J(0,1)*(J(1,0)*J(2,2)-J(1,2)*J(2,0)) +
560 J(0,2)*(J(1,0)*J(2,1)-J(1,1)*J(2,0));
564 real normOfInverse = 0.;
566 normOfInverse += (J(1,1)*J(2,2)-J(1,2)*J(2,1))*
567 (J(1,1)*J(2,2)-J(1,2)*J(2,1));
568 normOfInverse += (J(1,0)*J(2,2)-J(1,2)*J(2,0))*
569 (J(1,0)*J(2,2)-J(1,2)*J(2,0));
570 normOfInverse += (J(1,0)*J(2,1)-J(1,1)*J(2,0))*
571 (J(1,0)*J(2,1)-J(1,1)*J(2,0));
572 normOfInverse += (J(0,1)*J(2,2)-J(0,2)*J(2,1))*
573 (J(0,1)*J(2,2)-J(0,2)*J(2,1));
574 normOfInverse += (J(0,0)*J(2,2)-J(0,2)*J(2,0))*
575 (J(0,0)*J(2,2)-J(0,2)*J(2,0));
576 normOfInverse += (J(0,0)*J(2,1)-J(0,1)*J(2,0))*
577 (J(0,0)*J(2,1)-J(0,1)*J(2,0));
578 normOfInverse += (J(0,1)*J(1,2)-J(0,2)*J(1,1))*
579 (J(0,1)*J(1,2)-J(0,2)*J(1,1));
580 normOfInverse += (J(0,0)*J(1,2)-J(0,2)*J(1,0))*
581 (J(0,0)*J(1,2)-J(0,2)*J(1,0));
582 normOfInverse += (J(0,0)*J(1,1)-J(0,1)*J(1,0))*
583 (J(0,0)*J(1,1)-J(0,1)*J(1,0));
585 normOfInverse = sqrt(normOfInverse)/det;
587 K = sqrt(N2)*normOfInverse;
602 T(0,0) = T(1,1) = 1.;
603 T(0,1) = T(1,0) = 0.;
605 if ( referenceTransformation!=
NULL )
625 Winv(0,0) = T(0,0) - T(1,0)/sqrt(3.);
626 Winv(0,1) = T(0,1) - T(1,1)/sqrt(3.);
627 Winv(1,0) = 2*T(1,0)/sqrt(3.);
628 Winv(1,1) = 2*T(1,1)/sqrt(3.);
631 for (
int r=0;
r<2;
r++ )
632 for (
int c=0;
c<2;
c++ )
645 T(0,0) = T(1,1) = T(2,2) = 1.;
646 T(0,1) = T(1,0) = T(0,2) = T(1,2) = T(2,1) = T(2,0) = 0.;
648 if ( referenceTransformation!=
NULL )
655 Winv(0,0) = T(0,0) - T(1,0)/sqrt(3.) - T(2,0)/sqrt(3.)/sqrt(2.);
656 Winv(0,1) = T(0,1) - T(1,1)/sqrt(3.) - T(2,1)/sqrt(3.)/sqrt(2.);
657 Winv(0,2) = T(0,2) - T(1,2)/sqrt(3.) - T(2,2)/sqrt(3.)/sqrt(2.);
659 Winv(1,0) = 2*T(1,0)/sqrt(3.) - T(2,0)/sqrt(3.)/sqrt(2.);
660 Winv(1,1) = 2*T(1,1)/sqrt(3.) - T(2,1)/sqrt(3.)/sqrt(2.);
661 Winv(1,2) = 2*T(1,2)/sqrt(3.) - T(2,2)/sqrt(3.)/sqrt(2.);
663 Winv(2,0) = sqrt(3.)*T(2,0)/sqrt(2.);
664 Winv(2,1) = sqrt(3.)*T(2,1)/sqrt(2.);
665 Winv(2,2) = sqrt(3.)*T(2,2)/sqrt(2.);
669 Winv(0,0) = T(0,0)*3./2;
670 Winv(0,1) = T(0,1)*3./2;
673 Winv(1,0) = T(1,0)*3./2;
674 Winv(1,1) = T(1,1)*3./2;
675 Winv(1,2) = T(1,2)/2.;
677 Winv(2,0) = T(2,0)*3./2;
678 Winv(2,1) = T(2,1)*3./2;
682 for (
int r=0;
r<3;
r++ )
683 for (
int c=0;
c<3;
c++ )
727 if ( n==0 || n==3 || n==4 || n==7 )
733 if ( n==0 || n==1 || n==4 || n==5 )
739 if ( n==0 || n==1 || n==2 || n==3 )
751 if ( n==0 || n==3 || n==4 )
757 if ( n==0 || n==1 || n==4 )