Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
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. More...
 
void * create_custom_data (int array_num, size_t total_bytes)
 Allocate array of sequence-specific data. More...
 
AdjacencyDataTypeallocate_adjacency_data ()
 Allocate array for storing adjacency data. More...
 
void * allocate_tag_array (int index, int bytes_per_ent, const void *default_value=0)
 Allocate array of dense tag data. More...
 
SequenceDatasubset (EntityHandle start, EntityHandle end, const int *sequence_data_sizes) const
 Create new SequenceData that is a copy of a subset of this one. More...
 
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. More...
 
void release_tag_data (const int *tag_sizes, int num_tag_sizes)
 Free all tag data arrays. More...
 
void release_tag_data (int index, int tag_size)
 Free specified tag data array. More...
 

Public Attributes

TypeSequenceManager::SequenceDataPtr seqManData
 SequenceManager data. More...
 

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

◆ AdjacencyDataType

Definition at line 16 of file SequenceData.hpp.

Constructor & Destructor Documentation

◆ SequenceData() [1/2]

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 157 of file SequenceData.hpp.

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

References arraySet.

Referenced by subset().

◆ ~SequenceData()

moab::SequenceData::~SequenceData ( )
virtual

Definition at line 9 of file SequenceData.cpp.

10 {
11  for( int i = -numSequenceData; i <= (int)numTagData; ++i )
12  free( arraySet[i] );
13  free( arraySet - numSequenceData );
14 }

References arraySet, numSequenceData, and numTagData.

◆ SequenceData() [2/2]

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.

88  : numSequenceData( from->numSequenceData ), numTagData( from->numTagData ), startHandle( start ), endHandle( end )
89 {
90  assert( start <= end );
91  assert( from != 0 );
92  assert( from->start_handle() <= start );
93  assert( from->end_handle() >= end );
94 
95  void** array = (void**)malloc( sizeof( void* ) * ( numSequenceData + numTagData + 1 ) );
96  arraySet = array + numSequenceData;
97  const size_t offset = start - from->start_handle();
98  const size_t count = end - start + 1;
99 
100  for( int i = 0; i < numSequenceData; ++i )
101  copy_data_subset( -1 - i, sequence_data_sizes[i], from->get_sequence_data( i ), offset, count );
102  copy_data_subset( 0, sizeof( AdjacencyDataType* ), from->get_adjacency_data(), offset, count );
103  for( unsigned i = 1; i <= numTagData; ++i )
104  arraySet[i] = 0;
105 }

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

Member Function Documentation

◆ allocate_adjacency_data()

SequenceData::AdjacencyDataType * moab::SequenceData::allocate_adjacency_data ( )

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.

45 {
46  assert( !arraySet[0] );
47  const size_t s = sizeof( AdjacencyDataType* ) * size();
48  arraySet[0] = malloc( s );
49  memset( arraySet[0], 0, s );
50  return reinterpret_cast< AdjacencyDataType* >( arraySet[0] );
51 }

References arraySet, and size().

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

◆ allocate_tag_array()

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.

72 {
73  if( (unsigned)tag_num >= numTagData ) increase_tag_count( tag_num - numTagData + 1 );
74 
75  assert( !arraySet[tag_num + 1] );
76  return create_data( tag_num + 1, bytes_per_ent, default_value );
77 }

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

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

◆ copy_data_subset()

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.

108 {
109  if( !source )
110  arraySet[index] = 0;
111  else
112  {
113  arraySet[index] = malloc( count * size_per_ent );
114  memcpy( arraySet[index], (const char*)source + offset * size_per_ent, count * size_per_ent );
115  }
116 }

References arraySet.

Referenced by SequenceData().

◆ create_custom_data()

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.

34 {
35  const int index = -1 - array_num;
36  assert( array_num < numSequenceData );
37  assert( !arraySet[index] );
38 
39  void* array = malloc( total_bytes );
40  arraySet[index] = array;
41  return array;
42 }

References arraySet, and numSequenceData.

◆ create_data()

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.

17 {
18  char* array = (char*)malloc( bytes_per_ent * size() );
19  if( initial_value ) SysUtil::setmem( array, initial_value, bytes_per_ent, size() );
20 
21  arraySet[index] = array;
22  return array;
23 }

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

Referenced by allocate_tag_array(), and create_sequence_data().

◆ create_sequence_data()

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.

26 {
27  const int index = -1 - array_num;
28  assert( array_num < numSequenceData );
29  assert( !arraySet[index] );
30  return create_data( index, bytes_per_ent, initial_value );
31 }

References arraySet, create_data(), and numSequenceData.

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

◆ end_handle()

◆ get_adjacency_data() [1/2]

AdjacencyDataType* moab::SequenceData::get_adjacency_data ( )
inline
Returns
array of adjacency data, or NULL if none.

Definition at line 55 of file SequenceData.hpp.

56  {
57  return reinterpret_cast< AdjacencyDataType* >( arraySet[0] );
58  }

References arraySet.

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

◆ get_adjacency_data() [2/2]

AdjacencyDataType const* moab::SequenceData::get_adjacency_data ( ) const
inline
Returns
array of adjacency data, or NULL if none.

Definition at line 60 of file SequenceData.hpp.

61  {
62  return reinterpret_cast< AdjacencyDataType const* >( arraySet[0] );
63  }

References arraySet.

◆ get_sequence_data() [1/2]

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.

45  {
46  return arraySet[-1 - array_num];
47  }

References arraySet.

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

◆ get_sequence_data() [2/2]

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.

50  {
51  return arraySet[-1 - array_num];
52  }

References arraySet.

◆ get_tag_data() [1/2]

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.

67  {
68  return tag_num < numTagData ? arraySet[tag_num + 1] : 0;
69  }

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().

◆ get_tag_data() [2/2]

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.

72  {
73  return tag_num < numTagData ? arraySet[tag_num + 1] : 0;
74  }

References arraySet, and numTagData.

◆ increase_tag_count()

void moab::SequenceData::increase_tag_count ( unsigned  by_this_many)
private

Definition at line 53 of file SequenceData.cpp.

54 {
55  void** list = arraySet - numSequenceData;
56  const size_t sz = sizeof( void* ) * ( numSequenceData + numTagData + amount + 1 );
57  void** new_list = (void**)realloc( list, sz );
58  if( !new_list )
59  {
60  fprintf( stderr, "SequenceData::increase_tag_count(): reallocation of list failed\n" );
61  // Note: free(list) will be called in the destructor
62  return;
63  }
64  else
65  list = new_list;
66  arraySet = list + numSequenceData;
67  memset( arraySet + numTagData + 1, 0, sizeof( void* ) * amount );
68  numTagData += amount;
69 }

References arraySet, numSequenceData, and numTagData.

Referenced by allocate_tag_array(), and move_tag_data().

◆ move_tag_data()

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.

119 {
120  assert( destination->start_handle() >= start_handle() );
121  assert( destination->end_handle() <= end_handle() );
122  const size_t offset = destination->start_handle() - start_handle();
123  const size_t count = destination->size();
124  if( destination->numTagData < numTagData ) destination->increase_tag_count( numTagData - destination->numTagData );
125 
126  for( unsigned i = 1; i <= numTagData; ++i )
127  {
128  if( !arraySet[i] ) continue;
129 
130  assert( i <= (unsigned)num_tag_sizes );
131  if( num_tag_sizes )
132  {
133  } // empty line to prevent compiler warning
134 
135  const int tag_size = tag_sizes[i - 1];
136  if( !destination->arraySet[i] ) destination->arraySet[i] = malloc( count * tag_size );
137  memcpy( destination->arraySet[i], reinterpret_cast< char* >( arraySet[i] ) + offset * tag_size,
138  count * tag_size );
139  }
140 }

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

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

◆ release_tag_data() [1/2]

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.

143 {
144  assert( num_tag_sizes >= (int)numTagData );
145  if( num_tag_sizes )
146  {
147  } // empty line to prevent compiler warning
148  for( unsigned i = 0; i < numTagData; ++i )
149  release_tag_data( i, tag_sizes[i] );
150 }

References numTagData.

◆ release_tag_data() [2/2]

void moab::SequenceData::release_tag_data ( int  index,
int  tag_size 
)

Free specified tag data array.

Definition at line 152 of file SequenceData.cpp.

153 {
154  if( (unsigned)tag_num < numTagData )
155  {
156  if( tag_size == MB_VARIABLE_LENGTH && arraySet[tag_num + 1] )
157  {
158  VarLenTag* iter = reinterpret_cast< VarLenTag* >( arraySet[tag_num + 1] );
159  VarLenTag* const end = iter + size();
160  for( ; iter != end; ++iter )
161  iter->clear();
162  }
163  free( arraySet[tag_num + 1] );
164  arraySet[tag_num + 1] = 0;
165  }
166 }

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

◆ size()

◆ start_handle()

EntityHandle moab::SequenceData::start_handle ( ) const
inline
Returns
first handle in this sequence data

Definition at line 27 of file SequenceData.hpp.

28  {
29  return startHandle;
30  }

References startHandle.

Referenced by moab::Core::adjacencies_iterate(), moab::SweptElementData::calc_num_entities(), moab::ScdElementData::calc_num_entities(), 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::ScdElementData::get_element(), moab::SweptElementData::get_element(), moab::AEntityFactory::get_memory_use(), moab::ScdElementData::get_params(), moab::SweptElementData::get_params(), moab::ScdVertexData::get_params(), moab::SweptVertexData::get_params(), moab::ScdElementData::get_params_connectivity(), moab::SweptElementData::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().

◆ subset()

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. \NOTE Does not copy tag data.

Definition at line 79 of file SequenceData.cpp.

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

References SequenceData().

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

Member Data Documentation

◆ arraySet

◆ endHandle

EntityHandle moab::SequenceData::endHandle
private

Definition at line 154 of file SequenceData.hpp.

Referenced by end_handle(), and size().

◆ numSequenceData

const int moab::SequenceData::numSequenceData
private

◆ numTagData

unsigned moab::SequenceData::numTagData
private

◆ seqManData

◆ startHandle

EntityHandle moab::SequenceData::startHandle
private

Definition at line 154 of file SequenceData.hpp.

Referenced by size(), and start_handle().


The documentation for this class was generated from the following files: