Sierra Toolkit Version of the Day
FieldRestriction.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 
00010 #ifndef stk_mesh_baseImpl_FieldRestriction_hpp
00011 #define stk_mesh_baseImpl_FieldRestriction_hpp
00012 
00013 #include <vector>
00014 #include <Shards_Array.hpp>
00015 #include <stk_mesh/base/Types.hpp>
00016 #include <stk_mesh/base/EntityKey.hpp>
00017 
00018 #include <stk_util/util/SimpleArrayOps.hpp>
00019 
00020 namespace stk {
00021 namespace mesh {
00022 
00030 class FieldRestriction {
00031   public:
00032 
00033   typedef shards::array_traits::int_t size_type ;
00034 
00035   FieldRestriction()
00036     : m_entityrank_partordinal(InvalidEntityRank,InvalidPartOrdinal)
00037   {
00038     Copy<MaximumFieldDimension>( m_stride , size_type(0) );
00039   }
00040 
00041   FieldRestriction( const FieldRestriction & rhs )
00042     : m_entityrank_partordinal( rhs.m_entityrank_partordinal )
00043   {
00044     Copy< MaximumFieldDimension >( m_stride , rhs.m_stride );
00045   }
00046 
00047   FieldRestriction & operator = ( const FieldRestriction & rhs )
00048   {
00049     m_entityrank_partordinal = rhs.m_entityrank_partordinal ;
00050     Copy< MaximumFieldDimension >( m_stride , rhs.m_stride );
00051     return *this ;
00052   }
00053 
00054   FieldRestriction( EntityRank input_rank , PartOrdinal input_ordinal)
00055     : m_entityrank_partordinal( input_rank, input_ordinal )
00056   {
00057     Copy< MaximumFieldDimension >( m_stride , size_type(0) );
00058   }
00059 
00060   EntityRank entity_rank() const
00061   {
00062     return m_entityrank_partordinal.first;
00063   }
00064   PartOrdinal part_ordinal() const
00065   {
00066     return m_entityrank_partordinal.second;
00067   }
00068 
00069   size_type & stride( Ordinal index ) { return m_stride[index]; }
00070   const size_type & stride( Ordinal index ) const { return m_stride[index]; }
00071 
00072   size_type dimension() const { return m_stride[0]; }
00073 
00074   bool operator < ( const FieldRestriction & rhs ) const
00075   {
00076     return this->m_entityrank_partordinal < rhs.m_entityrank_partordinal;
00077   }
00078   bool operator == ( const FieldRestriction & rhs ) const
00079   {
00080     return this->m_entityrank_partordinal == rhs.m_entityrank_partordinal;
00081   }
00082   bool operator != ( const FieldRestriction & rhs ) const
00083   {
00084     return this->m_entityrank_partordinal != rhs.m_entityrank_partordinal;
00085   }
00086 
00087   bool not_equal_stride( const FieldRestriction & rhs ) const
00088   {
00089     return Compare< MaximumFieldDimension >::not_equal( this->m_stride , rhs.m_stride );
00090   }
00091 
00092   void print(
00093       std::ostream & os,
00094       const EntityRank & entity_rank,
00095       const Part & part,
00096       FieldArrayRank field_rank
00097       ) const;
00098 
00099   private:
00100   std::pair<EntityRank,PartOrdinal> m_entityrank_partordinal;
00101   size_type m_stride[ MaximumFieldDimension ];
00102 };
00103 
00104 typedef std::vector<FieldRestriction> FieldRestrictionVector;
00105 
00106 std::string print_restriction(
00107     const FieldRestriction & restr,
00108     const EntityRank & entity_rank,
00109     const Part & part,
00110     FieldArrayRank field_rank
00111     );
00112 
00113 } // namespace mesh
00114 } // namespace stk
00115 
00116 #endif // stk_mesh_baseImpl_FieldRestriction_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends