Sierra Toolkit  Version of the Day
Property.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 
10 #ifndef stk_mesh_Property_hpp
11 #define stk_mesh_Property_hpp
12 
13 //----------------------------------------------------------------------
14 
15 #include <iosfwd>
16 #include <string>
17 
18 #include <stk_util/environment/ReportHandler.hpp>
19 
20 #include <stk_mesh/base/Types.hpp>
21 #include <stk_mesh/base/MetaData.hpp>
22 #include <stk_mesh/base/PropertyBase.hpp>
23 
24 //----------------------------------------------------------------------
25 
26 namespace stk_classic {
27 namespace mesh {
28 
34 std::ostream & operator << ( std::ostream & , const PropertyBase & );
35 
37 std::ostream & print( std::ostream & ,
38  const char * const , const PropertyBase & );
39 
41 template< typename property_type >
42 inline
43 const typename property_type::data_type *
44 property_data( const property_type & prop , const Part & part )
45 {
46  const PropertyBase & prop_base = dynamic_cast< const PropertyBase & > (prop);
47  const MetaData * prop_meta_data = & MetaData::get(prop_base);
48  const MetaData * part_meta_data = & MetaData::get(part);
49  ThrowRequireMsg( prop_meta_data == part_meta_data,
50  "MetaData mismatch between property and part" );
51  return prop.data( part.mesh_meta_data_ordinal() );
52 }
53 
55 template< typename property_type >
56 inline
57 typename property_type::data_type *
58 property_data( property_type & prop , const Part & part )
59 {
60  const PropertyBase & prop_base = dynamic_cast< const PropertyBase & > (prop);
61  const MetaData * prop_meta_data = & MetaData::get(prop_base);
62  const MetaData * part_meta_data = & MetaData::get(part);
63  ThrowRequireMsg( prop_meta_data == part_meta_data,
64  "MetaData mismatch between property and part" );
65  return prop.data( part.mesh_meta_data_ordinal() );
66 }
67 
70 } // namespace mesh
71 } // namespace stk_classic
72 
73 #endif /* stk_mesh_Property_hpp */
74 
The manager of an integrated collection of parts and fields.
Definition: MetaData.hpp:56
std::ostream & print(std::ostream &, const char *const, const PropertyBase &)
Print field and field restrictions on new lines.
An application-defined subset of a problem domain.
Definition: Part.hpp:49
property_type::data_type * property_data(property_type &prop, const Part &part)
Query pointer to property data for a given part.
Definition: Property.hpp:58
unsigned mesh_meta_data_ordinal() const
Internally generated ordinal of this part that is unique within the owning meta data manager...
Definition: Part.hpp:72
Sierra Toolkit.
Property base class with an anonymous data type and anonymous multi-dimension.