|
Sierra Toolkit Version of the Day
|
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 00098 impl::PartImpl m_partImpl; 00099 00100 /* \brief A part is owned by a PartRepository, as such only the owning 00101 * PartRepository can create, delete, or modify a part. 00102 * The owner-modifies rule is enforced by the implementation being 00103 * a private data object on the Part and the PartRepository is a 00104 * friend. 00105 */ 00106 friend class ::stk::mesh::impl::PartRepository ; 00107 00108 #ifndef DOXYGEN_COMPILE 00109 00113 Part( MetaData * arg_meta_data , const std::string & arg_name, EntityRank arg_rank, size_t arg_ordinal) 00114 : m_partImpl(arg_meta_data,arg_name,arg_rank,arg_ordinal) 00115 { } 00116 00117 ~Part() {} 00118 Part(); 00119 Part( const Part & ); 00120 Part & operator = ( const Part & ); 00121 00122 #endif /* DOXYGEN_COMPILE */ 00123 00124 }; 00125 00126 //---------------------------------------------------------------------- 00128 struct PartLess { 00129 00130 inline bool operator()( const Part & lhs , const Part & rhs ) const 00131 { return lhs.mesh_meta_data_ordinal() < rhs.mesh_meta_data_ordinal(); } 00132 00133 inline bool operator()( const Part & lhs , const Part * rhs ) const 00134 { return lhs.mesh_meta_data_ordinal() < rhs->mesh_meta_data_ordinal(); } 00135 00136 inline bool operator()( const Part * lhs , const Part & rhs ) const 00137 { return lhs->mesh_meta_data_ordinal() < rhs.mesh_meta_data_ordinal(); } 00138 00139 inline bool operator()( const Part * lhs , const Part * rhs ) const 00140 { return lhs->mesh_meta_data_ordinal() < rhs->mesh_meta_data_ordinal(); } 00141 }; 00142 00144 void order( PartVector & ); 00145 00149 bool insert( PartVector & , Part & ); 00150 00152 void remove( PartVector & , Part & ); 00153 00155 Part * find( const PartVector & , const std::string & ); 00156 00158 bool contain( const PartVector & , const Part & ); 00159 00161 bool contain( const PartVector & , const PartVector & ); 00162 00164 size_t intersect( const PartVector & , const PartVector & ); 00165 00167 size_t intersect( const PartVector & , const PartVector & , PartVector & ); 00168 00172 bool intersect( const Part & , const Part & ); 00173 00174 //---------------------------------------------------------------------- 00178 std::ostream & print( std::ostream & , const char * const , const Part & ); 00179 00180 00184 } // namespace mesh 00185 } // namespace stk 00186 00187 //---------------------------------------------------------------------- 00188 //---------------------------------------------------------------------- 00189 00190 #endif 00191