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_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 
00099   void verify_and_clean_restrictions( const char       * arg_method ,
00100                                       const PartVector & arg_all_parts );
00101 
00102 
00103 
00104   void set_field_states( FieldBase ** field_states);
00105 
00106   FieldBaseImpl(
00107       MetaData                   * arg_mesh_meta_data ,
00108       unsigned                     arg_ordinal ,
00109       const std::string          & arg_name ,
00110       const DataTraits           & arg_traits ,
00111       unsigned                     arg_rank,
00112       const shards::ArrayDimTag  * const * arg_dim_tags,
00113       unsigned                     arg_number_of_states ,
00114       FieldState                   arg_this_state
00115       );
00116 
00117   ~FieldBaseImpl() {}
00118 
00119 private:
00120 
00121   FieldRestrictionVector & restrictions();
00122 
00123   const std::string            m_name ;                    
00124   CSet                         m_attribute ;               
00125   const DataTraits           & m_data_traits ;             
00126   MetaData             * const m_meta_data ;               
00127   const unsigned               m_ordinal ;                 
00128   const unsigned               m_num_states ;              
00129   const FieldState             m_this_state ;              
00130   unsigned                     m_rank ;                    
00131   FieldRestrictionVector       m_dim_map ;                 
00132   FieldBase                  * m_field_states[ MaximumFieldStates ];
00133   const shards::ArrayDimTag  * m_dim_tags[ MaximumFieldDimension ];
00134 
00135   //disallow copy and default constructors
00136   FieldBaseImpl();
00137   FieldBaseImpl( const FieldBase & );
00138   FieldBaseImpl & operator = ( const FieldBaseImpl & );
00139 };
00140 
00141 
00143 std::ostream & operator << ( std::ostream & , const FieldBaseImpl & );
00144 
00146 std::ostream & print( std::ostream & ,
00147                       const char * const , const FieldBase & );
00148 
00149 
00150 } // namespace impl
00151 } // namespace mesh
00152 } // namespace stk
00153 
00154 #endif // stk_mesh_baseImpl_FieldBaseIml_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends