MOAB: Mesh Oriented datABase  (version 5.4.1)
seqperf.cpp File Reference
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include "moab/Core.hpp"
#include "moab/ReadUtilIface.hpp"
#include "EntitySequence.hpp"
#include "SequenceManager.hpp"
+ Include dependency graph for seqperf.cpp:

Go to the source code of this file.

Defines

#define PRINT_SEQUENCE_COUNT
#define IS_BUILDING_MB
#define ARRSIZE(A)   ( sizeof( A ) / sizeof( ( A )[0] ) )

Typedefs

typedef void(* naf_t )()
typedef void(* iaf_t )(int)

Functions

long * permutation (long count)
 Generate random permutation of values in [0,count-1].
void init ()
 Initialize global variables.
void create_vertices_single ()
 create vertices one at a time
void create_vertices_block ()
 create vertices in block using ReadUtilIface
void create_elements_single ()
 create elements one at a time
void create_elements_block ()
 create elements in block using ReadUtilIface
void forward_order_query_vertices (int percent)
 calculate mean of all vertex coordinates
void reverse_order_query_vertices (int percent)
 calculate mean of all vertex coordinates
void random_order_query_vertices (int percent)
 calculate mean of all vertex coordinates
void forward_order_query_elements (int percent)
 check all element connectivity for valid vertex handles
void reverse_order_query_elements (int percent)
 check all element connectivity for valid vertex handles
void random_order_query_elements (int percent)
 check all element connectivity for valid vertex handles
void forward_order_query_element_verts (int percent)
 calculate centroid
void reverse_order_query_element_verts (int percent)
 calculate centroid
void random_order_query_element_verts (int percent)
 calculate centroid
void forward_order_delete_vertices (int percent)
 delete x% of vertices
void reverse_order_delete_vertices (int percent)
 delete x% of vertices
void random_order_delete_vertices (int percent)
 delete x% of vertices
void forward_order_delete_elements (int percent)
 delete x% of elements
void reverse_order_delete_elements (int percent)
 delete x% of elements
void random_order_delete_elements (int percent)
 delete x% of elements
void create_missing_vertices (int percent)
 re-create deleted vertices
void create_missing_elements (int percent)
 re-create deleted elements
unsigned get_number_sequences (EntityType type)
void vertex_coords (long vert_index, double &x, double &y, double &z)
 Coordinates for ith vertex in structured hex mesh.
void element_conn (long elem_index, EntityHandle conn[8])
 Connectivity for ith hex in structured hex mesh.
bool deleted_vert (long index, int percent)
 True if passed index is one of the x% to be deleted.
bool deleted_elem (long index, int percent)
 True if passed index is one of the x% to be deleted.
void delete_vert (long index, int percent)
 if (deleted_vert(index,percent)) delete vertex
void delete_elem (long index, int percent)
 if (deleted_elem(index,percent)) delete element
void usage ()
 print usage and exit
std::string ts (clock_t t)
 convert CPU time to string
void TIME (const char *str, void(*func)())
 run function, printing time spent
void TIME_QRY (const char *str, void(*func)(int percent), int percent)
 run function query_repeat times, printing time spent
void TIME_DEL (const char *str, void(*func)(int), int percent)
 run function with integer argument, printing time spent
void delete_mesh ()
 call MB::delete_mesh(). function so can be passed to TIME
void do_test (int create_mode, int order, int percent)
 Run a single combination of test parameters.
void parse_order (const char *str, std::vector< int > &list)
void parse_percent (const char *str, std::vector< int > &list)
int parse_positive_int (const char *str)
void check_default (std::vector< int > &list, const int *array, size_t array_len)
int main (int argc, char *argv[])
long vert_index (long x, long y, long z)

Variables

const bool dump_mesh = false
 write mesh to vtk file
const int default_intervals = 25
 defaul interval count for cubic structured hex mesh
const int default_query_count = 100
 number of times to do each query set
const int default_order [] = { 0, 1, 2 }
const int default_create [] = { 0, 1 }
const int default_delete [] = { 0, 10, 30, 50, 70, 90 }
long numSideInt
long numVert
long numElem
 total counts;
int queryCount
 number of times to do each query set
Core mb_core
 moab instance
Interfacemb = mb_core
 moab instance
EntityHandle vertStart
EntityHandle elemStart
 first handle
ReadUtilIfacereadTool = 0
long * queryVertPermutation = 0
 pupulated by init(): "random" order for vertices
long * queryElemPermutation = 0
 pupulated by init(): "random" order for elements
iaf_t query_verts [3] = { &forward_order_query_vertices, &reverse_order_query_vertices, &random_order_query_vertices }
iaf_t query_elems [3] = { &forward_order_query_elements, &reverse_order_query_elements, &random_order_query_elements }
iaf_t query_elem_verts [3]
iaf_t delete_verts [3]
iaf_t delete_elems [3]
const char * order_strs [] = { "Forward", "Reverse", "Random" }

Define Documentation

#define ARRSIZE (   A)    ( sizeof( A ) / sizeof( ( A )[0] ) )

Definition at line 31 of file seqperf.cpp.

Referenced by main(), and usage().

#define IS_BUILDING_MB

Definition at line 12 of file seqperf.cpp.

Definition at line 8 of file seqperf.cpp.


Typedef Documentation

typedef void( * iaf_t)(int)

Definition at line 120 of file seqperf.cpp.

typedef void( * naf_t)()

Definition at line 119 of file seqperf.cpp.


Function Documentation

void check_default ( std::vector< int > &  list,
const int *  array,
size_t  array_len 
)

Definition at line 302 of file seqperf.cpp.

Referenced by main().

{
    if( list.empty() ) std::copy( array, array + array_len, std::back_inserter( list ) );
}

create elements in block using ReadUtilIface

Definition at line 486 of file seqperf.cpp.

References conn, element_conn(), elemStart, ErrorCode, moab::ReadUtilIface::get_element_connect(), MBHEX, numElem, and readTool.

Referenced by do_test().

{
    EntityHandle* conn = 0;
    ErrorCode rval     = readTool->get_element_connect( numElem, 8, MBHEX, 0, elemStart, conn );
    if( rval && !conn )
    {
        assert( false );
        abort();
    }

    for( long i = 0; i < numElem; ++i )
        element_conn( i, conn + 8 * i );
}

create elements one at a time

Definition at line 465 of file seqperf.cpp.

References conn, moab::Core::create_element(), element_conn(), elemStart, ErrorCode, mb, MBHEX, and numElem.

Referenced by do_test().

{
    EntityHandle conn[8];
    element_conn( 0, conn );
    ErrorCode rval = mb.create_element( MBHEX, conn, 8, elemStart );
    if( rval )
    {
        assert( false );
        abort();
    }

    EntityHandle h;
    for( long i = 1; i < numElem; ++i )
    {
        element_conn( i, conn );
        rval = mb.create_element( MBHEX, conn, 8, h );
        assert( !rval );
        assert( h - elemStart == (EntityHandle)i );
    }
}
void create_missing_elements ( int  percent)

re-create deleted elements

Definition at line 804 of file seqperf.cpp.

References conn, moab::Core::create_element(), deleted_elem(), element_conn(), ErrorCode, mb, MBHEX, and numElem.

Referenced by do_test().

{
    EntityHandle h;
    ErrorCode rval;
    EntityHandle conn[8];
    for( long i = 0; i < numElem; ++i )
        if( deleted_elem( i, percent ) )
        {
            element_conn( i, conn );
            rval = mb.create_element( MBHEX, conn, 8, h );
            if( rval )
            {
                assert( false );
                abort();
            }
        }
}
void create_missing_vertices ( int  percent)

re-create deleted vertices

Definition at line 787 of file seqperf.cpp.

References moab::Core::create_vertex(), deleted_vert(), ErrorCode, mb, MB_SUCCESS, numVert, and vertex_coords().

Referenced by do_test().

{
    EntityHandle h;
    ErrorCode rval = MB_SUCCESS;
    if( rval )
    {
    }  // empty line to remove compiler warning
    double coords[3];
    for( long i = 0; i < numVert; ++i )
        if( deleted_vert( i, percent ) )
        {
            vertex_coords( i, coords[0], coords[1], coords[2] );
            rval = mb.create_vertex( coords, h );
            assert( !rval );
        }
}

create vertices in block using ReadUtilIface

Definition at line 449 of file seqperf.cpp.

References ErrorCode, moab::ReadUtilIface::get_node_coords(), numVert, readTool, vertex_coords(), vertStart, and z.

Referenced by do_test().

{
    std::vector< double* > arrays;
    ErrorCode rval = readTool->get_node_coords( 3, numVert, 0, vertStart, arrays );
    if( rval || arrays.size() != 3 )
    {
        assert( false );
        abort();
    }
    double *x = arrays[0], *y = arrays[1], *z = arrays[2];
    assert( x && y && z );

    for( long i = 0; i < numVert; ++i )
        vertex_coords( i, *x++, *y++, *z++ );
}

create vertices one at a time

Definition at line 429 of file seqperf.cpp.

References moab::Core::create_vertex(), ErrorCode, mb, numVert, vertex_coords(), and vertStart.

Referenced by do_test().

{
    double coords[3];
    vertex_coords( 0, coords[0], coords[1], coords[2] );
    ErrorCode rval = mb.create_vertex( coords, vertStart );
    assert( !rval );
    if( rval )
    {
    }  // empty line to remove compiler warning

    EntityHandle h;
    for( long i = 1; i < numVert; ++i )
    {
        vertex_coords( i, coords[0], coords[1], coords[2] );
        rval = mb.create_vertex( coords, h );
        assert( !rval );
        assert( h - vertStart == (EntityHandle)i );
    }
}
void delete_elem ( long  index,
int  percent 
) [inline]

if (deleted_elem(index,percent)) delete element

Definition at line 836 of file seqperf.cpp.

References moab::Core::delete_entities(), deleted_elem(), elemStart, ErrorCode, and mb.

Referenced by forward_order_delete_elements(), random_order_delete_elements(), and reverse_order_delete_elements().

{
    if( deleted_elem( index, percent ) )
    {
        EntityHandle h = index + elemStart;
        ErrorCode rval = mb.delete_entities( &h, 1 );
        if( rval )
        {
            assert( false );
            abort();
        }
    }
}
void delete_mesh ( )

call MB::delete_mesh(). function so can be passed to TIME

Definition at line 206 of file seqperf.cpp.

References moab::Core::delete_mesh(), and mb.

Referenced by do_test().

{
    mb.delete_mesh();
}
void delete_vert ( long  index,
int  percent 
) [inline]

if (deleted_vert(index,percent)) delete vertex

Definition at line 822 of file seqperf.cpp.

References moab::Core::delete_entities(), deleted_vert(), ErrorCode, mb, and vertStart.

Referenced by forward_order_delete_vertices(), random_order_delete_vertices(), and reverse_order_delete_vertices().

{
    if( deleted_vert( index, percent ) )
    {
        EntityHandle h = index + vertStart;
        ErrorCode rval = mb.delete_entities( &h, 1 );
        if( rval )
        {
            assert( false );
            abort();
        }
    }
}
bool deleted_elem ( long  index,
int  percent 
) [inline]

True if passed index is one of the x% to be deleted.

Definition at line 424 of file seqperf.cpp.

References numSideInt.

Referenced by create_missing_elements(), delete_elem(), random_order_query_element_verts(), and random_order_query_elements().

{
    return index % numSideInt + 1 >= ( numSideInt + 1 ) * ( 100 - percent ) / 100;
}
bool deleted_vert ( long  index,
int  percent 
) [inline]

True if passed index is one of the x% to be deleted.

Definition at line 419 of file seqperf.cpp.

References numSideInt.

Referenced by create_missing_vertices(), delete_vert(), and random_order_query_vertices().

{
    return index % ( numSideInt + 1 ) >= ( numSideInt + 1 ) * ( 100 - percent ) / 100;
}
void do_test ( int  create_mode,
int  order,
int  percent 
)

Run a single combination of test parameters.

Parameters:
create_mode0 == single, 1 == block
order0 == forward, 1 == reverse, 2 == random
percentpercent of entities to delete

Definition at line 212 of file seqperf.cpp.

References create_elements_block(), create_elements_single(), create_missing_elements(), create_missing_vertices(), create_vertices_block(), create_vertices_single(), delete_elems, delete_mesh(), delete_verts, dump_mesh, moab::Core::get_number_entities_by_type(), get_number_sequences(), mb, MB_SUCCESS, MBHEX, MBVERTEX, order_strs, query_elem_verts, query_elems, query_verts, t, TIME, TIME_DEL(), TIME_QRY(), ts(), and moab::Core::write_file().

{
    clock_t t = clock();
    if( create_mode )
    {
        std::cout << "Block Entity Creation (all entities in single block of memory)" << std::endl;
        TIME( "  Creating initial vertices", create_vertices_block );
        TIME( "  Creating initial elements", create_elements_block );
        if( dump_mesh && !percent && mb.write_file( "seqperf.vtk" ) == MB_SUCCESS )
            std::cout << "Wrote mesh to file: seqperf.vtk" << std::endl;
    }
    else
    {
        std::cout << "Single Entity Creation (entities grouped in memory blocks of constant size)" << std::endl;
        TIME( "  Creating initial vertices", create_vertices_single );
        TIME( "  Creating initial elements", create_elements_single );
    }

    std::cout << order_strs[order] << " order with deletion of " << percent << "% of vertices and elements"
              << std::endl;

    TIME_DEL( "  Deleting elements", delete_elems[order], percent );
    TIME_DEL( "  Deleting vertices", delete_verts[order], percent );

    int num_vert = 0;
    int num_elem = 0;
    mb.get_number_entities_by_type( 0, MBVERTEX, num_vert );
    mb.get_number_entities_by_type( 0, MBHEX, num_elem );
    std::cout << "  " << num_vert << " vertices and " << num_elem << " elements remaining" << std::endl;
#ifdef PRINT_SEQUENCE_COUNT
    std::cout << "  " << get_number_sequences( MBVERTEX ) << " vertex sequences and " << get_number_sequences( MBHEX )
              << " element sequences." << std::endl;
#endif

    TIME_QRY( "  Querying vertex coordinates", query_verts[order], percent );
    TIME_QRY( "  Querying element connectivity", query_elems[order], percent );
    TIME_QRY( "  Querying element coordinates", query_elem_verts[order], percent );

    TIME_DEL( "  Re-creating vertices", create_missing_vertices, percent );
    TIME_DEL( "  Re-creating elements", create_missing_elements, percent );

    TIME( "  Clearing mesh instance", delete_mesh );

    std::cout << "Total time for test: " << ts( clock() - t ) << std::endl << std::endl;
}
void element_conn ( long  elem_index,
EntityHandle  conn[8] 
) [inline]

Connectivity for ith hex in structured hex mesh.

Definition at line 404 of file seqperf.cpp.

References numSideInt, vert_index(), vertStart, and z.

Referenced by moab::HigherOrderFactory::add_center_node(), create_elements_block(), create_elements_single(), and create_missing_elements().

{
    const long x = elem_index % numSideInt;
    const long y = ( elem_index / numSideInt ) % numSideInt;
    const long z = ( elem_index / numSideInt / numSideInt );
    conn[0]      = vertStart + vert_index( x, y, z );
    conn[1]      = vertStart + vert_index( x + 1, y, z );
    conn[2]      = vertStart + vert_index( x + 1, y + 1, z );
    conn[3]      = vertStart + vert_index( x, y + 1, z );
    conn[4]      = vertStart + vert_index( x, y, z + 1 );
    conn[5]      = vertStart + vert_index( x + 1, y, z + 1 );
    conn[6]      = vertStart + vert_index( x + 1, y + 1, z + 1 );
    conn[7]      = vertStart + vert_index( x, y + 1, z + 1 );
}
void forward_order_delete_elements ( int  percent)

delete x% of elements

Definition at line 769 of file seqperf.cpp.

References delete_elem(), and numElem.

{
    for( long i = 0; i < numElem; ++i )
        delete_elem( i, percent );
}
void forward_order_delete_vertices ( int  percent)

delete x% of vertices

Definition at line 751 of file seqperf.cpp.

References delete_vert(), and numVert.

{
    for( long i = 0; i < numVert; ++i )
        delete_vert( i, percent );
}
void forward_order_query_element_verts ( int  percent)

calculate centroid

Definition at line 667 of file seqperf.cpp.

References conn, elemStart, ErrorCode, moab::Core::get_connectivity(), moab::Core::get_coords(), mb, MB_SUCCESS, numSideInt, and z.

{
    ErrorCode r = MB_SUCCESS;
    if( r )
    {
    }  // empty line to remove compiler warning
    const EntityHandle* conn;
    int len;
    long x, y, z;
    double coords[24];
    const long elem_per_edge = numSideInt;
    const long deleted_x     = ( numSideInt + 1 ) * ( 100 - percent ) / 100 - 1;
    EntityHandle h           = elemStart;
    for( z = 0; z < elem_per_edge; ++z )
    {
        for( y = 0; y < elem_per_edge; ++y )
        {
            for( x = 0; x < deleted_x; ++x, ++h )
            {
                r = mb.get_connectivity( h, conn, len );
                assert( MB_SUCCESS == r );
                assert( conn && 8 == len );
                r = mb.get_coords( conn, len, coords );
                assert( MB_SUCCESS == r );
            }
            h += ( elem_per_edge - deleted_x );
        }
    }
}
void forward_order_query_elements ( int  percent)

check all element connectivity for valid vertex handles

Definition at line 571 of file seqperf.cpp.

References conn, elemStart, ErrorCode, moab::Core::get_connectivity(), mb, MB_SUCCESS, numSideInt, and z.

{
    ErrorCode r;
    const EntityHandle* conn;
    int len;
    long x, y, z;
    const long elem_per_edge = numSideInt;
    const long deleted_x     = ( numSideInt + 1 ) * ( 100 - percent ) / 100 - 1;
    EntityHandle h           = elemStart;
    for( z = 0; z < elem_per_edge; ++z )
    {
        for( y = 0; y < elem_per_edge; ++y )
        {
            for( x = 0; x < deleted_x; ++x, ++h )
            {
                r = mb.get_connectivity( h, conn, len );
                assert( MB_SUCCESS == r );
                if( r )
                {
                }  // empty line to remove compiler warning
                assert( conn && 8 == len );
            }
            h += ( elem_per_edge - deleted_x );
        }
    }
}
void forward_order_query_vertices ( int  percent)

calculate mean of all vertex coordinates

Definition at line 500 of file seqperf.cpp.

References ErrorCode, moab::Core::get_coords(), mb, MB_SUCCESS, numSideInt, vertStart, and z.

{
    ErrorCode r;
    double coords[3];
    long x, y, z;
    const long vert_per_edge = numSideInt + 1;
    const long deleted_x     = ( numSideInt + 1 ) * ( 100 - percent ) / 100;
    EntityHandle h           = vertStart;
    for( z = 0; z < vert_per_edge; ++z )
    {
        for( y = 0; y < vert_per_edge; ++y )
        {
            for( x = 0; x < deleted_x; ++x, ++h )
            {
                r = mb.get_coords( &h, 1, coords );
                if( MB_SUCCESS != r )
                {
                    assert( false );
                    abort();
                }
            }
            h += ( vert_per_edge - deleted_x );
        }
    }
}
unsigned get_number_sequences ( EntityType  type)

Definition at line 851 of file seqperf.cpp.

References moab::SequenceManager::entity_map(), moab::TypeSequenceManager::get_sequence_count(), mb_core, and moab::Core::sequence_manager().

Referenced by do_test().

{
#ifdef MB_ENTITY_SEQUENCE_HPP
    return mb_core.sequence_manager()->entity_map( type )->size();
#else
    return mb_core.sequence_manager()->entity_map( type ).get_sequence_count();
#endif
}
void init ( )

Initialize global variables.

Definition at line 72 of file seqperf.cpp.

References ErrorCode, mb, numElem, numVert, permutation(), moab::Interface::query_interface(), queryElemPermutation, queryVertPermutation, and readTool.

{
    ErrorCode rval = mb.query_interface( readTool );
    if( rval || !readTool )
    {
        assert( false );
        abort();
    }

    queryVertPermutation = permutation( numVert );
    queryElemPermutation = permutation( numElem );
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 307 of file seqperf.cpp.

References ARRSIZE, check_default(), default_create, default_delete, default_intervals, default_order, default_query_count, do_test(), init(), numElem, numSideInt, numVert, parse_order(), parse_percent(), parse_positive_int(), queryCount, queryElemPermutation, queryVertPermutation, t, ts(), and usage.

{
    // Parse arguments
    std::vector< int > createList, orderList, deleteList;
    numSideInt = default_intervals;
    queryCount = default_query_count;

    for( int i = 1; i < argc; ++i )
    {
        // check that arg is a '-' followed by a single character
        if( argv[i][0] != '-' || argv[i][1] == '\0' || argv[i][2] != '\0' ) usage();

        const char flag = argv[i][1];
        switch( flag )
        {
            case 'b':
                createList.push_back( 1 );
                break;
            case 's':
                createList.push_back( 0 );
                break;
            default:
                if( ++i == argc ) usage();
                switch( flag )
                {
                    case 'i':
                        numSideInt = parse_positive_int( argv[i] );
                        break;
                    case 'o':
                        parse_order( argv[i], orderList );
                        break;
                    case 'd':
                        parse_percent( argv[i], deleteList );
                        break;
                    case 'q':
                        queryCount = parse_positive_int( argv[i] );
                        break;
                    default:
                        usage();
                }
        }
    }
    check_default( createList, default_create, ARRSIZE( default_create ) );
    check_default( orderList, default_order, ARRSIZE( default_order ) );
    check_default( deleteList, default_delete, ARRSIZE( default_delete ) );

    // Do some initialization.

    int numSideVert = numSideInt + 1;
    numVert         = numSideVert * numSideVert * numSideVert;
    numElem         = numSideInt * numSideInt * numSideInt;
    if( numVert / numSideVert / numSideVert != numSideVert )  // overflow
        usage();
    init();

    // Echo input args

    std::cout << numSideInt << "x" << numSideInt << "x" << numSideInt << " hex grid: " << numElem << " elements and "
              << numVert << " vertices" << std::endl;

    // Run tests

    std::vector< int >::const_iterator i, j, k;
    clock_t t = clock();
    for( i = createList.begin(); i != createList.end(); ++i )
    {
        for( j = deleteList.begin(); j != deleteList.end(); ++j )
        {
            for( k = orderList.begin(); k != orderList.end(); ++k )
            {
                do_test( *i, *k, *j );
            }
        }
    }

    // Clean up

    std::cout << "TOTAL: " << ts( clock() - t ) << std::endl << std::endl;
    delete[] queryVertPermutation;
    delete[] queryElemPermutation;
    return 0;
}
void parse_order ( const char *  str,
std::vector< int > &  list 
)

Definition at line 260 of file seqperf.cpp.

References usage.

Referenced by main().

{
    if( str[0] == 'f' )
    {
        if( strncmp( str, "forward", strlen( str ) ) != 0 ) usage();
        list.push_back( 0 );
    }
    else if( str[0] != 'r' )
        usage();
    else if( str[1] == 'e' )
    {
        if( strncmp( str, "reverse", strlen( str ) ) != 0 ) usage();
        list.push_back( 0 );
    }
    else
    {
        if( strncmp( str, "random", strlen( str ) ) != 0 ) usage();
        list.push_back( 0 );
    }
}
void parse_percent ( const char *  str,
std::vector< int > &  list 
)

Definition at line 281 of file seqperf.cpp.

References usage.

Referenced by main().

{
    char* endptr;
    long p = strtol( str, &endptr, 0 );
    if( !endptr || *endptr || p < 0 || p > 100 ) usage();

    list.push_back( (int)p );
}
int parse_positive_int ( const char *  str)

Definition at line 290 of file seqperf.cpp.

References usage.

Referenced by main().

{
    char* endptr;
    long p = strtol( str, &endptr, 0 );
    if( !endptr || *endptr || p < 1 ) usage();
    int result = p;
    if( p != (long)result )  // overflow
        usage();

    return result;
}
long* permutation ( long  count)

Generate random permutation of values in [0,count-1].

Definition at line 46 of file seqperf.cpp.

References swap(), and t.

Referenced by init().

{
    srand( count );
    long* array = new long[count];
    for( long i = 0; i < count; ++i )
        array[i] = i;

    for( long i = 0; i < count; ++i )
    {
        long r = rand();
        if( count > RAND_MAX )
        {
            r += RAND_MAX * rand();
            if( count / RAND_MAX > RAND_MAX )
            {
                long t = (long)RAND_MAX * rand();
                r += (long)RAND_MAX * t;
            }
        }
        std::swap( array[i], array[r % count] );
    }

    return array;
}
void random_order_delete_elements ( int  percent)

delete x% of elements

Definition at line 781 of file seqperf.cpp.

References delete_elem(), numElem, and queryElemPermutation.

{
    for( long i = 0; i < numElem; ++i )
        delete_elem( queryElemPermutation[i], percent );
}
void random_order_delete_vertices ( int  percent)

delete x% of vertices

Definition at line 763 of file seqperf.cpp.

References delete_vert(), numVert, and queryVertPermutation.

{
    for( long i = 0; i < numVert; ++i )
        delete_vert( queryVertPermutation[i], percent );
}
void random_order_query_element_verts ( int  percent)

calculate centroid

Definition at line 729 of file seqperf.cpp.

References conn, deleted_elem(), elemStart, ErrorCode, moab::Core::get_connectivity(), moab::Core::get_coords(), mb, MB_SUCCESS, numElem, and queryElemPermutation.

{
    ErrorCode r = MB_SUCCESS;
    if( r )
    {
    }  // empty line to remove compiler warning
    const EntityHandle* conn;
    int len;
    double coords[24];
    for( long i = 0; i < numElem; ++i )
    {
        if( !deleted_elem( queryElemPermutation[i], percent ) )
        {
            r = mb.get_connectivity( elemStart + queryElemPermutation[i], conn, len );
            assert( MB_SUCCESS == r );
            assert( conn && 8 == len );
            r = mb.get_coords( conn, len, coords );
            assert( MB_SUCCESS == r );
        }
    }
}
void random_order_query_elements ( int  percent)

check all element connectivity for valid vertex handles

Definition at line 626 of file seqperf.cpp.

References conn, deleted_elem(), elemStart, ErrorCode, moab::Core::get_connectivity(), mb, MB_SUCCESS, numElem, and queryElemPermutation.

{
    ErrorCode r;
    const EntityHandle* conn;
    int len;
    for( long i = 0; i < numElem; ++i )
    {
        if( !deleted_elem( queryElemPermutation[i], percent ) )
        {
            r = mb.get_connectivity( elemStart + queryElemPermutation[i], conn, len );
            assert( MB_SUCCESS == r );
            if( r )
            {
            }  // empty line to remove compiler warning
            assert( conn && 8 == len );
        }
    }
}
void random_order_query_vertices ( int  percent)

calculate mean of all vertex coordinates

Definition at line 552 of file seqperf.cpp.

References deleted_vert(), ErrorCode, moab::Core::get_coords(), mb, MB_SUCCESS, numVert, queryVertPermutation, and vertStart.

{
    ErrorCode r;
    EntityHandle h;
    double coords[3];
    for( long i = 0; i < numVert; ++i )
    {
        if( !deleted_vert( queryVertPermutation[i], percent ) )
        {
            h = vertStart + queryVertPermutation[i];
            r = mb.get_coords( &h, 1, coords );
            assert( MB_SUCCESS == r );
            if( r )
            {
            }  // empty line to remove compiler warning
        }
    }
}
void reverse_order_delete_elements ( int  percent)

delete x% of elements

Definition at line 775 of file seqperf.cpp.

References delete_elem(), and numElem.

{
    for( long i = numElem - 1; i >= 0; --i )
        delete_elem( i, percent );
}
void reverse_order_delete_vertices ( int  percent)

delete x% of vertices

Definition at line 757 of file seqperf.cpp.

References delete_vert(), and numVert.

{
    for( long i = numVert - 1; i >= 0; --i )
        delete_vert( i, percent );
}
void reverse_order_query_element_verts ( int  percent)

calculate centroid

Definition at line 697 of file seqperf.cpp.

References conn, elemStart, ErrorCode, moab::Core::get_connectivity(), moab::Core::get_coords(), mb, MB_SUCCESS, numElem, numSideInt, and z.

{
    ErrorCode r = MB_SUCCESS;
    if( r )
    {
    }  // empty statement to remove compiler warning

    const EntityHandle* conn;
    int len;
    long x, y, z;
    double coords[24];
    const long elem_per_edge = numSideInt;
    const long deleted_x     = ( numSideInt + 1 ) * ( 100 - percent ) / 100 - 1;
    EntityHandle h           = elemStart + numElem - 1;
    ;
    for( z = elem_per_edge - 1; z >= 0; --z )
    {
        for( y = elem_per_edge - 1; y >= 0; --y )
        {
            h -= ( elem_per_edge - deleted_x );
            for( x = deleted_x - 1; x >= 0; --x, --h )
            {
                r = mb.get_connectivity( h, conn, len );
                assert( MB_SUCCESS == r );
                assert( conn && 8 == len );
                r = mb.get_coords( conn, len, coords );
                assert( MB_SUCCESS == r );
            }
        }
    }
}
void reverse_order_query_elements ( int  percent)

check all element connectivity for valid vertex handles

Definition at line 598 of file seqperf.cpp.

References conn, elemStart, ErrorCode, moab::Core::get_connectivity(), mb, MB_SUCCESS, numElem, numSideInt, and z.

{
    ErrorCode r;
    const EntityHandle* conn;
    int len;
    long x, y, z;
    const long elem_per_edge = numSideInt;
    const long deleted_x     = ( numSideInt + 1 ) * ( 100 - percent ) / 100 - 1;
    EntityHandle h           = elemStart + numElem - 1;
    ;
    for( z = elem_per_edge - 1; z >= 0; --z )
    {
        for( y = elem_per_edge - 1; y >= 0; --y )
        {
            h -= ( elem_per_edge - deleted_x );
            for( x = deleted_x - 1; x >= 0; --x, --h )
            {
                r = mb.get_connectivity( h, conn, len );
                assert( MB_SUCCESS == r );
                if( r )
                {
                }  // empty line to remove compiler warning
                assert( conn && 8 == len );
            }
        }
    }
}
void reverse_order_query_vertices ( int  percent)

calculate mean of all vertex coordinates

Definition at line 526 of file seqperf.cpp.

References ErrorCode, moab::Core::get_coords(), mb, MB_SUCCESS, numSideInt, numVert, vertStart, and z.

{
    ErrorCode r;
    double coords[3];
    long x, y, z;
    const long vert_per_edge = numSideInt + 1;
    const long deleted_x     = ( numSideInt + 1 ) * ( 100 - percent ) / 100;
    EntityHandle h           = vertStart + numVert - 1;
    ;
    for( z = vert_per_edge - 1; z >= 0; --z )
    {
        for( y = vert_per_edge - 1; y >= 0; --y )
        {
            h -= ( vert_per_edge - deleted_x );
            for( x = deleted_x - 1; x >= 0; --x, --h )
            {
                r = mb.get_coords( &h, 1, coords );
                assert( MB_SUCCESS == r );
                if( r )
                {
                }  // empty line to remove compiler warning
            }
        }
    }
}
void TIME ( const char *  str,
void(*)()  func 
)

run function, printing time spent

Definition at line 178 of file seqperf.cpp.

References t, and ts().

{
    std::cout << str << "... " << std::flush;
    clock_t t = clock();
    ( *func )();
    std::cout << ts( clock() - t ) << std::endl;
}
void TIME_DEL ( const char *  str,
void(*)(int)  func,
int  percent 
)

run function with integer argument, printing time spent

Definition at line 197 of file seqperf.cpp.

References t, and ts().

Referenced by do_test().

{
    std::cout << str << "... " << std::flush;
    clock_t t = clock();
    ( *func )( percent );
    std::cout << ts( clock() - t ) << std::endl;
}
void TIME_QRY ( const char *  str,
void(*)(int percent)  func,
int  percent 
)

run function query_repeat times, printing time spent

Definition at line 187 of file seqperf.cpp.

References queryCount, t, and ts().

Referenced by do_test().

{
    std::cout << str << "... " << std::flush;
    clock_t t = clock();
    for( int i = 0; i < queryCount; ++i )
        ( *func )( percent );
    std::cout << ts( clock() - t ) << std::endl;
}
std::string ts ( clock_t  t)

convert CPU time to string

Examples:
DirectAccessWithHoles.cpp.

Definition at line 170 of file seqperf.cpp.

Referenced by do_test(), moab::HiReconstruction::eval_vander_bivar_cmf(), moab::HiReconstruction::eval_vander_univar_cmf(), main(), obbstat_write(), TIME(), TIME_DEL(), and TIME_QRY().

{
    std::ostringstream s;
    s << ( (double)t ) / CLOCKS_PER_SEC << 's';
    return s.str();
}
void usage ( )

print usage and exit

Definition at line 151 of file seqperf.cpp.

References ARRSIZE, default_delete, default_intervals, and default_query_count.

{
    std::cerr << "Usage: seqperf [-i <intervals>] [-o <order>] [-d <percent>] [-b|-s] [-q <count>]" << std::endl;
    std::cerr << " -i specify size of cubic structured hex mesh in intervals.  Default: " << default_intervals
              << std::endl;
    std::cerr << " -o one of \"forward\", \"reverse\", or \"random\".  May be specified multiple "
                 "times.  Default is all."
              << std::endl;
    std::cerr << " -d percent of entities to delete.  May be specified multiple times.  Default is {";
    for( unsigned i = 0; i < ARRSIZE( default_delete ) - 1; ++i )
        std::cerr << default_delete[i] << ",";
    std::cerr << default_delete[ARRSIZE( default_delete ) - 1] << "}" << std::endl;
    std::cerr << " -b block creation of mesh" << std::endl;
    std::cerr << " -s single entity mesh creation" << std::endl;
    std::cerr << " -q number of times to repeat queries.  Default: " << default_query_count << std::endl;
    exit( 1 );
}
long vert_index ( long  x,
long  y,
long  z 
) [inline]

Definition at line 398 of file seqperf.cpp.

References numSideInt, and z.

Referenced by element_conn(), MBMesquite::PatchData::get_domain_normal_at_vertex(), MBMesquite::PatchData::get_subpatch(), and moab::ReadNASTRAN::load_file().

{
    const long vs = numSideInt + 1;
    return x + vs * ( y + vs * z );
}
void vertex_coords ( long  vert_index,
double &  x,
double &  y,
double &  z 
) [inline]

Coordinates for ith vertex in structured hex mesh.

Definition at line 390 of file seqperf.cpp.

References numSideInt.

Referenced by create_missing_vertices(), create_vertices_block(), create_vertices_single(), main(), moab::SimplexTemplateRefiner::refine_3_simplex(), setup_mesh(), and test_build_from_pts().

{
    const long vs = numSideInt + 1;
    x             = vert_index % vs;
    y             = ( vert_index / vs ) % vs;
    z             = ( vert_index / vs / vs );
}

Variable Documentation

const int default_create[] = { 0, 1 }

Definition at line 29 of file seqperf.cpp.

Referenced by main().

const int default_delete[] = { 0, 10, 30, 50, 70, 90 }

Definition at line 30 of file seqperf.cpp.

Referenced by main(), and usage().

const int default_intervals = 25

defaul interval count for cubic structured hex mesh

Definition at line 26 of file seqperf.cpp.

Referenced by main(), and usage().

const int default_order[] = { 0, 1, 2 }

Definition at line 28 of file seqperf.cpp.

Referenced by main().

const int default_query_count = 100

number of times to do each query set

Definition at line 27 of file seqperf.cpp.

Referenced by main(), and usage().

moab instance

Definition at line 39 of file seqperf.cpp.

moab instance

Definition at line 38 of file seqperf.cpp.

Referenced by get_number_sequences(), and main().

const char* order_strs[] = { "Forward", "Reverse", "Random" }

Definition at line 135 of file seqperf.cpp.

Referenced by do_test().

number of times to do each query set

Definition at line 35 of file seqperf.cpp.

Referenced by main(), and TIME_QRY().

pupulated by init(): "random" order for elements

Definition at line 43 of file seqperf.cpp.

Referenced by init(), main(), random_order_delete_elements(), random_order_query_element_verts(), and random_order_query_elements().

pupulated by init(): "random" order for vertices

Definition at line 42 of file seqperf.cpp.

Referenced by init(), main(), random_order_delete_vertices(), and random_order_query_vertices().

Definition at line 41 of file seqperf.cpp.

Referenced by create_elements_block(), create_vertices_block(), and init().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines