![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
#include <SequenceData.hpp>
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 |
AdjacencyDataType * | get_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. | |
AdjacencyDataType * | allocate_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. | |
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. | |
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 |
Definition at line 13 of file SequenceData.hpp.
typedef std::vector< EntityHandle >* moab::SequenceData::AdjacencyDataType |
Definition at line 16 of file SequenceData.hpp.
moab::SequenceData::SequenceData | ( | int | num_sequence_arrays, |
EntityHandle | start, | ||
EntityHandle | end | ||
) | [inline] |
num_sequence_arrays | Number of data arrays needed by the EntitySequence |
start | First handle in this SequenceData |
end | Last handle in this SequenceData |
Definition at line 157 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;
}
moab::SequenceData::~SequenceData | ( | ) | [virtual] |
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;
}
Allocate array for storing adjacency data.
Allocate array for storing adjacency data.
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.
index | Dense tag ID for which to allocate array. |
bytes_per_ent | Bytes to allocate for each entity. |
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 107 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.
array_num | Index for which to allocate array. Must be in [0,num_sequence_arrays], where num_sequence_arrays is constructor argument. |
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.
array_num | Index for which to allocate array. Must be in [0,num_sequence_arrays], where num_sequence_arrays is constructor argument. |
bytes_per_ent | Bytes to allocate for each entity. |
initial_val | Value to initialize array with. If non-null, must be bytes_per_ent long. If NULL, array will be zeroed. |
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 );
}
EntityHandle moab::SequenceData::end_handle | ( | ) | const [inline] |
Definition at line 33 of file SequenceData.hpp.
References endHandle.
Referenced by moab::TypeSequenceManager::check_valid_data(), moab::VarLenDenseTag::get_array(), moab::DenseTag::get_array_private(), moab::TypeSequenceManager::get_memory_use(), moab::TypeSequenceManager::insert_sequence(), moab::TypeSequenceManager::is_free_handle(), moab::TypeSequenceManager::is_free_sequence(), move_tag_data(), moab::operator<<(), moab::Core::print_database(), SequenceData(), and moab::EntitySequence::using_entire_data().
{
return endHandle;
}
AdjacencyDataType* moab::SequenceData::get_adjacency_data | ( | ) | [inline] |
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] );
}
AdjacencyDataType const* moab::SequenceData::get_adjacency_data | ( | ) | const [inline] |
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] |
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] |
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] |
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] |
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 118 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 142 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 152 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;
}
}
EntityID moab::SequenceData::size | ( | ) | const [inline] |
Definition at line 38 of file SequenceData.hpp.
References endHandle, and startHandle.
Referenced by allocate_adjacency_data(), moab::TypeSequenceManager::append_memory_use(), create_data(), moab::SequenceManager::create_scd_sequence(), moab::SequenceManager::create_sweep_sequence(), moab::VarLenDenseTag::get_array(), moab::DenseTag::get_array_private(), moab::SweptElementSeq::get_const_memory_use(), moab::StructuredElementSeq::get_const_memory_use(), moab::AEntityFactory::get_memory_use(), moab::VarLenDenseTag::get_memory_use(), moab::SweptElementData::get_params(), moab::ScdElementData::get_params(), move_tag_data(), and release_tag_data().
{
return endHandle + 1 - startHandle;
}
EntityHandle moab::SequenceData::start_handle | ( | ) | const [inline] |
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(), 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.
start | First handle for resulting subset |
end | Last handle for resulting subset |
sequence_data_sizes | Bytes-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(), and moab::VertexSequence::create_data_subset().
{
return new SequenceData( this, start, end, sequence_data_sizes );
}
void** moab::SequenceData::arraySet [private] |
Definition at line 153 of file SequenceData.hpp.
Referenced by allocate_adjacency_data(), allocate_tag_array(), copy_data_subset(), create_custom_data(), create_data(), create_sequence_data(), get_adjacency_data(), get_sequence_data(), get_tag_data(), increase_tag_count(), move_tag_data(), release_tag_data(), SequenceData(), and ~SequenceData().
EntityHandle moab::SequenceData::endHandle [private] |
Definition at line 154 of file SequenceData.hpp.
Referenced by end_handle(), and size().
const int moab::SequenceData::numSequenceData [private] |
Definition at line 151 of file SequenceData.hpp.
Referenced by create_custom_data(), create_sequence_data(), increase_tag_count(), SequenceData(), and ~SequenceData().
unsigned moab::SequenceData::numTagData [private] |
Definition at line 152 of file SequenceData.hpp.
Referenced by allocate_tag_array(), get_tag_data(), increase_tag_count(), move_tag_data(), release_tag_data(), SequenceData(), and ~SequenceData().
SequenceManager data.
Definition at line 129 of file SequenceData.hpp.
Referenced by moab::TypeSequenceManager::append_memory_use(), moab::TypeSequenceManager::check_valid_data(), moab::TypeSequenceManager::erase(), moab::TypeSequenceManager::get_occupied_size(), moab::TypeSequenceManager::insert_sequence(), moab::TypeSequenceManager::remove_sequence(), and moab::TypeSequenceManager::replace_subsequence().
EntityHandle moab::SequenceData::startHandle [private] |
Definition at line 154 of file SequenceData.hpp.
Referenced by size(), and start_handle().