MOAB: Mesh Oriented datABase  (version 5.2.1)
SweptElementData.cpp
Go to the documentation of this file.
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 <assert.h>
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     switch( CN::Dimension( TYPE_FROM_HANDLE( start_handle ) ) )
00031     {
00032         default:
00033             result = 0;
00034             assert( false );
00035             break;
00036         case 3:
00037             result *= krange;
00038         case 2:
00039             result *= jrange;
00040         case 1:
00041             result *= irange;
00042     }
00043     return result;
00044 }
00045 
00046 SweptElementData::SweptElementData( EntityHandle shandle, const int imin, const int jmin, const int kmin,
00047                                     const int imax, const int jmax, const int kmax, const int* /*Cq*/ )
00048     : SequenceData( 0, shandle, shandle + calc_num_entities( shandle, imax - imin, jmax - jmin, kmax - kmin ) - 1 )
00049 {
00050     // need to have meaningful parameters
00051     assert( imax >= imin && jmax >= jmin && kmax >= kmin );
00052 
00053     elementParams[0] = HomCoord( imin, jmin, kmin );
00054     elementParams[1] = HomCoord( imax, jmax, kmax );
00055     elementParams[2] = HomCoord( 1, 1, 1 );
00056 
00057     // assign and compute parameter stuff
00058     dIJK[0]   = elementParams[1][0] - elementParams[0][0] + 1;
00059     dIJK[1]   = elementParams[1][1] - elementParams[0][1] + 1;
00060     dIJK[2]   = elementParams[1][2] - elementParams[0][2] + 1;
00061     dIJKm1[0] = dIJK[0] - 1;
00062     dIJKm1[1] = dIJK[1] - 1;
00063     dIJKm1[2] = dIJK[2] - 1;
00064 }
00065 
00066 SweptElementData::~SweptElementData() {}
00067 
00068 bool SweptElementData::boundary_complete() const
00069 {
00070     // test the bounding vertex sequences to see if they fully define the
00071     // vertex parameter space for this rectangular block of elements
00072 
00073     int p;
00074     std::vector< VertexDataRef > minlist, maxlist;
00075 
00076     // pseudo code:
00077     // for each vertex sequence v:
00078     for( std::vector< VertexDataRef >::const_iterator vseq = vertexSeqRefs.begin(); vseq != vertexSeqRefs.end();
00079          ++vseq )
00080     {
00081         //   test min corner mincorner:
00082         bool mincorner = true;
00083         //   for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1):
00084         for( p = 0; p < 3; p++ )
00085         {
00086 
00087             //     for each vsequence v' != v:
00088             for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin();
00089                  othervseq != vertexSeqRefs.end(); ++othervseq )
00090             {
00091                 if( othervseq == vseq ) continue;
00092                 //       if v.min-p contained in v'
00093                 if( ( *othervseq ).contains( ( *vseq ).minmax[0] - HomCoord::unitv[p] ) )
00094                 {
00095                     //         mincorner = false
00096                     mincorner = false;
00097                     break;
00098                 }
00099             }
00100             if( !mincorner ) break;
00101         }
00102 
00103         bool maxcorner = true;
00104         //   for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1):
00105         for( p = 0; p < 3; p++ )
00106         {
00107 
00108             //     for each vsequence v' != v:
00109             for( std::vector< VertexDataRef >::const_iterator othervseq = vertexSeqRefs.begin();
00110                  othervseq != vertexSeqRefs.end(); ++othervseq )
00111             {
00112                 if( othervseq == vseq ) continue;
00113                 //       if v.max+p contained in v'
00114                 if( ( *othervseq ).contains( ( *vseq ).minmax[1] + HomCoord::unitv[p] ) )
00115                 {
00116                     //         maxcorner = false
00117                     maxcorner = false;
00118                     break;
00119                 }
00120             }
00121             if( !maxcorner ) break;
00122         }
00123 
00124         //   if mincorner add to min corner list minlist
00125         if( mincorner ) minlist.push_back( *vseq );
00126         //   if maxcorner add to max corner list maxlist
00127         if( maxcorner ) maxlist.push_back( *vseq );
00128     }
00129 
00130     //
00131     // if minlist.size = 1 & maxlist.size = 1 & minlist[0] = esequence.min &
00132     //         maxlist[0] = esequence.max+(1,1,1)
00133     if( minlist.size() == 1 && maxlist.size() == 1 && minlist[0].minmax[0] == elementParams[0] &&
00134         maxlist[0].minmax[1] == elementParams[1] )
00135         //   complete
00136         return true;
00137     // else
00138 
00139     return false;
00140 }
00141 
00142 SequenceData* SweptElementData::subset( EntityHandle /*start*/, EntityHandle /*end*/,
00143                                         const int* /*sequence_data_sizes*/, const int* /*tag_data_sizes*/ ) const
00144 {
00145     return 0;
00146 }
00147 
00148 unsigned long SweptElementData::get_memory_use() const
00149 {
00150     return sizeof( *this ) + vertexSeqRefs.capacity() * sizeof( VertexDataRef );
00151 }
00152 
00153 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines