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 private:
00134 
00138   MetaData & meta_data() const { return m_impl.meta_data(); }
00139 
00140   friend class ::stk::mesh::MetaData ;
00141   friend class ::stk::mesh::impl::FieldRepository ;
00142   friend class ::stk::mesh::impl::FieldBaseImpl ;
00143 
00145   friend class ::stk::mesh::UnitTestFieldImpl ;
00146 
00147   FieldBase(
00148       MetaData                   * arg_mesh_meta_data ,
00149       unsigned                     arg_ordinal ,
00150       const std::string          & arg_name ,
00151       const DataTraits           & arg_traits ,
00152       unsigned                     arg_rank,
00153       const shards::ArrayDimTag  * const * arg_dim_tags,
00154       unsigned                     arg_number_of_states ,
00155       FieldState                   arg_this_state
00156       )
00157     : m_impl(
00158         arg_mesh_meta_data,
00159         arg_ordinal,
00160         arg_name,
00161         arg_traits,
00162         arg_rank,
00163         arg_dim_tags,
00164         arg_number_of_states,
00165         arg_this_state
00166         )
00167   {}
00168 
00169   // WORKAROUND 5/19/2010 [DGB]: intel 10.? and pgi do not link if this is made virtual
00170   //  virtual ~FieldBase();
00171   ~FieldBase();
00172 
00173   impl::FieldBaseImpl  m_impl;
00174 
00175   //the following functions are declared but not defined
00176   FieldBase();
00177   FieldBase( const FieldBase & );
00178   FieldBase & operator = ( const FieldBase & );
00179 };
00180 
00182 std::ostream & operator << ( std::ostream & , const FieldBase & );
00183 
00185 std::ostream & print( std::ostream & ,
00186                       const char * const , const FieldBase & );
00187 
00188 } //namespace mesh
00189 } //namespace stk
00190 
00191 #endif //stk_mesh_base_FieldBase_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends