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