Sierra Toolkit Version of the Day
FieldRepository.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_FieldRepository_hpp
00009 #define stk_mesh_baseImpl_FieldRepository_hpp
00010 
00011 #include <iosfwd>
00012 #include <stk_util/util/SameType.hpp>
00013 #include <stk_util/util/StaticAssert.hpp>
00014 #include <stk_util/parallel/Parallel.hpp>
00015 #include <stk_mesh/base/Types.hpp>
00016 #include <stk_mesh/base/Part.hpp>
00017 #include <stk_mesh/base/Field.hpp>
00018 #include <stk_mesh/base/PropertyBase.hpp>
00019 #include <stk_mesh/baseImpl/PartRepository.hpp>
00020 
00021 #include <stk_mesh/baseImpl/FieldBaseImpl.hpp>
00022 
00023 namespace stk {
00024 namespace mesh {
00025 
00026 typedef std::vector<FieldBase *> FieldVector;
00027 
00028 namespace impl {
00029 
00030 class FieldRepository {
00031 
00032   public:
00033     FieldRepository() {}
00034     ~FieldRepository();
00035 
00036     FieldBase * get_field(
00037         const char                        * arg_method ,
00038         const std::string                 & arg_name ,
00039         const DataTraits                  & arg_traits ,
00040         unsigned                            arg_rank ,
00041         const shards::ArrayDimTag * const * arg_dim_tags ,
00042         unsigned                            arg_num_states
00043         ) const;
00044 
00045     FieldBase * declare_field(
00046         const std::string                 & arg_name ,
00047         const DataTraits                  & arg_traits ,
00048         unsigned                            arg_rank ,
00049         const shards::ArrayDimTag * const * arg_dim_tags ,
00050         unsigned                            arg_num_states ,
00051         MetaData                          * arg_meta_data
00052         );
00053 
00054     void verify_and_clean_restrictions(
00055         const char       * arg_method ,
00056         const PartVector & arg_all_parts );
00057 
00058     const FieldVector & get_fields() const {
00059       return m_fields;
00060     }
00061 
00062     template<class T>
00063       const T *
00064       declare_attribute_with_delete( FieldBase & f , const T * a )
00065       {
00066         return f.m_impl.declare_attribute_with_delete(a);
00067       }
00068 
00069     template<class T>
00070       const T *
00071       declare_attribute_no_delete( FieldBase & f , const T * a )
00072       {
00073         return f.m_impl.declare_attribute_no_delete(a);
00074       }
00075 
00076     void declare_field_restriction(
00077         const char     * arg_method,
00078         FieldBase      & arg_field ,
00079         unsigned         arg_entity_rank ,
00080         const Part     & arg_part ,
00081         const PartVector & arg_all_parts,
00082         const unsigned * arg_stride )
00083     {
00084       arg_field.m_impl.insert_restriction( arg_method, arg_entity_rank, arg_part, arg_stride);
00085       verify_and_clean_restrictions( arg_method, arg_all_parts );
00086     }
00087 
00088   private:
00089     FieldVector m_fields;
00090 
00091     //disallow copy and assignment
00092     FieldRepository( const FieldRepository &);
00093     FieldRepository & operator = ( const FieldRepository &);
00094 };
00095 
00096 } // namespace impl
00097 } // namespace mesh
00098 } // namespace stk
00099 
00100 #endif //stk_mesh_baseImpl_FieldRepository_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends