moab
moab::SequenceManager Class Reference

#include <SequenceManager.hpp>

List of all members.

Public Member Functions

 ~SequenceManager ()
void clear ()
ErrorCode find (EntityHandle handle, EntitySequence *&sequence_out)
ErrorCode find (EntityHandle handle, const EntitySequence *&sequence_out) const
void get_entities (EntityType type, Range &entities_out) const
void get_entities (Range &entities_out) const
void get_entities (EntityType type, std::vector< EntityHandle > &entities_out) const
void get_entities (std::vector< EntityHandle > &entities_out) const
EntityID get_number_entities (EntityType type) const
EntityID get_number_entities () const
const EntitySequenceget_last_accessed_sequence (EntityType type) const
ErrorCode replace_subsequence (EntitySequence *new_seq)
 Replace subset of existing sequence with new sequence (splits existing sequence)
ErrorCode check_valid_entities (Error *error_handler, const Range &entities) const
ErrorCode check_valid_entities (Error *error_handler, const EntityHandle entities[], size_t num_entities, bool root_set_okay=false) const
ErrorCode delete_entity (Error *error_handler, EntityHandle entity)
ErrorCode delete_entities (Error *error_handler, const Range &entities)
ErrorCode create_vertex (const double coords[3], EntityHandle &handle_out)
ErrorCode create_element (EntityType type, const EntityHandle *conn_array, unsigned num_vertices, EntityHandle &handle_out)
ErrorCode create_mesh_set (unsigned flags, EntityHandle &handle_out)
ErrorCode allocate_mesh_set (EntityHandle at_this_handle, unsigned flags)
ErrorCode create_entity_sequence (EntityType type, EntityID num_entities, int nodes_per_entity, EntityID start_id_hint, EntityHandle &first_handle_out, EntitySequence *&sequence_out, int sequence_size)
 Allocate a block of consecutive entity handles.
ErrorCode create_meshset_sequence (EntityID num_sets, EntityID start_id_hint, const unsigned *flags, EntityHandle &first_handle_out, EntitySequence *&sequence_out)
 Allocate a block of consecutive mesh sets.
ErrorCode create_meshset_sequence (EntityID num_sets, EntityID start_id_hint, unsigned flags, EntityHandle &first_handle_out, EntitySequence *&sequence_out)
 Allocate a block of consecutive mesh sets.
ErrorCode create_scd_sequence (int imin, int jmin, int kmin, int imax, int jmax, int kmax, EntityType type, EntityID start_id_hint, EntityHandle &first_handle_out, EntitySequence *&sequence_out, int *is_periodic=NULL)
ErrorCode create_scd_sequence (const HomCoord &coord_min, const HomCoord &coord_max, EntityType type, EntityID start_id_hint, EntityHandle &first_handle_out, EntitySequence *&sequence_out, int *is_periodic=NULL)
ErrorCode create_sweep_sequence (int imin, int jmin, int kmin, int imax, int jmax, int kmax, int *Cq, EntityType type, EntityID start_id_hint, EntityHandle &first_handle_out, EntitySequence *&sequence_out)
ErrorCode create_sweep_sequence (const HomCoord &coord_min, const HomCoord &coord_max, int *Cq, EntityType type, EntityID start_id_hint, EntityHandle &first_handle_out, EntitySequence *&sequence_out)
ErrorCode add_vsequence (EntitySequence *vert_seq, EntitySequence *elem_seq, const HomCoord &p1, const HomCoord &q1, const HomCoord &p2, const HomCoord &q2, const HomCoord &p3, const HomCoord &q3, bool bb_input=false, const HomCoord *bb_min=NULL, const HomCoord *bb_max=NULL)
TypeSequenceManagerentity_map (EntityType type)
const TypeSequenceManagerentity_map (EntityType type) const
void get_memory_use (unsigned long &total_entity_storage, unsigned long &total_storage) const
void get_memory_use (EntityType type, unsigned long &total_entity_storage, unsigned long &total_storage) const
void get_memory_use (const Range &entities, unsigned long &total_entity_storage, unsigned long &total_amortized_storage) const
ErrorCode reserve_tag_array (Error *error_handler, int tag_size, int &array_id_out)
ErrorCode release_tag_array (Error *error_handler, int id, bool release_id)
EntityID new_sequence_size (EntityHandle start_handle, EntityID requested_size, int sequence_size) const
 Size to allocate for new SquenceData THIS FUNCTION SHOULD ONLY BE CALLED WHEN ALLOCATING FROM ReadUtil IN BULK (since it will allocate lesser of requested_size and default_size) If sequence_size != -1, will try to allocate that, unless there isn't available space.

Static Public Member Functions

static EntityID default_poly_sequence_size (int entity_connectivity_length)
 Get default size of POLYGON and POLYHEDRON SequenceData.

Static Public Attributes

static const EntityID DEFAULT_VERTEX_SEQUENCE_SIZE = 512*1024
 Default allocation size for vertices.
static const EntityID DEFAULT_ELEMENT_SEQUENCE_SIZE = DEFAULT_VERTEX_SEQUENCE_SIZE
 Default allocation size for elements.
static const EntityID DEFAULT_POLY_SEQUENCE_SIZE = 16*1024
 Default allocation size for poly's.
static const EntityID DEFAULT_MESHSET_SEQUENCE_SIZE = DEFAULT_VERTEX_SEQUENCE_SIZE
 Default allocation size for meshsets.

Private Member Functions

void trim_sequence_block (EntityHandle start_handle, EntityHandle &end_handle_in_out, unsigned maximum_sequence_size)
 Utility function for allocate_mesh_set (and similar)
EntityHandle sequence_start_handle (EntityType type, EntityID entity_count, int values_per_entity, EntityID start_id_hint, SequenceData *&data_out, EntityID &data_size)
 Get range of handles in which to create an entity sequence.

Private Attributes

TypeSequenceManager typeData [MBMAXTYPE]
std::vector< int > tagSizes

Detailed Description

Definition at line 13 of file SequenceManager.hpp.


Constructor & Destructor Documentation

Definition at line 33 of file SequenceManager.cpp.

{
    // release variable-length tag data
  for (unsigned i = 0; i < tagSizes.size(); ++i)
    if (tagSizes[i] == MB_VARIABLE_LENGTH)
      release_tag_array( 0, i, false );
}

Member Function Documentation

ErrorCode moab::SequenceManager::add_vsequence ( EntitySequence vert_seq,
EntitySequence elem_seq,
const HomCoord p1,
const HomCoord q1,
const HomCoord p2,
const HomCoord q2,
const HomCoord p3,
const HomCoord q3,
bool  bb_input = false,
const HomCoord bb_min = NULL,
const HomCoord bb_max = NULL 
)

Add a structured vertex sequence to this structured element sequence; see comments in ScdElementData

Definition at line 739 of file SequenceManager.cpp.

{
    // check first that they're structured vtx/elem sequences
  ScdVertexData *scd_vd = dynamic_cast<ScdVertexData*>(vert_seq->data());
  if (!scd_vd) return MB_FAILURE;
  
  ScdElementData *scd_ed = dynamic_cast<ScdElementData*>(elem_seq->data());
  if (!scd_ed) return MB_FAILURE;

  if (bb_min && bb_max)
    return scd_ed->add_vsequence(scd_vd, p1, q1, p2, q2, p3, q3, 
                                 bb_input, *bb_min, *bb_max);
  else
    return scd_ed->add_vsequence(scd_vd, p1, q1, p2, q2, p3, q3, 
                                 bb_input, HomCoord::unitv[0], HomCoord::unitv[0]);
}
ErrorCode moab::SequenceManager::allocate_mesh_set ( EntityHandle  at_this_handle,
unsigned  flags 
)

Allocate an entity set with the specified handle.

Returns:
MB_ALREADY_ALLOCATED if handle is in use, MB_SUCCESS otherwise.

Definition at line 320 of file SequenceManager.cpp.

{
  SequenceData* data = 0;
  TypeSequenceManager::iterator seqptr; 
  EntityHandle block_start = 1, block_end = 0;
  ErrorCode rval = typeData[MBENTITYSET].is_free_handle( handle, seqptr, data, block_start, block_end );
  if (MB_SUCCESS != rval)
    return rval;
  
  MeshSetSequence* seq;
  if (seqptr != typeData[MBENTITYSET].end()) {
    seq = static_cast<MeshSetSequence*>(*seqptr);
    if (seq->start_handle() - 1 == handle) {
      rval = seq->push_front( 1, &flags );
      if (MB_SUCCESS == rval) {
        rval = typeData[MBENTITYSET].notify_prepended( seqptr );
        if (MB_SUCCESS != rval)
          seq->pop_front( 1 );
      }
      return rval;
    }
    else if (seq->end_handle() + 1 == handle) {
      rval = seq->push_back( 1, &flags );
      if (MB_SUCCESS == rval) {
        rval = typeData[MBENTITYSET].notify_appended( seqptr );
        if (MB_SUCCESS != rval)
          seq->pop_back( 1 );
      }
      return rval;
    }
    else
      return MB_FAILURE; // should be unreachable
  }
  else {
    if (data) {
      seq = new MeshSetSequence( handle, 1, flags, data );
    }
    else {
      assert( handle >= block_start && handle <= block_end );
      trim_sequence_block( handle, block_end, DEFAULT_MESHSET_SEQUENCE_SIZE );
      seq = new MeshSetSequence( handle, 1, flags, block_end - handle + 1 );
    }
    
    rval = typeData[MBENTITYSET].insert_sequence( seq );
    if (MB_SUCCESS != rval) {
      SequenceData* vdata = seq->data();
      delete seq;
      if (!data)
        delete vdata;
      return rval;
    }
  
    return MB_SUCCESS;
  }
}
ErrorCode moab::SequenceManager::check_valid_entities ( Error error_handler,
const Range entities 
) const

Check if passed entity handles are valid

Definition at line 74 of file SequenceManager.cpp.

{
  ErrorCode rval;
  Range::const_pair_iterator i;
  for (i = entities.const_pair_begin(); i != entities.const_pair_end(); ++i) {
    const EntityType type1 = TYPE_FROM_HANDLE(i->first);
    const EntityType type2 = TYPE_FROM_HANDLE(i->second);
    if (type1 == type2) {
      rval = typeData[type1].check_valid_handles( error, i->first, i->second );
      if (MB_SUCCESS != rval)
        return rval;
    }
    else {
      int junk;
      EntityHandle split = CREATE_HANDLE( type2, 0, junk );
      rval = typeData[type1].check_valid_handles( error, i->first, split-1 );
      if (MB_SUCCESS != rval)
        return rval;
      rval = typeData[type2].check_valid_handles( error, split, i->second );
      if (MB_SUCCESS != rval)
        return rval;
    }
  }
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::check_valid_entities ( Error error_handler,
const EntityHandle  entities[],
size_t  num_entities,
bool  root_set_okay = false 
) const

Check if passed entity handles are valid

Parameters:
root_set_okayIf true, do not returnan error if the passed array contains one or more zero-valued handles

Delete all contained data

Definition at line 41 of file SequenceManager.cpp.

{
    // destroy all TypeSequenceManager instances
  for (EntityType t = MBVERTEX; t < MBMAXTYPE; ++t)
    typeData[t].~TypeSequenceManager();
    
    // now re-create TypeSequenceManager instances
  for (EntityType t = MBVERTEX; t < MBMAXTYPE; ++t)
    new (typeData+t) TypeSequenceManager();
}  
ErrorCode moab::SequenceManager::create_element ( EntityType  type,
const EntityHandle conn_array,
unsigned  num_vertices,
EntityHandle handle_out 
)

Allocate a element (possibly in an existing sequence) and assign it the passed connectivity.

Definition at line 205 of file SequenceManager.cpp.

{
  if (type <= MBVERTEX || type >= MBENTITYSET)
    return MB_TYPE_OUT_OF_RANGE;
  
  const EntityHandle start = CREATE_HANDLE( type, MB_START_ID );
  const EntityHandle   end = CREATE_HANDLE( type,   MB_END_ID );
  bool append;
  TypeSequenceManager::iterator seq = typeData[type].find_free_handle( start, end, append, conn_len );
  UnstructuredElemSeq* eseq;
  
  if (seq == typeData[type].end()) {
    SequenceData* seq_data = 0;
    unsigned size = DEFAULT_ELEMENT_SEQUENCE_SIZE;
    if (type == MBPOLYGON || type == MBPOLYHEDRON) {
      size = default_poly_sequence_size( conn_len );
    }
    EntityID seq_data_size = 0;
    handle = typeData[type].find_free_sequence( size, start, end, seq_data, seq_data_size, conn_len );
    if (!handle) 
      return MB_FAILURE;
    
    if (MBPOLYGON == type || MBPOLYHEDRON == type) {
      if (seq_data) 
        eseq = new PolyElementSeq( handle, 1, conn_len, seq_data );
      else
        eseq = new PolyElementSeq( handle, 1, conn_len, size );
    }
    else {
      if (seq_data) 
        eseq = new UnstructuredElemSeq( handle, 1, conn_len, seq_data );
      else
        eseq = new UnstructuredElemSeq( handle, 1, conn_len, size );
    }
    
    ErrorCode rval = typeData[type].insert_sequence( eseq );
    if (MB_SUCCESS != rval) {
      SequenceData* vdata = eseq->data();
      delete eseq;
      if (!seq_data)
        delete vdata;
    
      return rval;
    }
  }
  else {  
    eseq = reinterpret_cast<UnstructuredElemSeq*>(*seq);
    if (append) {
      eseq->push_back( 1 );
      handle = eseq->end_handle();
      typeData[type].notify_appended( seq );
    }
    else {
      eseq->push_front( 1 );
      handle = eseq->start_handle();
      typeData[type].notify_prepended( seq );
    }
  }
  
  return eseq->set_connectivity( handle, conn, conn_len );
}
ErrorCode moab::SequenceManager::create_entity_sequence ( EntityType  type,
EntityID  num_entities,
int  nodes_per_entity,
EntityID  start_id_hint,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out,
int  sequence_size 
)

Allocate a block of consecutive entity handles.

Allocate a block of consecutive entity handles. Handles may be appended or prepended to an existing entity sequence.

Parameters:
typeThe type of of entity for which to allocate handles
num_entitiesNumber of entities to allocate
nodes_per_entityNumber of nodes in connectivity for elements, ignored MBVERTEX, MBPOLYGON, MBPOLYHEDRON, and MBENTITYSET types.
start_id_hintPreferred ID portion for first handle. May be ignored if not available.
first_handle_outFirst allocated handle. Allocated handles are [first_handle_out, first_handle_out+num_entities-1].
sequence_outThe sequence in which the entities were allocated. NOTE: first_handle_out may not be first handle in sequence.
sequence_sizeIf specified, allocate this sequence size instead of DEFAULT_***_SEQUENCE_SIZE

Definition at line 438 of file SequenceManager.cpp.

{
  SequenceData* data = 0;
  EntityID data_size = 0;
  handle = sequence_start_handle( type, count, size, start, data, data_size );
    
  if (!handle)
    return MB_MEMORY_ALLOCATION_FAILED;
  
  switch (type) {
  case MBENTITYSET:
  case MBMAXTYPE:
    return MB_TYPE_OUT_OF_RANGE;
  
  case MBVERTEX:
    if (size != 0)
      return MB_INDEX_OUT_OF_RANGE;

    if (data)
      sequence = new VertexSequence( handle, count, data );
    else {
      if (!data_size)
        data_size = new_sequence_size(handle, count, sequence_size);
      sequence = new VertexSequence( handle, count, data_size );
    }
    break;
  
  case MBPOLYGON:
  case MBPOLYHEDRON:
    if (size == 0)
      return MB_INDEX_OUT_OF_RANGE;

    if (data)
      sequence = new PolyElementSeq( handle, count, size, data );
    else {
      if (!data_size)
        data_size = new_sequence_size(handle, count, 
                                      (-1 == sequence_size ? default_poly_sequence_size(size) :
                                       sequence_size));
      sequence = new PolyElementSeq( handle, count, size, data_size );
    }
    break;
  
  default:
    if (size == 0)
      return MB_INDEX_OUT_OF_RANGE;

    if (data)
      sequence = new UnstructuredElemSeq( handle, count, size, data );
    else {
      if (!data_size)
        data_size = new_sequence_size(handle, count, sequence_size);
      sequence = new UnstructuredElemSeq( handle, count, size, data_size );
    }
      // tjt calling new_sequence_size 'cuz don't have a sequence data;
      // start 41467, count 246
    break;
  }
  
  ErrorCode result = typeData[type].insert_sequence( sequence );
  if (MB_SUCCESS != result) {
      // change to NULL if had an existing data or if no existing data,
      // change to the new data created
    data = data ? 0 : sequence->data();
    delete sequence;
    delete data;
    return result;
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::create_mesh_set ( unsigned  flags,
EntityHandle handle_out 
)

Allocate an entity set (possibly in an existing sequence)

Definition at line 272 of file SequenceManager.cpp.

{
  const EntityHandle start = CREATE_HANDLE( MBENTITYSET, MB_START_ID );
  const EntityHandle   end = CREATE_HANDLE( MBENTITYSET,   MB_END_ID );
  bool append;
  TypeSequenceManager::iterator seq = typeData[MBENTITYSET].find_free_handle( start, end, append );
  MeshSetSequence* msseq;
  
  if (seq == typeData[MBENTITYSET].end()) {
    SequenceData* seq_data = 0;
    EntityID seq_data_size = 0;
    handle = typeData[MBENTITYSET].find_free_sequence( DEFAULT_MESHSET_SEQUENCE_SIZE, start, end, seq_data, seq_data_size );
    if (!handle) 
      return MB_FAILURE;
    
    if (seq_data) 
      msseq = new MeshSetSequence( handle, 1, flags, seq_data );
    else
      msseq = new MeshSetSequence( handle, 1, flags, DEFAULT_MESHSET_SEQUENCE_SIZE );
      
    ErrorCode rval = typeData[MBENTITYSET].insert_sequence( msseq );
    if (MB_SUCCESS != rval) {
      SequenceData* vdata = msseq->data();
      delete msseq;
      if (!seq_data)
        delete vdata;
    
      return rval;
    }
  }
  else {  
    msseq = reinterpret_cast<MeshSetSequence*>(*seq);
    if (append) {
      msseq->push_back( 1, &flags );
      handle = msseq->end_handle();
      typeData[MBENTITYSET].notify_appended( seq );
    }
    else {
      msseq->push_front( 1, &flags );
      handle = msseq->start_handle();
      typeData[MBENTITYSET].notify_prepended( seq );
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::create_meshset_sequence ( EntityID  num_sets,
EntityID  start_id_hint,
const unsigned *  flags,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out 
)

Allocate a block of consecutive mesh sets.

Allocate a block of consecutive entity handles. Handles may be appended or prepended to an existing entity sequence.

Parameters:
typeThe type of of entity for which to allocate handles
num_setsNumber of entities to allocate
start_id_hintPreferred ID portion for first handle. May be ignored if not available.
processor_idProcessor ID to embed in handles
flagsArray of length 'num_sets' containing entity set creating flags.
first_handle_outFirst allocated handle. Allocated handles are [first_handle_out, first_handle_out+num_entities-1].
sequence_outThe sequence in which the entities were allocated. NOTE: first_handle_out may not be first handle in sequence.

Definition at line 518 of file SequenceManager.cpp.

{
  SequenceData* data = 0;
  EntityID data_size = 0;
  handle = sequence_start_handle( MBENTITYSET, count, 0, start, data, data_size );

  if (!handle)
    return MB_MEMORY_ALLOCATION_FAILED;
  
  if (data)
    sequence = new MeshSetSequence( handle, count, flags, data );
  else
    sequence = new MeshSetSequence( handle, count, flags, count );
  
  
  
  ErrorCode result = typeData[MBENTITYSET].insert_sequence( sequence );
  if (MB_SUCCESS != result) {
      // change to NULL if had an existing data or if no existing data,
      // change to the new data created
    data = data ? 0 : sequence->data();
    delete sequence;
    delete data;
    return result;
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::create_meshset_sequence ( EntityID  num_sets,
EntityID  start_id_hint,
unsigned  flags,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out 
)

Allocate a block of consecutive mesh sets.

Alternate form that creates all mesh sets with same flags.

Definition at line 553 of file SequenceManager.cpp.

{
  SequenceData* data = 0;
  EntityID data_size = 0;
  handle = sequence_start_handle( MBENTITYSET, count, 0, start, data, data_size );
  if (!handle)
    return MB_MEMORY_ALLOCATION_FAILED;
  
  if (data)
    sequence = new MeshSetSequence( handle, count, flags, data );
  else
    sequence = new MeshSetSequence( handle, count, flags, count );
  
  
  
  ErrorCode result = typeData[MBENTITYSET].insert_sequence( sequence );
  if (MB_SUCCESS != result) {
      // change to NULL if had an existing data or if no existing data,
      // change to the new data created
    data = data ? 0 : sequence->data();
    delete sequence;
    delete data;
    return result;
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::create_scd_sequence ( int  imin,
int  jmin,
int  kmin,
int  imax,
int  jmax,
int  kmax,
EntityType  type,
EntityID  start_id_hint,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out,
int *  is_periodic = NULL 
)

Create structured mesh

Definition at line 586 of file SequenceManager.cpp.

{
  int this_dim = CN::Dimension(type);

    // use > instead of != in the following assert to also catch cases where imin > imax, etc.
  assert((this_dim < 3 || kmax > kmin) &&
         (this_dim < 2 || jmax > jmin) &&
         (this_dim < 1 || imax > imin));

    // compute # entities; not as easy as it would appear...
  EntityID num_ent;
  if (MBVERTEX == type)
    num_ent = (EntityID)(imax-imin+1)*(EntityID)(jmax-jmin+1)*(EntityID)(kmax-kmin+1);
  else {
    num_ent = (imax-imin + (is_periodic && is_periodic[0] ? 1 : 0)) *
      (this_dim >= 2 ? (jmax-jmin + (is_periodic && is_periodic[1] ? 1 : 0)) : 1) *
      (this_dim >= 3 ? (kmax-kmin) : 1);
  }

  if (MBVERTEX == type && (is_periodic && (is_periodic[0] || is_periodic[1])))
    return MB_FAILURE;
    
    // get a start handle
  SequenceData* data = 0;
  EntityID data_size = 0;
  handle = sequence_start_handle( type, num_ent, -1, start_id_hint, data, data_size );

  if (!handle)
    return MB_MEMORY_ALLOCATION_FAILED;
  assert(!data);
  
  switch (type) {
  case MBVERTEX:
    data = new ScdVertexData( handle, imin, jmin, kmin, imax, jmax, kmax );
    sequence = new VertexSequence( handle, data->size(), data );
    break;
  case MBEDGE:
  case MBQUAD:
  case MBHEX:
      sequence = new StructuredElementSeq( handle, imin, jmin, kmin, imax, jmax, kmax, 
                                           is_periodic);
    break;
  default:
    return MB_TYPE_OUT_OF_RANGE;
  }
  
  ErrorCode result = typeData[type].insert_sequence( sequence );
  if (MB_SUCCESS != result) {
    data = sequence->data();
    delete sequence;
    delete data;
    return result;
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::create_scd_sequence ( const HomCoord coord_min,
const HomCoord coord_max,
EntityType  type,
EntityID  start_id_hint,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out,
int *  is_periodic = NULL 
)

Create structured mesh

Definition at line 650 of file SequenceManager.cpp.

{
  return create_scd_sequence( coord_min.i(), coord_min.j(), coord_min.k(),
                              coord_max.i(), coord_max.j(), coord_max.k(),
                              type, start_id_hint,
                              first_handle_out, sequence_out, is_periodic);
}
ErrorCode moab::SequenceManager::create_sweep_sequence ( int  imin,
int  jmin,
int  kmin,
int  imax,
int  jmax,
int  kmax,
int *  Cq,
EntityType  type,
EntityID  start_id_hint,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out 
)

Create swept mesh

Definition at line 665 of file SequenceManager.cpp.

{
  int this_dim = CN::Dimension(type);

  assert((this_dim < 3 || kmax > kmin) &&
         (this_dim < 2 || jmax > jmin) &&
         (this_dim < 1 || imax > imin));

  EntityID num_ent;
  if (MBVERTEX == type)
    num_ent = (EntityID)(imax-imin+1)*(EntityID)(jmax-jmin+1)*(EntityID)(kmax-kmin+1);
  else {
    num_ent = (imax-imin) *
      (this_dim >= 2 ? (jmax-jmin) : 1) *
      (this_dim >= 3 ? (kmax-kmin) : 1);
  }
  
    // get a start handle
  SequenceData* data = 0;
  EntityID data_size = 0;
  handle = sequence_start_handle( type, num_ent, -1, start_id_hint, data, data_size );

  if (!handle)
    return MB_MEMORY_ALLOCATION_FAILED;
  assert(!data);
  
  switch (type) {
  case MBVERTEX:
    data = new ScdVertexData( handle, imin, jmin, kmin, imax, jmax, kmax );
    sequence = new VertexSequence( handle, data->size(), data );
    break;
  case MBEDGE:
  case MBQUAD:
  case MBHEX:
    sequence = new SweptElementSeq( handle, imin, jmin, kmin, imax, jmax, kmax, Cq );
    break;
  default:
    return MB_TYPE_OUT_OF_RANGE;
  }
  
  ErrorCode result = typeData[type].insert_sequence( sequence );
  if (MB_SUCCESS != result) {
    data = sequence->data();
    delete sequence;
    delete data;
    return result;
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::SequenceManager::create_sweep_sequence ( const HomCoord coord_min,
const HomCoord coord_max,
int *  Cq,
EntityType  type,
EntityID  start_id_hint,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out 
)

Create swept mesh

Definition at line 723 of file SequenceManager.cpp.

{
  return create_sweep_sequence( coord_min.i(), coord_min.j(), coord_min.k(),
                coord_max.i(), coord_max.j(), coord_max.k(),
                Cq,
                type, start_id_hint,
                first_handle_out, sequence_out );
}
ErrorCode moab::SequenceManager::create_vertex ( const double  coords[3],
EntityHandle handle_out 
)

Allocate a vertex (possibly in an existing sequence) and assign it the passed coordinate values.

Definition at line 156 of file SequenceManager.cpp.

{
  const EntityHandle start = CREATE_HANDLE( MBVERTEX, MB_START_ID );
  const EntityHandle   end = CREATE_HANDLE( MBVERTEX,   MB_END_ID );
  bool append;
  TypeSequenceManager::iterator seq = typeData[MBVERTEX].find_free_handle( start, end, append );
  VertexSequence* vseq;
  
  if (seq == typeData[MBVERTEX].end()) {
    SequenceData* seq_data = 0;
    EntityID seq_data_size = 0;
    handle = typeData[MBVERTEX].find_free_sequence( DEFAULT_VERTEX_SEQUENCE_SIZE, start, end, seq_data, seq_data_size );
    if (!handle) 
      return MB_FAILURE;
    
    if (seq_data) 
      vseq = new VertexSequence( handle, 1, seq_data );
    else
      vseq = new VertexSequence( handle, 1, DEFAULT_VERTEX_SEQUENCE_SIZE );
      
    ErrorCode rval = typeData[MBVERTEX].insert_sequence( vseq );
    if (MB_SUCCESS != rval) {
      SequenceData* vdata = vseq->data();
      delete vseq;
      if (!seq_data)
        delete vdata;
    
      return rval;
    }
  }
  else {  
    vseq = reinterpret_cast<VertexSequence*>(*seq);
    if (append) {
      vseq->push_back( 1 );
      handle = vseq->end_handle();
      typeData[MBVERTEX].notify_appended( seq );
    }
    else {
      vseq->push_front( 1 );
      handle = vseq->start_handle();
      typeData[MBVERTEX].notify_prepended( seq );
    }
  }
  
  return vseq->set_coordinates( handle, coords );
}
EntityID moab::SequenceManager::default_poly_sequence_size ( int  entity_connectivity_length) [static]

Get default size of POLYGON and POLYHEDRON SequenceData.

Definition at line 30 of file SequenceManager.cpp.

  {  return std::max( DEFAULT_POLY_SEQUENCE_SIZE / conn_len, (EntityID)1 ); }
ErrorCode moab::SequenceManager::delete_entities ( Error error_handler,
const Range entities 
)

Delete entities

Definition at line 126 of file SequenceManager.cpp.

{
  ErrorCode rval = check_valid_entities( error, entities );
  if (MB_SUCCESS != rval)
    return rval;
  
  ErrorCode result = MB_SUCCESS;
  Range::const_pair_iterator i;
  for (i = entities.const_pair_begin(); i != entities.const_pair_end(); ++i) {
    const EntityType type1 = TYPE_FROM_HANDLE(i->first);
    const EntityType type2 = TYPE_FROM_HANDLE(i->second);
    if (type1 == type2) {
      rval = typeData[type1].erase( error, i->first, i->second );
      if (MB_SUCCESS != rval)
        return result = rval;
    }
    else {
      int junk;
      EntityHandle split = CREATE_HANDLE( type2, 0, junk );
      rval = typeData[type1].erase( error, i->first, split-1 );
      if (MB_SUCCESS != rval)
        return result = rval;
      rval = typeData[type2].erase( error, split, i->second );
      if (MB_SUCCESS != rval)
        return result = rval;
    }
  }
  return result;
}

Delete an entity. Deletes sequence if only contained entity.

Definition at line 121 of file SequenceManager.cpp.

{
  return typeData[TYPE_FROM_HANDLE(entity)].erase( error, entity );
}

Get data for a specific EntityType

Definition at line 232 of file SequenceManager.hpp.

      { return typeData[type]; }
const TypeSequenceManager& moab::SequenceManager::entity_map ( EntityType  type) const [inline]

Get data for a specific EntityType

Definition at line 236 of file SequenceManager.hpp.

      { return typeData[type]; }
ErrorCode moab::SequenceManager::find ( EntityHandle  handle,
EntitySequence *&  sequence_out 
) [inline]

Find entity sequence containing specified handle.

Returns:
MB_SUCCESS or MB_ENTITY_NOT_FOUND

Definition at line 25 of file SequenceManager.hpp.

      { 
        return typeData[TYPE_FROM_HANDLE(handle)].find( handle, sequence_out );
      }
ErrorCode moab::SequenceManager::find ( EntityHandle  handle,
const EntitySequence *&  sequence_out 
) const [inline]

Find entity sequence containing specified handle.

Returns:
MB_SUCCESS or MB_ENTITY_NOT_FOUND

Definition at line 33 of file SequenceManager.hpp.

      { 
        return typeData[TYPE_FROM_HANDLE(handle)].find( handle, sequence_out );
      }
void moab::SequenceManager::get_entities ( EntityType  type,
Range entities_out 
) const [inline]

Get all entities of a given EntityType, return all entities if type == MBMAXTYPE

Definition at line 40 of file SequenceManager.hpp.

      { 
        if (type == MBMAXTYPE)
          get_entities( entities_out );
        else
          typeData[type].get_entities( entities_out ); 
      }
void moab::SequenceManager::get_entities ( Range entities_out) const

Definition at line 52 of file SequenceManager.cpp.

{
  for (EntityType t = MBENTITYSET; t >= MBVERTEX; --t)
    typeData[t].get_entities( entities_out );
}
void moab::SequenceManager::get_entities ( EntityType  type,
std::vector< EntityHandle > &  entities_out 
) const [inline]

Get all entities of a given EntityType, return all entities if type == MBMAXTYPE

Definition at line 52 of file SequenceManager.hpp.

      { 
        if (type == MBMAXTYPE)
          get_entities( entities_out );
        else
          typeData[type].get_entities( entities_out ); 
      }
void moab::SequenceManager::get_entities ( std::vector< EntityHandle > &  entities_out) const

Definition at line 58 of file SequenceManager.cpp.

{
  for (EntityType t = MBVERTEX; t != MBMAXTYPE; ++t)
    typeData[t].get_entities( entities_out );
}
const EntitySequence* moab::SequenceManager::get_last_accessed_sequence ( EntityType  type) const [inline]

Get most recently accessed sequence for a given type

Definition at line 70 of file SequenceManager.hpp.

      { return typeData[type].get_last_accessed(); }
void moab::SequenceManager::get_memory_use ( unsigned long &  total_entity_storage,
unsigned long &  total_storage 
) const

Definition at line 770 of file SequenceManager.cpp.

{
  total_entity_storage = 0;
  total_storage = 0;
  unsigned long temp_entity, temp_total;
  for (EntityType i = MBVERTEX; i < MBMAXTYPE; ++i) {
    temp_entity = temp_total = 0;
    get_memory_use( i, temp_entity, temp_total );
    total_entity_storage += temp_entity;
    total_storage        += temp_total;
  }
}
void moab::SequenceManager::get_memory_use ( EntityType  type,
unsigned long &  total_entity_storage,
unsigned long &  total_storage 
) const

Definition at line 785 of file SequenceManager.cpp.

{
  typeData[type].get_memory_use( total_entity_storage, total_storage );
}
void moab::SequenceManager::get_memory_use ( const Range entities,
unsigned long &  total_entity_storage,
unsigned long &  total_amortized_storage 
) const

Definition at line 792 of file SequenceManager.cpp.

{
  total_entity_storage = 0;
  total_amortized_storage = 0;
  unsigned long temp_entity, temp_total;
  Range::const_pair_iterator i;
  for (i = entities.const_pair_begin(); i != entities.const_pair_end(); ++i) {
    const EntityType t1 = TYPE_FROM_HANDLE(i->first);
    const EntityType t2 = TYPE_FROM_HANDLE(i->second);
    if (t1 == t2) {
      temp_entity = temp_total = 0;
      typeData[t1].get_memory_use( i->first, i->second, temp_entity, temp_total );
      total_entity_storage += temp_entity;
      total_amortized_storage += temp_total;
    }
    else {
      int junk;
 
      temp_entity = temp_total = 0;
      typeData[t1].get_memory_use( i->first, CREATE_HANDLE(t1,MB_END_ID,junk), temp_entity, temp_total );
      total_entity_storage += temp_entity;
      total_amortized_storage += temp_total;

      temp_entity = temp_total = 0;
      typeData[t2].get_memory_use( CREATE_HANDLE(t2,MB_START_ID,junk), i->second, temp_entity, temp_total );
      total_entity_storage += temp_entity;
      total_amortized_storage += temp_total;
    }
  }
}
EntityID moab::SequenceManager::get_number_entities ( EntityType  type) const [inline]

Count entities of a given EntityType

Definition at line 63 of file SequenceManager.hpp.

      { return type == MBMAXTYPE ? get_number_entities() : typeData[type].get_number_entities(); }

Count entities of a given EntityType

Definition at line 64 of file SequenceManager.cpp.

{
  EntityID sum = 0;
  for (EntityType t = MBVERTEX; t != MBMAXTYPE; ++t)
    sum += typeData[t].get_number_entities();
  return sum;
}
EntityID moab::SequenceManager::new_sequence_size ( EntityHandle  start_handle,
EntityID  requested_size,
int  sequence_size 
) const

Size to allocate for new SquenceData THIS FUNCTION SHOULD ONLY BE CALLED WHEN ALLOCATING FROM ReadUtil IN BULK (since it will allocate lesser of requested_size and default_size) If sequence_size != -1, will try to allocate that, unless there isn't available space.

Definition at line 411 of file SequenceManager.cpp.

{
#ifdef USE_MPI
    // if we're compiled parallel, increase requested size by a factor of 1.5, to allow
    // for ghosts; if non-default value used for sequence_size that'll take precedent anyway
  requested_size *= 1.5;
#endif
  
  if (sequence_size < (int)requested_size)
    return requested_size;
  
  EntityHandle last = typeData[TYPE_FROM_HANDLE(start)].last_free_handle( start );
  if (!last) {
    assert( false );
    return 0;
  }
  
  EntityID available_size = last - start + 1;
  if (sequence_size < available_size)
    return sequence_size;
  else
    return available_size;
}
ErrorCode moab::SequenceManager::release_tag_array ( Error error_handler,
int  id,
bool  release_id 
)

Release any storage assocociated with a tag ID, and optionally, release the reserved tag ID.

Definition at line 846 of file SequenceManager.cpp.

{
  if ((unsigned)index >= tagSizes.size() || UNUSED_SIZE == tagSizes[index]) {
    if (error_handler)
      error_handler->set_last_error( "Invalid dense tag index: %d", index );
    return MB_TAG_NOT_FOUND;
  }
  
  for (EntityType t = MBVERTEX; t <= MBENTITYSET; ++t) {
    TypeSequenceManager& seqs = entity_map(t);
    for (TypeSequenceManager::iterator i = seqs.begin(); i != seqs.end(); ++i)
      (*i)->data()->release_tag_data( index, tagSizes[index] );
  }

  if (release_id) 
    tagSizes[index] = UNUSED_SIZE;
  return MB_SUCCESS;
}

Replace subset of existing sequence with new sequence (splits existing sequence)

Used for converting number of nodes for fixed-connectivity-length elements. Input sequence must be a non-strict subset of an existing sequence. Existing sequence will be removed, modified, or split into two prevent it from overlapping the new sequence.

Definition at line 764 of file SequenceManager.cpp.

{
  const EntityType type = TYPE_FROM_HANDLE(new_seq->start_handle());
  return typeData[type].replace_subsequence( new_seq, &tagSizes[0], tagSizes.size() );
}
ErrorCode moab::SequenceManager::reserve_tag_array ( Error error_handler,
int  tag_size,
int &  array_id_out 
)

Allocate a tag ID

Parameters:
tag_sizeThe size of the tag value for each entity

Definition at line 825 of file SequenceManager.cpp.

{
  if (size < 1 && size != MB_VARIABLE_LENGTH) {
    error_handler->set_last_error( "Invalid tag size: %d", size );
    return MB_INVALID_SIZE;
  }
  
  std::vector<int>::iterator i = std::find( tagSizes.begin(), tagSizes.end(), UNUSED_SIZE );
  if (i == tagSizes.end()) {
    index = tagSizes.size();
    tagSizes.push_back( size );
  }
  else {
    index = i - tagSizes.begin();
    *i = size;
  }
  
  return MB_SUCCESS;
}
EntityHandle moab::SequenceManager::sequence_start_handle ( EntityType  type,
EntityID  entity_count,
int  values_per_entity,
EntityID  start_id_hint,
SequenceData *&  data_out,
EntityID data_size 
) [private]

Get range of handles in which to create an entity sequence.

Get range of handles in whcih to place a new entity sequence.

Parameters:
typeThe EntityType for the contents of the sequence
entity_countThe number of entities in the range
values_per_entityVertices per element, zero for other types
start_id_hintPreferred id of first handle
processor_rankMPI processor ID
data_outOutput: Either NULL or an existing SequenceData with a sufficiently large block to accomodate the handle range.
Returns:
zero if no available handle range, start handle otherwise.

Definition at line 391 of file SequenceManager.cpp.

{
  TypeSequenceManager &tsm = typeData[type];
  data = 0;
  EntityHandle handle = CREATE_HANDLE( type, start );
  if (start < MB_START_ID ||
      !tsm.is_free_sequence( handle, count, data, size )) {
    EntityHandle pstart = CREATE_HANDLE( type, MB_START_ID );
    EntityHandle pend   = CREATE_HANDLE( type,   MB_END_ID );
    handle = tsm.find_free_sequence( count, pstart, pend, data, data_size, size);
  }
  return handle;
}
void moab::SequenceManager::trim_sequence_block ( EntityHandle  start_handle,
EntityHandle end_handle_in_out,
unsigned  maximum_sequence_size 
) [private]

Utility function for allocate_mesh_set (and similar)

Given a block of available handles, determine the non-strict subset at which to create a new EntitySequence.

Definition at line 378 of file SequenceManager.cpp.

{
  assert( end_handle >= start_handle );
  assert( (int)max_size > 0 ); // cast to int also prohibits some rediculously large values
  
    // if input range is larger than preferred size, trim it
  if (end_handle - start_handle >= max_size)
    end_handle = start_handle + max_size - 1;
}

Member Data Documentation

Default allocation size for elements.

Definition at line 280 of file SequenceManager.hpp.

Default allocation size for meshsets.

Definition at line 286 of file SequenceManager.hpp.

Default allocation size for poly's.

Definition at line 283 of file SequenceManager.hpp.

Default allocation size for vertices.

Definition at line 277 of file SequenceManager.hpp.

std::vector<int> moab::SequenceManager::tagSizes [private]

Definition at line 322 of file SequenceManager.hpp.


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