Sierra Toolkit  Version of the Day
FieldRepository.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 #ifndef stk_mesh_baseImpl_FieldRepository_hpp
9 #define stk_mesh_baseImpl_FieldRepository_hpp
10 
11 #include <iosfwd>
12 #include <stk_util/util/SameType.hpp>
13 #include <stk_util/util/StaticAssert.hpp>
14 #include <stk_util/parallel/Parallel.hpp>
15 #include <stk_mesh/base/Types.hpp>
16 #include <stk_mesh/base/Part.hpp>
17 #include <stk_mesh/base/Field.hpp>
18 #include <stk_mesh/base/PropertyBase.hpp>
19 #include <stk_mesh/baseImpl/PartRepository.hpp>
20 
21 #include <stk_mesh/baseImpl/FieldBaseImpl.hpp>
22 
23 namespace stk_classic {
24 namespace mesh {
25 
26 typedef std::vector<FieldBase *> FieldVector;
27 
28 namespace impl {
29 
30 class FieldRepository {
31 
32  public:
33  FieldRepository() {}
34  ~FieldRepository();
35 
36  FieldBase * get_field(
37  const char * arg_method ,
38  const std::string & arg_name ,
39  const DataTraits & arg_traits ,
40  unsigned arg_rank ,
41  const shards::ArrayDimTag * const * arg_dim_tags ,
42  unsigned arg_num_states
43  ) const;
44 
45  FieldBase * declare_field(
46  const std::string & arg_name ,
47  const DataTraits & arg_traits ,
48  unsigned arg_rank ,
49  const shards::ArrayDimTag * const * arg_dim_tags ,
50  unsigned arg_num_states ,
51  MetaData * arg_meta_data
52  );
53 
54  void verify_and_clean_restrictions(
55  const char * arg_method ,
56  const Part& superset, const Part& subset,
57  const PartVector & arg_all_parts );
58 
59  const FieldVector & get_fields() const {
60  return m_fields;
61  }
62 
63  template<class T>
64  const T *
65  declare_attribute_with_delete( FieldBase & f , const T * a )
66  {
67  return f.m_impl.declare_attribute_with_delete(a);
68  }
69 
70  template<class T>
71  const T *
72  declare_attribute_no_delete( FieldBase & f , const T * a )
73  {
74  return f.m_impl.declare_attribute_no_delete(a);
75  }
76 
77  void declare_field_restriction(
78  const char * arg_method,
79  FieldBase & arg_field ,
80  unsigned arg_entity_rank ,
81  const Part & arg_part ,
82  const PartVector & arg_all_parts,
83  const unsigned * arg_stride ,
84  const void * arg_init_value = NULL)
85  {
86  arg_field.m_impl.insert_restriction( arg_method, arg_entity_rank, arg_part, arg_stride, arg_init_value);
87  }
88 
89  void declare_field_restriction(
90  const char * arg_method,
91  FieldBase & arg_field ,
92  unsigned arg_entity_rank ,
93  const Selector & arg_selector ,
94  const PartVector & arg_all_parts,
95  const unsigned * arg_stride ,
96  const void * arg_init_value = NULL)
97  {
98  arg_field.m_impl.insert_restriction( arg_method, arg_entity_rank, arg_selector, arg_stride, arg_init_value);
99  }
100 
101  private:
102  FieldVector m_fields;
103 
104  //disallow copy and assignment
105  FieldRepository( const FieldRepository &);
106  FieldRepository & operator = ( const FieldRepository &);
107 };
108 
109 } // namespace impl
110 } // namespace mesh
111 } // namespace stk_classic
112 
113 #endif //stk_mesh_baseImpl_FieldRepository_hpp
const stk_classic::mesh::FieldBase * get_field(const FieldIdMap &field_id_map, int field_id)
Definition: ImplDetails.cpp:51
Sierra Toolkit.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31