9 #ifndef stk_mesh_MetaData_hpp
10 #define stk_mesh_MetaData_hpp
16 #include <stk_util/util/SameType.hpp>
17 #include <stk_util/util/StaticAssert.hpp>
18 #include <stk_util/parallel/Parallel.hpp>
20 #include <stk_mesh/base/Types.hpp>
21 #include <stk_mesh/base/Part.hpp>
22 #include <stk_mesh/base/Field.hpp>
23 #include <stk_mesh/base/PropertyBase.hpp>
24 #include <stk_mesh/base/EntityKey.hpp>
25 #include <stk_mesh/base/Selector.hpp>
27 #include <stk_mesh/baseImpl/PartRepository.hpp>
28 #include <stk_mesh/baseImpl/FieldBaseImpl.hpp>
29 #include <stk_mesh/baseImpl/FieldRepository.hpp>
44 print_entity_key( std::ostream & os,
const MetaData & meta_data,
const EntityKey & key);
47 print_entity_key(
const MetaData & meta_data,
const EntityKey & key );
65 inline static MetaData &
get(
const Part & part ) {
return part.meta_data(); }
66 inline static MetaData &
get(
const FieldBase & field ) {
return field.meta_data(); }
75 explicit MetaData(
const std::vector<std::string>& entity_rank_names );
114 const char * required_by = NULL )
const ;
161 Part & target_part );
172 const T * declare_attribute_no_delete(
Part & part,
const T * attribute);
174 bool remove_attribute(
Part & part,
const T * attribute);
186 EntityRank entity_rank(
const std::string &name )
const;
188 const std::vector<std::string> & entity_rank_names()
const
189 {
return m_entity_rank_names ; }
191 std::vector<std::string>::size_type entity_rank_count()
const
192 {
return m_entity_rank_names.size(); }
194 const std::string & entity_rank_name( EntityRank entity_rank )
const ;
214 template<
class field_type >
215 field_type *
get_field(
const std::string & name )
const ;
219 return m_field_repo.get_fields() ;
231 template<
class field_type >
233 unsigned number_of_states = 1 );
243 const T * declare_attribute_no_delete(
FieldBase & field,
const T * attribute);
264 template<
class Po
interFieldType ,
class ReferencedFieldType >
267 ReferencedFieldType & referenced_field );
271 {
return m_field_relations ; }
277 const T * get_attribute()
const ;
287 const T * declare_attribute_no_delete(
const T * attribute);
290 bool remove_attribute(
const T * );
304 template<
typename DataType >
309 {
return m_properties ; }
317 template<
typename DataType >
355 const std::string & arg_name,
356 const DataTraits & arg_traits ,
358 const shards::ArrayDimTag *
const * arg_dim_tags ,
359 unsigned arg_num_states );
364 EntityRank arg_entity_rank ,
365 const Part & arg_part ,
366 const unsigned * arg_stride ,
367 const void* arg_init_value = NULL );
372 EntityRank arg_entity_rank ,
374 const unsigned * arg_stride ,
375 const void* arg_init_value = NULL );
379 MetaData & operator = (
const MetaData & );
381 Part & declare_internal_part(
const std::string & p_name);
383 Part & declare_internal_part(
const std::string & p_name, EntityRank rank);
386 impl::PartRepository m_part_repo ;
389 Part * m_universal_part ;
391 Part * m_shares_part ;
394 impl::FieldRepository m_field_repo ;
396 std::vector< FieldRelation > m_field_relations ;
397 std::vector< PropertyBase* > m_properties ;
398 std::vector< std::string > m_entity_rank_names ;
400 unsigned m_spatial_dimension;
406 void require_committed()
const ;
408 void require_not_committed()
const ;
410 void require_same_mesh_meta_data(
const MetaData & rhs )
const ;
412 void require_valid_entity_rank( EntityRank rank)
const ;
414 void require_not_relation_target(
const Part *
const part )
const ;
419 const std::type_info & ,
420 unsigned = 0 )
const ;
422 void internal_declare_field_relation(
FieldBase & ,
426 void clean_field_restrictions();
440 template<
class field_type >
441 field_type &
put_field( field_type & field ,
444 const void* init_value = NULL);
446 template<
class field_type >
447 field_type &
put_field( field_type & field ,
449 const Selector & selector ,
450 const void* init_value = NULL);
457 template<
class field_type >
458 field_type &
put_field( field_type & field ,
462 const void* init_value = NULL);
464 template<
class field_type >
465 field_type &
put_field( field_type & field ,
467 const Selector & selector ,
469 const void* init_value = NULL);
471 template<
class field_type >
472 field_type &
put_field( field_type & field ,
477 const void* init_value = NULL);
479 template<
class field_type >
480 field_type &
put_field( field_type & field ,
482 const Selector & selector ,
485 const void* init_value = NULL);
487 template<
class field_type >
488 field_type &
put_field( field_type & field ,
494 const void* init_value = NULL);
496 template<
class field_type >
497 field_type &
put_field( field_type & field ,
499 const Selector & selector ,
503 const void* init_value = NULL);
505 template<
class field_type >
506 field_type &
put_field( field_type & field ,
513 const void* init_value = NULL);
515 template<
class field_type >
516 field_type &
put_field( field_type & field ,
524 const void* init_value = NULL);
526 template<
class field_type >
527 field_type &
put_field( field_type & field ,
536 const void* init_value = NULL);
538 template<
class field_type >
539 field_type &
put_field( field_type & field ,
549 const void* init_value = NULL);
559 #ifndef DOXYGEN_COMPILE
566 {
return * m_part_repo.get_all_parts()[ord] ; }
568 template<
class field_type >
572 typedef FieldTraits< field_type > Traits ;
574 const DataTraits & dt = data_traits< typename Traits::data_type >();
576 const shards::ArrayDimTag * tags[8] ;
578 Traits::assign_tags( tags );
580 FieldBase *
const field =
581 m_field_repo.get_field(
"stk::mesh::MetaData::get_field" ,
582 name , dt , Traits::Rank , tags , 0 );
584 return static_cast< field_type *
>( field );
587 template<
class field_type >
590 unsigned number_of_states )
592 typedef FieldTraits< field_type > Traits ;
594 const DataTraits & dt = data_traits< typename Traits::data_type >();
596 const shards::ArrayDimTag * tags[8] ;
598 Traits::assign_tags( tags );
600 return *
static_cast< field_type *
>(
604 template<
class field_type >
610 const void* init_value)
612 typedef FieldTraits< field_type > Traits ;
613 typedef typename Traits::Helper Helper ;
617 Helper::assign( stride );
619 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
624 template<
class field_type >
628 EntityRank entity_rank ,
629 const Selector & selector ,
630 const void* init_value)
632 typedef FieldTraits< field_type > Traits ;
633 typedef typename Traits::Helper Helper ;
637 Helper::assign( stride );
639 MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
644 template<
class field_type >
646 field_type &
put_field( field_type &field ,
647 EntityRank entity_rank ,
650 const void* init_value )
652 typedef FieldTraits< field_type > Traits ;
653 typedef typename Traits::Helper Helper ;
657 Helper::assign( stride , n1 );
659 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
664 template<
class field_type >
666 field_type &
put_field( field_type &field ,
667 EntityRank entity_rank ,
668 const Selector &selector ,
670 const void* init_value )
672 typedef FieldTraits< field_type > Traits ;
673 typedef typename Traits::Helper Helper ;
677 Helper::assign( stride , n1 );
679 MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
684 template<
class field_type >
686 field_type &
put_field( field_type &field ,
687 EntityRank entity_rank ,
691 const void* init_value )
693 typedef FieldTraits< field_type > Traits ;
694 typedef typename Traits::Helper Helper ;
698 Helper::assign( stride , n1 , n2 );
700 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
705 template<
class field_type >
707 field_type &
put_field( field_type &field ,
708 EntityRank entity_rank ,
709 const Selector &selector ,
712 const void* init_value )
714 typedef FieldTraits< field_type > Traits ;
715 typedef typename Traits::Helper Helper ;
719 Helper::assign( stride , n1 , n2 );
721 MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
726 template<
class field_type >
728 field_type &
put_field( field_type &field ,
729 EntityRank entity_rank ,
734 const void* init_value )
736 typedef FieldTraits< field_type > Traits ;
737 typedef typename Traits::Helper Helper ;
741 Helper::assign( stride , n1 , n2 , n3 );
743 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
748 template<
class field_type >
750 field_type &
put_field( field_type &field ,
751 EntityRank entity_rank ,
752 const Selector &selector ,
756 const void* init_value )
758 typedef FieldTraits< field_type > Traits ;
759 typedef typename Traits::Helper Helper ;
763 Helper::assign( stride , n1 , n2 , n3 );
765 MetaData::get(field).declare_field_restriction( field, entity_rank, selector, stride, init_value);
770 template<
class field_type >
772 field_type &
put_field( field_type &field ,
773 EntityRank entity_rank ,
779 const void* init_value )
781 typedef FieldTraits< field_type > Traits ;
782 typedef typename Traits::Helper Helper ;
786 Helper::assign( stride , n1 , n2 , n3 , n4 );
788 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
793 template<
class field_type >
795 field_type &
put_field( field_type &field ,
796 EntityRank entity_rank ,
803 const void* init_value )
805 typedef FieldTraits< field_type > Traits ;
806 typedef typename Traits::Helper Helper ;
810 Helper::assign( stride , n1 , n2 , n3 , n4, n5 );
812 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
817 template<
class field_type >
819 field_type &
put_field( field_type &field ,
820 EntityRank entity_rank ,
828 const void* init_value )
830 typedef FieldTraits< field_type > Traits ;
831 typedef typename Traits::Helper Helper ;
835 Helper::assign( stride , n1 , n2 , n3 , n4, n5, n6 );
837 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
842 template<
class field_type >
844 field_type &
put_field( field_type &field ,
845 EntityRank entity_rank ,
854 const void* init_value )
856 typedef FieldTraits< field_type > Traits ;
857 typedef typename Traits::Helper Helper ;
861 Helper::assign( stride , n1 , n2 , n3 , n4, n5, n6, n7 );
863 MetaData::get(field).declare_field_restriction( field, entity_rank, part, stride, init_value);
873 require_not_committed();
880 MetaData::get_attribute()
const
881 {
return m_attributes.
get<T>(); }
886 MetaData::declare_attribute_no_delete(
const T * attribute )
888 require_not_committed();
895 MetaData::remove_attribute(
const T * a )
897 return m_attributes.
remove( a );
905 require_not_committed();
906 return m_part_repo.declare_attribute_with_delete( part, attribute );
912 MetaData::declare_attribute_no_delete( Part & part ,
const T * attribute )
914 require_not_committed();
915 return m_part_repo.declare_attribute_no_delete( part, attribute );
921 MetaData::remove_attribute( Part & part ,
const T * attribute )
923 return m_part_repo.remove_attribute(part, attribute);
931 require_not_committed();
932 return m_field_repo.declare_attribute_with_delete(field, attribute);
938 MetaData::declare_attribute_no_delete( FieldBase & field ,
const T * attribute )
940 require_not_committed();
941 return m_field_repo.declare_attribute_no_delete(field, attribute);
946 template<
class Po
interFieldType ,
class ReferencedFieldType >
949 PointerFieldType & pointer_field ,
951 ReferencedFieldType & referenced_field )
953 typedef typename FieldTraits< PointerFieldType >::data_type pointer_type ;
954 typedef typename FieldTraits< ReferencedFieldType >::data_type data_type ;
956 StaticAssert< SameType< pointer_type , data_type * >::value >::ok();
957 StaticAssert< FieldTraits< PointerFieldType >::Rank == 1 >::ok();
959 internal_declare_field_relation( pointer_field , stencil , referenced_field );
964 template<
typename DataType >
969 Property<void> *
const pv = get_property_base( name,
typeid(DataType) );
970 return pv ? pv->property<DataType>() : (Property<DataType>*) NULL ;
973 template< typename DataType >
978 Property<void> * pv = get_property_base(name,
typeid(DataType),size);
979 Property<DataType> * prop = NULL ;
982 prop = pv->property<DataType>();
986 pv = prop =
new Property<DataType>( *this , m_properties.size() , name );
989 pv = prop =
new Property< std::vector<DataType> >(
990 *this , m_properties.size() , name , size );
992 m_properties.push_back( pv );
1000 property.add_property( part.mesh_meta_data_ordinal() );
1006 return rank < m_entity_rank_names.size();
1011 is_auto_declared_part(
const Part &part)
1013 const std::string &part_name = part.name();
1015 return !part_name.empty() && part_name[0] ==
'{';
std::vector< Part * > PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
This is a class for selecting buckets based on a set of meshparts and set logic.
Property with defined data type and multi-dimensions (if any)
const T * insert_with_delete(const T *)
void verify_parallel_consistency(const MetaData &s, ParallelMachine pm)
Verify that the meta data is identical on all processors.
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
int(* relation_stencil_ptr)(unsigned from_type, unsigned to_type, unsigned identifier)
A relation stencil maps entity relationships to ordinals.
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
A container for the field data of a homogeneous collection of entities.
const T * insert_no_delete(const T *)
Field base class with an anonymous data type and anonymous multi-dimension.
field_type & put_field(field_type &field, EntityRank entity_rank, const Part &part, const void *init_value=NULL)
Declare a field to exist for a given entity type and Part.
An application-defined subset of a problem domain.
Manager for an integrated collection of entities, entity relations, and buckets of field data...
Set of entities of arbitrary types.
Data for ghosting mesh entities.
Property base class with an anonymous data type and anonymous multi-dimension.