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
SweptElementData.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 "SweptElementData.hpp" 17 #include "SweptVertexData.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 SweptElementData::calc_num_entities( EntityHandle start_handle, int irange, int jrange, int krange ) 28 { 29  size_t result = 1; 30  auto dim = CN::Dimension( TYPE_FROM_HANDLE( start_handle ) ); 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 } 49  50 SweptElementData::SweptElementData( EntityHandle shandle, 51  const int imin, 52  const int jmin, 53  const int kmin, 54  const int imax, 55  const int jmax, 56  const int kmax, 57  const int* /*Cq*/ ) 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 } 75  76 SweptElementData::~SweptElementData() {} 77  78 bool SweptElementData::boundary_complete() const 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 } 151  152 SequenceData* SweptElementData::subset( EntityHandle /*start*/, 153  EntityHandle /*end*/, 154  const int* /*sequence_data_sizes*/, 155  const int* /*tag_data_sizes*/ ) const 156 { 157  return 0; 158 } 159  160 unsigned long SweptElementData::get_memory_use() const 161 { 162  return sizeof( *this ) + vertexSeqRefs.capacity() * sizeof( VertexDataRef ); 163 } 164  165 } // namespace moab