Sierra Toolkit Version of the Day
FieldBase.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 
00009 #ifndef stk_mesh_base_FieldBase_hpp
00010 #define stk_mesh_base_FieldBase_hpp
00011 
00012 #include <iosfwd>
00013 #include <string>
00014 #include <vector>
00015 
00016 #include <Shards_Array.hpp>
00017 
00018 #include <stk_util/util/SimpleArrayOps.hpp>
00019 #include <stk_util/util/CSet.hpp>
00020 
00021 #include <stk_mesh/base/Types.hpp>
00022 #include <stk_mesh/base/DataTraits.hpp>
00023 
00024 #include <stk_mesh/base/FieldState.hpp>
00025 
00026 #include <stk_mesh/base/FieldRestriction.hpp>
00027 #include <stk_mesh/baseImpl/FieldBaseImpl.hpp>
00028 
00029 namespace stk {
00030 namespace mesh {
00031 
00032 class UnitTestFieldImpl;
00033 
00034 namespace impl {
00035 
00036 class FieldRepository;
00037 
00038 }
00039 
00040 //----------------------------------------------------------------------
00049 // Implementation details:
00050 //   Simply wraps a FieldBaseImpl object which is kept as a member, all calls are
00051 //   inlined and passed through to the impl object. This design is analogous
00052 //   to the "P-impl" pattern.
00053 class FieldBase
00054 {
00055   public:
00059   MetaData & mesh_meta_data() const { return m_impl.meta_data(); }
00063   unsigned mesh_meta_data_ordinal() const { return m_impl.ordinal(); }
00064 
00066   const std::string & name() const { return m_impl.name() ; }
00067 
00069   template<class Type> bool type_is() const
00070   { return m_impl.type_is<Type>(); }
00071 
00075   const DataTraits & data_traits() const { return m_impl.data_traits() ; }
00076 
00078   unsigned number_of_states() const { return m_impl.number_of_states() ; }
00079 
00081   FieldState state() const { return m_impl.state() ; }
00082 
00086   unsigned rank() const { return m_impl.rank(); }
00087 
00092   const shards::ArrayDimTag * const * dimension_tags() const
00093   { return m_impl.dimension_tags() ; }
00094 
00098   unsigned max_size( EntityRank entity_rank) const {
00099     return m_impl.max_size( entity_rank );
00100   }
00101 
00102   //----------------------------------------
00103 
00105   template<class A>
00106   const A * attribute() const { return m_impl.attribute<A>(); }
00107 
00108   typedef FieldRestriction Restriction;
00109 
00111   typedef FieldRestrictionVector RestrictionVector;
00112 
00116   const RestrictionVector &restrictions() const {
00117     return m_impl.restrictions();
00118   }
00119 
00120   const RestrictionVector &selector_restrictions() const {
00121     return m_impl.selector_restrictions();
00122   }
00123 
00127   const Restriction & restriction( unsigned entity_rank , const Part & part ) const {
00128     return m_impl.restriction( entity_rank, part);
00129   }
00130 
00131   //----------------------------------------
00132 
00133   FieldBase * field_state( FieldState fstate) const {
00134     return m_impl.field_state(fstate);
00135   }
00136 
00137   const void* get_initial_value() const { return m_impl.get_initial_value(); }
00138 
00139   void* get_initial_value() { return m_impl.get_initial_value(); }
00140 
00141   unsigned get_initial_value_num_bytes() const { return m_impl.get_initial_value_num_bytes(); }
00142 
00143 private:
00144 
00148   MetaData & meta_data() const { return m_impl.meta_data(); }
00149 
00150   friend class ::stk::mesh::MetaData ;
00151   friend class ::stk::mesh::impl::FieldRepository ;
00152   friend class ::stk::mesh::impl::FieldBaseImpl ;
00153 
00155   friend class ::stk::mesh::UnitTestFieldImpl ;
00156 
00157   FieldBase(
00158       MetaData                   * arg_mesh_meta_data ,
00159       unsigned                     arg_ordinal ,
00160       const std::string          & arg_name ,
00161       const DataTraits           & arg_traits ,
00162       unsigned                     arg_rank,
00163       const shards::ArrayDimTag  * const * arg_dim_tags,
00164       unsigned                     arg_number_of_states ,
00165       FieldState                   arg_this_state
00166       )
00167     : m_impl(
00168         arg_mesh_meta_data,
00169         arg_ordinal,
00170         arg_name,
00171         arg_traits,
00172         arg_rank,
00173         arg_dim_tags,
00174         arg_number_of_states,
00175         arg_this_state
00176         )
00177   {}
00178 
00179   // WORKAROUND 5/19/2010 [DGB]: intel 10.? and pgi do not link if this is made virtual
00180   //  virtual ~FieldBase();
00181 
00182   impl::FieldBaseImpl  m_impl;
00183 
00184   //the following functions are declared but not defined
00185   FieldBase();
00186   FieldBase( const FieldBase & );
00187   FieldBase & operator = ( const FieldBase & );
00188 };
00189 
00191 std::ostream & operator << ( std::ostream & , const FieldBase & );
00192 
00194 std::ostream & print( std::ostream & ,
00195                       const char * const , const FieldBase & );
00196 
00197 } //namespace mesh
00198 } //namespace stk
00199 
00200 #endif //stk_mesh_base_FieldBase_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines