Sierra Toolkit Version of the Day
FieldBaseImpl.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 #ifndef stk_mesh_baseImpl_FieldBaseImpl_hpp
00009 #define stk_mesh_baseImpl_FieldBaseImpl_hpp
00010 
00011 #include <vector>
00012 #include <Shards_Array.hpp>
00013 #include <stk_mesh/base/DataTraits.hpp>
00014 
00015 #include <stk_mesh/base/FieldState.hpp>
00016 #include <stk_mesh/base/FieldRestriction.hpp>
00017 
00018 #include <stk_util/util/CSet.hpp>
00019 
00020 namespace stk {
00021 namespace mesh {
00022 
00023 class FieldBase;
00024 class MetaData;
00025 
00026 namespace impl {
00027 
00028 class FieldBaseImpl {
00029 public:
00030 
00031   MetaData & meta_data() const {
00032     return *m_meta_data ;
00033   }
00034 
00035   unsigned ordinal() const {
00036     return m_ordinal ;
00037   }
00038 
00039   const std::string & name() const {
00040     return m_name ;
00041   }
00042 
00043   template<class Type>
00044   bool type_is() const {
00045     return m_data_traits.type_info == typeid(Type) ;
00046   }
00047 
00048   const DataTraits & data_traits() const {
00049     return m_data_traits ;
00050   }
00051 
00052   unsigned number_of_states() const {
00053     return m_num_states ;
00054   }
00055 
00056   FieldState state() const {
00057     return m_this_state ;
00058   }
00059 
00060   unsigned rank() const {
00061     return m_field_rank ;
00062   }
00063 
00064   const shards::ArrayDimTag * const * dimension_tags() const {
00065     return m_dim_tags ;
00066   }
00067 
00068   //not inline
00069   unsigned max_size( unsigned entity_rank) const ;
00070 
00071   template<class A>
00072   const A * attribute() const {
00073     return m_attribute.template get<A>();
00074   }
00075 
00076   template<class A>
00077     const A * declare_attribute_no_delete(const A * a) {
00078       return m_attribute.template insert_no_delete<A>(a);
00079     }
00080 
00081   template<class A>
00082     const A * declare_attribute_with_delete(const A * a) {
00083       return m_attribute.template insert_with_delete<A>(a);
00084     }
00085 
00086   const FieldRestriction & restriction( unsigned entity_rank , const Part & part) const ;
00087 
00088   const FieldRestrictionVector &restrictions() const ;
00089 
00090   FieldBase * field_state(FieldState fstate) const {
00091     return m_field_states[fstate];
00092   }
00093 
00094   void insert_restriction( const char       * arg_method ,
00095                            EntityRank         arg_entity_rank ,
00096                            const Part       & arg_part ,
00097                            const unsigned   * arg_stride ,
00098                            const void*        arg_init_value = NULL);
00099 
00100   void verify_and_clean_restrictions( const char       * arg_method ,
00101                                       const PartVector & arg_all_parts );
00102 
00103   const void* get_initial_value() const;
00104 
00105   void* get_initial_value();
00106 
00107   unsigned get_initial_value_num_bytes() const;
00108 
00109   void set_field_states( FieldBase ** field_states);
00110 
00111   FieldBaseImpl(
00112       MetaData                   * arg_mesh_meta_data ,
00113       unsigned                     arg_ordinal ,
00114       const std::string          & arg_name ,
00115       const DataTraits           & arg_traits ,
00116       unsigned                     arg_rank,
00117       const shards::ArrayDimTag  * const * arg_dim_tags,
00118       unsigned                     arg_number_of_states ,
00119       FieldState                   arg_this_state
00120       );
00121 
00122   ~FieldBaseImpl();
00123 
00124 private:
00125 
00126   void set_initial_value(const void* new_initial_value, unsigned num_scalars, unsigned num_bytes);
00127 
00128   FieldRestrictionVector & restrictions();
00129 
00130   const std::string            m_name ;                    
00131   CSet                         m_attribute ;               
00132   const DataTraits           & m_data_traits ;             
00133   MetaData             * const m_meta_data ;               
00134   const unsigned               m_ordinal ;                 
00135   const unsigned               m_num_states ;              
00136   const FieldState             m_this_state ;              
00137   unsigned                     m_field_rank ;              
00138   FieldRestrictionVector       m_dim_map ;                 
00139   FieldBase                  * m_field_states[ MaximumFieldStates ];
00140   const shards::ArrayDimTag  * m_dim_tags[ MaximumFieldDimension ];
00141   void*                        m_initial_value;
00142   unsigned                     m_initial_value_num_bytes;
00143 
00144   //disallow copy and default constructors
00145   FieldBaseImpl();
00146   FieldBaseImpl( const FieldBase & );
00147   FieldBaseImpl & operator = ( const FieldBaseImpl & );
00148 };
00149 
00150 
00152 std::ostream & operator << ( std::ostream & , const FieldBaseImpl & );
00153 
00155 std::ostream & print( std::ostream & ,
00156                       const char * const , const FieldBase & );
00157 
00158 
00159 } // namespace impl
00160 } // namespace mesh
00161 } // namespace stk
00162 
00163 #endif // stk_mesh_baseImpl_FieldBaseIml_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends