Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 #include "SweptElementData.hpp" 00017 #include "SweptVertexData.hpp" 00018 #include "moab/Interface.hpp" 00019 #include "moab/ReadUtilIface.hpp" 00020 #include "moab/CN.hpp" 00021 #include "Internals.hpp" 00022 #include <cassert> 00023 00024 namespace moab 00025 { 00026 00027 EntityID SweptElementData::calc_num_entities( EntityHandle start_handle, int irange, int jrange, int krange ) 00028 { 00029 size_t result = 1; 00030 auto dim = CN::Dimension( TYPE_FROM_HANDLE( start_handle ) ); 00031 switch( dim ) 00032 { 00033 case 3: 00034 result *= krange; 00035 // fall through 00036 case 2: 00037 result *= jrange; 00038 // fall through 00039 case 1: 00040 result *= irange; 00041 break; 00042 default: 00043 result = 0; 00044 assert( false ); 00045 break; 00046 } 00047 return result; 00048 } 00049 00050 SweptElementData::SweptElementData( EntityHandle shandle, 00051 const int imin, 00052 const int jmin, 00053 const int kmin, 00054 const int imax, 00055 const int jmax, 00056 const int kmax, 00057 const int* /*Cq*/ ) 00058 : SequenceData( 0, shandle, shandle + calc_num_entities( shandle, imax - imin, jmax - jmin, kmax - kmin ) - 1 ) 00059 { 00060 // need to have meaningful parameters 00061 assert( imax >= imin && jmax >= jmin && kmax >= kmin ); 00062 00063 elementParams[0] = HomCoord( imin, jmin, kmin ); 00064 elementParams[1] = HomCoord( imax, jmax, kmax ); 00065 elementParams[2] = HomCoord( 1, 1, 1 ); 00066 00067 // assign and compute parameter stuff 00068 dIJK[0] = elementParams[1][0] - elementParams[0][0] + 1; 00069 dIJK[1] = elementParams[1][1] - elementParams[0][1] + 1; 00070 dIJK[2] = elementParams[1][2] - elementParams[0][2] + 1; 00071 dIJKm1[0] = dIJK[0] - 1; 00072 dIJKm1[1] = dIJK[1] - 1; 00073 dIJKm1[2] = dIJK[2] - 1; 00074 } 00075 00076 SweptElementData::~SweptElementData() {} 00077 00078 bool SweptElementData::boundary_complete() const 00079 { 00080 // test the bounding vertex sequences to see if they fully define the 00081 // vertex parameter space for this rectangular block of elements 00082 00083 int p; 00084 std::vector< VertexDataRef > minlist, maxlist; 00085 00086 // pseudo code: 00087 // for each vertex sequence v: 00088 for( std::vector< VertexDataRef >::const_iterator vseq = vertexSeqRefs.begin(); vseq != vertexSeqRefs.end(); 00089 ++vseq ) 00090 { 00091 // test min corner mincorner: 00092 bool mincorner = true; 00093 // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1): 00094 for( p = 0; p < 3; p++ ) 00095 { 00096 00097 // for each vsequence v' != v: 00098 for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin(); 00099 othervseq != vertexSeqRefs.end(); ++othervseq ) 00100 { 00101 if( othervseq == vseq ) continue; 00102 // if v.min-p contained in v' 00103 if( ( *othervseq ).contains( ( *vseq ).minmax[0] - HomCoord::unitv[p] ) ) 00104 { 00105 // mincorner = false 00106 mincorner = false; 00107 break; 00108 } 00109 } 00110 if( !mincorner ) break; 00111 } 00112 00113 bool maxcorner = true; 00114 // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1): 00115 for( p = 0; p < 3; p++ ) 00116 { 00117 00118 // for each vsequence v' != v: 00119 for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin(); 00120 othervseq != vertexSeqRefs.end(); ++othervseq ) 00121 { 00122 if( othervseq == vseq ) continue; 00123 // if v.max+p contained in v' 00124 if( ( *othervseq ).contains( ( *vseq ).minmax[1] + HomCoord::unitv[p] ) ) 00125 { 00126 // maxcorner = false 00127 maxcorner = false; 00128 break; 00129 } 00130 } 00131 if( !maxcorner ) break; 00132 } 00133 00134 // if mincorner add to min corner list minlist 00135 if( mincorner ) minlist.push_back( *vseq ); 00136 // if maxcorner add to max corner list maxlist 00137 if( maxcorner ) maxlist.push_back( *vseq ); 00138 } 00139 00140 // 00141 // if minlist.size = 1 & maxlist.size = 1 & minlist[0] = esequence.min & 00142 // maxlist[0] = esequence.max+(1,1,1) 00143 if( minlist.size() == 1 && maxlist.size() == 1 && minlist[0].minmax[0] == elementParams[0] && 00144 maxlist[0].minmax[1] == elementParams[1] ) 00145 // complete 00146 return true; 00147 // else 00148 00149 return false; 00150 } 00151 00152 SequenceData* SweptElementData::subset( EntityHandle /*start*/, 00153 EntityHandle /*end*/, 00154 const int* /*sequence_data_sizes*/, 00155 const int* /*tag_data_sizes*/ ) const 00156 { 00157 return 0; 00158 } 00159 00160 unsigned long SweptElementData::get_memory_use() const 00161 { 00162 return sizeof( *this ) + vertexSeqRefs.capacity() * sizeof( VertexDataRef ); 00163 } 00164 00165 } // namespace moab