Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::SweptElementData Class Reference

#include <SweptElementData.hpp>

+ Inheritance diagram for moab::SweptElementData:
+ Collaboration diagram for moab::SweptElementData:

Classes

class  VertexDataRef
 structure to hold references to bounding vertex blocks More...
 

Public Member Functions

 SweptElementData (EntityHandle start_handle, const int imin, const int jmin, const int kmin, const int imax, const int jmax, const int kmax, const int *Cq)
 constructor More...
 
virtual ~SweptElementData ()
 
EntityHandle get_vertex (const HomCoord &coords) const
 get handle of vertex at homogeneous coords More...
 
EntityHandle get_vertex (int i, int j, int k) const
 
EntityHandle get_element (const int i, const int j, const int k) const
 get handle of element at i, j, k More...
 
const HomCoordmin_params () const
 get min params for this element More...
 
const HomCoordmax_params () const
 get max params for this element More...
 
void param_extents (int &di, int &dj, int &dk) const
 get the number of vertices in each direction, inclusive More...
 
ErrorCode get_params (const EntityHandle ehandle, int &i, int &j, int &k) const
 given a handle, get the corresponding parameters More...
 
int i_min () const
 convenience functions for parameter extents More...
 
int j_min () const
 
int k_min () const
 
int i_max () const
 
int j_max () const
 
int k_max () const
 
bool boundary_complete () const
 test the bounding vertex sequences and determine whether they fully define the vertices covering this element block's parameter space More...
 
bool contains (const HomCoord &coords) const
 test whether this sequence contains these parameters More...
 
ErrorCode get_params_connectivity (const int i, const int j, const int k, std::vector< EntityHandle > &connectivity) const
 get connectivity of an entity given entity's parameters More...
 
ErrorCode add_vsequence (SweptVertexData *vseq, 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=HomCoord::unitv[0], const HomCoord &bb_max=HomCoord::unitv[0])
 add a vertex seq ref to this element sequence; if bb_input is true, bounding box (in eseq-local coords) of vseq being added is input in bb_min and bb_max (allows partial sharing of vseq rather than the whole vseq); if it's false, the whole vseq is referenced and the eseq-local coordinates is computed from the transformed bounding box of the vseq More...
 
SequenceDatasubset (EntityHandle start, EntityHandle end, const int *sequence_data_sizes, const int *tag_data_sizes) const
 
unsigned long get_memory_use () const
 
- Public Member Functions inherited from moab::SequenceData
 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...
 

Static Public Member Functions

static EntityID calc_num_entities (EntityHandle start_handle, int irange, int jrange, int krange)
 

Private Member Functions

 SweptElementData ()
 bare constructor, so compiler doesn't create one for me More...
 

Private Attributes

HomCoord elementParams [3]
 parameter min/max/stride, in homogeneous coords ijkh More...
 
int dIJK [3]
 difference between max and min params plus one (i.e. # VERTICES in each parametric direction) More...
 
int dIJKm1 [3]
 difference between max and min params (i.e. # ELEMENTS in each parametric direction) More...
 
std::vector< VertexDataRefvertexSeqRefs
 list of bounding vertex blocks More...
 

Additional Inherited Members

- Public Types inherited from moab::SequenceData
typedef std::vector< EntityHandle > * AdjacencyDataType
 
- Public Attributes inherited from moab::SequenceData
TypeSequenceManager::SequenceDataPtr seqManData
 SequenceManager data. More...
 
- Protected Member Functions inherited from moab::SequenceData
 SequenceData (const SequenceData *subset_from, EntityHandle start, EntityHandle end, const int *sequence_data_sizes)
 

Detailed Description

Definition at line 43 of file SweptElementData.hpp.

Constructor & Destructor Documentation

◆ SweptElementData() [1/2]

moab::SweptElementData::SweptElementData ( )
private

bare constructor, so compiler doesn't create one for me

◆ SweptElementData() [2/2]

moab::SweptElementData::SweptElementData ( EntityHandle  start_handle,
const int  imin,
const int  jmin,
const int  kmin,
const int  imax,
const int  jmax,
const int  kmax,
const int *  Cq 
)

constructor

Definition at line 50 of file SweptElementData.cpp.

58  : SequenceData( 0, shandle, shandle + calc_num_entities( shandle, imax - imin, jmax - jmin, kmax - kmin ) - 1 )
59 {
60  // need to have meaningful parameters
61  assert( imax >= imin && jmax >= jmin && kmax >= kmin );
62 
63  elementParams[0] = HomCoord( imin, jmin, kmin );
64  elementParams[1] = HomCoord( imax, jmax, kmax );
65  elementParams[2] = HomCoord( 1, 1, 1 );
66 
67  // assign and compute parameter stuff
68  dIJK[0] = elementParams[1][0] - elementParams[0][0] + 1;
69  dIJK[1] = elementParams[1][1] - elementParams[0][1] + 1;
70  dIJK[2] = elementParams[1][2] - elementParams[0][2] + 1;
71  dIJKm1[0] = dIJK[0] - 1;
72  dIJKm1[1] = dIJK[1] - 1;
73  dIJKm1[2] = dIJK[2] - 1;
74 }

References dIJK, dIJKm1, and elementParams.

◆ ~SweptElementData()

moab::SweptElementData::~SweptElementData ( )
virtual

Definition at line 76 of file SweptElementData.cpp.

76 {}

Member Function Documentation

◆ add_vsequence()

ErrorCode moab::SweptElementData::add_vsequence ( SweptVertexData vseq,
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 = HomCoord::unitv[0],
const HomCoord bb_max = HomCoord::unitv[0] 
)
inline

add a vertex seq ref to this element sequence; if bb_input is true, bounding box (in eseq-local coords) of vseq being added is input in bb_min and bb_max (allows partial sharing of vseq rather than the whole vseq); if it's false, the whole vseq is referenced and the eseq-local coordinates is computed from the transformed bounding box of the vseq

Definition at line 266 of file SweptElementData.hpp.

276 {
277  // compute the transform given the vseq-local parameters and the mapping to
278  // this element sequence's parameters passed in minmax
279  HomXform M;
280  M.three_pt_xform( p1, q1, p2, q2, p3, q3 );
281 
282  // min and max in element seq's parameter system may not be same as those in
283  // vseq's system, so need to take min/max
284 
285  HomCoord minmax[2];
286  if( bb_input )
287  {
288  minmax[0] = bb_min;
289  minmax[1] = bb_max;
290  }
291  else
292  {
293  minmax[0] = vseq->min_params() * M;
294  minmax[1] = vseq->max_params() * M;
295  }
296 
297  // check against other vseq's to make sure they don't overlap
298  for( std::vector< VertexDataRef >::const_iterator vsit = vertexSeqRefs.begin(); vsit != vertexSeqRefs.end();
299  ++vsit )
300  if( ( *vsit ).contains( minmax[0] ) || ( *vsit ).contains( minmax[1] ) ) return MB_FAILURE;
301 
302  HomCoord tmp_min( std::min( minmax[0].i(), minmax[1].i() ), std::min( minmax[0].j(), minmax[1].j() ),
303  std::min( minmax[0].k(), minmax[1].k() ) );
304  HomCoord tmp_max( std::max( minmax[0].i(), minmax[1].i() ), std::max( minmax[0].j(), minmax[1].j() ),
305  std::max( minmax[0].k(), minmax[1].k() ) );
306 
307  // set up a new vertex sequence reference
308  VertexDataRef tmp_seq_ref( tmp_min, tmp_max, M, vseq );
309 
310  // add to the list
311  vertexSeqRefs.push_back( tmp_seq_ref );
312 
313  return MB_SUCCESS;
314 }

References moab::SweptVertexData::max_params(), MB_SUCCESS, moab::SweptVertexData::min_params(), moab::HomXform::three_pt_xform(), and vertexSeqRefs.

◆ boundary_complete()

bool moab::SweptElementData::boundary_complete ( ) const

test the bounding vertex sequences and determine whether they fully define the vertices covering this element block's parameter space

Definition at line 78 of file SweptElementData.cpp.

79 {
80  // test the bounding vertex sequences to see if they fully define the
81  // vertex parameter space for this rectangular block of elements
82 
83  int p;
84  std::vector< VertexDataRef > minlist, maxlist;
85 
86  // pseudo code:
87  // for each vertex sequence v:
88  for( std::vector< VertexDataRef >::const_iterator vseq = vertexSeqRefs.begin(); vseq != vertexSeqRefs.end();
89  ++vseq )
90  {
91  // test min corner mincorner:
92  bool mincorner = true;
93  // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1):
94  for( p = 0; p < 3; p++ )
95  {
96 
97  // for each vsequence v' != v:
98  for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin();
99  othervseq != vertexSeqRefs.end(); ++othervseq )
100  {
101  if( othervseq == vseq ) continue;
102  // if v.min-p contained in v'
103  if( ( *othervseq ).contains( ( *vseq ).minmax[0] - HomCoord::unitv[p] ) )
104  {
105  // mincorner = false
106  mincorner = false;
107  break;
108  }
109  }
110  if( !mincorner ) break;
111  }
112 
113  bool maxcorner = true;
114  // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1):
115  for( p = 0; p < 3; p++ )
116  {
117 
118  // for each vsequence v' != v:
119  for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin();
120  othervseq != vertexSeqRefs.end(); ++othervseq )
121  {
122  if( othervseq == vseq ) continue;
123  // if v.max+p contained in v'
124  if( ( *othervseq ).contains( ( *vseq ).minmax[1] + HomCoord::unitv[p] ) )
125  {
126  // maxcorner = false
127  maxcorner = false;
128  break;
129  }
130  }
131  if( !maxcorner ) break;
132  }
133 
134  // if mincorner add to min corner list minlist
135  if( mincorner ) minlist.push_back( *vseq );
136  // if maxcorner add to max corner list maxlist
137  if( maxcorner ) maxlist.push_back( *vseq );
138  }
139 
140  //
141  // if minlist.size = 1 & maxlist.size = 1 & minlist[0] = esequence.min &
142  // maxlist[0] = esequence.max+(1,1,1)
143  if( minlist.size() == 1 && maxlist.size() == 1 && minlist[0].minmax[0] == elementParams[0] &&
144  maxlist[0].minmax[1] == elementParams[1] )
145  // complete
146  return true;
147  // else
148 
149  return false;
150 }

References elementParams, moab::HomCoord::unitv, and vertexSeqRefs.

Referenced by get_vertex().

◆ calc_num_entities()

EntityID moab::SweptElementData::calc_num_entities ( EntityHandle  start_handle,
int  irange,
int  jrange,
int  krange 
)
static

Definition at line 27 of file SweptElementData.cpp.

28 {
29  size_t result = 1;
31  switch( dim )
32  {
33  case 3:
34  result *= krange;
35  // fall through
36  case 2:
37  result *= jrange;
38  // fall through
39  case 1:
40  result *= irange;
41  break;
42  default:
43  result = 0;
44  assert( false );
45  break;
46  }
47  return result;
48 }

References dim, moab::CN::Dimension(), moab::SequenceData::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ contains()

bool moab::SweptElementData::contains ( const HomCoord coords) const
inline

test whether this sequence contains these parameters

Definition at line 225 of file SweptElementData.hpp.

226 {
227  // upper bound is < instead of <= because element params max is one less
228  // than vertex params max
229  return ( temp >= elementParams[0] && temp < elementParams[1] );
230 }

References elementParams.

Referenced by get_params_connectivity().

◆ get_element()

EntityHandle moab::SweptElementData::get_element ( const int  i,
const int  j,
const int  k 
) const
inline

get handle of element at i, j, k

Definition at line 180 of file SweptElementData.hpp.

181 {
182  return start_handle() + ( i - i_min() ) + ( j - j_min() ) * dIJKm1[0] + ( k - k_min() ) * dIJKm1[0] * dIJKm1[1];
183 }

References dIJKm1, i_min(), j_min(), k_min(), and moab::SequenceData::start_handle().

◆ get_memory_use()

unsigned long moab::SweptElementData::get_memory_use ( ) const

Definition at line 160 of file SweptElementData.cpp.

161 {
162  return sizeof( *this ) + vertexSeqRefs.capacity() * sizeof( VertexDataRef );
163 }

References vertexSeqRefs.

◆ get_params()

ErrorCode moab::SweptElementData::get_params ( const EntityHandle  ehandle,
int &  i,
int &  j,
int &  k 
) const
inline

given a handle, get the corresponding parameters

Definition at line 203 of file SweptElementData.hpp.

204 {
205  if( TYPE_FROM_HANDLE( ehandle ) != TYPE_FROM_HANDLE( start_handle() ) ) return MB_FAILURE;
206 
207  int hdiff = ehandle - start_handle();
208 
209  // use double ?: test below because on some platforms, both sides of the : are
210  // evaluated, and if dIJKm1[1] is zero, that'll generate a divide-by-zero
211  k = ( dIJKm1[1] > 0 ? hdiff / ( dIJKm1[1] > 0 ? dIJKm1[0] * dIJKm1[1] : 1 ) : 0 );
212  j = ( hdiff - ( k * dIJKm1[0] * dIJKm1[1] ) ) / dIJKm1[0];
213  i = hdiff % dIJKm1[0];
214 
215  k += elementParams[0].k();
216  j += elementParams[0].j();
217  i += elementParams[0].i();
218 
219  return ( ehandle >= start_handle() && ehandle < start_handle() + size() && i >= i_min() && i <= i_max() &&
220  j >= j_min() && j <= j_max() && k >= k_min() && k <= k_max() )
221  ? MB_SUCCESS
222  : MB_FAILURE;
223 }

References dIJKm1, elementParams, moab::HomCoord::i(), i_max(), i_min(), moab::HomCoord::j(), j_max(), j_min(), moab::HomCoord::k(), k_max(), k_min(), MB_SUCCESS, moab::SequenceData::size(), moab::SequenceData::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ get_params_connectivity()

ErrorCode moab::SweptElementData::get_params_connectivity ( const int  i,
const int  j,
const int  k,
std::vector< EntityHandle > &  connectivity 
) const
inline

get connectivity of an entity given entity's parameters

Definition at line 316 of file SweptElementData.hpp.

320 {
321  if( contains( HomCoord( i, j, k ) ) == false ) return MB_FAILURE;
322 
323  connectivity.push_back( get_vertex( i, j, k ) );
324  connectivity.push_back( get_vertex( i + 1, j, k ) );
325  if( CN::Dimension( TYPE_FROM_HANDLE( start_handle() ) ) < 2 ) return MB_SUCCESS;
326  connectivity.push_back( get_vertex( i + 1, j + 1, k ) );
327  connectivity.push_back( get_vertex( i, j + 1, k ) );
328  if( CN::Dimension( TYPE_FROM_HANDLE( start_handle() ) ) < 3 ) return MB_SUCCESS;
329  connectivity.push_back( get_vertex( i, j, k + 1 ) );
330  connectivity.push_back( get_vertex( i + 1, j, k + 1 ) );
331  connectivity.push_back( get_vertex( i + 1, j + 1, k + 1 ) );
332  connectivity.push_back( get_vertex( i, j + 1, k + 1 ) );
333  return MB_SUCCESS;
334 }

References contains(), moab::CN::Dimension(), get_vertex(), MB_SUCCESS, moab::SequenceData::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ get_vertex() [1/2]

EntityHandle moab::SweptElementData::get_vertex ( const HomCoord coords) const
inline

get handle of vertex at homogeneous coords

Definition at line 247 of file SweptElementData.hpp.

248 {
249  assert( boundary_complete() );
250  for( std::vector< VertexDataRef >::const_iterator it = vertexSeqRefs.begin(); it != vertexSeqRefs.end(); ++it )
251  {
252  if( ( *it ).minmax[0] <= coords && ( *it ).minmax[1] >= coords )
253  {
254  // first get the vertex block-local parameters
255  HomCoord local_coords = coords / ( *it ).xform;
256 
257  // now get the vertex handle for those coords
258  return ( *it ).srcSeq->get_vertex( local_coords );
259  }
260  }
261 
262  // got here, it's an error
263  return 0;
264 }

References boundary_complete(), and vertexSeqRefs.

Referenced by get_params_connectivity(), and get_vertex().

◆ get_vertex() [2/2]

EntityHandle moab::SweptElementData::get_vertex ( int  i,
int  j,
int  k 
) const
inline

Definition at line 95 of file SweptElementData.hpp.

96  {
97  return get_vertex( HomCoord( i, j, k ) );
98  }

References get_vertex().

◆ i_max()

int moab::SweptElementData::i_max ( ) const
inline

Definition at line 128 of file SweptElementData.hpp.

129  {
130  return ( elementParams[1].hom_coord() )[0];
131  }

References elementParams.

Referenced by get_params().

◆ i_min()

int moab::SweptElementData::i_min ( ) const
inline

convenience functions for parameter extents

Definition at line 116 of file SweptElementData.hpp.

117  {
118  return ( elementParams[0].hom_coord() )[0];
119  }

References elementParams.

Referenced by get_element(), and get_params().

◆ j_max()

int moab::SweptElementData::j_max ( ) const
inline

Definition at line 132 of file SweptElementData.hpp.

133  {
134  return ( elementParams[1].hom_coord() )[1];
135  }

References elementParams.

Referenced by get_params().

◆ j_min()

int moab::SweptElementData::j_min ( ) const
inline

Definition at line 120 of file SweptElementData.hpp.

121  {
122  return ( elementParams[0].hom_coord() )[1];
123  }

References elementParams.

Referenced by get_element(), and get_params().

◆ k_max()

int moab::SweptElementData::k_max ( ) const
inline

Definition at line 136 of file SweptElementData.hpp.

137  {
138  return ( elementParams[1].hom_coord() )[2];
139  }

References elementParams.

Referenced by get_params().

◆ k_min()

int moab::SweptElementData::k_min ( ) const
inline

Definition at line 124 of file SweptElementData.hpp.

125  {
126  return ( elementParams[0].hom_coord() )[2];
127  }

References elementParams.

Referenced by get_element(), and get_params().

◆ max_params()

const HomCoord & moab::SweptElementData::max_params ( ) const
inline

get max params for this element

Definition at line 190 of file SweptElementData.hpp.

191 {
192  return elementParams[1];
193 }

References elementParams.

◆ min_params()

const HomCoord & moab::SweptElementData::min_params ( ) const
inline

get min params for this element

Definition at line 185 of file SweptElementData.hpp.

186 {
187  return elementParams[0];
188 }

References elementParams.

◆ param_extents()

void moab::SweptElementData::param_extents ( int &  di,
int &  dj,
int &  dk 
) const
inline

get the number of vertices in each direction, inclusive

Definition at line 196 of file SweptElementData.hpp.

197 {
198  di = dIJK[0];
199  dj = dIJK[1];
200  dk = dIJK[2];
201 }

References dIJK.

◆ subset()

SequenceData * moab::SweptElementData::subset ( EntityHandle  start,
EntityHandle  end,
const int *  sequence_data_sizes,
const int *  tag_data_sizes 
) const

Definition at line 152 of file SweptElementData.cpp.

156 {
157  return 0;
158 }

Member Data Documentation

◆ dIJK

int moab::SweptElementData::dIJK[3]
private

difference between max and min params plus one (i.e. # VERTICES in each parametric direction)

Definition at line 68 of file SweptElementData.hpp.

Referenced by param_extents(), and SweptElementData().

◆ dIJKm1

int moab::SweptElementData::dIJKm1[3]
private

difference between max and min params (i.e. # ELEMENTS in each parametric direction)

Definition at line 72 of file SweptElementData.hpp.

Referenced by get_element(), get_params(), and SweptElementData().

◆ elementParams

HomCoord moab::SweptElementData::elementParams[3]
private

parameter min/max/stride, in homogeneous coords ijkh

Definition at line 64 of file SweptElementData.hpp.

Referenced by boundary_complete(), contains(), get_params(), i_max(), i_min(), j_max(), j_min(), k_max(), k_min(), max_params(), min_params(), and SweptElementData().

◆ vertexSeqRefs

std::vector< VertexDataRef > moab::SweptElementData::vertexSeqRefs
private

list of bounding vertex blocks

Definition at line 78 of file SweptElementData.hpp.

Referenced by add_vsequence(), boundary_complete(), get_memory_use(), and get_vertex().


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