Sierra Toolkit Version of the Day
Part.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 #ifndef stk_mesh_Part_hpp
00010 #define stk_mesh_Part_hpp
00011 
00012 //----------------------------------------------------------------------
00013 
00014 #include <iosfwd>
00015 #include <string>
00016 #include <vector>
00017 
00018 #include <stk_util/util/CSet.hpp>
00019 #include <stk_mesh/base/Types.hpp>
00020 #include <stk_mesh/base/PartRelation.hpp>
00021 #include <stk_mesh/baseImpl/PartImpl.hpp>
00022 
00023 //----------------------------------------------------------------------
00024 
00025 namespace stk {
00026 namespace mesh {
00027 
00028 namespace impl {
00029   class PartRepository;
00030 } // namespace impl
00031 
00037 //----------------------------------------------------------------------
00049 class Part {
00050 public:
00051 
00055   MetaData & mesh_meta_data() const { return m_partImpl.mesh_meta_data(); }
00056 
00064   unsigned primary_entity_rank() const { return m_partImpl.primary_entity_rank(); }
00065 
00067   const std::string & name() const { return m_partImpl.name(); }
00068 
00072   unsigned mesh_meta_data_ordinal() const { return m_partImpl.mesh_meta_data_ordinal(); }
00073 
00075   const PartVector & supersets() const { return m_partImpl.supersets(); }
00076 
00078   const PartVector & subsets() const { return m_partImpl.subsets(); }
00079 
00081   const PartVector & intersection_of() const { return m_partImpl.intersection_of(); }
00082 
00084   const std::vector<PartRelation> & relations() const { return m_partImpl.relations(); }
00085 
00087   bool operator == ( const Part & rhs ) const { return this == & rhs ; }
00088 
00090   bool operator != ( const Part & rhs ) const { return this != & rhs ; }
00091 
00093   template<class A>
00094   const A * attribute() const { return m_partImpl.attribute<A>(); }
00095 
00096 private:
00097 
00101   MetaData & meta_data() const { return m_partImpl.mesh_meta_data(); }
00102 
00103 
00104   impl::PartImpl m_partImpl;
00105 
00106   /* \brief  A part is owned by a PartRepository, as such only the owning
00107    *         PartRepository can create, delete, or modify a part.
00108    *         The owner-modifies rule is enforced by the implementation being
00109    *         a private data object on the Part and the PartRepository is a
00110    *         friend.
00111    */
00112   friend class ::stk::mesh::impl::PartRepository ;
00113   friend class ::stk::mesh::MetaData ;
00114 
00115 #ifndef DOXYGEN_COMPILE
00116 
00120   Part( MetaData * arg_meta_data , const std::string & arg_name, EntityRank arg_rank, size_t arg_ordinal)
00121     : m_partImpl(arg_meta_data,arg_name,arg_rank,arg_ordinal)
00122   { }
00123 
00124   ~Part() {}
00125   Part();
00126   Part( const Part & );
00127   Part & operator = ( const Part & );
00128 
00129 #endif /* DOXYGEN_COMPILE */
00130 
00131 };
00132 
00133 //----------------------------------------------------------------------
00135 struct PartLess {
00136 
00137   inline bool operator()( const Part & lhs , const Part & rhs ) const
00138     { return lhs.mesh_meta_data_ordinal() < rhs.mesh_meta_data_ordinal(); }
00139 
00140   inline bool operator()( const Part & lhs , const Part * rhs ) const
00141     { return lhs.mesh_meta_data_ordinal() < rhs->mesh_meta_data_ordinal(); }
00142 
00143   inline bool operator()( const Part * lhs , const Part & rhs ) const
00144     { return lhs->mesh_meta_data_ordinal() < rhs.mesh_meta_data_ordinal(); }
00145 
00146   inline bool operator()( const Part * lhs , const Part * rhs ) const
00147     { return lhs->mesh_meta_data_ordinal() < rhs->mesh_meta_data_ordinal(); }
00148 };
00149 
00151 void order( PartVector & );
00152 
00156 bool insert( PartVector & , Part & );
00157 
00159 void remove( PartVector & , Part & );
00160 
00162 Part * find( const PartVector & , const std::string & );
00163 
00165 bool contain( const PartVector & , const Part & );
00166 
00168 bool contain( const PartVector & , const PartVector & );
00169 
00171 size_t intersect( const PartVector & , const PartVector & );
00172 
00174 size_t intersect( const PartVector & , const PartVector & , PartVector & );
00175 
00179 bool intersect( const Part & , const Part & );
00180 
00181 //----------------------------------------------------------------------
00185 std::ostream & print( std::ostream & , const char * const , const Part & );
00186 
00187 
00191 } // namespace mesh
00192 } // namespace stk
00193 
00194 //----------------------------------------------------------------------
00195 //----------------------------------------------------------------------
00196 
00197 #endif
00198 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends