MOAB: Mesh Oriented datABase  (version 5.5.0)
tstt_perf_binding.cpp File Reference
#include <sys/resource.h>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cassert>
#include "iMesh.h"
+ Include dependency graph for tstt_perf_binding.cpp:

Go to the source code of this file.

Macros

#define VINDEX(i, j, k)   ( ( i ) + ( (j)*numv ) + ( (k)*numv_sq ) )
 
#define VINDEX(i, j, k)   ( ( i ) + ( (j)*numv ) + ( (k)*numv_sq ) )
 

Functions

void query_elem_to_vert (iMesh_Instance mesh)
 
void query_vert_to_elem (iMesh_Instance mesh)
 
void print_time (const bool print_em, double &tot_time, double &utime, double &stime, long &imem, long &rmem)
 
void build_connect (const int nelem, const int vstart, int *&connect)
 
void testB (iMesh_Instance mesh, const int nelem, const double *coords, int *connect)
 
void testC (iMesh_Instance mesh, const int nelem, const double *coords)
 
void compute_edge (double *start, const int nelem, const double xint, const int stride)
 
void compute_face (double *a, const int nelem, const double xint, const int stride1, const int stride2)
 
void build_coords (const int nelem, double *&coords)
 
int main (int argc, char *argv[])
 

Variables

double LENGTH = 1.0
 

Macro Definition Documentation

◆ VINDEX [1/2]

#define VINDEX (   i,
  j,
 
)    ( ( i ) + ( (j)*numv ) + ( (k)*numv_sq ) )

◆ VINDEX [2/2]

#define VINDEX (   i,
  j,
 
)    ( ( i ) + ( (j)*numv ) + ( (k)*numv_sq ) )

Function Documentation

◆ build_connect()

void build_connect ( const int  nelem,
const int  vstart,
int *&  connect 
)

Definition at line 623 of file tstt_perf_binding.cpp.

624 {
625  // allocate the memory
626  int nume_tot = nelem * nelem * nelem;
627  connect = (int*)malloc( 8 * nume_tot * sizeof( int ) );
628 
629  int vijk;
630  int numv = nelem + 1;
631  int numv_sq = numv * numv;
632  int idx = 0;
633  for( int i = 0; i < nelem; i++ )
634  {
635  for( int j = 0; j < nelem; j++ )
636  {
637  for( int k = 0; k < nelem; k++ )
638  {
639  vijk = vstart + VINDEX( i, j, k );
640  connect[idx++] = vijk;
641  connect[idx++] = vijk + 1;
642  connect[idx++] = vijk + 1 + numv;
643  connect[idx++] = vijk + numv;
644  connect[idx++] = vijk + numv * numv;
645  connect[idx++] = vijk + 1 + numv * numv;
646  connect[idx++] = vijk + 1 + numv + numv * numv;
647  connect[idx++] = vijk + numv + numv * numv;
648  assert( i <= numv * numv * numv );
649  }
650  }
651  }
652 }

References VINDEX.

Referenced by main().

◆ build_coords()

void build_coords ( const int  nelem,
double *&  coords 
)

Definition at line 479 of file tstt_perf_binding.cpp.

480 {
481  double ttime0, ttime1, utime1, stime1;
482  long imem, rmem;
483  print_time( false, ttime0, utime1, stime1, imem, rmem );
484 
485  // allocate the memory
486  int numv = nelem + 1;
487  int numv_sq = numv * numv;
488  int tot_numv = numv * numv * numv;
489  coords = (double*)malloc( 3 * tot_numv * sizeof( double ) );
490 
491 // use FORTRAN-like indexing
492 #define VINDEX( i, j, k ) ( ( i ) + ( (j)*numv ) + ( (k)*numv_sq ) )
493  int idx;
494  double scale1, scale2, scale3;
495  // use these to prevent optimization on 1-scale, etc (real map wouldn't have
496  // all these equal)
497  scale1 = LENGTH / nelem;
498  scale2 = LENGTH / nelem;
499  scale3 = LENGTH / nelem;
500 
501 #ifdef REALTFI
502  // use a real TFI xform to compute coordinates
503  // compute edges
504  // i (stride=1)
505  compute_edge( &coords[VINDEX( 0, 0, 0 )], nelem, scale1, 1 );
506  compute_edge( &coords[VINDEX( 0, nelem, 0 )], nelem, scale1, 1 );
507  compute_edge( &coords[VINDEX( 0, 0, nelem )], nelem, scale1, 1 );
508  compute_edge( &coords[VINDEX( 0, nelem, nelem )], nelem, scale1, 1 );
509  // j (stride=numv)
510  compute_edge( &coords[VINDEX( 0, 0, 0 )], nelem, scale1, numv );
511  compute_edge( &coords[VINDEX( nelem, 0, 0 )], nelem, scale1, numv );
512  compute_edge( &coords[VINDEX( 0, 0, nelem )], nelem, scale1, numv );
513  compute_edge( &coords[VINDEX( nelem, 0, nelem )], nelem, scale1, numv );
514  // k (stride=numv^2)
515  compute_edge( &coords[VINDEX( 0, 0, 0 )], nelem, scale1, numv_sq );
516  compute_edge( &coords[VINDEX( nelem, 0, 0 )], nelem, scale1, numv_sq );
517  compute_edge( &coords[VINDEX( 0, nelem, 0 )], nelem, scale1, numv_sq );
518  compute_edge( &coords[VINDEX( nelem, nelem, 0 )], nelem, scale1, numv_sq );
519 
520  // compute faces
521  // i=0, nelem
522  compute_face( &coords[VINDEX( 0, 0, 0 )], nelem, scale1, numv, numv_sq );
523  compute_face( &coords[VINDEX( nelem, 0, 0 )], nelem, scale1, numv, numv_sq );
524  // j=0, nelem
525  compute_face( &coords[VINDEX( 0, 0, 0 )], nelem, scale1, 1, numv_sq );
526  compute_face( &coords[VINDEX( 0, nelem, 0 )], nelem, scale1, 1, numv_sq );
527  // k=0, nelem
528  compute_face( &coords[VINDEX( 0, 0, 0 )], nelem, scale1, 1, numv );
529  compute_face( &coords[VINDEX( 0, 0, nelem )], nelem, scale1, 1, numv );
530 
531  // initialize corner indices
532  int i000 = VINDEX( 0, 0, 0 );
533  int ia00 = VINDEX( nelem, 0, 0 );
534  int i0t0 = VINDEX( 0, nelem, 0 );
535  int iat0 = VINDEX( nelem, nelem, 0 );
536  int i00g = VINDEX( 0, 0, nelem );
537  int ia0g = VINDEX( nelem, 0, nelem );
538  int i0tg = VINDEX( 0, nelem, nelem );
539  int iatg = VINDEX( nelem, nelem, nelem );
540  double cX, cY, cZ;
541  int adaInts = nelem;
542  int tseInts = nelem;
543  int gammaInts = nelem;
544 
545  for( int i = 1; i < nelem; i++ )
546  {
547  for( int j = 1; j < nelem; j++ )
548  {
549  for( int k = 1; k < nelem; k++ )
550  {
551  // idx = VINDEX(i,j,k);
552  double tse = i * scale1;
553  double ada = j * scale2;
554  double gamma = k * scale3;
555  double tm1 = 1.0 - tse;
556  double am1 = 1.0 - ada;
557  double gm1 = 1.0 - gamma;
558 
559  cX = gm1 * ( am1 * ( tm1 * coords[i000] + tse * coords[i0t0] ) +
560  ada * ( tm1 * coords[ia00] + tse * coords[iat0] ) ) +
561  gamma * ( am1 * ( tm1 * coords[i00g] + tse * coords[i0tg] ) +
562  ada * ( tm1 * coords[ia0g] + tse * coords[iatg] ) );
563 
564  cY = gm1 * ( am1 * ( tm1 * coords[i000] + tse * coords[i0t0] ) +
565  ada * ( tm1 * coords[ia00] + tse * coords[iat0] ) ) +
566  gamma * ( am1 * ( tm1 * coords[i00g] + tse * coords[i0tg] ) +
567  ada * ( tm1 * coords[ia0g] + tse * coords[iatg] ) );
568 
569  cZ = gm1 * ( am1 * ( tm1 * coords[i000] + tse * coords[i0t0] ) +
570  ada * ( tm1 * coords[ia00] + tse * coords[iat0] ) ) +
571  gamma * ( am1 * ( tm1 * coords[i00g] + tse * coords[i0tg] ) +
572  ada * ( tm1 * coords[ia0g] + tse * coords[iatg] ) );
573 
574  double* ai0k = &coords[VINDEX( k, 0, i )];
575  double* aiak = &coords[VINDEX( k, adaInts, i )];
576  double* a0jk = &coords[VINDEX( k, j, 0 )];
577  double* atjk = &coords[VINDEX( k, j, tseInts )];
578  double* aij0 = &coords[VINDEX( 0, j, i )];
579  double* aijg = &coords[VINDEX( gammaInts, j, i )];
580 
581  coords[VINDEX( i, j, k )] = ( am1 * ai0k[0] + ada * aiak[0] + tm1 * a0jk[0] + tse * atjk[0] +
582  gm1 * aij0[0] + gamma * aijg[0] ) /
583  2.0 -
584  cX / 2.0;
585 
586  coords[nelem + 1 + VINDEX( i, j, k )] =
587  ( am1 * ai0k[nelem + 1] + ada * aiak[nelem + 1] + tm1 * a0jk[nelem + 1] + tse * atjk[nelem + 1] +
588  gm1 * aij0[nelem + 1] + gamma * aijg[nelem + 1] ) /
589  2.0 -
590  cY / 2.0;
591 
592  coords[2 * ( nelem + 1 ) + VINDEX( i, j, k )] =
593  ( am1 * ai0k[2 * ( nelem + 1 )] + ada * aiak[2 * ( nelem + 1 )] + tm1 * a0jk[2 * ( nelem + 1 )] +
594  tse * atjk[2 * ( nelem + 1 )] + gm1 * aij0[2 * ( nelem + 1 )] +
595  gamma * aijg[2 * ( nelem + 1 )] ) /
596  2.0 -
597  cZ / 2.0;
598  }
599  }
600  }
601 
602 #else
603  for( int i = 0; i < numv; i++ )
604  {
605  for( int j = 0; j < numv; j++ )
606  {
607  for( int k = 0; k < numv; k++ )
608  {
609  idx = VINDEX( i, j, k );
610  // blocked coordinate ordering
611  coords[idx] = i * scale1;
612  coords[tot_numv + idx] = j * scale2;
613  coords[2 * tot_numv + idx] = k * scale3;
614  }
615  }
616  }
617 #endif
618 
619  print_time( false, ttime1, utime1, stime1, imem, rmem );
620  std::cout << "TSTTbinding/MOAB: TFI time = " << ttime1 - ttime0 << " sec" << std::endl;
621 }

References compute_edge(), compute_face(), LENGTH, print_time(), and VINDEX.

Referenced by main().

◆ compute_edge()

void compute_edge ( double *  start,
const int  nelem,
const double  xint,
const int  stride 
)

Definition at line 434 of file tstt_perf_binding.cpp.

435 {
436  for( int i = 1; i < nelem; i++ )
437  {
438  start[i * stride] = start[0] + i * xint;
439  start[nelem + 1 + i * stride] = start[nelem + 1] + i * xint;
440  start[2 * ( nelem + 1 ) + i * stride] = start[2 * ( nelem + 1 )] + i * xint;
441  }
442 }

Referenced by build_coords().

◆ compute_face()

void compute_face ( double *  a,
const int  nelem,
const double  xint,
const int  stride1,
const int  stride2 
)

Definition at line 444 of file tstt_perf_binding.cpp.

445 {
446  // 2D TFI on a face starting at a, with strides stride1 in ada and stride2 in tse
447  for( int j = 1; j < nelem; j++ )
448  {
449  double tse = j * xint;
450  for( int i = 1; i < nelem; i++ )
451  {
452  double ada = i * xint;
453 
454  a[i * stride1 + j * stride2] =
455  ( 1.0 - ada ) * a[i * stride1] + ada * a[i * stride1 + nelem * stride2] +
456  ( 1.0 - tse ) * a[j * stride2] + tse * a[j * stride2 + nelem * stride1] -
457  ( 1.0 - tse ) * ( 1.0 - ada ) * a[0] - ( 1.0 - tse ) * ada * a[nelem * stride1] -
458  tse * ( 1.0 - ada ) * a[nelem * stride2] - tse * ada * a[nelem * ( stride1 + stride2 )];
459  a[nelem + 1 + i * stride1 + j * stride2] =
460  ( 1.0 - ada ) * a[nelem + 1 + i * stride1] + ada * a[nelem + 1 + i * stride1 + nelem * stride2] +
461  ( 1.0 - tse ) * a[nelem + 1 + j * stride2] + tse * a[nelem + 1 + j * stride2 + nelem * stride1] -
462  ( 1.0 - tse ) * ( 1.0 - ada ) * a[nelem + 1 + 0] -
463  ( 1.0 - tse ) * ada * a[nelem + 1 + nelem * stride1] -
464  tse * ( 1.0 - ada ) * a[nelem + 1 + nelem * stride2] -
465  tse * ada * a[nelem + 1 + nelem * ( stride1 + stride2 )];
466  a[2 * ( nelem + 1 ) + i * stride1 + j * stride2] =
467  ( 1.0 - ada ) * a[2 * ( nelem + 1 ) + i * stride1] +
468  ada * a[2 * ( nelem + 1 ) + i * stride1 + nelem * stride2] +
469  ( 1.0 - tse ) * a[2 * ( nelem + 1 ) + j * stride2] +
470  tse * a[2 * ( nelem + 1 ) + j * stride2 + nelem * stride1] -
471  ( 1.0 - tse ) * ( 1.0 - ada ) * a[2 * ( nelem + 1 ) + 0] -
472  ( 1.0 - tse ) * ada * a[2 * ( nelem + 1 ) + nelem * stride1] -
473  tse * ( 1.0 - ada ) * a[2 * ( nelem + 1 ) + nelem * stride2] -
474  tse * ada * a[2 * ( nelem + 1 ) + nelem * ( stride1 + stride2 )];
475  }
476  }
477 }

Referenced by build_coords().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 45 of file tstt_perf_binding.cpp.

46 {
47  int nelem = 20;
48  if( argc < 3 )
49  {
50  std::cout << "Usage: " << argv[0] << " <ints_per_side> <A|B|C>" << std::endl;
51  return 1;
52  }
53 
54  char which_test = '\0';
55 
56  sscanf( argv[1], "%d", &nelem );
57  sscanf( argv[2], "%c", &which_test );
58 
59  if( which_test != 'B' && which_test != 'C' )
60  {
61  std::cout << "Must indicate B or C for test." << std::endl;
62  return 1;
63  }
64 
65  std::cout << "number of elements: " << nelem << "; test " << which_test << std::endl;
66 
67  // initialize the data in native format
68 
69  // pre-build the coords array
70  double* coords;
71  build_coords( nelem, coords );
72  assert( NULL != coords );
73 
74  // test B: create mesh using bulk interface
75 
76  // create an implementation
78  int result;
79  iMesh_newMesh( NULL, &mesh, &result, 0 );
80  int* connect = NULL;
81 
82  if( iBase_SUCCESS != result )
83  {
84  cerr << "Couldn't create mesh instance." << endl;
85  iMesh_dtor( mesh, &result );
86  return 1;
87  }
88 
89  iMesh_setGeometricDimension( mesh, 3, &result );
90  if( iBase_SUCCESS != result )
91  {
92  cerr << "Couldn't set geometric dimension." << endl;
93  iMesh_dtor( mesh, &result );
94  return 1;
95  }
96 
97  switch( which_test )
98  {
99  case 'B':
100  build_connect( nelem, 1, connect );
101 
102  // test B: create mesh using bulk interface
103  testB( mesh, nelem, coords, connect );
104  break;
105 
106  case 'C':
107  // test C: create mesh using individual interface
108  testC( mesh, nelem, coords );
109  break;
110  }
111 
112  free( coords );
113 
114  return 0;
115 }

References build_connect(), build_coords(), iBase_SUCCESS, iMesh_dtor, iMesh_newMesh, iMesh_setGeometricDimension, mesh, testB(), and testC().

◆ print_time()

void print_time ( const bool  print_em,
double &  tot_time,
double &  utime,
double &  stime,
long &  imem,
long &  rmem 
)

Definition at line 407 of file tstt_perf_binding.cpp.

408 {
409  // Disabling this for windows
410  // Different platforms follow different conventions for usage
411 #ifndef _WIN32 // Windows does not have rusage
412  struct rusage r_usage;
413  getrusage( RUSAGE_SELF, &r_usage );
414  utime = (double)r_usage.ru_utime.tv_sec + ( (double)r_usage.ru_utime.tv_usec / 1.e6 );
415  stime = (double)r_usage.ru_stime.tv_sec + ( (double)r_usage.ru_stime.tv_usec / 1.e6 );
416  tot_time = utime + stime;
417  if( print_em )
418  std::cout << "User, system, total time = " << utime << ", " << stime << ", " << tot_time << std::endl;
419 
420 #ifndef LINUX
421  imem = r_usage.ru_idrss;
422  rmem = r_usage.ru_maxrss;
423  std::cout << "Max resident set size = " << r_usage.ru_maxrss << " kbytes" << std::endl;
424  std::cout << "Int resident set size = " << r_usage.ru_idrss << " kbytes" << std::endl;
425 #else
426  imem = rmem = 0;
427  system( "ps o args,drs,rss | grep perf | grep -v grep" ); // RedHat 9.0 doesnt fill in actual
428  // memory data
429 #endif
430  // delete [] hex_array;
431 #endif // if not on windows
432 }

Referenced by build_coords(), testB(), and testC().

◆ query_elem_to_vert()

void query_elem_to_vert ( iMesh_Instance  mesh)

Definition at line 281 of file tstt_perf_binding.cpp.

282 {
283  iBase_EntityHandle* all_hexes = NULL;
284  int all_hexes_size, all_hexes_allocated = 0;
285 
286  // get all the hex elements
287  int success;
289  iMesh_getRootSet( mesh, &root_set, &success );
290  if( iBase_SUCCESS != success )
291  {
292  cerr << "Couldn't get root set." << endl;
293  return;
294  }
295 
296  iMesh_getEntities( mesh, root_set, iBase_REGION, iMesh_HEXAHEDRON, &all_hexes, &all_hexes_allocated,
297  &all_hexes_size, &success );
298  if( iBase_SUCCESS != success )
299  {
300  cerr << "Couldn't get all hex elements in query_mesh" << endl;
301  return;
302  }
303 
304  // now loop over elements
305  iBase_EntityHandle* dum_connect = NULL;
306  int dum_connect_allocated = 0, dum_connect_size;
307  double* dum_coords = NULL;
308  int dum_coords_size, dum_coords_allocated = 0;
309  int order;
310  iMesh_getDfltStorage( mesh, &order, &success );
311  if( iBase_SUCCESS != success ) return;
312 
313  for( int i = 0; i < all_hexes_size; i++ )
314  {
315  // get the connectivity of this element; will allocate space on 1st iteration,
316  // but will have correct size on subsequent ones
317  iMesh_getEntAdj( mesh, all_hexes[i], iBase_VERTEX, &dum_connect, &dum_connect_allocated, &dum_connect_size,
318  &success );
319 
320  if( iBase_SUCCESS == success )
321  {
322  // get vertex coordinates; ; will allocate space on 1st iteration,
323  // but will have correct size on subsequent ones
324  iMesh_getVtxArrCoords( mesh, dum_connect, dum_connect_size, order, &dum_coords, &dum_coords_allocated,
325  &dum_coords_size, &success );
326 
327  double centroid[3] = { 0.0, 0.0, 0.0 };
328  if( order == iBase_BLOCKED )
329  {
330  for( int j = 0; j < 8; j++ )
331  {
332  centroid[0] += dum_coords[j];
333  centroid[1] += dum_coords[8 + j];
334  centroid[2] += dum_coords[16 + j];
335  }
336  }
337  else
338  {
339  for( int j = 0; j < 8; j++ )
340  {
341  centroid[0] += dum_coords[3 * j];
342  centroid[1] += dum_coords[3 * j + 1];
343  centroid[2] += dum_coords[3 * j + 2];
344  }
345  }
346  }
347 
348  if( iBase_SUCCESS != success )
349  {
350  cerr << "Problem getting connectivity or vertex coords." << endl;
351  return;
352  }
353  }
354 
355  free( all_hexes );
356  free( dum_connect );
357  free( dum_coords );
358 }

References iBase_BLOCKED, iBase_REGION, iBase_SUCCESS, iBase_VERTEX, iMesh_getDfltStorage, iMesh_getEntAdj, iMesh_getEntities, iMesh_getRootSet, iMesh_getVtxArrCoords, iMesh_HEXAHEDRON, mesh, and root_set.

Referenced by testB(), and testC().

◆ query_vert_to_elem()

void query_vert_to_elem ( iMesh_Instance  mesh)

Definition at line 360 of file tstt_perf_binding.cpp.

361 {
362  iBase_EntityHandle* all_verts = NULL;
363  int all_verts_allocated = 0, all_verts_size;
364 
366  int success;
367  iMesh_getRootSet( mesh, &root_set, &success );
368  if( iBase_SUCCESS != success )
369  {
370  cerr << "Couldn't get root set." << endl;
371  return;
372  }
373 
374  // get all the vertices elements
375  iMesh_getEntities( mesh, root_set, iBase_VERTEX, iMesh_POINT, &all_verts, &all_verts_allocated, &all_verts_size,
376  &success );
377  if( iBase_SUCCESS != success )
378  {
379  cerr << "Couldn't get all vertices in query_vert_to_elem" << endl;
380  return;
381  }
382 
383  // for this mesh, should never be more than 8 hexes connected to a vertex
384  iBase_EntityHandle* dum_hexes = (iBase_EntityHandle*)calloc( 8, sizeof( iBase_EntityHandle ) );
385 
386  int dum_hexes_allocated = 8, dum_hexes_size;
387 
388  // now loop over vertices
389  for( int i = 0; i < all_verts_size; i++ )
390  {
391 
392  // get the connectivity of this element; will have to allocate space on every
393  // iteration, since size can vary
394  iMesh_getEntAdj( mesh, all_verts[i], iBase_REGION, &dum_hexes, &dum_hexes_allocated, &dum_hexes_size,
395  &success );
396  if( iBase_SUCCESS != success )
397  {
398  cerr << "Problem getting connectivity or vertex coords." << endl;
399  // do not return early, as we would leak memory
400  }
401  }
402 
403  free( dum_hexes );
404  free( all_verts );
405 }

References iBase_REGION, iBase_SUCCESS, iBase_VERTEX, iMesh_getEntAdj, iMesh_getEntities, iMesh_getRootSet, iMesh_POINT, mesh, and root_set.

Referenced by testB(), and testC().

◆ testB()

void testB ( iMesh_Instance  mesh,
const int  nelem,
const double *  coords,
int *  connect 
)

Definition at line 117 of file tstt_perf_binding.cpp.

118 {
119  double utime, stime, ttime0, ttime1, ttime2, ttime3, ttime4;
120  long imem0, rmem0, imem1, rmem1, imem2, rmem2, imem3, rmem3, imem4, rmem4;
121 
122  print_time( false, ttime0, utime, stime, imem0, rmem0 );
123  int num_verts = ( nelem + 1 ) * ( nelem + 1 ) * ( nelem + 1 );
124  int num_elems = nelem * nelem * nelem;
125 
126  // create vertices as a block; initialize to NULL so allocation is done in interface
127  iBase_EntityHandle* vertices = NULL;
128  int vertices_allocated = 0, vertices_size;
129  int result;
130  iMesh_createVtxArr( mesh, num_verts, iBase_BLOCKED, coords, 3 * num_verts, &vertices, &vertices_allocated,
131  &vertices_size, &result );
132  if( iBase_SUCCESS != result )
133  {
134  cerr << "Couldn't create vertices in bulk call" << endl;
135  free( vertices );
136  return;
137  }
138 
139  // need to explicitly fill connectivity array, since we don't know
140  // the format of entity handles
141  int nconnect = 8 * num_elems;
142  iBase_EntityHandle* sidl_connect = (iBase_EntityHandle*)malloc( nconnect * sizeof( iBase_EntityHandle ) );
143 
144  for( int i = 0; i < nconnect; i++ )
145  {
146  // use connect[i]-1 because we used starting vertex index (vstart) of 1
147  assert( connect[i] - 1 < num_verts );
148  sidl_connect[i] = vertices[connect[i] - 1];
149  }
150 
151  // no longer need vertices and connect arrays, free here to reduce overall peak memory usage
152  free( vertices );
153  free( connect );
154 
155  // create the entities
156  iBase_EntityHandle* new_hexes = NULL;
157  int new_hexes_allocated = 0, new_hexes_size;
158  int* status = NULL;
159  int status_allocated = 0, status_size;
160 
161  iMesh_createEntArr( mesh, iMesh_HEXAHEDRON, sidl_connect, nconnect, &new_hexes, &new_hexes_allocated,
162  &new_hexes_size, &status, &status_allocated, &status_size, &result );
163  if( iBase_SUCCESS != result )
164  {
165  cerr << "Couldn't create hex elements in bulk call" << endl;
166  free( new_hexes );
167  free( status );
168  free( sidl_connect );
169  return;
170  }
171 
172  print_time( false, ttime1, utime, stime, imem1, rmem1 );
173 
174  free( status );
175  free( new_hexes );
176  free( sidl_connect );
177 
178  // query the mesh 2 ways
180 
181  print_time( false, ttime2, utime, stime, imem2, rmem2 );
182 
184 
185  print_time( false, ttime3, utime, stime, imem3, rmem3 );
186 
187  iMesh_dtor( mesh, &result );
188 
189  print_time( false, ttime4, utime, stime, imem4, rmem4 );
190 
191  std::cout << "TSTTb/MOAB_ucd_blocked: nelem, construct, e_to_v, v_to_e, after_dtor = " << nelem << ", "
192  << ttime1 - ttime0 << ", " << ttime2 - ttime1 << ", " << ttime3 - ttime2 << ", " << ttime4 - ttime3
193  << " seconds" << std::endl;
194  std::cout << "TSTTb/MOAB_ucd_blocked_memory_(rss): initial, after_construction, e-v, v-e, after_dtor:" << rmem0
195  << ", " << rmem1 << ", " << rmem2 << ", " << rmem3 << ", " << rmem4 << " kb" << std::endl;
196 }

References iBase_BLOCKED, iBase_SUCCESS, iMesh_createEntArr, iMesh_createVtxArr, iMesh_dtor, iMesh_HEXAHEDRON, mesh, print_time(), query_elem_to_vert(), and query_vert_to_elem().

Referenced by main().

◆ testC()

void testC ( iMesh_Instance  mesh,
const int  nelem,
const double *  coords 
)

Definition at line 198 of file tstt_perf_binding.cpp.

199 {
200  double utime, stime, ttime0, ttime1, ttime2, ttime3, ttime4;
201  long imem0, rmem0, imem1, rmem1, imem2, rmem2, imem3, rmem3, imem4, rmem4;
202  print_time( false, ttime0, utime, stime, imem0, rmem0 );
203 
204  // need some dimensions
205  int numv = nelem + 1;
206  int numv_sq = numv * numv;
207  int num_verts = numv * numv * numv;
208 #define VINDEX( i, j, k ) ( ( i ) + ( (j)*numv ) + ( (k)*numv_sq ) )
209 
210  // array to hold vertices created individually
211  iBase_EntityHandle* sidl_vertices = (iBase_EntityHandle*)malloc( num_verts * sizeof( iBase_EntityHandle ) );
212  int result;
213 
214  for( int i = 0; i < num_verts; i++ )
215  {
216  // create the vertex
217  iMesh_createVtx( mesh, coords[i], coords[i + num_verts], coords[i + 2 * num_verts], sidl_vertices + i,
218  &result );
219  if( iBase_SUCCESS != result )
220  {
221  cerr << "Couldn't create vertex in individual call" << endl;
222  return;
223  }
224  }
225 
226  iBase_EntityHandle tmp_conn[8], new_hex;
227 
228  for( int i = 0; i < nelem; i++ )
229  {
230  for( int j = 0; j < nelem; j++ )
231  {
232  for( int k = 0; k < nelem; k++ )
233  {
234  int vijk = VINDEX( i, j, k );
235  tmp_conn[0] = sidl_vertices[vijk];
236  tmp_conn[1] = sidl_vertices[vijk + 1];
237  tmp_conn[2] = sidl_vertices[vijk + 1 + numv];
238  tmp_conn[3] = sidl_vertices[vijk + numv];
239  tmp_conn[4] = sidl_vertices[vijk + numv * numv];
240  tmp_conn[5] = sidl_vertices[vijk + 1 + numv * numv];
241  tmp_conn[6] = sidl_vertices[vijk + 1 + numv + numv * numv];
242  tmp_conn[7] = sidl_vertices[vijk + numv + numv * numv];
243 
244  // create the entity
245 
246  int status;
247  iMesh_createEnt( mesh, iMesh_HEXAHEDRON, tmp_conn, 8, &new_hex, &status, &result );
248  if( iBase_SUCCESS != result )
249  {
250  cerr << "Couldn't create hex element in individual call" << endl;
251  // return; do not return if errors, as we would leak memory
252  }
253  }
254  }
255  }
256 
257  print_time( false, ttime1, utime, stime, imem1, rmem1 );
258 
259  free( sidl_vertices );
260 
261  // query the mesh 2 ways
263 
264  print_time( false, ttime2, utime, stime, imem2, rmem2 );
265 
267 
268  print_time( false, ttime3, utime, stime, imem3, rmem3 );
269 
270  iMesh_dtor( mesh, &result );
271 
272  print_time( false, ttime4, utime, stime, imem4, rmem4 );
273 
274  std::cout << "TSTTb/MOAB_ucd_indiv: nelem, construct, e_to_v, v_to_e, after_dtor = " << nelem << ", "
275  << ttime1 - ttime0 << ", " << ttime2 - ttime1 << ", " << ttime3 - ttime2 << ", " << ttime4 - ttime3
276  << " seconds" << std::endl;
277  std::cout << "TSTTb/MOAB_ucd_indiv_memory_(rss): initial, after_construction, e-v, v-e, after_dtor:" << rmem0
278  << ", " << rmem1 << ", " << rmem2 << ", " << rmem3 << ", " << rmem4 << " kb" << std::endl;
279 }

References iBase_SUCCESS, iMesh_createEnt, iMesh_createVtx, iMesh_dtor, iMesh_HEXAHEDRON, mesh, print_time(), query_elem_to_vert(), query_vert_to_elem(), and VINDEX.

Referenced by main().

Variable Documentation

◆ LENGTH

double LENGTH = 1.0

Definition at line 31 of file tstt_perf_binding.cpp.

Referenced by build_coords().