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 
00123   const Restriction & restriction( unsigned entity_rank , const Part & part ) const {
00124     return m_impl.restriction( entity_rank, part);
00125   }
00126 
00127   //----------------------------------------
00128 
00129   FieldBase * field_state( FieldState fstate) const {
00130     return m_impl.field_state(fstate);
00131   }
00132 
00133   const void* get_initial_value() const { return m_impl.get_initial_value(); }
00134 
00135   void* get_initial_value() { return m_impl.get_initial_value(); }
00136 
00137 private:
00138 
00142   MetaData & meta_data() const { return m_impl.meta_data(); }
00143 
00144   friend class ::stk::mesh::MetaData ;
00145   friend class ::stk::mesh::impl::FieldRepository ;
00146   friend class ::stk::mesh::impl::FieldBaseImpl ;
00147 
00149   friend class ::stk::mesh::UnitTestFieldImpl ;
00150 
00151   FieldBase(
00152       MetaData                   * arg_mesh_meta_data ,
00153       unsigned                     arg_ordinal ,
00154       const std::string          & arg_name ,
00155       const DataTraits           & arg_traits ,
00156       unsigned                     arg_rank,
00157       const shards::ArrayDimTag  * const * arg_dim_tags,
00158       unsigned                     arg_number_of_states ,
00159       FieldState                   arg_this_state
00160       )
00161     : m_impl(
00162         arg_mesh_meta_data,
00163         arg_ordinal,
00164         arg_name,
00165         arg_traits,
00166         arg_rank,
00167         arg_dim_tags,
00168         arg_number_of_states,
00169         arg_this_state
00170         )
00171   {}
00172 
00173   // WORKAROUND 5/19/2010 [DGB]: intel 10.? and pgi do not link if this is made virtual
00174   //  virtual ~FieldBase();
00175   ~FieldBase();
00176 
00177   impl::FieldBaseImpl  m_impl;
00178 
00179   //the following functions are declared but not defined
00180   FieldBase();
00181   FieldBase( const FieldBase & );
00182   FieldBase & operator = ( const FieldBase & );
00183 };
00184 
00186 std::ostream & operator << ( std::ostream & , const FieldBase & );
00187 
00189 std::ostream & print( std::ostream & ,
00190                       const char * const , const FieldBase & );
00191 
00192 } //namespace mesh
00193 } //namespace stk
00194 
00195 #endif //stk_mesh_base_FieldBase_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends