23 #define VERDICT_EXPORTS
31 #if defined( __BORLANDC__ )
48 double scale = pow(
verdict_hex_size / ( v1 % ( v2 * v3 ) ), 0.33333333333 );
62 #define make_hex_nodes( coord, pos ) \
63 for( int mhcii = 0; mhcii < 8; mhcii++ ) \
65 ( pos )[mhcii].set( ( coord )[mhcii][0], ( coord )[mhcii][1], ( coord )[mhcii][2] ); \
68 #define make_edge_length_squares( edges, lengths ) \
70 for( int melii = 0; melii < 12; melii++ ) \
71 ( lengths )[melii] = ( edges )[melii].length_squared(); \
77 edges[0].
set( coordinates[1][0] - coordinates[0][0], coordinates[1][1] - coordinates[0][1],
78 coordinates[1][2] - coordinates[0][2] );
79 edges[1].
set( coordinates[2][0] - coordinates[1][0], coordinates[2][1] - coordinates[1][1],
80 coordinates[2][2] - coordinates[1][2] );
81 edges[2].
set( coordinates[3][0] - coordinates[2][0], coordinates[3][1] - coordinates[2][1],
82 coordinates[3][2] - coordinates[2][2] );
83 edges[3].
set( coordinates[0][0] - coordinates[3][0], coordinates[0][1] - coordinates[3][1],
84 coordinates[0][2] - coordinates[3][2] );
85 edges[4].
set( coordinates[5][0] - coordinates[4][0], coordinates[5][1] - coordinates[4][1],
86 coordinates[5][2] - coordinates[4][2] );
87 edges[5].
set( coordinates[6][0] - coordinates[5][0], coordinates[6][1] - coordinates[5][1],
88 coordinates[6][2] - coordinates[5][2] );
89 edges[6].
set( coordinates[7][0] - coordinates[6][0], coordinates[7][1] - coordinates[6][1],
90 coordinates[7][2] - coordinates[6][2] );
91 edges[7].
set( coordinates[4][0] - coordinates[7][0], coordinates[4][1] - coordinates[7][1],
92 coordinates[4][2] - coordinates[7][2] );
93 edges[8].
set( coordinates[4][0] - coordinates[0][0], coordinates[4][1] - coordinates[0][1],
94 coordinates[4][2] - coordinates[0][2] );
95 edges[9].
set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
96 coordinates[5][2] - coordinates[1][2] );
97 edges[10].
set( coordinates[6][0] - coordinates[2][0], coordinates[6][1] - coordinates[2][1],
98 coordinates[6][2] - coordinates[2][2] );
99 edges[11].
set( coordinates[7][0] - coordinates[3][0], coordinates[7][1] - coordinates[3][1],
100 coordinates[7][2] - coordinates[3][2] );
110 for( ii = 0; ii < 8; ii++ )
112 position[ii].
set( coordinates[ii][0], coordinates[ii][1], coordinates[ii][2] );
117 point_1256 += position[2];
118 point_1256 += position[5];
119 point_1256 += position[6];
122 point_0374 += position[3];
123 point_0374 += position[7];
124 point_0374 += position[4];
127 centroid += point_0374;
131 for( i = 0; i < 8; i++ )
132 position[i] -= centroid;
135 double DX = point_1256.
x() - point_0374.
x();
136 double DY = point_1256.
y() - point_0374.
y();
137 double DZ = point_1256.
z() - point_0374.
z();
139 double AMAGX = sqrt( DX * DX + DZ * DZ );
140 double AMAGY = sqrt( DX * DX + DY * DY + DZ * DZ );
141 double FMAGX = AMAGX == 0.0 ? 1.0 : 0.0;
142 double FMAGY = AMAGY == 0.0 ? 1.0 : 0.0;
144 double CZ = DX / ( AMAGX + FMAGX ) + FMAGX;
145 double SZ = DZ / ( AMAGX + FMAGX );
146 double CY = AMAGX / ( AMAGY + FMAGY ) + FMAGY;
147 double SY = DY / ( AMAGY + FMAGY );
151 for( i = 0; i < 8; i++ )
153 temp = CY * CZ * position[i].
x() + CY * SZ * position[i].
z() + SY * position[i].
y();
154 position[i].
y( -SY * CZ * position[i].x() - SY * SZ * position[i].
z() + CY * position[i].
y() );
155 position[i].
z( -SZ * position[i].x() + CZ * position[i].
z() );
156 position[i].
x( temp );
161 delta -= position[1];
162 delta += position[2];
163 delta += position[3];
164 delta -= position[4];
165 delta -= position[5];
166 delta += position[6];
167 delta += position[7];
172 AMAGY = sqrt( DY * DY + DZ * DZ );
173 FMAGY = AMAGY == 0.0 ? 1.0 : 0.0;
175 double CX = DY / ( AMAGY + FMAGY ) + FMAGY;
176 double SX = DZ / ( AMAGY + FMAGY );
178 for( i = 0; i < 8; i++ )
180 temp = CX * position[i].
y() + SX * position[i].
z();
181 position[i].
z( -SX * position[i].y() + CX * position[i].
z() );
182 position[i].
y( temp );
186 double safe_ratio3(
const double numerator,
const double denominator,
const double max_ratio )
191 const double filter_n = max_ratio * 1.0e-16;
192 const double filter_d = 1.0e-16;
193 if( fabs( numerator ) <= filter_n && fabs( denominator ) >= filter_d )
195 return_value = numerator / denominator;
199 return_value = fabs( numerator ) / max_ratio >= fabs( denominator )
200 ? ( ( numerator >= 0.0 && denominator >= 0.0 ) || ( numerator < 0.0 && denominator < 0.0 )
203 : numerator / denominator;
209 double safe_ratio(
const double numerator,
const double denominator )
215 if( fabs( numerator ) <= filter_n && fabs( denominator ) >= filter_d )
217 return_value = numerator / denominator;
229 double det = xxi % ( xet * xze );
236 double term1 = xxi % xxi + xet % xet + xze % xze;
238 ( ( xxi * xet ) % ( xxi * xet ) ) + ( ( xet * xze ) % ( xet * xze ) ) + ( ( xze * xxi ) % ( xze * xxi ) );
240 return sqrt( term1 * term2 ) / det;
245 static const double third = 1.0 / 3.0;
247 double g11, g12, g13, g22, g23, g33, rt_g;
255 rt_g = xxi % ( xet * xze );
260 double norm_G_squared = g11 * g11 + 2.0 * g12 * g12 + 2.0 * g13 * g13 + g22 * g22 + 2.0 * g23 * g23 + g33 * g33;
262 double norm_J_squared = g11 + g22 + g33;
264 oddy_metric = ( norm_G_squared - third * norm_J_squared * norm_J_squared ) / pow( rt_g, 4. * third );
276 double temp[3],
edge[12];
280 for( i = 0; i < 3; i++ )
282 temp[i] = coordinates[1][i] - coordinates[0][i];
283 temp[i] = temp[i] * temp[i];
285 edge[0] = sqrt( temp[0] + temp[1] + temp[2] );
287 for( i = 0; i < 3; i++ )
289 temp[i] = coordinates[2][i] - coordinates[1][i];
290 temp[i] = temp[i] * temp[i];
292 edge[1] = sqrt( temp[0] + temp[1] + temp[2] );
294 for( i = 0; i < 3; i++ )
296 temp[i] = coordinates[3][i] - coordinates[2][i];
297 temp[i] = temp[i] * temp[i];
299 edge[2] = sqrt( temp[0] + temp[1] + temp[2] );
301 for( i = 0; i < 3; i++ )
303 temp[i] = coordinates[0][i] - coordinates[3][i];
304 temp[i] = temp[i] * temp[i];
306 edge[3] = sqrt( temp[0] + temp[1] + temp[2] );
308 for( i = 0; i < 3; i++ )
310 temp[i] = coordinates[5][i] - coordinates[4][i];
311 temp[i] = temp[i] * temp[i];
313 edge[4] = sqrt( temp[0] + temp[1] + temp[2] );
315 for( i = 0; i < 3; i++ )
317 temp[i] = coordinates[6][i] - coordinates[5][i];
318 temp[i] = temp[i] * temp[i];
320 edge[5] = sqrt( temp[0] + temp[1] + temp[2] );
322 for( i = 0; i < 3; i++ )
324 temp[i] = coordinates[7][i] - coordinates[6][i];
325 temp[i] = temp[i] * temp[i];
327 edge[6] = sqrt( temp[0] + temp[1] + temp[2] );
329 for( i = 0; i < 3; i++ )
331 temp[i] = coordinates[4][i] - coordinates[7][i];
332 temp[i] = temp[i] * temp[i];
334 edge[7] = sqrt( temp[0] + temp[1] + temp[2] );
336 for( i = 0; i < 3; i++ )
338 temp[i] = coordinates[4][i] - coordinates[0][i];
339 temp[i] = temp[i] * temp[i];
341 edge[8] = sqrt( temp[0] + temp[1] + temp[2] );
343 for( i = 0; i < 3; i++ )
345 temp[i] = coordinates[5][i] - coordinates[1][i];
346 temp[i] = temp[i] * temp[i];
348 edge[9] = sqrt( temp[0] + temp[1] + temp[2] );
350 for( i = 0; i < 3; i++ )
352 temp[i] = coordinates[6][i] - coordinates[2][i];
353 temp[i] = temp[i] * temp[i];
355 edge[10] = sqrt( temp[0] + temp[1] + temp[2] );
357 for( i = 0; i < 3; i++ )
359 temp[i] = coordinates[7][i] - coordinates[3][i];
360 temp[i] = temp[i] * temp[i];
362 edge[11] = sqrt( temp[0] + temp[1] + temp[2] );
364 double _edge =
edge[0];
368 for( i = 1; i < 12; i++ )
370 return (
double)_edge;
374 for( i = 1; i < 12; i++ )
376 return (
double)_edge;
382 double temp[3], diag[4];
386 for( i = 0; i < 3; i++ )
388 temp[i] = coordinates[6][i] - coordinates[0][i];
389 temp[i] = temp[i] * temp[i];
391 diag[0] = sqrt( temp[0] + temp[1] + temp[2] );
393 for( i = 0; i < 3; i++ )
395 temp[i] = coordinates[4][i] - coordinates[2][i];
396 temp[i] = temp[i] * temp[i];
398 diag[1] = sqrt( temp[0] + temp[1] + temp[2] );
400 for( i = 0; i < 3; i++ )
402 temp[i] = coordinates[7][i] - coordinates[1][i];
403 temp[i] = temp[i] * temp[i];
405 diag[2] = sqrt( temp[0] + temp[1] + temp[2] );
407 for( i = 0; i < 3; i++ )
409 temp[i] = coordinates[5][i] - coordinates[3][i];
410 temp[i] = temp[i] * temp[i];
412 diag[3] = sqrt( temp[0] + temp[1] + temp[2] );
414 double diagonal = diag[0];
417 for( i = 1; i < 4; i++ )
419 return (
double)diagonal;
423 for( i = 1; i < 4; i++ )
425 return (
double)diagonal;
439 efg = coordinates[1];
440 efg += coordinates[2];
441 efg += coordinates[5];
442 efg += coordinates[6];
443 efg -= coordinates[0];
444 efg -= coordinates[3];
445 efg -= coordinates[4];
446 efg -= coordinates[7];
450 efg = coordinates[2];
451 efg += coordinates[3];
452 efg += coordinates[6];
453 efg += coordinates[7];
454 efg -= coordinates[0];
455 efg -= coordinates[1];
456 efg -= coordinates[4];
457 efg -= coordinates[5];
461 efg = coordinates[4];
462 efg += coordinates[5];
463 efg += coordinates[6];
464 efg += coordinates[7];
465 efg -= coordinates[0];
466 efg -= coordinates[1];
467 efg -= coordinates[2];
468 efg -= coordinates[3];
472 efg = coordinates[0];
473 efg += coordinates[2];
474 efg += coordinates[4];
475 efg += coordinates[6];
476 efg -= coordinates[1];
477 efg -= coordinates[3];
478 efg -= coordinates[5];
479 efg -= coordinates[7];
483 efg = coordinates[0];
484 efg += coordinates[3];
485 efg += coordinates[5];
486 efg += coordinates[6];
487 efg -= coordinates[1];
488 efg -= coordinates[2];
489 efg -= coordinates[4];
490 efg -= coordinates[7];
494 efg = coordinates[0];
495 efg += coordinates[1];
496 efg += coordinates[6];
497 efg += coordinates[7];
498 efg -= coordinates[2];
499 efg -= coordinates[3];
500 efg -= coordinates[4];
501 efg -= coordinates[5];
505 efg = coordinates[0];
506 efg += coordinates[2];
507 efg += coordinates[5];
508 efg += coordinates[7];
509 efg -= coordinates[1];
510 efg -= coordinates[5];
511 efg -= coordinates[6];
512 efg -= coordinates[2];
548 double mab, mcd, mef, Mab, Mcd, Mef;
549 double mgh, mij, mkl, Mgh, Mij, Mkl;
613 m2 = mab < mcd ? mab : mcd;
614 m2 = m2 < mef ? m2 : mef;
615 m2 = m2 < mgh ? m2 : mgh;
616 m2 = m2 < mij ? m2 : mij;
617 m2 = m2 < mkl ? m2 : mkl;
622 M2 = Mab > Mcd ? Mab : Mcd;
623 M2 = M2 > Mef ? M2 : Mef;
624 M2 = M2 > Mgh ? M2 : Mgh;
625 M2 = M2 > Mij ? M2 : Mij;
626 M2 = M2 > Mkl ? M2 : Mkl;
627 m2 = m2 < mef ? m2 : mef;
629 M2 = Mab > Mcd ? Mab : Mcd;
630 M2 = M2 > Mef ? M2 : Mef;
632 double edge_ratio = sqrt( M2 / m2 );
649 double aspect_12, aspect_13, aspect_23;
655 double mag_efg1 = efg1.
length();
656 double mag_efg2 = efg2.
length();
657 double mag_efg3 = efg3.
length();
679 double skew_1, skew_2, skew_3;
689 skew_1 = fabs( efg1 % efg2 );
690 skew_2 = fabs( efg1 % efg3 );
691 skew_3 = fabs( efg2 % efg3 );
742 volume = (double)( efg1 % ( efg2 * efg3 ) ) / 64.0;
755 static const double HEX_STRETCH_SCALE_FACTOR = sqrt( 3.0 );
760 double stretch = HEX_STRETCH_SCALE_FACTOR *
safe_ratio( min_edge, max_diag );
777 double diagonal =
safe_ratio( min_diag, max_diag );
783 #define SQR( x ) ( ( x ) * ( x ) )
796 double x1 = coordinates[0][0];
797 double x2 = coordinates[1][0];
798 double x3 = coordinates[2][0];
799 double x4 = coordinates[3][0];
800 double x5 = coordinates[4][0];
801 double x6 = coordinates[5][0];
802 double x7 = coordinates[6][0];
803 double x8 = coordinates[7][0];
805 double y1 = coordinates[0][1];
806 double y2 = coordinates[1][1];
807 double y3 = coordinates[2][1];
808 double y4 = coordinates[3][1];
809 double y5 = coordinates[4][1];
810 double y6 = coordinates[5][1];
811 double y7 = coordinates[6][1];
812 double y8 = coordinates[7][1];
814 double z1 = coordinates[0][2];
815 double z2 = coordinates[1][2];
816 double z3 = coordinates[2][2];
817 double z4 = coordinates[3][2];
818 double z5 = coordinates[4][2];
819 double z6 = coordinates[5][2];
820 double z7 = coordinates[6][2];
821 double z8 = coordinates[7][2];
823 double z24 = z2 - z4;
824 double z52 = z5 - z2;
825 double z45 = z4 - z5;
827 ( y2 * ( z6 - z3 - z45 ) + y3 * z24 + y4 * ( z3 - z8 - z52 ) + y5 * ( z8 - z6 - z24 ) + y6 * z52 + y8 * z45 ) /
830 double z31 = z3 - z1;
831 double z63 = z6 - z3;
832 double z16 = z1 - z6;
834 ( y3 * ( z7 - z4 - z16 ) + y4 * z31 + y1 * ( z4 - z5 - z63 ) + y6 * ( z5 - z7 - z31 ) + y7 * z63 + y5 * z16 ) /
837 double z42 = z4 - z2;
838 double z74 = z7 - z4;
839 double z27 = z2 - z7;
841 ( y4 * ( z8 - z1 - z27 ) + y1 * z42 + y2 * ( z1 - z6 - z74 ) + y7 * ( z6 - z8 - z42 ) + y8 * z74 + y6 * z27 ) /
844 double z13 = z1 - z3;
845 double z81 = z8 - z1;
846 double z38 = z3 - z8;
848 ( y1 * ( z5 - z2 - z38 ) + y2 * z13 + y3 * ( z2 - z7 - z81 ) + y8 * ( z7 - z5 - z13 ) + y5 * z81 + y7 * z38 ) /
851 double z86 = z8 - z6;
852 double z18 = z1 - z8;
853 double z61 = z6 - z1;
855 ( y8 * ( z4 - z7 - z61 ) + y7 * z86 + y6 * ( z7 - z2 - z18 ) + y1 * ( z2 - z4 - z86 ) + y4 * z18 + y2 * z61 ) /
858 double z57 = z5 - z7;
859 double z25 = z2 - z5;
860 double z72 = z7 - z2;
862 ( y5 * ( z1 - z8 - z72 ) + y8 * z57 + y7 * ( z8 - z3 - z25 ) + y2 * ( z3 - z1 - z57 ) + y1 * z25 + y3 * z72 ) /
865 double z68 = z6 - z8;
866 double z36 = z3 - z6;
867 double z83 = z8 - z3;
869 ( y6 * ( z2 - z5 - z83 ) + y5 * z68 + y8 * ( z5 - z4 - z36 ) + y3 * ( z4 - z2 - z68 ) + y2 * z36 + y4 * z83 ) /
872 double z75 = z7 - z5;
873 double z47 = z4 - z7;
874 double z54 = z5 - z4;
876 ( y7 * ( z3 - z6 - z54 ) + y6 * z75 + y5 * ( z6 - z1 - z47 ) + y4 * ( z1 - z3 - z75 ) + y3 * z47 + y1 * z54 ) /
879 double x24 = x2 - x4;
880 double x52 = x5 - x2;
881 double x45 = x4 - x5;
883 ( z2 * ( x6 - x3 - x45 ) + z3 * x24 + z4 * ( x3 - x8 - x52 ) + z5 * ( x8 - x6 - x24 ) + z6 * x52 + z8 * x45 ) /
886 double x31 = x3 - x1;
887 double x63 = x6 - x3;
888 double x16 = x1 - x6;
890 ( z3 * ( x7 - x4 - x16 ) + z4 * x31 + z1 * ( x4 - x5 - x63 ) + z6 * ( x5 - x7 - x31 ) + z7 * x63 + z5 * x16 ) /
893 double x42 = x4 - x2;
894 double x74 = x7 - x4;
895 double x27 = x2 - x7;
897 ( z4 * ( x8 - x1 - x27 ) + z1 * x42 + z2 * ( x1 - x6 - x74 ) + z7 * ( x6 - x8 - x42 ) + z8 * x74 + z6 * x27 ) /
900 double x13 = x1 - x3;
901 double x81 = x8 - x1;
902 double x38 = x3 - x8;
904 ( z1 * ( x5 - x2 - x38 ) + z2 * x13 + z3 * ( x2 - x7 - x81 ) + z8 * ( x7 - x5 - x13 ) + z5 * x81 + z7 * x38 ) /
907 double x86 = x8 - x6;
908 double x18 = x1 - x8;
909 double x61 = x6 - x1;
911 ( z8 * ( x4 - x7 - x61 ) + z7 * x86 + z6 * ( x7 - x2 - x18 ) + z1 * ( x2 - x4 - x86 ) + z4 * x18 + z2 * x61 ) /
914 double x57 = x5 - x7;
915 double x25 = x2 - x5;
916 double x72 = x7 - x2;
918 ( z5 * ( x1 - x8 - x72 ) + z8 * x57 + z7 * ( x8 - x3 - x25 ) + z2 * ( x3 - x1 - x57 ) + z1 * x25 + z3 * x72 ) /
921 double x68 = x6 - x8;
922 double x36 = x3 - x6;
923 double x83 = x8 - x3;
925 ( z6 * ( x2 - x5 - x83 ) + z5 * x68 + z8 * ( x5 - x4 - x36 ) + z3 * ( x4 - x2 - x68 ) + z2 * x36 + z4 * x83 ) /
928 double x75 = x7 - x5;
929 double x47 = x4 - x7;
930 double x54 = x5 - x4;
932 ( z7 * ( x3 - x6 - x54 ) + z6 * x75 + z5 * ( x6 - x1 - x47 ) + z4 * ( x1 - x3 - x75 ) + z3 * x47 + z1 * x54 ) /
935 double y24 = y2 - y4;
936 double y52 = y5 - y2;
937 double y45 = y4 - y5;
939 ( x2 * ( y6 - y3 - y45 ) + x3 * y24 + x4 * ( y3 - y8 - y52 ) + x5 * ( y8 - y6 - y24 ) + x6 * y52 + x8 * y45 ) /
942 double y31 = y3 - y1;
943 double y63 = y6 - y3;
944 double y16 = y1 - y6;
946 ( x3 * ( y7 - y4 - y16 ) + x4 * y31 + x1 * ( y4 - y5 - y63 ) + x6 * ( y5 - y7 - y31 ) + x7 * y63 + x5 * y16 ) /
949 double y42 = y4 - y2;
950 double y74 = y7 - y4;
951 double y27 = y2 - y7;
953 ( x4 * ( y8 - y1 - y27 ) + x1 * y42 + x2 * ( y1 - y6 - y74 ) + x7 * ( y6 - y8 - y42 ) + x8 * y74 + x6 * y27 ) /
956 double y13 = y1 - y3;
957 double y81 = y8 - y1;
958 double y38 = y3 - y8;
960 ( x1 * ( y5 - y2 - y38 ) + x2 * y13 + x3 * ( y2 - y7 - y81 ) + x8 * ( y7 - y5 - y13 ) + x5 * y81 + x7 * y38 ) /
963 double y86 = y8 - y6;
964 double y18 = y1 - y8;
965 double y61 = y6 - y1;
967 ( x8 * ( y4 - y7 - y61 ) + x7 * y86 + x6 * ( y7 - y2 - y18 ) + x1 * ( y2 - y4 - y86 ) + x4 * y18 + x2 * y61 ) /
970 double y57 = y5 - y7;
971 double y25 = y2 - y5;
972 double y72 = y7 - y2;
974 ( x5 * ( y1 - y8 - y72 ) + x8 * y57 + x7 * ( y8 - y3 - y25 ) + x2 * ( y3 - y1 - y57 ) + x1 * y25 + x3 * y72 ) /
977 double y68 = y6 - y8;
978 double y36 = y3 - y6;
979 double y83 = y8 - y3;
981 ( x6 * ( y2 - y5 - y83 ) + x5 * y68 + x8 * ( y5 - y4 - y36 ) + x3 * ( y4 - y2 - y68 ) + x2 * y36 + x4 * y83 ) /
984 double y75 = y7 - y5;
985 double y47 = y4 - y7;
986 double y54 = y5 - y4;
988 ( x7 * ( y3 - y6 - y54 ) + x6 * y75 + x5 * ( y6 - y1 - y47 ) + x4 * ( y1 - y3 - y75 ) + x3 * y47 + x1 * y54 ) /
994 double volume = coordinates[0][0] * gradop[1][1] + coordinates[1][0] * gradop[2][1] +
995 coordinates[2][0] * gradop[3][1] + coordinates[3][0] * gradop[4][1] +
996 coordinates[4][0] * gradop[5][1] + coordinates[5][0] * gradop[6][1] +
997 coordinates[6][0] * gradop[7][1] + coordinates[7][0] * gradop[8][1];
1000 (
SQR( gradop[1][1] ) +
SQR( gradop[2][1] ) +
SQR( gradop[3][1] ) +
SQR( gradop[4][1] ) +
SQR( gradop[5][1] ) +
1001 SQR( gradop[6][1] ) +
SQR( gradop[7][1] ) +
SQR( gradop[8][1] ) +
SQR( gradop[1][2] ) +
SQR( gradop[2][2] ) +
1002 SQR( gradop[3][2] ) +
SQR( gradop[4][2] ) +
SQR( gradop[5][2] ) +
SQR( gradop[6][2] ) +
SQR( gradop[7][2] ) +
1003 SQR( gradop[8][2] ) +
SQR( gradop[1][3] ) +
SQR( gradop[2][3] ) +
SQR( gradop[3][3] ) +
SQR( gradop[4][3] ) +
1004 SQR( gradop[5][3] ) +
SQR( gradop[6][3] ) +
SQR( gradop[7][3] ) +
SQR( gradop[8][3] ) );
1006 return (
double)sqrt( aspect );
1017 double oddy = 0.0, current_oddy;
1027 current_oddy =
oddy_comp( xxi, xet, xze );
1028 if( current_oddy > oddy )
1030 oddy = current_oddy;
1033 xxi.
set( coordinates[1][0] - coordinates[0][0], coordinates[1][1] - coordinates[0][1],
1034 coordinates[1][2] - coordinates[0][2] );
1036 xet.
set( coordinates[3][0] - coordinates[0][0], coordinates[3][1] - coordinates[0][1],
1037 coordinates[3][2] - coordinates[0][2] );
1039 xze.
set( coordinates[4][0] - coordinates[0][0], coordinates[4][1] - coordinates[0][1],
1040 coordinates[4][2] - coordinates[0][2] );
1042 current_oddy =
oddy_comp( xxi, xet, xze );
1043 if( current_oddy > oddy )
1045 oddy = current_oddy;
1048 xxi.
set( coordinates[2][0] - coordinates[1][0], coordinates[2][1] - coordinates[1][1],
1049 coordinates[2][2] - coordinates[1][2] );
1051 xet.
set( coordinates[0][0] - coordinates[1][0], coordinates[0][1] - coordinates[1][1],
1052 coordinates[0][2] - coordinates[1][2] );
1054 xze.
set( coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
1055 coordinates[5][2] - coordinates[1][2] );
1057 current_oddy =
oddy_comp( xxi, xet, xze );
1058 if( current_oddy > oddy )
1060 oddy = current_oddy;
1063 xxi.
set( coordinates[3][0] - coordinates[2][0], coordinates[3][1] - coordinates[2][1],
1064 coordinates[3][2] - coordinates[2][2] );
1066 xet.
set( coordinates[1][0] - coordinates[2][0], coordinates[1][1] - coordinates[2][1],
1067 coordinates[1][2] - coordinates[2][2] );
1069 xze.
set( coordinates[6][0] - coordinates[2][0], coordinates[6][1] - coordinates[2][1],
1070 coordinates[6][2] - coordinates[2][2] );
1072 current_oddy =
oddy_comp( xxi, xet, xze );
1073 if( current_oddy > oddy )
1075 oddy = current_oddy;
1078 xxi.
set( coordinates[0][0] - coordinates[3][0], coordinates[0][1] - coordinates[3][1],
1079 coordinates[0][2] - coordinates[3][2] );
1081 xet.
set( coordinates[2][0] - coordinates[3][0], coordinates[2][1] - coordinates[3][1],
1082 coordinates[2][2] - coordinates[3][2] );
1084 xze.
set( coordinates[7][0] - coordinates[3][0], coordinates[7][1] - coordinates[3][1],
1085 coordinates[7][2] - coordinates[3][2] );
1087 current_oddy =
oddy_comp( xxi, xet, xze );
1088 if( current_oddy > oddy )
1090 oddy = current_oddy;
1093 xxi.
set( coordinates[7][0] - coordinates[4][0], coordinates[7][1] - coordinates[4][1],
1094 coordinates[7][2] - coordinates[4][2] );
1096 xet.
set( coordinates[5][0] - coordinates[4][0], coordinates[5][1] - coordinates[4][1],
1097 coordinates[5][2] - coordinates[4][2] );
1099 xze.
set( coordinates[0][0] - coordinates[4][0], coordinates[0][1] - coordinates[4][1],
1100 coordinates[0][2] - coordinates[4][2] );
1102 current_oddy =
oddy_comp( xxi, xet, xze );
1103 if( current_oddy > oddy )
1105 oddy = current_oddy;
1108 xxi.
set( coordinates[4][0] - coordinates[5][0], coordinates[4][1] - coordinates[5][1],
1109 coordinates[4][2] - coordinates[5][2] );
1111 xet.
set( coordinates[6][0] - coordinates[5][0], coordinates[6][1] - coordinates[5][1],
1112 coordinates[6][2] - coordinates[5][2] );
1114 xze.
set( coordinates[1][0] - coordinates[5][0], coordinates[1][1] - coordinates[5][1],
1115 coordinates[1][2] - coordinates[5][2] );
1117 current_oddy =
oddy_comp( xxi, xet, xze );
1118 if( current_oddy > oddy )
1120 oddy = current_oddy;
1123 xxi.
set( coordinates[5][0] - coordinates[6][0], coordinates[5][1] - coordinates[6][1],
1124 coordinates[5][2] - coordinates[6][2] );
1126 xet.
set( coordinates[7][0] - coordinates[6][0], coordinates[7][1] - coordinates[6][1],
1127 coordinates[7][2] - coordinates[6][2] );
1129 xze.
set( coordinates[2][0] - coordinates[6][0], coordinates[2][1] - coordinates[6][1],
1130 coordinates[2][2] - coordinates[6][2] );
1132 current_oddy =
oddy_comp( xxi, xet, xze );
1133 if( current_oddy > oddy )
1135 oddy = current_oddy;
1138 xxi.
set( coordinates[6][0] - coordinates[7][0], coordinates[6][1] - coordinates[7][1],
1139 coordinates[6][2] - coordinates[7][2] );
1141 xet.
set( coordinates[4][0] - coordinates[7][0], coordinates[4][1] - coordinates[7][1],
1142 coordinates[4][2] - coordinates[7][2] );
1144 xze.
set( coordinates[3][0] - coordinates[7][0], coordinates[3][1] - coordinates[7][1],
1145 coordinates[3][2] - coordinates[7][2] );
1147 current_oddy =
oddy_comp( xxi, xet, xze );
1148 if( current_oddy > oddy )
1150 oddy = current_oddy;
1170 double med_aspect_frobenius = 0.;
1175 xxi = node_pos[1] - node_pos[0];
1176 xet = node_pos[3] - node_pos[0];
1177 xze = node_pos[4] - node_pos[0];
1182 xxi = node_pos[2] - node_pos[1];
1183 xet = node_pos[0] - node_pos[1];
1184 xze = node_pos[5] - node_pos[1];
1189 xxi = node_pos[3] - node_pos[2];
1190 xet = node_pos[1] - node_pos[2];
1191 xze = node_pos[6] - node_pos[2];
1196 xxi = node_pos[0] - node_pos[3];
1197 xet = node_pos[2] - node_pos[3];
1198 xze = node_pos[7] - node_pos[3];
1203 xxi = node_pos[7] - node_pos[4];
1204 xet = node_pos[5] - node_pos[4];
1205 xze = node_pos[0] - node_pos[4];
1210 xxi = node_pos[4] - node_pos[5];
1211 xet = node_pos[6] - node_pos[5];
1212 xze = node_pos[1] - node_pos[5];
1217 xxi = node_pos[5] - node_pos[6];
1218 xet = node_pos[7] - node_pos[6];
1219 xze = node_pos[2] - node_pos[6];
1224 xxi = node_pos[6] - node_pos[7];
1225 xet = node_pos[4] - node_pos[7];
1226 xze = node_pos[3] - node_pos[7];
1229 med_aspect_frobenius /= 24.;
1249 double condition = 0.0, current_condition;
1257 if( current_condition > condition )
1259 condition = current_condition;
1264 xxi = node_pos[1] - node_pos[0];
1265 xet = node_pos[3] - node_pos[0];
1266 xze = node_pos[4] - node_pos[0];
1269 if( current_condition > condition )
1271 condition = current_condition;
1276 xxi = node_pos[2] - node_pos[1];
1277 xet = node_pos[0] - node_pos[1];
1278 xze = node_pos[5] - node_pos[1];
1281 if( current_condition > condition )
1283 condition = current_condition;
1288 xxi = node_pos[3] - node_pos[2];
1289 xet = node_pos[1] - node_pos[2];
1290 xze = node_pos[6] - node_pos[2];
1293 if( current_condition > condition )
1295 condition = current_condition;
1300 xxi = node_pos[0] - node_pos[3];
1301 xet = node_pos[2] - node_pos[3];
1302 xze = node_pos[7] - node_pos[3];
1305 if( current_condition > condition )
1307 condition = current_condition;
1312 xxi = node_pos[7] - node_pos[4];
1313 xet = node_pos[5] - node_pos[4];
1314 xze = node_pos[0] - node_pos[4];
1317 if( current_condition > condition )
1319 condition = current_condition;
1324 xxi = node_pos[4] - node_pos[5];
1325 xet = node_pos[6] - node_pos[5];
1326 xze = node_pos[1] - node_pos[5];
1329 if( current_condition > condition )
1331 condition = current_condition;
1336 xxi = node_pos[5] - node_pos[6];
1337 xet = node_pos[7] - node_pos[6];
1338 xze = node_pos[2] - node_pos[6];
1341 if( current_condition > condition )
1343 condition = current_condition;
1348 xxi = node_pos[6] - node_pos[7];
1349 xet = node_pos[4] - node_pos[7];
1350 xze = node_pos[3] - node_pos[7];
1353 if( current_condition > condition )
1355 condition = current_condition;
1389 double current_jacobian;
1396 current_jacobian = xxi % ( xet * xze ) / 64.0;
1397 if( current_jacobian < jacobian )
1399 jacobian = current_jacobian;
1404 xxi = node_pos[1] - node_pos[0];
1405 xet = node_pos[3] - node_pos[0];
1406 xze = node_pos[4] - node_pos[0];
1408 current_jacobian = xxi % ( xet * xze );
1409 if( current_jacobian < jacobian )
1411 jacobian = current_jacobian;
1416 xxi = node_pos[2] - node_pos[1];
1417 xet = node_pos[0] - node_pos[1];
1418 xze = node_pos[5] - node_pos[1];
1420 current_jacobian = xxi % ( xet * xze );
1421 if( current_jacobian < jacobian )
1423 jacobian = current_jacobian;
1428 xxi = node_pos[3] - node_pos[2];
1429 xet = node_pos[1] - node_pos[2];
1430 xze = node_pos[6] - node_pos[2];
1432 current_jacobian = xxi % ( xet * xze );
1433 if( current_jacobian < jacobian )
1435 jacobian = current_jacobian;
1440 xxi = node_pos[0] - node_pos[3];
1441 xet = node_pos[2] - node_pos[3];
1442 xze = node_pos[7] - node_pos[3];
1444 current_jacobian = xxi % ( xet * xze );
1445 if( current_jacobian < jacobian )
1447 jacobian = current_jacobian;
1452 xxi = node_pos[7] - node_pos[4];
1453 xet = node_pos[5] - node_pos[4];
1454 xze = node_pos[0] - node_pos[4];
1456 current_jacobian = xxi % ( xet * xze );
1457 if( current_jacobian < jacobian )
1459 jacobian = current_jacobian;
1464 xxi = node_pos[4] - node_pos[5];
1465 xet = node_pos[6] - node_pos[5];
1466 xze = node_pos[1] - node_pos[5];
1468 current_jacobian = xxi % ( xet * xze );
1469 if( current_jacobian < jacobian )
1471 jacobian = current_jacobian;
1476 xxi = node_pos[5] - node_pos[6];
1477 xet = node_pos[7] - node_pos[6];
1478 xze = node_pos[2] - node_pos[6];
1480 current_jacobian = xxi % ( xet * xze );
1481 if( current_jacobian < jacobian )
1483 jacobian = current_jacobian;
1488 xxi = node_pos[6] - node_pos[7];
1489 xet = node_pos[4] - node_pos[7];
1490 xze = node_pos[3] - node_pos[7];
1492 current_jacobian = xxi % ( xet * xze );
1493 if( current_jacobian < jacobian )
1495 jacobian = current_jacobian;
1512 double temp_norm_jac, lengths;
1513 double len1_sq, len2_sq, len3_sq;
1523 jacobi = xxi % ( xet * xze );
1533 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1534 temp_norm_jac = jacobi / lengths;
1536 if( temp_norm_jac < min_norm_jac )
1537 min_norm_jac = temp_norm_jac;
1539 temp_norm_jac = jacobi;
1543 xxi = node_pos[1] - node_pos[0];
1544 xet = node_pos[3] - node_pos[0];
1545 xze = node_pos[4] - node_pos[0];
1547 jacobi = xxi % ( xet * xze );
1557 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1558 temp_norm_jac = jacobi / lengths;
1559 if( temp_norm_jac < min_norm_jac )
1560 min_norm_jac = temp_norm_jac;
1562 temp_norm_jac = jacobi;
1566 xxi = node_pos[2] - node_pos[1];
1567 xet = node_pos[0] - node_pos[1];
1568 xze = node_pos[5] - node_pos[1];
1570 jacobi = xxi % ( xet * xze );
1580 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1581 temp_norm_jac = jacobi / lengths;
1582 if( temp_norm_jac < min_norm_jac )
1583 min_norm_jac = temp_norm_jac;
1585 temp_norm_jac = jacobi;
1589 xxi = node_pos[3] - node_pos[2];
1590 xet = node_pos[1] - node_pos[2];
1591 xze = node_pos[6] - node_pos[2];
1593 jacobi = xxi % ( xet * xze );
1603 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1604 temp_norm_jac = jacobi / lengths;
1605 if( temp_norm_jac < min_norm_jac )
1606 min_norm_jac = temp_norm_jac;
1608 temp_norm_jac = jacobi;
1612 xxi = node_pos[0] - node_pos[3];
1613 xet = node_pos[2] - node_pos[3];
1614 xze = node_pos[7] - node_pos[3];
1616 jacobi = xxi % ( xet * xze );
1626 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1627 temp_norm_jac = jacobi / lengths;
1628 if( temp_norm_jac < min_norm_jac )
1629 min_norm_jac = temp_norm_jac;
1631 temp_norm_jac = jacobi;
1635 xxi = node_pos[7] - node_pos[4];
1636 xet = node_pos[5] - node_pos[4];
1637 xze = node_pos[0] - node_pos[4];
1639 jacobi = xxi % ( xet * xze );
1649 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1650 temp_norm_jac = jacobi / lengths;
1651 if( temp_norm_jac < min_norm_jac )
1652 min_norm_jac = temp_norm_jac;
1654 temp_norm_jac = jacobi;
1658 xxi = node_pos[4] - node_pos[5];
1659 xet = node_pos[6] - node_pos[5];
1660 xze = node_pos[1] - node_pos[5];
1662 jacobi = xxi % ( xet * xze );
1672 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1673 temp_norm_jac = jacobi / lengths;
1674 if( temp_norm_jac < min_norm_jac )
1675 min_norm_jac = temp_norm_jac;
1677 temp_norm_jac = jacobi;
1681 xxi = node_pos[5] - node_pos[6];
1682 xet = node_pos[7] - node_pos[6];
1683 xze = node_pos[2] - node_pos[6];
1685 jacobi = xxi % ( xet * xze );
1695 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1696 temp_norm_jac = jacobi / lengths;
1697 if( temp_norm_jac < min_norm_jac )
1698 min_norm_jac = temp_norm_jac;
1700 temp_norm_jac = jacobi;
1704 xxi = node_pos[6] - node_pos[7];
1705 xet = node_pos[4] - node_pos[7];
1706 xze = node_pos[3] - node_pos[7];
1708 jacobi = xxi % ( xet * xze );
1718 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1719 temp_norm_jac = jacobi / lengths;
1720 if( temp_norm_jac < min_norm_jac ) min_norm_jac = temp_norm_jac;
1737 double min_shear = 1.0;
1739 double det, len1_sq, len2_sq, len3_sq, lengths;
1746 xxi = node_pos[1] - node_pos[0];
1747 xet = node_pos[3] - node_pos[0];
1748 xze = node_pos[4] - node_pos[0];
1756 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1757 det = xxi % ( xet * xze );
1763 shear = det / lengths;
1768 xxi = node_pos[2] - node_pos[1];
1769 xet = node_pos[0] - node_pos[1];
1770 xze = node_pos[5] - node_pos[1];
1778 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1779 det = xxi % ( xet * xze );
1785 shear = det / lengths;
1790 xxi = node_pos[3] - node_pos[2];
1791 xet = node_pos[1] - node_pos[2];
1792 xze = node_pos[6] - node_pos[2];
1800 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1801 det = xxi % ( xet * xze );
1807 shear = det / lengths;
1812 xxi = node_pos[0] - node_pos[3];
1813 xet = node_pos[2] - node_pos[3];
1814 xze = node_pos[7] - node_pos[3];
1822 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1823 det = xxi % ( xet * xze );
1829 shear = det / lengths;
1834 xxi = node_pos[7] - node_pos[4];
1835 xet = node_pos[5] - node_pos[4];
1836 xze = node_pos[0] - node_pos[4];
1844 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1845 det = xxi % ( xet * xze );
1851 shear = det / lengths;
1856 xxi = node_pos[4] - node_pos[5];
1857 xet = node_pos[6] - node_pos[5];
1858 xze = node_pos[1] - node_pos[5];
1866 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1867 det = xxi % ( xet * xze );
1873 shear = det / lengths;
1878 xxi = node_pos[5] - node_pos[6];
1879 xet = node_pos[7] - node_pos[6];
1880 xze = node_pos[2] - node_pos[6];
1888 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1889 det = xxi % ( xet * xze );
1895 shear = det / lengths;
1900 xxi = node_pos[6] - node_pos[7];
1901 xet = node_pos[4] - node_pos[7];
1902 xze = node_pos[3] - node_pos[7];
1910 lengths = sqrt( len1_sq * len2_sq * len3_sq );
1911 det = xxi % ( xet * xze );
1917 shear = det / lengths;
1935 double min_shape = 1.0;
1936 static const double two_thirds = 2.0 / 3.0;
1945 xxi = node_pos[1] - node_pos[0];
1946 xet = node_pos[3] - node_pos[0];
1947 xze = node_pos[4] - node_pos[0];
1949 det = xxi % ( xet * xze );
1951 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
1955 if( shape < min_shape )
1962 xxi = node_pos[2] - node_pos[1];
1963 xet = node_pos[0] - node_pos[1];
1964 xze = node_pos[5] - node_pos[1];
1966 det = xxi % ( xet * xze );
1968 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
1972 if( shape < min_shape )
1979 xxi = node_pos[3] - node_pos[2];
1980 xet = node_pos[1] - node_pos[2];
1981 xze = node_pos[6] - node_pos[2];
1983 det = xxi % ( xet * xze );
1985 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
1989 if( shape < min_shape )
1996 xxi = node_pos[0] - node_pos[3];
1997 xet = node_pos[2] - node_pos[3];
1998 xze = node_pos[7] - node_pos[3];
2000 det = xxi % ( xet * xze );
2002 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
2006 if( shape < min_shape )
2013 xxi = node_pos[7] - node_pos[4];
2014 xet = node_pos[5] - node_pos[4];
2015 xze = node_pos[0] - node_pos[4];
2017 det = xxi % ( xet * xze );
2019 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
2023 if( shape < min_shape )
2030 xxi = node_pos[4] - node_pos[5];
2031 xet = node_pos[6] - node_pos[5];
2032 xze = node_pos[1] - node_pos[5];
2034 det = xxi % ( xet * xze );
2036 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
2040 if( shape < min_shape )
2047 xxi = node_pos[5] - node_pos[6];
2048 xet = node_pos[7] - node_pos[6];
2049 xze = node_pos[2] - node_pos[6];
2051 det = xxi % ( xet * xze );
2053 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
2057 if( shape < min_shape )
2064 xxi = node_pos[6] - node_pos[7];
2065 xet = node_pos[4] - node_pos[7];
2066 xze = node_pos[3] - node_pos[7];
2068 det = xxi % ( xet * xze );
2070 shape = 3 * pow( det, two_thirds ) / ( xxi % xxi + xet % xet + xze % xze );
2074 if( shape < min_shape )
2096 double det, det_sum = 0;
2101 double detw = xxi % ( xet * xze );
2110 xxi = node_pos[1] - node_pos[0];
2111 xet = node_pos[3] - node_pos[0];
2112 xze = node_pos[4] - node_pos[0];
2114 det = xxi % ( xet * xze );
2119 xxi = node_pos[2] - node_pos[1];
2120 xet = node_pos[0] - node_pos[1];
2121 xze = node_pos[5] - node_pos[1];
2123 det = xxi % ( xet * xze );
2128 xxi = node_pos[3] - node_pos[2];
2129 xet = node_pos[1] - node_pos[2];
2130 xze = node_pos[6] - node_pos[2];
2132 det = xxi % ( xet * xze );
2137 xxi = node_pos[0] - node_pos[3];
2138 xet = node_pos[2] - node_pos[3];
2139 xze = node_pos[7] - node_pos[3];
2141 det = xxi % ( xet * xze );
2146 xxi = node_pos[7] - node_pos[4];
2147 xet = node_pos[5] - node_pos[4];
2148 xze = node_pos[0] - node_pos[4];
2150 det = xxi % ( xet * xze );
2155 xxi = node_pos[4] - node_pos[5];
2156 xet = node_pos[6] - node_pos[5];
2157 xze = node_pos[1] - node_pos[5];
2159 det = xxi % ( xet * xze );
2164 xxi = node_pos[5] - node_pos[6];
2165 xet = node_pos[7] - node_pos[6];
2166 xze = node_pos[2] - node_pos[6];
2168 det = xxi % ( xet * xze );
2173 xxi = node_pos[6] - node_pos[7];
2174 xet = node_pos[4] - node_pos[7];
2175 xze = node_pos[3] - node_pos[7];
2177 det = xxi % ( xet * xze );
2182 tau = det_sum / ( 8 * detw );
2201 double shape =
v_hex_shape( num_nodes, coordinates );
2203 double shape_size =
size * shape;
2217 double shear =
v_hex_shear( num_nodes, coordinates );
2219 double shear_size = shear *
size;
2232 int number_of_gauss_points = 0;
2233 if( num_nodes == 8 )
2235 number_of_gauss_points = 2;
2236 else if( num_nodes == 20 )
2238 number_of_gauss_points = 3;
2240 int number_dimension = 3;
2241 int total_number_of_gauss_points = number_of_gauss_points * number_of_gauss_points * number_of_gauss_points;
2263 double jacobian, minimum_jacobian;
2264 double element_volume = 0.0;
2268 for( ife = 0; ife < total_number_of_gauss_points; ife++ )
2271 xxi.
set( 0.0, 0.0, 0.0 );
2272 xet.
set( 0.0, 0.0, 0.0 );
2273 xze.
set( 0.0, 0.0, 0.0 );
2275 for( ja = 0; ja < num_nodes; ja++ )
2277 xin.
set( coordinates[ja][0], coordinates[ja][1], coordinates[ja][2] );
2278 xxi += dndy1[ife][ja] * xin;
2279 xet += dndy2[ife][ja] * xin;
2280 xze += dndy3[ife][ja] * xin;
2283 jacobian = xxi % ( xet * xze );
2284 if( minimum_jacobian > jacobian ) minimum_jacobian = jacobian;
2286 element_volume += weight[ife] * jacobian;
2296 for( node_id = 0; node_id < num_nodes; node_id++ )
2299 xxi.
set( 0.0, 0.0, 0.0 );
2300 xet.
set( 0.0, 0.0, 0.0 );
2301 xze.
set( 0.0, 0.0, 0.0 );
2303 for( ja = 0; ja < num_nodes; ja++ )
2305 xin.
set( coordinates[ja][0], coordinates[ja][1], coordinates[ja][2] );
2306 xxi += dndy1_at_node[node_id][ja] * xin;
2307 xet += dndy2_at_node[node_id][ja] * xin;
2308 xze += dndy3_at_node[node_id][ja] * xin;
2311 jacobian = xxi % ( xet * xze );
2312 if( minimum_jacobian > jacobian ) minimum_jacobian = jacobian;
2314 distortion = minimum_jacobian / element_volume * 8.;
2315 return (
double)distortion;
2652 double coordinates[][3],
2653 unsigned int metrics_request_flag,
2671 double max_edge_ratio_12, max_edge_ratio_13, max_edge_ratio_23;
2673 double mag_efg1 = efg1.
length();
2674 double mag_efg2 = efg2.
length();
2675 double mag_efg3 = efg3.
length();
2699 double skewx = fabs( vec1 % vec2 );
2700 double skewy = fabs( vec1 % vec3 );
2701 double skewz = fabs( vec2 % vec3 );
2726 if( metrics_request_flag &
2731 static const double two_thirds = 2.0 / 3.0;
2739 if( metrics_request_flag &
2746 double current_jacobian, current_scaled_jacobian, current_condition, current_shape, detw = 0, det_sum = 0,
2756 detw = xxi % ( xet * xze );
2760 xxi = edges[0] - edges[2] + edges[4] - edges[6];
2761 xet = edges[1] - edges[3] + edges[5] - edges[7];
2762 xze = edges[8] + edges[9] + edges[10] + edges[11];
2764 current_jacobian = xxi % ( xet * xze ) / 64.0;
2765 if( current_jacobian < jacobian ) jacobian = current_jacobian;
2769 current_jacobian *= 64.0;
2770 current_scaled_jacobian =
2772 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
2778 if( current_condition > condition )
2780 condition = current_condition;
2786 current_oddy =
oddy_comp( xxi, xet, xze );
2787 if( current_oddy > oddy )
2789 oddy = current_oddy;
2794 current_jacobian = edges[0] % ( -edges[3] * edges[8] );
2795 if( current_jacobian < jacobian ) jacobian = current_jacobian;
2799 det_sum += current_jacobian;
2811 current_scaled_jacobian =
2814 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
2819 current_condition =
condition_comp( edges[0], -edges[3], edges[8] );
2820 if( current_condition > condition )
2822 condition = current_condition;
2828 current_oddy =
oddy_comp( edges[0], -edges[3], edges[8] );
2829 if( current_oddy > oddy )
2831 oddy = current_oddy;
2838 current_shape = 3 * pow( current_jacobian, two_thirds ) /
2843 if( current_shape < shape )
2845 shape = current_shape;
2850 current_jacobian = edges[1] % ( -edges[0] * edges[9] );
2851 if( current_jacobian < jacobian ) jacobian = current_jacobian;
2855 det_sum += current_jacobian;
2867 current_scaled_jacobian =
2870 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
2875 current_condition =
condition_comp( edges[1], -edges[0], edges[9] );
2876 if( current_condition > condition )
2878 condition = current_condition;
2884 current_oddy =
oddy_comp( edges[1], -edges[0], edges[9] );
2885 if( current_oddy > oddy )
2887 oddy = current_oddy;
2894 current_shape = 3 * pow( current_jacobian, two_thirds ) /
2899 if( current_shape < shape )
2901 shape = current_shape;
2906 current_jacobian = edges[2] % ( -edges[1] * edges[10] );
2907 if( current_jacobian < jacobian ) jacobian = current_jacobian;
2911 det_sum += current_jacobian;
2923 current_scaled_jacobian =
2926 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
2931 current_condition =
condition_comp( edges[2], -edges[1], edges[10] );
2932 if( current_condition > condition )
2934 condition = current_condition;
2940 current_oddy =
oddy_comp( edges[2], -edges[1], edges[10] );
2941 if( current_oddy > oddy )
2943 oddy = current_oddy;
2950 current_shape = 3 * pow( current_jacobian, two_thirds ) /
2955 if( current_shape < shape )
2957 shape = current_shape;
2962 current_jacobian = edges[3] % ( -edges[2] * edges[11] );
2963 if( current_jacobian < jacobian ) jacobian = current_jacobian;
2967 det_sum += current_jacobian;
2979 current_scaled_jacobian =
2982 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
2987 current_condition =
condition_comp( edges[3], -edges[2], edges[11] );
2988 if( current_condition > condition )
2990 condition = current_condition;
2996 current_oddy =
oddy_comp( edges[3], -edges[2], edges[11] );
2997 if( current_oddy > oddy )
2999 oddy = current_oddy;
3006 current_shape = 3 * pow( current_jacobian, two_thirds ) /
3011 if( current_shape < shape )
3013 shape = current_shape;
3018 current_jacobian = edges[4] % ( -edges[8] * -edges[7] );
3019 if( current_jacobian < jacobian ) jacobian = current_jacobian;
3023 det_sum += current_jacobian;
3035 current_scaled_jacobian =
3038 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
3043 current_condition =
condition_comp( edges[4], -edges[8], -edges[7] );
3044 if( current_condition > condition )
3046 condition = current_condition;
3052 current_oddy =
oddy_comp( edges[4], -edges[8], -edges[7] );
3053 if( current_oddy > oddy )
3055 oddy = current_oddy;
3062 current_shape = 3 * pow( current_jacobian, two_thirds ) /
3067 if( current_shape < shape )
3069 shape = current_shape;
3074 current_jacobian = -edges[4] % ( edges[5] * -edges[9] );
3075 if( current_jacobian < jacobian ) jacobian = current_jacobian;
3079 det_sum += current_jacobian;
3091 current_scaled_jacobian =
3094 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
3099 current_condition =
condition_comp( -edges[4], edges[5], -edges[9] );
3100 if( current_condition > condition )
3102 condition = current_condition;
3108 current_oddy =
oddy_comp( -edges[4], edges[5], -edges[9] );
3109 if( current_oddy > oddy )
3111 oddy = current_oddy;
3118 current_shape = 3 * pow( current_jacobian, two_thirds ) /
3123 if( current_shape < shape )
3125 shape = current_shape;
3130 current_jacobian = -edges[5] % ( edges[6] * -edges[10] );
3131 if( current_jacobian < jacobian ) jacobian = current_jacobian;
3135 det_sum += current_jacobian;
3147 current_scaled_jacobian =
3150 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
3155 current_condition =
condition_comp( -edges[5], edges[6], -edges[10] );
3156 if( current_condition > condition )
3158 condition = current_condition;
3164 current_oddy =
oddy_comp( -edges[5], edges[6], -edges[10] );
3165 if( current_oddy > oddy )
3167 oddy = current_oddy;
3174 current_shape = 3 * pow( current_jacobian, two_thirds ) /
3179 if( current_shape < shape )
3181 shape = current_shape;
3186 current_jacobian = -edges[6] % ( edges[7] * -edges[11] );
3187 if( current_jacobian < jacobian ) jacobian = current_jacobian;
3191 det_sum += current_jacobian;
3203 current_scaled_jacobian =
3206 if( current_scaled_jacobian < scaled_jacobian ) shear = scaled_jacobian = current_scaled_jacobian;
3211 current_condition =
condition_comp( -edges[6], edges[7], -edges[11] );
3212 if( current_condition > condition )
3214 condition = current_condition;
3220 current_oddy =
oddy_comp( -edges[6], edges[7], -edges[11] );
3221 if( current_oddy > oddy )
3223 oddy = current_oddy;
3230 current_shape = 3 * pow( current_jacobian, two_thirds ) /
3235 if( current_shape < shape )
3237 shape = current_shape;
3245 double tau = det_sum / ( 8 * detw );
3263 metric_vals->
shear = (double)shear;
3266 if( metrics_request_flag &
V_HEX_SHAPE ) metric_vals->
shape = (double)shape;
3274 if( metrics_request_flag &
V_HEX_ODDY ) metric_vals->
oddy = (double)oddy;
3278 static const double HEX_STRETCH_SCALE_FACTOR = sqrt( 3.0 );
3280 for(
int j = 1; j < 12; j++ )
3285 metric_vals->
stretch = (double)( HEX_STRETCH_SCALE_FACTOR * (
safe_ratio( sqrt( min_edge ), max_diag ) ) );
3301 if( metric_vals->
skew > 0 )
3307 if( metric_vals->
taper > 0 )
3313 if( metric_vals->
volume > 0 )
3319 if( metric_vals->
stretch > 0 )
3337 if( metric_vals->
oddy > 0 )
3361 if( metric_vals->
shear > 0 )
3367 if( metric_vals->
shape > 0 )