Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ScdElementData.cpp
Go to the documentation of this file.
1 /** 2  * MOAB, a Mesh-Oriented datABase, is a software component for creating, 3  * storing and accessing finite element mesh data. 4  * 5  * Copyright 2004 Sandia Corporation. Under the terms of Contract 6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 7  * retains certain rights in this software. 8  * 9  * This library is free software; you can redistribute it and/or 10  * modify it under the terms of the GNU Lesser General Public 11  * License as published by the Free Software Foundation; either 12  * version 2.1 of the License, or (at your option) any later version. 13  * 14  */ 15  16 #include "ScdElementData.hpp" 17 #include "ScdVertexData.hpp" 18 #include "moab/Interface.hpp" 19 #include "moab/ReadUtilIface.hpp" 20 #include "moab/CN.hpp" 21 #include "Internals.hpp" 22 #include <cassert> 23  24 namespace moab 25 { 26  27 EntityID ScdElementData::calc_num_entities( EntityHandle start_handle, 28  int irange, 29  int jrange, 30  int krange, 31  int* is_periodic ) 32 { 33  size_t result = 1; 34  auto dim = CN::Dimension( TYPE_FROM_HANDLE( start_handle ) ); 35  switch( dim ) 36  { 37  case 3: 38  result *= krange; 39  // fall through 40  case 2: 41  result *= ( is_periodic && is_periodic[1] ? ( jrange + 1 ) : jrange ); 42  // fall through 43  case 1: 44  result *= ( is_periodic && is_periodic[0] ? ( irange + 1 ) : irange ); 45  break; 46  default: 47  result = 0; 48  assert( false ); 49  break; 50  } 51  return result; 52 } 53  54 ScdElementData::ScdElementData( EntityHandle shandle, 55  const int imin, 56  const int jmin, 57  const int kmin, 58  const int imax, 59  const int jmax, 60  const int kmax, 61  int* is_p ) 62  : SequenceData( 0, 63  shandle, 64  shandle + calc_num_entities( shandle, imax - imin, jmax - jmin, kmax - kmin, is_p ) - 1 ) 65 { 66  // need to have meaningful parameters 67  assert( imax >= imin && jmax >= jmin && kmax >= kmin ); 68  69  isPeriodic[0] = ( is_p ? is_p[0] : 0 ); 70  isPeriodic[1] = ( is_p ? is_p[1] : 0 ); 71  72  boxParams[0] = HomCoord( imin, jmin, kmin ); 73  boxParams[1] = HomCoord( imax, jmax, kmax ); 74  boxParams[2] = HomCoord( 1, 1, 1 ); 75  76  // assign and compute parameter stuff 77  dIJK[0] = boxParams[1][0] - boxParams[0][0] + 1; 78  dIJK[1] = boxParams[1][1] - boxParams[0][1] + 1; 79  dIJK[2] = boxParams[1][2] - boxParams[0][2] + 1; 80  dIJKm1[0] = dIJK[0] - ( isPeriodic[0] ? 0 : 1 ); 81  dIJKm1[1] = dIJK[1] - ( isPeriodic[1] ? 0 : 1 ); 82  dIJKm1[2] = dIJK[2] - 1; 83 } 84  85 ScdElementData::~ScdElementData() {} 86  87 bool ScdElementData::boundary_complete() const 88 { 89  // test the bounding vertex sequences to see if they fully define the 90  // vertex parameter space for this rectangular block of elements 91  92  int p; 93  std::vector< VertexDataRef > minlist, maxlist; 94  95  // pseudo code: 96  // for each vertex sequence v: 97  for( std::vector< VertexDataRef >::const_iterator vseq = vertexSeqRefs.begin(); vseq != vertexSeqRefs.end(); 98  ++vseq ) 99  { 100  // test min corner mincorner: 101  bool mincorner = true; 102  // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1): 103  for( p = 0; p < 3; p++ ) 104  { 105  106  // for each vsequence v' != v: 107  for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin(); 108  othervseq != vertexSeqRefs.end(); ++othervseq ) 109  { 110  if( othervseq == vseq ) continue; 111  // if v.min-p contained in v' 112  if( ( *othervseq ).contains( ( *vseq ).minmax[0] - HomCoord::unitv[p] ) ) 113  { 114  // mincorner = false 115  mincorner = false; 116  break; 117  } 118  } 119  if( !mincorner ) break; 120  } 121  122  bool maxcorner = true; 123  // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1): 124  for( p = 0; p < 3; p++ ) 125  { 126  127  // for each vsequence v' != v: 128  for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin(); 129  othervseq != vertexSeqRefs.end(); ++othervseq ) 130  { 131  if( othervseq == vseq ) continue; 132  // if v.max+p contained in v' 133  if( ( *othervseq ).contains( ( *vseq ).minmax[1] + HomCoord::unitv[p] ) ) 134  { 135  // maxcorner = false 136  maxcorner = false; 137  break; 138  } 139  } 140  if( !maxcorner ) break; 141  } 142  143  // if mincorner add to min corner list minlist 144  if( mincorner ) minlist.push_back( *vseq ); 145  // if maxcorner add to max corner list maxlist 146  if( maxcorner ) maxlist.push_back( *vseq ); 147  } 148  149  // 150  // if minlist.size = 1 & maxlist.size = 1 & minlist[0] = esequence.min & 151  // maxlist[0] = esequence.max+(1,1,1) 152  if( minlist.size() == 1 && maxlist.size() == 1 && minlist[0].minmax[0] == boxParams[0] && 153  maxlist[0].minmax[1] == boxParams[1] ) 154  // complete 155  return true; 156  // else 157  158  return false; 159 } 160  161 SequenceData* ScdElementData::subset( EntityHandle /*start*/, 162  EntityHandle /*end*/, 163  const int* /*sequence_data_sizes*/, 164  const int* /*tag_data_sizes*/ ) const 165 { 166  return 0; 167 } 168  169 unsigned long ScdElementData::get_memory_use() const 170 { 171  return sizeof( *this ) + vertexSeqRefs.capacity() * sizeof( VertexDataRef ); 172 } 173  174 } // namespace moab