moab
|
#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 17 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 152 of file SequenceData.hpp.
: 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 8 of file SequenceData.cpp.
{ 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 82 of file SequenceData.cpp.
: 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 47 of file SequenceData.cpp.
{ 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 66 of file SequenceData.cpp.
{ 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 108 of file SequenceData.cpp.
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 36 of file SequenceData.cpp.
{ 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 15 of file SequenceData.cpp.
{ 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.
{ 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 34 of file SequenceData.hpp.
{ return endHandle; }
AdjacencyDataType* moab::SequenceData::get_adjacency_data | ( | ) | [inline] |
Definition at line 48 of file SequenceData.hpp.
{ return reinterpret_cast<AdjacencyDataType*>(arraySet[0]); }
AdjacencyDataType const* moab::SequenceData::get_adjacency_data | ( | ) | const [inline] |
Definition at line 51 of file SequenceData.hpp.
{ return reinterpret_cast<AdjacencyDataType const*>(arraySet[0]); }
void* moab::SequenceData::get_sequence_data | ( | int | array_num | ) | [inline] |
Definition at line 41 of file SequenceData.hpp.
{ return arraySet[-1-array_num]; }
void const* moab::SequenceData::get_sequence_data | ( | int | array_num | ) | const [inline] |
Definition at line 44 of file SequenceData.hpp.
{ return arraySet[-1-array_num]; }
void* moab::SequenceData::get_tag_data | ( | unsigned | tag_num | ) | [inline] |
Definition at line 55 of file SequenceData.hpp.
{ return tag_num < numTagData ? arraySet[tag_num+1] : 0; }
void const* moab::SequenceData::get_tag_data | ( | unsigned | tag_num | ) | const [inline] |
Definition at line 58 of file SequenceData.hpp.
{ return tag_num < numTagData ? arraySet[tag_num+1] : 0; }
void moab::SequenceData::increase_tag_count | ( | unsigned | by_this_many | ) | [private] |
Definition at line 56 of file SequenceData.cpp.
{ void** list = arraySet - numSequenceData; const size_t sz = sizeof(void*) * (numSequenceData + numTagData + amount + 1); list = (void**)realloc( list, sz ); 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 124 of file SequenceData.cpp.
{ 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 149 of file SequenceData.cpp.
{ 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 157 of file SequenceData.cpp.
{ 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 37 of file SequenceData.hpp.
{ return endHandle + 1 - startHandle; }
EntityHandle moab::SequenceData::start_handle | ( | ) | const [inline] |
Definition at line 30 of file SequenceData.hpp.
{ 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 75 of file SequenceData.cpp.
{ return new SequenceData( this, start, end, sequence_data_sizes ); }
void** moab::SequenceData::arraySet [private] |
Definition at line 148 of file SequenceData.hpp.
EntityHandle moab::SequenceData::endHandle [private] |
Definition at line 149 of file SequenceData.hpp.
const int moab::SequenceData::numSequenceData [private] |
Definition at line 146 of file SequenceData.hpp.
unsigned moab::SequenceData::numTagData [private] |
Definition at line 147 of file SequenceData.hpp.
SequenceManager data.
Definition at line 118 of file SequenceData.hpp.
EntityHandle moab::SequenceData::startHandle [private] |
Definition at line 149 of file SequenceData.hpp.