Sierra Toolkit Version of the Day
MetaData.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010, 2011 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_MetaData_hpp
00010 #define stk_mesh_MetaData_hpp
00011 
00012 //----------------------------------------------------------------------
00013 
00014 #include <iosfwd>
00015 
00016 #include <stk_util/util/SameType.hpp>
00017 #include <stk_util/util/StaticAssert.hpp>
00018 #include <stk_util/parallel/Parallel.hpp>
00019 
00020 #include <stk_mesh/base/Types.hpp>
00021 #include <stk_mesh/base/Part.hpp>
00022 #include <stk_mesh/base/Field.hpp>
00023 #include <stk_mesh/base/PropertyBase.hpp>
00024 #include <stk_mesh/base/EntityKey.hpp>
00025 #include <stk_mesh/base/Selector.hpp>
00026 
00027 #include <stk_mesh/baseImpl/PartRepository.hpp>
00028 #include <stk_mesh/baseImpl/FieldBaseImpl.hpp>
00029 #include <stk_mesh/baseImpl/FieldRepository.hpp>
00030 
00031 namespace stk {
00032 namespace mesh {
00033 
00034 namespace fem {
00035 class FEMMetaData;
00036 }
00037 
00043 std::ostream &
00044 print_entity_key( std::ostream & os, const MetaData & meta_data, const EntityKey & key);
00045 
00046 std::string
00047 print_entity_key( const MetaData & meta_data, const EntityKey & key );
00048 
00049 //----------------------------------------------------------------------
00056 class MetaData {
00057 public:
00058 
00060   //------------------------------------
00065   inline static MetaData & get( const Part & part ) { return part.meta_data(); }
00066   inline static MetaData & get( const FieldBase & field ) { return field.meta_data(); }
00067   inline static MetaData & get( const PropertyBase & property ) { return property.meta_data(); }
00068 
00069   static MetaData & get( const BulkData & bulk_data );
00070   static MetaData & get( const Bucket & bucket );
00071   static MetaData & get( const Entity & entity );
00072   static MetaData & get( const Ghosting & ghost );
00073 
00075   explicit MetaData( const std::vector<std::string>& entity_rank_names );
00076 
00078   MetaData();
00079 
00080   //------------------------------------
00088   Part & universal_part() const { return *m_universal_part; }
00089 
00093   Part & locally_owned_part()  const { return *m_owns_part ; }
00094 
00098   Part & globally_shared_part() const { return *m_shares_part ; }
00099 
00101   //------------------------------------
00112 
00113   Part * get_part( const std::string & p_name,
00114                    const char * required_by = NULL ) const ;
00115 
00117   Part & get_part( unsigned ord ) const ;
00118 
00120   const PartVector & get_parts() const { return m_part_repo.get_all_parts(); }
00121 
00129   Part & declare_part( const std::string & p_name, EntityRank rank );
00130 
00136   Part & declare_part( const std::string & p_name);
00137 
00145   Part & declare_part( const PartVector & p_name);
00146 
00148   void declare_part_subset( Part & superset , Part & subset );
00149 
00159   void declare_part_relation( Part & root_part ,
00160                               relation_stencil_ptr stencil ,
00161                               Part & target_part );
00162 
00169   template<class T>
00170   const T * declare_attribute_with_delete( Part & part, const T * attribute);
00171   template<class T>
00172   const T * declare_attribute_no_delete( Part & part, const T * attribute);
00173   template<class T>
00174   bool remove_attribute( Part & part, const T * attribute);
00175 
00177   //------------------------------------
00184   void set_entity_rank_names(const std::vector<std::string> &entity_rank_names);
00185 
00186   EntityRank entity_rank( const std::string &name ) const;
00187 
00188   const std::vector<std::string> & entity_rank_names() const
00189     { return m_entity_rank_names ; }
00190 
00191   std::vector<std::string>::size_type entity_rank_count() const
00192     { return m_entity_rank_names.size(); }
00193 
00194   const std::string & entity_rank_name( EntityRank entity_rank ) const ;
00195 
00199   bool check_rank(EntityRank rank) const;
00200 
00202   //------------------------------------
00214   template< class field_type >
00215   field_type * get_field( const std::string & name ) const ;
00216 
00218   const FieldVector & get_fields() const {
00219     return m_field_repo.get_fields() ;
00220   }
00221 
00231   template< class field_type >
00232   field_type & declare_field( const std::string & name ,
00233                               unsigned number_of_states = 1 );
00234 
00240   template<class T>
00241   const T * declare_attribute_with_delete( FieldBase & field, const T * attribute);
00242   template<class T>
00243   const T * declare_attribute_no_delete( FieldBase & field, const T * attribute);
00244 
00264   template< class PointerFieldType , class ReferencedFieldType >
00265   void declare_field_relation( PointerFieldType & pointer_field ,
00266                                relation_stencil_ptr stencil ,
00267                                ReferencedFieldType & referenced_field );
00268 
00270   const std::vector<FieldRelation> & get_field_relations() const
00271     { return m_field_relations ; }
00272 
00274   //------------------------------------
00275 
00276   template<class T>
00277   const T * get_attribute() const ;
00278 
00283   template<class T>
00284   const T * declare_attribute_with_delete( const T * attribute);
00285 
00286   template<class T>
00287   const T * declare_attribute_no_delete( const T * attribute);
00288 
00289   template<class T>
00290   bool remove_attribute( const T * );
00291 
00292   //------------------------------------
00304   template< typename DataType >
00305   Property<DataType> * get_property( const std::string & name ) const ;
00306 
00308   const std::vector< PropertyBase * > & get_properties() const
00309     { return m_properties ; }
00310 
00317   template< typename DataType >
00318   Property<DataType> & declare_property( const std::string & name ,
00319                                          unsigned size = 1 );
00320 
00322   void put_property( PropertyBase & property, Part & part);
00323 
00325   unsigned get_spatial_dimension() const { return m_spatial_dimension; }
00326 
00335   void commit();
00336 
00338   bool is_commit() const { return m_commit ; }
00339 
00343   ~MetaData();
00344 
00346   //------------------------------------
00347 
00354   FieldBase * declare_field_base(
00355     const std::string & arg_name,
00356     const DataTraits  & arg_traits ,
00357     unsigned            arg_rank ,
00358     const shards::ArrayDimTag * const * arg_dim_tags ,
00359     unsigned arg_num_states );
00360 
00363   void declare_field_restriction( FieldBase      & arg_field ,
00364                                   EntityRank       arg_entity_rank ,
00365                                   const Part     & arg_part ,
00366                                   const unsigned * arg_stride ,
00367                                   const void*      arg_init_value = NULL );
00368 
00371   void declare_field_restriction( FieldBase      & arg_field ,
00372                                   EntityRank       arg_entity_rank ,
00373                                   const Selector & arg_selector ,
00374                                   const unsigned * arg_stride ,
00375                                   const void*      arg_init_value = NULL );
00377 private:
00378   MetaData( const MetaData & );                
00379   MetaData & operator = ( const MetaData & );  
00380 
00381   Part & declare_internal_part( const std::string & p_name);
00382 
00383   Part & declare_internal_part( const std::string & p_name, EntityRank rank);
00384 
00385   bool   m_commit ;
00386   impl::PartRepository m_part_repo ;
00387   CSet   m_attributes ;
00388 
00389   Part * m_universal_part ;
00390   Part * m_owns_part ;
00391   Part * m_shares_part ;
00392 
00393 
00394   impl::FieldRepository        m_field_repo ;
00395 
00396   std::vector< FieldRelation > m_field_relations ;
00397   std::vector< PropertyBase* > m_properties ;
00398   std::vector< std::string >   m_entity_rank_names ;
00399 
00400   unsigned m_spatial_dimension;
00401   friend class fem::FEMMetaData;
00402 
00406   void require_committed() const ;
00407 
00408   void require_not_committed() const ;
00409 
00410   void require_same_mesh_meta_data( const MetaData & rhs ) const ;
00411 
00412   void require_valid_entity_rank( EntityRank rank) const ;
00413 
00414   void require_not_relation_target( const Part * const part ) const ;
00416   //------------------------------------
00417 
00418   Property<void> * get_property_base( const std::string & ,
00419                                       const std::type_info & ,
00420                                       unsigned = 0 ) const ;
00421 
00422   void internal_declare_field_relation( FieldBase & ,
00423                                         relation_stencil_ptr ,
00424                                         FieldBase & );
00425 
00426   void clean_field_restrictions();
00427 };
00428 
00430 void verify_parallel_consistency( const MetaData & , ParallelMachine );
00431 
00440 template< class field_type >
00441 field_type & put_field( field_type & field ,
00442                         EntityRank  entity_rank ,
00443                         const Part & part ,
00444                         const void* init_value = NULL);
00445 
00446 template< class field_type >
00447 field_type & put_field( field_type & field ,
00448                         EntityRank  entity_rank ,
00449                         const Selector & selector ,
00450                         const void* init_value = NULL);
00451 
00457 template< class field_type >
00458 field_type & put_field( field_type & field ,
00459                         EntityRank  entity_rank ,
00460                         const Part & part ,
00461                         unsigned     n1 ,
00462                         const void* init_value = NULL);
00463 
00464 template< class field_type >
00465 field_type & put_field( field_type & field ,
00466                         EntityRank  entity_rank ,
00467                         const Selector & selector ,
00468                         unsigned     n1 ,
00469                         const void* init_value = NULL);
00470 
00471 template< class field_type >
00472 field_type & put_field( field_type & field ,
00473                         EntityRank  entity_rank ,
00474                         const Part & part ,
00475                         unsigned     n1 ,
00476                         unsigned     n2 ,
00477                         const void* init_value = NULL);
00478 
00479 template< class field_type >
00480 field_type & put_field( field_type & field ,
00481                         EntityRank  entity_rank ,
00482                         const Selector & selector ,
00483                         unsigned     n1 ,
00484                         unsigned     n2 ,
00485                         const void* init_value = NULL);
00486 
00487 template< class field_type >
00488 field_type & put_field( field_type & field ,
00489                         EntityRank  entity_rank ,
00490                         const Part & part ,
00491                         unsigned     n1 ,
00492                         unsigned     n2 ,
00493                         unsigned     n3 ,
00494                         const void* init_value = NULL);
00495 
00496 template< class field_type >
00497 field_type & put_field( field_type & field ,
00498                         EntityRank  entity_rank ,
00499                         const Selector & selector ,
00500                         unsigned     n1 ,
00501                         unsigned     n2 ,
00502                         unsigned     n3 ,
00503                         const void* init_value = NULL);
00504 
00505 template< class field_type >
00506 field_type & put_field( field_type & field ,
00507                         EntityRank  entity_rank ,
00508                         const Part & part ,
00509                         unsigned     n1 ,
00510                         unsigned     n2 ,
00511                         unsigned     n3 ,
00512                         unsigned     n4 ,
00513                         const void* init_value = NULL);
00514 
00515 template< class field_type >
00516 field_type & put_field( field_type & field ,
00517                         EntityRank  entity_rank ,
00518                         const Part & part ,
00519                         unsigned     n1 ,
00520                         unsigned     n2 ,
00521                         unsigned     n3 ,
00522                         unsigned     n4 ,
00523                         unsigned     n5 ,
00524                         const void* init_value = NULL);
00525 
00526 template< class field_type >
00527 field_type & put_field( field_type & field ,
00528                         EntityRank  entity_rank ,
00529                         const Part & part ,
00530                         unsigned     n1 ,
00531                         unsigned     n2 ,
00532                         unsigned     n3 ,
00533                         unsigned     n4 ,
00534                         unsigned     n5 ,
00535                         unsigned     n6 ,
00536                         const void* init_value = NULL);
00537 
00538 template< class field_type >
00539 field_type & put_field( field_type & field ,
00540                         EntityRank  entity_rank ,
00541                         const Part & part ,
00542                         unsigned     n1 ,
00543                         unsigned     n2 ,
00544                         unsigned     n3 ,
00545                         unsigned     n4 ,
00546                         unsigned     n5 ,
00547                         unsigned     n6 ,
00548                         unsigned     n7 ,
00549                         const void* init_value = NULL);
00553 } // namespace mesh
00554 } // namespace stk
00555 
00556 //----------------------------------------------------------------------
00557 //----------------------------------------------------------------------
00558 
00559 #ifndef DOXYGEN_COMPILE
00560 
00561 namespace stk {
00562 namespace mesh {
00563 
00564 inline
00565 Part & MetaData::get_part( unsigned ord ) const
00566 { return * m_part_repo.get_all_parts()[ord] ; }
00567 
00568 template< class field_type >
00569 inline
00570 field_type * MetaData::get_field( const std::string & name ) const
00571 {
00572   typedef FieldTraits< field_type > Traits ;
00573 
00574   const DataTraits & dt = data_traits< typename Traits::data_type >();
00575 
00576   const shards::ArrayDimTag * tags[8] ;
00577 
00578   Traits::assign_tags( tags );
00579 
00580   FieldBase * const field =
00581     m_field_repo.get_field( "stk::mesh::MetaData::get_field" ,
00582                           name , dt , Traits::Rank , tags , 0 );
00583 
00584   return static_cast< field_type * >( field );
00585 }
00586 
00587 template< class field_type >
00588 inline
00589 field_type & MetaData::declare_field( const std::string & name ,
00590                                       unsigned number_of_states )
00591 {
00592   typedef FieldTraits< field_type > Traits ;
00593 
00594   const DataTraits & dt = data_traits< typename Traits::data_type >();
00595 
00596   const shards::ArrayDimTag * tags[8] ;
00597 
00598   Traits::assign_tags( tags );
00599 
00600   return * static_cast< field_type * >(
00601     declare_field_base( name , dt , Traits::Rank , tags , number_of_states ) );
00602 }
00603 
00604 template< class field_type >
00605 inline
00606 field_type & put_field(
00607   field_type & field ,
00608   EntityRank entity_rank ,
00609   const Part & part ,
00610   const void* init_value)
00611 {
00612   typedef FieldTraits< field_type > Traits ;
00613   typedef typename Traits::Helper   Helper ;
00614 
00615   unsigned stride[8] ;
00616 
00617   Helper::assign( stride );
00618 
00619   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00620 
00621   return field ;
00622 }
00623 
00624 template< class field_type >
00625 inline
00626 field_type & put_field(
00627   field_type & field ,
00628   EntityRank entity_rank ,
00629   const Selector & selector ,
00630   const void* init_value)
00631 {
00632   typedef FieldTraits< field_type > Traits ;
00633   typedef typename Traits::Helper   Helper ;
00634 
00635   unsigned stride[8] ;
00636 
00637   Helper::assign( stride );
00638 
00639   MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
00640 
00641   return field ;
00642 }
00643 
00644 template< class field_type >
00645 inline
00646 field_type & put_field( field_type &field ,
00647                         EntityRank entity_rank ,
00648                         const Part &part ,
00649                         unsigned    n1 ,
00650                         const void* init_value )
00651 {
00652   typedef FieldTraits< field_type > Traits ;
00653   typedef typename Traits::Helper   Helper ;
00654 
00655   unsigned stride[8] ;
00656 
00657   Helper::assign( stride , n1 );
00658 
00659   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00660 
00661   return field ;
00662 }
00663 
00664 template< class field_type >
00665 inline
00666 field_type & put_field( field_type &field ,
00667                         EntityRank entity_rank ,
00668                         const Selector &selector ,
00669                         unsigned    n1 ,
00670                         const void* init_value )
00671 {
00672   typedef FieldTraits< field_type > Traits ;
00673   typedef typename Traits::Helper   Helper ;
00674 
00675   unsigned stride[8] ;
00676 
00677   Helper::assign( stride , n1 );
00678 
00679   MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
00680 
00681   return field ;
00682 }
00683 
00684 template< class field_type >
00685 inline
00686 field_type & put_field( field_type &field ,
00687                         EntityRank entity_rank ,
00688                         const Part &part ,
00689                         unsigned    n1 ,
00690                         unsigned    n2 ,
00691                         const void* init_value )
00692 {
00693   typedef FieldTraits< field_type > Traits ;
00694   typedef typename Traits::Helper   Helper ;
00695 
00696   unsigned stride[8] ;
00697 
00698   Helper::assign( stride , n1 , n2 );
00699 
00700   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00701 
00702   return field ;
00703 }
00704 
00705 template< class field_type >
00706 inline
00707 field_type & put_field( field_type &field ,
00708                         EntityRank entity_rank ,
00709                         const Selector &selector ,
00710                         unsigned    n1 ,
00711                         unsigned    n2 ,
00712                         const void* init_value )
00713 {
00714   typedef FieldTraits< field_type > Traits ;
00715   typedef typename Traits::Helper   Helper ;
00716 
00717   unsigned stride[8] ;
00718 
00719   Helper::assign( stride , n1 , n2 );
00720 
00721   MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
00722 
00723   return field ;
00724 }
00725 
00726 template< class field_type >
00727 inline
00728 field_type & put_field( field_type &field ,
00729                         EntityRank entity_rank ,
00730                         const Part &part ,
00731                         unsigned    n1 ,
00732                         unsigned    n2 ,
00733                         unsigned    n3 ,
00734                         const void* init_value )
00735 {
00736   typedef FieldTraits< field_type > Traits ;
00737   typedef typename Traits::Helper   Helper ;
00738 
00739   unsigned stride[8] ;
00740 
00741   Helper::assign( stride , n1 , n2 , n3 );
00742 
00743   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00744 
00745   return field ;
00746 }
00747 
00748 template< class field_type >
00749 inline
00750 field_type & put_field( field_type &field ,
00751                         EntityRank entity_rank ,
00752                         const Selector &selector ,
00753                         unsigned    n1 ,
00754                         unsigned    n2 ,
00755                         unsigned    n3 ,
00756                         const void* init_value )
00757 {
00758   typedef FieldTraits< field_type > Traits ;
00759   typedef typename Traits::Helper   Helper ;
00760 
00761   unsigned stride[8] ;
00762 
00763   Helper::assign( stride , n1 , n2 , n3 );
00764 
00765   MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
00766 
00767   return field ;
00768 }
00769 
00770 template< class field_type >
00771 inline
00772 field_type & put_field( field_type &field ,
00773                         EntityRank entity_rank ,
00774                         const Part &part ,
00775                         unsigned    n1 ,
00776                         unsigned    n2 ,
00777                         unsigned    n3 ,
00778                         unsigned    n4 ,
00779                         const void* init_value )
00780 {
00781   typedef FieldTraits< field_type > Traits ;
00782   typedef typename Traits::Helper   Helper ;
00783 
00784   unsigned stride[8] ;
00785 
00786   Helper::assign( stride , n1 , n2 , n3 , n4 );
00787 
00788   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00789 
00790   return field ;
00791 }
00792 
00793 template< class field_type >
00794 inline
00795 field_type & put_field( field_type &field ,
00796                         EntityRank entity_rank ,
00797                         const Part &part ,
00798                         unsigned    n1 ,
00799                         unsigned    n2 ,
00800                         unsigned    n3 ,
00801                         unsigned    n4 ,
00802                         unsigned    n5 ,
00803                         const void* init_value )
00804 {
00805   typedef FieldTraits< field_type > Traits ;
00806   typedef typename Traits::Helper   Helper ;
00807 
00808   unsigned stride[8] ;
00809 
00810   Helper::assign( stride , n1 , n2 , n3 , n4, n5 );
00811 
00812   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00813 
00814   return field ;
00815 }
00816 
00817 template< class field_type >
00818 inline
00819 field_type & put_field( field_type &field ,
00820                         EntityRank entity_rank ,
00821                         const Part &part ,
00822                         unsigned    n1 ,
00823                         unsigned    n2 ,
00824                         unsigned    n3 ,
00825                         unsigned    n4 ,
00826                         unsigned    n5 ,
00827                         unsigned    n6 ,
00828                         const void* init_value )
00829 {
00830   typedef FieldTraits< field_type > Traits ;
00831   typedef typename Traits::Helper   Helper ;
00832 
00833   unsigned stride[8] ;
00834 
00835   Helper::assign( stride , n1 , n2 , n3 , n4, n5, n6 );
00836 
00837   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00838 
00839   return field ;
00840 }
00841 
00842 template< class field_type >
00843 inline
00844 field_type & put_field( field_type &field ,
00845                         EntityRank entity_rank ,
00846                         const Part &part ,
00847                         unsigned    n1 ,
00848                         unsigned    n2 ,
00849                         unsigned    n3 ,
00850                         unsigned    n4 ,
00851                         unsigned    n5 ,
00852                         unsigned    n6 ,
00853                         unsigned    n7 ,
00854                         const void* init_value )
00855 {
00856   typedef FieldTraits< field_type > Traits ;
00857   typedef typename Traits::Helper   Helper ;
00858 
00859   unsigned stride[8] ;
00860 
00861   Helper::assign( stride , n1 , n2 , n3 , n4, n5, n6, n7 );
00862 
00863   MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
00864 
00865   return field ;
00866 }
00867 
00868 template<class T>
00869 inline
00870 const T *
00871 MetaData::declare_attribute_with_delete( const T * a )
00872 {
00873   require_not_committed();
00874   return m_attributes.insert_with_delete( a );
00875 }
00876 
00877 template<class T>
00878 inline
00879 const T *
00880 MetaData::get_attribute() const
00881 { return m_attributes.get<T>(); }
00882 
00883 template<class T>
00884 inline
00885 const T *
00886 MetaData::declare_attribute_no_delete( const T * attribute )
00887 {
00888   require_not_committed();
00889   return m_attributes.insert_no_delete( attribute );
00890 }
00891 
00892 template<class T>
00893 inline
00894 bool
00895 MetaData::remove_attribute( const T * a )
00896 {
00897   return m_attributes.remove( a );
00898 }
00899 
00900 template<class T>
00901 inline
00902 const T *
00903 MetaData::declare_attribute_with_delete( Part & part , const T * attribute )
00904 {
00905   require_not_committed();
00906   return m_part_repo.declare_attribute_with_delete( part, attribute );
00907 }
00908 
00909 template<class T>
00910 inline
00911 const T *
00912 MetaData::declare_attribute_no_delete( Part & part , const T * attribute )
00913 {
00914   require_not_committed();
00915   return m_part_repo.declare_attribute_no_delete( part, attribute );
00916 }
00917 
00918 template<class T>
00919 inline
00920 bool
00921 MetaData::remove_attribute( Part & part , const T * attribute )
00922 {
00923   return m_part_repo.remove_attribute(part, attribute);
00924 }
00925 
00926 template<class T>
00927 inline
00928 const T *
00929 MetaData::declare_attribute_with_delete( FieldBase & field , const T * attribute )
00930 {
00931   require_not_committed();
00932   return m_field_repo.declare_attribute_with_delete(field, attribute);
00933 }
00934 
00935 template<class T>
00936 inline
00937 const T *
00938 MetaData::declare_attribute_no_delete( FieldBase & field , const T * attribute )
00939 {
00940   require_not_committed();
00941   return m_field_repo.declare_attribute_no_delete(field, attribute);
00942 }
00943 
00944 //----------------------------------------------------------------------
00945 
00946 template< class PointerFieldType , class ReferencedFieldType >
00947 inline
00948 void MetaData::declare_field_relation(
00949   PointerFieldType & pointer_field ,
00950   relation_stencil_ptr stencil ,
00951   ReferencedFieldType & referenced_field )
00952 {
00953   typedef typename FieldTraits< PointerFieldType >::data_type pointer_type ;
00954   typedef typename FieldTraits< ReferencedFieldType >::data_type data_type ;
00955 
00956   StaticAssert< SameType< pointer_type , data_type * >::value >::ok();
00957   StaticAssert< FieldTraits< PointerFieldType >::Rank == 1 >::ok();
00958 
00959   internal_declare_field_relation( pointer_field , stencil , referenced_field );
00960 }
00961 
00962 //----------------------------------------------------------------------
00963 
00964 template< typename DataType >
00965 inline
00966 Property<DataType> *
00967 MetaData::get_property( const std::string & name ) const
00968 {
00969   Property<void> * const pv = get_property_base( name, typeid(DataType) );
00970   return pv ? pv->property<DataType>() : (Property<DataType>*) NULL ;
00971 }
00972 
00973 template< typename DataType >
00974 inline
00975 Property<DataType> &
00976 MetaData::declare_property( const std::string & name , unsigned size )
00977 {
00978   Property<void> * pv = get_property_base(name,typeid(DataType),size);
00979   Property<DataType> * prop = NULL ;
00980 
00981   if ( pv != NULL ) {
00982     prop = pv->property<DataType>();
00983   }
00984   else {
00985     if ( 1 == size ) {
00986       pv = prop = new Property<DataType>( *this , m_properties.size() , name );
00987     }
00988     else {
00989       pv = prop = new Property< std::vector<DataType> >(
00990                     *this , m_properties.size() , name , size );
00991     }
00992     m_properties.push_back( pv );
00993   }
00994   return *prop ;
00995 }
00996 
00997 inline
00998 void MetaData::put_property( PropertyBase & property , Part & part )
00999 {
01000   property.add_property( part.mesh_meta_data_ordinal() );
01001 }
01002 
01003 inline
01004 bool MetaData::check_rank(EntityRank rank) const
01005 {
01006   return rank < m_entity_rank_names.size();
01007 }
01008 
01009 inline
01010 bool
01011 is_auto_declared_part(const Part &part)
01012 {
01013   const std::string &part_name = part.name();
01014 
01015   return !part_name.empty() && part_name[0] == '{';
01016 }
01017 
01018 } // namespace mesh
01019 } // namespace stk
01020 
01021 #endif /* DOXYGEN_COMPILE */
01022 
01023 //----------------------------------------------------------------------
01024 //----------------------------------------------------------------------
01025 
01026 #endif /* stk_mesh_MetaData_hpp */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines