Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 #include "UnstructuredElemSeq.hpp" 00002 #include "SequenceData.hpp" 00003 #include "moab/CN.hpp" 00004 00005 namespace moab 00006 { 00007 00008 UnstructuredElemSeq::UnstructuredElemSeq( EntityHandle shandle, 00009 EntityID entity_count, 00010 unsigned nodes_per_entity, 00011 SequenceData* dat ) 00012 : ElementSequence( shandle, entity_count, nodes_per_entity, dat ) 00013 { 00014 } 00015 00016 UnstructuredElemSeq::UnstructuredElemSeq( EntityHandle shandle, 00017 EntityID entity_count, 00018 unsigned nodes_per_entity, 00019 EntityID data_size ) 00020 : ElementSequence( shandle, 00021 entity_count, 00022 nodes_per_entity, 00023 new SequenceData( 1, shandle, shandle + data_size - 1 ) ) 00024 { 00025 data()->create_sequence_data( 0, nodes_per_entity * sizeof( EntityHandle ) ); 00026 } 00027 00028 UnstructuredElemSeq::~UnstructuredElemSeq() {} 00029 00030 int UnstructuredElemSeq::values_per_entity() const 00031 { 00032 return nodes_per_element(); 00033 } 00034 00035 EntitySequence* UnstructuredElemSeq::split( EntityHandle here ) 00036 { 00037 if( here <= start_handle() || here > end_handle() ) return 0; 00038 00039 return new UnstructuredElemSeq( *this, here ); 00040 } 00041 00042 SequenceData* UnstructuredElemSeq::create_data_subset( EntityHandle start, EntityHandle end ) const 00043 { 00044 int esize = nodes_per_element() * sizeof( EntityHandle ); 00045 return data()->subset( start, end, &esize ); 00046 } 00047 00048 void UnstructuredElemSeq::get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const 00049 { 00050 bytes_per_entity = nodes_per_element() * sizeof( EntityHandle ); 00051 size_of_sequence = sizeof( *this ); 00052 } 00053 00054 ErrorCode UnstructuredElemSeq::get_connectivity( EntityHandle handle, 00055 std::vector< EntityHandle >& connect, 00056 bool topological ) const 00057 { 00058 EntityHandle const* conn = get_array() + nodes_per_element() * ( handle - start_handle() ); 00059 int len = topological ? CN::VerticesPerEntity( type() ) : nodes_per_element(); 00060 connect.reserve( connect.size() + len ); 00061 std::copy( conn, conn + len, std::back_inserter( connect ) ); 00062 return MB_SUCCESS; 00063 } 00064 00065 ErrorCode UnstructuredElemSeq::get_connectivity( EntityHandle handle, 00066 EntityHandle const*& conn_ptr, 00067 int& len, 00068 bool topological, 00069 std::vector< EntityHandle >* ) const 00070 { 00071 conn_ptr = get_array() + nodes_per_element() * ( handle - start_handle() ); 00072 len = topological ? CN::VerticesPerEntity( type() ) : nodes_per_element(); 00073 return MB_SUCCESS; 00074 } 00075 00076 ErrorCode UnstructuredElemSeq::set_connectivity( EntityHandle handle, EntityHandle const* connect, int connect_length ) 00077 { 00078 if( (unsigned)connect_length != nodes_per_element() ) return MB_INDEX_OUT_OF_RANGE; 00079 EntityHandle* conn_ptr = get_array() + nodes_per_element() * ( handle - start_handle() ); 00080 std::copy( connect, connect + connect_length, conn_ptr ); 00081 return MB_SUCCESS; 00082 } 00083 00084 EntityHandle* UnstructuredElemSeq::get_connectivity_array() 00085 { 00086 return get_array(); 00087 } 00088 00089 ErrorCode UnstructuredElemSeq::push_back( EntityID count ) 00090 { 00091 return EntitySequence::append_entities( count ); 00092 } 00093 00094 ErrorCode UnstructuredElemSeq::push_front( EntityID count ) 00095 { 00096 return EntitySequence::prepend_entities( count ); 00097 } 00098 00099 } // namespace moab