void test01 ( ) /******************************************************************************/ /* Purpose: TEST01 tests R8TRIS2. Licensing: This code is distributed under the GNU LGPL license. Modified: 25 October 2012 Author: John Burkardt */ { int element_neighbor[3*2*9]; int element_num; int element_order = 3; int node_num = 9; double node_xy[2*9] = { 0.0, 0.0, 0.0, 1.0, 0.2, 0.5, 0.3, 0.6, 0.4, 0.5, 0.6, 0.4, 0.6, 0.5, 1.0, 0.0, 1.0, 1.0 }; int triangle[3*2*9]; printf ( "\n" ); printf ( "TEST01\n" ); printf ( " R8TRIS2 computes the Delaunay triangulation of\n" ); printf ( " a set of nodes in 2D.\n" ); /* Set up the Delaunay triangulation. */ r8tris2 ( node_num, node_xy, &element_num, triangle, element_neighbor ); triangulation_order3_print ( node_num, element_num, node_xy, triangle, element_neighbor ); return; }
void test08 ( ) /******************************************************************************/ /* Purpose: TEST08 tests TRIANGULATION_ORDER3_PRINT. Licensing: This code is distributed under the GNU LGPL license. Modified: 23 October 2012 Author: John Burkardt */ { # define NODE_NUM 9 # define DIM_NUM 2 # define TRI_NUM 12 double g_xy[DIM_NUM*NODE_NUM] = { 0.0, 0.0, 0.0, 1.0, 0.2, 0.5, 0.3, 0.6, 0.4, 0.5, 0.6, 0.4, 0.6, 0.5, 1.0, 0.0, 1.0, 1.0 }; int nod_tri[TRI_NUM*3] = { 2, 1, 3, 3, 1, 6, 2, 3, 4, 4, 3, 5, 7, 4, 5, 5, 3, 6, 7, 5, 6, 9, 4, 7, 6, 1, 8, 7, 6, 8, 7, 8, 9, 2, 4, 9 }; int triangle_neighbor[TRI_NUM*3] = { -28, 2, 3, 1, 9, 6, 1, 4, 12, 3, 6, 5, 8, 4, 7, 4, 2, 7, 5, 6, 10, 12, 5, 11, 2, -34, 10, 7, 9, 11, 10, -38, 8, 3, 8, -3 }; printf ( "\n" ); printf ( "TEST08\n" ); printf ( " TRIANGULATION_ORDER3_PRINT prints out a triangulation.\n" ); triangulation_order3_print ( NODE_NUM, TRI_NUM, g_xy, nod_tri, triangle_neighbor ); return; # undef NODE_NUM # undef DIM_NUM # undef TRI_NUM }
void test02 ( ) /******************************************************************************/ /* Purpose: TEST02 tests PWL_INTERP_2D_SCATTERED_VALUE. Licensing: This code is distributed under the GNU LGPL license. Modified: 25 October 2012 Author: John Burkardt */ { int element_neighbor[3*2*9]; int element_num; int element_order = 3; int i; int j; int k; int ni = 25; int node_num = 9; double node_xy[2*9] = { 0.0, 0.0, 0.0, 1.0, 0.2, 0.5, 0.3, 0.6, 0.4, 0.5, 0.6, 0.4, 0.6, 0.5, 1.0, 0.0, 1.0, 1.0 }; int triangle[3*2*9]; double x; double xyi[2*25]; double y; double zd[9]; double ze; double *zi; printf ( "\n" ); printf ( "TEST02\n" ); printf ( " PWL_INTERP_2D_SCATTERED_VALUE evaluates a\n" ); printf ( " piecewise linear interpolant to scattered data.\n" ); /* Set up the Delaunay triangulation. */ r8tris2 ( node_num, node_xy, &element_num, triangle, element_neighbor ); for ( j = 0; j < element_num; j++ ) { for ( i = 0; i < 3; i++ ) { if ( 0 < element_neighbor[i+j*3] ) { element_neighbor[i+j*3] = element_neighbor[i+j*3] - 1; } } } triangulation_order3_print ( node_num, element_num, node_xy, triangle, element_neighbor ); /* Define the Z data. */ for ( i = 0; i < node_num; i++ ) { x = node_xy[0+i*2]; y = node_xy[1+i*2]; zd[i] = x + 2.0 * y; } /* Define the interpolation points. */ k = 0; for ( i = 0; i <= 4; i++ ) { for ( j = 0; j <= 4; j++ ) { xyi[0+k*2] = ( i - 1 ) / 4.0; xyi[1+k*2] = ( j - 1 ) / 4.0; k = k + 1; } } /* Evaluate the interpolant. */ zi = pwl_interp_2d_scattered_value ( node_num, node_xy, zd, element_num, triangle, element_neighbor, ni, xyi ); printf ( "\n" ); printf ( " K Xi(K) Yi(K) Zi(K) Z(X,Y)\n" ); printf ( "\n" ); for ( k = 0; k < ni; k++ ) { ze = xyi[0+k*2] + 2.0 * xyi[1+k*2]; printf ( " %4d %10.4f %10.4f %10.4f %10.4f\n", k, xyi[0+k*2], xyi[1+k*2], zi[k], ze ); } free ( zi ); return; }
void test05 ( ) /******************************************************************************/ /* Purpose: TEST05 tests R8TRIS2. Licensing: This code is distributed under the GNU LGPL license. Modified: 23 October 2012 Author: John Burkardt */ { # define DIM_NUM 2 # define NODE_NUM 9 int error; double g_xy[DIM_NUM*NODE_NUM] = { 0.0, 0.0, 0.0, 1.0, 0.2, 0.5, 0.3, 0.6, 0.4, 0.5, 0.6, 0.4, 0.6, 0.5, 1.0, 0.0, 1.0, 1.0 }; int nod_tri[2*NODE_NUM*3]; int triangle_neighbor[2*NODE_NUM*3]; int tri_num; printf ( "\n" ); printf ( "TEST05\n" ); printf ( " R8TRIS2 computes the Delaunay triangulation of a\n" ); printf ( " pointset in 2D.\n" ); /* Set up the Delaunay triangulation. */ error = r8tris2 ( NODE_NUM, g_xy, &tri_num, nod_tri, triangle_neighbor ); if ( error == 0 ) { printf ( "\n" ); printf ( " R8TRIS2 computed the Delaunay triangulation with no\n" ); printf ( " errors detected.\n" ); } else { printf ( "\n" ); printf ( " R8TRIS2 detected an error condition of index %d\n", error ); return; } triangulation_order3_print ( NODE_NUM, tri_num, g_xy, nod_tri, triangle_neighbor ); return; # undef NODE_NUM # undef DIM_NUM }