Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
StructuredElementSeq.hpp
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 #ifndef STRUCTURED_ELEMENT_SEQUENCE
00017 #define STRUCTURED_ELEMENT_SEQUENCE
00018 
00019 //
00020 // Class: StructuredElementSeq
00021 //
00022 // Purpose: represent a rectangular element of mesh
00023 //
00024 // A ScdElement represents a rectangular element of mesh, including both vertices and
00025 // elements, and the parametric space used to address that element.  Vertex data,
00026 // i.e. coordinates, may not be stored directly in the element, but the element returns
00027 // information about the vertex handles of vertices in the element.  Vertex and element
00028 // handles associated with the element are each contiguous.
00029 
00030 #include "ElementSequence.hpp"
00031 #include "ScdElementData.hpp"
00032 
00033 namespace moab
00034 {
00035 
00036 class StructuredElementSeq : public ElementSequence
00037 {
00038   public:
00039     //! constructor
00040     StructuredElementSeq( EntityHandle start_handle,
00041                           const int imin,
00042                           const int jmin,
00043                           const int kmin,
00044                           const int imax,
00045                           const int jmax,
00046                           const int kmax,
00047                           int* is_periodic = NULL );
00048 
00049     virtual ~StructuredElementSeq();
00050 
00051     ScdElementData* sdata()
00052     {
00053         return reinterpret_cast< ScdElementData* >( data() );
00054     }
00055     ScdElementData const* sdata() const
00056     {
00057         return reinterpret_cast< const ScdElementData* >( data() );
00058     }
00059 
00060     //! get handle of vertex at i, j, k
00061     EntityHandle get_vertex( const int i, const int j, const int k ) const
00062     {
00063         return get_vertex( HomCoord( i, j, k ) );
00064     }
00065 
00066     //! get handle of vertex at homogeneous coords
00067     inline EntityHandle get_vertex( const HomCoord& coords ) const
00068     {
00069         return sdata()->get_vertex( coords );
00070     }
00071 
00072     //! get handle of element at i, j, k
00073     EntityHandle get_element( const int i, const int j, const int k ) const
00074     {
00075         return sdata()->get_element( i, j, k );
00076     }
00077 
00078     //! get handle of element at homogeneous coords
00079     EntityHandle get_element( const HomCoord& coords ) const
00080     {
00081         return sdata()->get_element( coords.i(), coords.j(), coords.k() );
00082     }
00083 
00084     //! get min params for this element
00085     const HomCoord& min_params() const
00086     {
00087         return sdata()->min_params();
00088     }
00089     void min_params( HomCoord& coords ) const
00090     {
00091         coords = min_params();
00092     }
00093     void min_params( int& i, int& j, int& k ) const
00094     {
00095         i = min_params().i();
00096         j = min_params().j();
00097         k = min_params().k();
00098     }
00099 
00100     //! get max params for this element
00101     const HomCoord& max_params() const
00102     {
00103         return sdata()->max_params();
00104     }
00105     void max_params( HomCoord& coords ) const
00106     {
00107         coords = max_params();
00108     }
00109     void max_params( int& i, int& j, int& k ) const
00110     {
00111         i = max_params().i();
00112         j = max_params().j();
00113         k = max_params().k();
00114     }
00115 
00116     //! get the number of vertices in each direction, inclusive
00117     void param_extents( int& di, int& dj, int& dk ) const
00118     {
00119         sdata()->param_extents( di, dj, dk );
00120     }
00121 
00122     //! given a handle, get the corresponding parameters
00123     ErrorCode get_params( const EntityHandle ehandle, int& i, int& j, int& k ) const
00124     {
00125         return sdata()->get_params( ehandle, i, j, k );
00126     }
00127 
00128     //! convenience functions for parameter extents
00129     int i_min() const
00130     {
00131         return min_params().i();
00132     }
00133     int j_min() const
00134     {
00135         return min_params().j();
00136     }
00137     int k_min() const
00138     {
00139         return min_params().k();
00140     }
00141     int i_max() const
00142     {
00143         return max_params().i();
00144     }
00145     int j_max() const
00146     {
00147         return max_params().j();
00148     }
00149     int k_max() const
00150     {
00151         return max_params().k();
00152     }
00153 
00154     //! test the bounding vertex sequences and determine whether they fully
00155     //! define the vertices covering this element block's parameter space
00156     inline bool boundary_complete() const
00157     {
00158         return sdata()->boundary_complete();
00159     }
00160 
00161     //! test whether this sequence contains these parameters
00162     bool contains( const int i, const int j, const int k ) const
00163     {
00164         return sdata()->contains( HomCoord( i, j, k ) );
00165     }
00166     inline bool contains( const HomCoord& coords ) const
00167     {
00168         return sdata()->contains( coords );
00169     }
00170 
00171     //! get connectivity of an entity given entity's parameters
00172     ErrorCode get_params_connectivity( const int i,
00173                                        const int j,
00174                                        const int k,
00175                                        std::vector< EntityHandle >& connectivity ) const
00176     {
00177         return sdata()->get_params_connectivity( i, j, k, connectivity );
00178     }
00179 
00180     //! Return whether box is periodic in i
00181     /** Return whether box is periodic in i
00182      * \return True if box is periodic in i direction
00183      */
00184     int is_periodic_i() const
00185     {
00186         return sdata()->is_periodic_i();
00187     };
00188 
00189     //! Return whether box is periodic in j
00190     /** Return whether box is periodic in j
00191      * \return True if box is periodic in j direction
00192      */
00193     int is_periodic_j() const
00194     {
00195         return sdata()->is_periodic_j();
00196     };
00197 
00198     //! Return whether box is periodic in i and j
00199     /** Return whether box is periodic in i and j
00200      * \param is_periodic_ij Non-zero if periodic in i [0] or j [1]
00201      */
00202     void is_periodic( int is_periodic_ij[2] ) const
00203     {
00204         sdata()->is_periodic( is_periodic_ij );
00205     };
00206 
00207     /***************** Methods from ElementSequence *****************/
00208 
00209     virtual ErrorCode get_connectivity( EntityHandle handle,
00210                                         std::vector< EntityHandle >& connect,
00211                                         bool topological = false ) const;
00212 
00213     virtual ErrorCode get_connectivity( EntityHandle handle,
00214                                         EntityHandle const*& connect,
00215                                         int& connect_length,
00216                                         bool topological                     = false,
00217                                         std::vector< EntityHandle >* storage = 0 ) const;
00218 
00219     virtual ErrorCode set_connectivity( EntityHandle handle, EntityHandle const* connect, int connect_length );
00220 
00221     virtual EntityHandle* get_connectivity_array();
00222 
00223     /***************** Methods from EntitySequence *****************/
00224 
00225     /* Replace the ElementSequence implementation of this method with
00226      * one that always returns zero, because we cannot re-use handles
00227      * that are within a ScdElementData
00228      */
00229     virtual int values_per_entity() const;
00230 
00231     virtual EntitySequence* split( EntityHandle here );
00232 
00233     virtual SequenceData* create_data_subset( EntityHandle start_handle, EntityHandle end_handle ) const;
00234 
00235     virtual void get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const;
00236 
00237   protected:
00238     StructuredElementSeq( StructuredElementSeq& split_from, EntityHandle here ) : ElementSequence( split_from, here ) {}
00239 };
00240 
00241 }  // namespace moab
00242 
00243 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines