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