MOAB: Mesh Oriented datABase  (version 5.2.1)
moab::SequenceData Class Reference

#include <SequenceData.hpp>

+ Inheritance diagram for moab::SequenceData:
+ Collaboration diagram for moab::SequenceData:

Public Types

typedef std::vector
< EntityHandle > * 
AdjacencyDataType

Public Member Functions

 SequenceData (int num_sequence_arrays, EntityHandle start, EntityHandle end)
virtual ~SequenceData ()
EntityHandle start_handle () const
EntityHandle end_handle () const
EntityID size () const
void * get_sequence_data (int array_num)
void const * get_sequence_data (int array_num) const
AdjacencyDataTypeget_adjacency_data ()
AdjacencyDataType const * get_adjacency_data () const
void * get_tag_data (unsigned tag_num)
void const * get_tag_data (unsigned tag_num) const
void * create_sequence_data (int array_num, int bytes_per_ent, const void *initial_val=0)
 Allocate array of sequence-specific data.
void * create_custom_data (int array_num, size_t total_bytes)
 Allocate array of sequence-specific data.
AdjacencyDataTypeallocate_adjacency_data ()
 Allocate array for storing adjacency data.
void * allocate_tag_array (int index, int bytes_per_ent, const void *default_value=0)
 Allocate array of dense tag data.
SequenceDatasubset (EntityHandle start, EntityHandle end, const int *sequence_data_sizes) const
 Create new SequenceData that is a copy of a subset of this one.
void move_tag_data (SequenceData *destination, const int *tag_sizes, int num_tag_sizes)
 Move tag data for a subset of this sequences to specified sequence.
void release_tag_data (const int *tag_sizes, int num_tag_sizes)
 Free all tag data arrays.
void release_tag_data (int index, int tag_size)
 Free specified tag data array.

Public Attributes

TypeSequenceManager::SequenceDataPtr seqManData
 SequenceManager data.

Protected Member Functions

 SequenceData (const SequenceData *subset_from, EntityHandle start, EntityHandle end, const int *sequence_data_sizes)

Private Member Functions

void increase_tag_count (unsigned by_this_many)
void * create_data (int index, int bytes_per_ent, const void *initial_val=0)
void copy_data_subset (int index, int size_per_ent, const void *source, size_t offset, size_t count)

Private Attributes

const int numSequenceData
unsigned numTagData
void ** arraySet
EntityHandle startHandle
EntityHandle endHandle

Detailed Description

Definition at line 13 of file SequenceData.hpp.


Member Typedef Documentation

Definition at line 16 of file SequenceData.hpp.


Constructor & Destructor Documentation

moab::SequenceData::SequenceData ( int  num_sequence_arrays,
EntityHandle  start,
EntityHandle  end 
) [inline]
Parameters:
num_sequence_arraysNumber of data arrays needed by the EntitySequence
startFirst handle in this SequenceData
endLast handle in this SequenceData

Definition at line 155 of file SequenceData.hpp.

References arraySet.

Referenced by subset().

    : numSequenceData( num_sequence_arrays ), numTagData( 0 ), startHandle( start ), endHandle( end )
{
    const size_t sz = sizeof( void* ) * ( num_sequence_arrays + 1 );
    void** data     = (void**)malloc( sz );
    memset( data, 0, sz );
    arraySet = data + num_sequence_arrays;
}

Definition at line 9 of file SequenceData.cpp.

References arraySet, numSequenceData, and numTagData.

{
    for( int i = -numSequenceData; i <= (int)numTagData; ++i )
        free( arraySet[i] );
    free( arraySet - numSequenceData );
}
moab::SequenceData::SequenceData ( const SequenceData subset_from,
EntityHandle  start,
EntityHandle  end,
const int *  sequence_data_sizes 
) [protected]

Definition at line 84 of file SequenceData.cpp.

References arraySet, copy_data_subset(), end_handle(), get_adjacency_data(), get_sequence_data(), numSequenceData, numTagData, and start_handle().

    : numSequenceData( from->numSequenceData ), numTagData( from->numTagData ), startHandle( start ), endHandle( end )
{
    assert( start <= end );
    assert( from != 0 );
    assert( from->start_handle() <= start );
    assert( from->end_handle() >= end );

    void** array        = (void**)malloc( sizeof( void* ) * ( numSequenceData + numTagData + 1 ) );
    arraySet            = array + numSequenceData;
    const size_t offset = start - from->start_handle();
    const size_t count  = end - start + 1;

    for( int i = 0; i < numSequenceData; ++i )
        copy_data_subset( -1 - i, sequence_data_sizes[i], from->get_sequence_data( i ), offset, count );
    copy_data_subset( 0, sizeof( AdjacencyDataType* ), from->get_adjacency_data(), offset, count );
    for( unsigned i = 1; i <= numTagData; ++i )
        arraySet[i] = 0;
}

Member Function Documentation

Allocate array for storing adjacency data.

Allocate array for storing adjacency data.

Returns:
The newly allocated array, or NULL if already allocated.

Definition at line 44 of file SequenceData.cpp.

References arraySet, and size().

Referenced by moab::AEntityFactory::set_adjacency_ptr().

{
    assert( !arraySet[0] );
    const size_t s = sizeof( AdjacencyDataType* ) * size();
    arraySet[0]    = malloc( s );
    memset( arraySet[0], 0, s );
    return reinterpret_cast< AdjacencyDataType* >( arraySet[0] );
}
void * moab::SequenceData::allocate_tag_array ( int  index,
int  bytes_per_ent,
const void *  default_value = 0 
)

Allocate array of dense tag data.

Allocate an array of dense tag data.

Parameters:
indexDense tag ID for which to allocate array.
bytes_per_entBytes to allocate for each entity.
Returns:
The newly allocated array, or NULL if error.

Definition at line 71 of file SequenceData.cpp.

References arraySet, create_data(), increase_tag_count(), and numTagData.

Referenced by moab::VarLenDenseTag::get_array(), and moab::DenseTag::get_array_private().

{
    if( (unsigned)tag_num >= numTagData ) increase_tag_count( tag_num - numTagData + 1 );

    assert( !arraySet[tag_num + 1] );
    return create_data( tag_num + 1, bytes_per_ent, default_value );
}
void moab::SequenceData::copy_data_subset ( int  index,
int  size_per_ent,
const void *  source,
size_t  offset,
size_t  count 
) [private]

Definition at line 105 of file SequenceData.cpp.

References arraySet.

Referenced by SequenceData().

{
    if( !source )
        arraySet[index] = 0;
    else
    {
        arraySet[index] = malloc( count * size_per_ent );
        memcpy( arraySet[index], (const char*)source + offset * size_per_ent, count * size_per_ent );
    }
}
void * moab::SequenceData::create_custom_data ( int  array_num,
size_t  total_bytes 
)

Allocate array of sequence-specific data.

Allocate an array of EntitySequence-specific data.

Parameters:
array_numIndex for which to allocate array. Must be in [0,num_sequence_arrays], where num_sequence_arrays is constructor argument.
Returns:
The newly allocated array, or NULL if error.

Definition at line 33 of file SequenceData.cpp.

References arraySet, and numSequenceData.

{
    const int index = -1 - array_num;
    assert( array_num < numSequenceData );
    assert( !arraySet[index] );

    void* array     = malloc( total_bytes );
    arraySet[index] = array;
    return array;
}
void * moab::SequenceData::create_data ( int  index,
int  bytes_per_ent,
const void *  initial_val = 0 
) [private]

Definition at line 16 of file SequenceData.cpp.

References arraySet, moab::SysUtil::setmem(), and size().

Referenced by allocate_tag_array(), and create_sequence_data().

{
    char* array = (char*)malloc( bytes_per_ent * size() );
    if( initial_value ) SysUtil::setmem( array, initial_value, bytes_per_ent, size() );

    arraySet[index] = array;
    return array;
}
void * moab::SequenceData::create_sequence_data ( int  array_num,
int  bytes_per_ent,
const void *  initial_val = 0 
)

Allocate array of sequence-specific data.

Allocate an array of EntitySequence-specific data.

Parameters:
array_numIndex for which to allocate array. Must be in [0,num_sequence_arrays], where num_sequence_arrays is constructor argument.
bytes_per_entBytes to allocate for each entity.
initial_valValue to initialize array with. If non-null, must be bytes_per_ent long. If NULL, array will be zeroed.
Returns:
The newly allocated array, or NULL if error.

Definition at line 25 of file SequenceData.cpp.

References arraySet, create_data(), and numSequenceData.

Referenced by moab::MeshSetSequence::initialize(), moab::ScdVertexData::ScdVertexData(), moab::SweptVertexData::SweptVertexData(), moab::UnstructuredElemSeq::UnstructuredElemSeq(), and moab::VertexSequence::VertexSequence().

{
    const int index = -1 - array_num;
    assert( array_num < numSequenceData );
    assert( !arraySet[index] );
    return create_data( index, bytes_per_ent, initial_value );
}
Returns:
array of adjacency data, or NULL if none.

Definition at line 55 of file SequenceData.hpp.

References arraySet.

Referenced by moab::Core::adjacencies_iterate(), moab::AEntityFactory::get_adjacency_ptr(), SequenceData(), and moab::AEntityFactory::set_adjacency_ptr().

    {
        return reinterpret_cast< AdjacencyDataType* >( arraySet[0] );
    }
Returns:
array of adjacency data, or NULL if none.

Definition at line 60 of file SequenceData.hpp.

References arraySet.

    {
        return reinterpret_cast< AdjacencyDataType const* >( arraySet[0] );
    }
void* moab::SequenceData::get_sequence_data ( int  array_num) [inline]
Returns:
ith array of EnitySequence-specific data

Definition at line 44 of file SequenceData.hpp.

References arraySet.

Referenced by moab::VertexSequence::array(), moab::MeshSetSequence::array(), moab::Core::coords_iterate(), moab::UnstructuredElemSeq::get_array(), moab::ScdBox::get_coordinate_arrays(), and SequenceData().

    {
        return arraySet[-1 - array_num];
    }
void const* moab::SequenceData::get_sequence_data ( int  array_num) const [inline]
Returns:
ith array of EnitySequence-specific data

Definition at line 49 of file SequenceData.hpp.

References arraySet.

    {
        return arraySet[-1 - array_num];
    }
void* moab::SequenceData::get_tag_data ( unsigned  tag_num) [inline]
Returns:
array of dense tag data, or NULL if none.

Definition at line 66 of file SequenceData.hpp.

References arraySet, and numTagData.

Referenced by moab::VarLenDenseTag::get_array(), moab::DenseTag::get_array_private(), moab::DenseTag::get_memory_use(), moab::VarLenDenseTag::get_memory_use(), and moab::get_tagged().

    {
        return tag_num < numTagData ? arraySet[tag_num + 1] : 0;
    }
void const* moab::SequenceData::get_tag_data ( unsigned  tag_num) const [inline]
Returns:
array of dense tag data, or NULL if none.

Definition at line 71 of file SequenceData.hpp.

References arraySet, and numTagData.

    {
        return tag_num < numTagData ? arraySet[tag_num + 1] : 0;
    }
void moab::SequenceData::increase_tag_count ( unsigned  by_this_many) [private]

Definition at line 53 of file SequenceData.cpp.

References arraySet, numSequenceData, and numTagData.

Referenced by allocate_tag_array(), and move_tag_data().

{
    void** list     = arraySet - numSequenceData;
    const size_t sz = sizeof( void* ) * ( numSequenceData + numTagData + amount + 1 );
    void** new_list = (void**)realloc( list, sz );
    if( !new_list )
    {
        fprintf( stderr, "SequenceData::increase_tag_count(): reallocation of list failed\n" );
        // Note: free(list) will be called in the destructor
        return;
    }
    else
        list = new_list;
    arraySet = list + numSequenceData;
    memset( arraySet + numTagData + 1, 0, sizeof( void* ) * amount );
    numTagData += amount;
}
void moab::SequenceData::move_tag_data ( SequenceData destination,
const int *  tag_sizes,
int  num_tag_sizes 
)

Move tag data for a subset of this sequences to specified sequence.

Definition at line 116 of file SequenceData.cpp.

References arraySet, end_handle(), increase_tag_count(), numTagData, size(), and start_handle().

Referenced by moab::TypeSequenceManager::replace_subsequence().

{
    assert( destination->start_handle() >= start_handle() );
    assert( destination->end_handle() <= end_handle() );
    const size_t offset = destination->start_handle() - start_handle();
    const size_t count  = destination->size();
    if( destination->numTagData < numTagData ) destination->increase_tag_count( numTagData - destination->numTagData );

    for( unsigned i = 1; i <= numTagData; ++i )
    {
        if( !arraySet[i] ) continue;

        assert( i <= (unsigned)num_tag_sizes );
        if( num_tag_sizes ) {}  // empty line to prevent compiler warning

        const int tag_size = tag_sizes[i - 1];
        if( !destination->arraySet[i] ) destination->arraySet[i] = malloc( count * tag_size );
        memcpy( destination->arraySet[i], reinterpret_cast< char* >( arraySet[i] ) + offset * tag_size,
                count * tag_size );
    }
}
void moab::SequenceData::release_tag_data ( const int *  tag_sizes,
int  num_tag_sizes 
)

Free all tag data arrays.

Definition at line 138 of file SequenceData.cpp.

References numTagData.

{
    assert( num_tag_sizes >= (int)numTagData );
    if( num_tag_sizes ) {}  // empty line to prevent compiler warning
    for( unsigned i = 0; i < numTagData; ++i )
        release_tag_data( i, tag_sizes[i] );
}
void moab::SequenceData::release_tag_data ( int  index,
int  tag_size 
)

Free specified tag data array.

Definition at line 146 of file SequenceData.cpp.

References arraySet, moab::VarLenTag::clear(), MB_VARIABLE_LENGTH, numTagData, and size().

{
    if( (unsigned)tag_num < numTagData )
    {
        if( tag_size == MB_VARIABLE_LENGTH && arraySet[tag_num + 1] )
        {
            VarLenTag* iter      = reinterpret_cast< VarLenTag* >( arraySet[tag_num + 1] );
            VarLenTag* const end = iter + size();
            for( ; iter != end; ++iter )
                iter->clear();
        }
        free( arraySet[tag_num + 1] );
        arraySet[tag_num + 1] = 0;
    }
}
Returns:
first handle in this sequence data

Definition at line 27 of file SequenceData.hpp.

References startHandle.

Referenced by moab::Core::adjacencies_iterate(), moab::TypeSequenceManager::check_valid_data(), moab::Core::coords_iterate(), moab::AEntityFactory::get_adjacency_ptr(), moab::UnstructuredElemSeq::get_array(), moab::VarLenDenseTag::get_array(), moab::DenseTag::get_array_private(), moab::VertexSequence::get_coordinate_arrays(), moab::VertexSequence::get_coordinates(), moab::VertexSequence::get_coordinates_ref(), moab::SweptElementData::get_element(), moab::ScdElementData::get_element(), moab::ScdVertexData::get_params(), moab::SweptVertexData::get_params(), moab::SweptElementData::get_params(), moab::ScdElementData::get_params(), moab::SweptElementData::get_params_connectivity(), moab::ScdElementData::get_params_connectivity(), moab::MeshSetSequence::get_set(), moab::get_tagged(), moab::ScdVertexData::get_vertex(), moab::SweptVertexData::get_vertex(), moab::MeshSetSequence::initialize(), moab::TypeSequenceManager::insert_sequence(), moab::TypeSequenceManager::is_free_handle(), moab::TypeSequenceManager::is_free_sequence(), move_tag_data(), moab::operator<<(), moab::MeshSetSequence::pop_back(), moab::MeshSetSequence::pop_front(), moab::Core::print_database(), moab::MeshSetSequence::push_back(), moab::MeshSetSequence::push_front(), moab::TypeSequenceManager::remove_sequence(), moab::ScdBox::ScdBox(), seqman_equal(), SequenceData(), moab::AEntityFactory::set_adjacency_ptr(), moab::VertexSequence::set_coordinates(), moab::EntitySequence::using_entire_data(), and moab::MeshSetSequence::~MeshSetSequence().

    {
        return startHandle;
    }
SequenceData * moab::SequenceData::subset ( EntityHandle  start,
EntityHandle  end,
const int *  sequence_data_sizes 
) const

Create new SequenceData that is a copy of a subset of this one.

Create a new SequenceData that is a copy of a subset of this one. This function is intended for use in subdividing a SequenceData for operations such as changing the number of nodes in a block of elements.

Parameters:
startFirst handle for resulting subset
endLast handle for resulting subset
sequence_data_sizesBytes-per-entity for sequence-specific data. Does not copy tag data.

Definition at line 79 of file SequenceData.cpp.

References SequenceData().

Referenced by moab::UnstructuredElemSeq::create_data_subset(), moab::VertexSequence::create_data_subset(), and DumSeq::create_data_subset().

{
    return new SequenceData( this, start, end, sequence_data_sizes );
}

Member Data Documentation

Definition at line 152 of file SequenceData.hpp.

Referenced by end_handle(), and size().

Definition at line 152 of file SequenceData.hpp.

Referenced by size(), and start_handle().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines