Sierra Toolkit  Version of the Day
FieldBase.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 
9 #ifndef stk_mesh_base_FieldBase_hpp
10 #define stk_mesh_base_FieldBase_hpp
11 
12 #include <iosfwd>
13 #include <string>
14 #include <vector>
15 
16 #include <Shards_Array.hpp>
17 
18 #include <stk_util/util/SimpleArrayOps.hpp>
19 #include <stk_util/util/CSet.hpp>
20 
21 #include <stk_mesh/base/Types.hpp>
22 #include <stk_mesh/base/DataTraits.hpp>
23 
24 #include <stk_mesh/base/FieldState.hpp>
25 
26 #include <stk_mesh/base/FieldRestriction.hpp>
27 #include <stk_mesh/baseImpl/FieldBaseImpl.hpp>
28 
29 namespace stk_classic {
30 namespace mesh {
31 
32 class UnitTestFieldImpl;
33 
34 namespace impl {
35 
36 class FieldRepository;
37 
38 }
39 
40 //----------------------------------------------------------------------
49 // Implementation details:
50 // Simply wraps a FieldBaseImpl object which is kept as a member, all calls are
51 // inlined and passed through to the impl object. This design is analogous
52 // to the "P-impl" pattern.
53 class FieldBase
54 {
55  public:
59  MetaData & mesh_meta_data() const { return m_impl.meta_data(); }
63  unsigned mesh_meta_data_ordinal() const { return m_impl.ordinal(); }
64 
66  const std::string & name() const { return m_impl.name() ; }
67 
69  template<class Type> bool type_is() const
70  { return m_impl.type_is<Type>(); }
71 
75  const DataTraits & data_traits() const { return m_impl.data_traits() ; }
76 
78  unsigned number_of_states() const { return m_impl.number_of_states() ; }
79 
81  FieldState state() const { return m_impl.state() ; }
82 
86  unsigned rank() const { return m_impl.rank(); }
87 
92  const shards::ArrayDimTag * const * dimension_tags() const
93  { return m_impl.dimension_tags() ; }
94 
98  unsigned max_size( EntityRank entity_rank) const {
99  return m_impl.max_size( entity_rank );
100  }
101 
102  //----------------------------------------
103 
105  template<class A>
106  const A * attribute() const { return m_impl.attribute<A>(); }
107 
108  typedef FieldRestriction Restriction;
109 
111  typedef FieldRestrictionVector RestrictionVector;
112 
117  return m_impl.restrictions();
118  }
119 
120  const RestrictionVector &selector_restrictions() const {
121  return m_impl.selector_restrictions();
122  }
123 
127  const Restriction & restriction( unsigned entity_rank , const Part & part ) const {
128  return m_impl.restriction( entity_rank, part);
129  }
130 
131  //----------------------------------------
132 
133  FieldBase * field_state( FieldState fstate) const {
134  return m_impl.field_state(fstate);
135  }
136 
137  const void* get_initial_value() const { return m_impl.get_initial_value(); }
138 
139  void* get_initial_value() { return m_impl.get_initial_value(); }
140 
141  unsigned get_initial_value_num_bytes() const { return m_impl.get_initial_value_num_bytes(); }
142 
143 private:
144 
148  MetaData & meta_data() const { return m_impl.meta_data(); }
149 
150  friend class ::stk_classic::mesh::MetaData ;
151  friend class ::stk_classic::mesh::impl::FieldRepository ;
152  friend class ::stk_classic::mesh::impl::FieldBaseImpl ;
153 
155  friend class ::stk_classic::mesh::UnitTestFieldImpl ;
156 
157  FieldBase(
158  MetaData * arg_mesh_meta_data ,
159  unsigned arg_ordinal ,
160  const std::string & arg_name ,
161  const DataTraits & arg_traits ,
162  unsigned arg_rank,
163  const shards::ArrayDimTag * const * arg_dim_tags,
164  unsigned arg_number_of_states ,
165  FieldState arg_this_state
166  )
167  : m_impl(
168  arg_mesh_meta_data,
169  arg_ordinal,
170  arg_name,
171  arg_traits,
172  arg_rank,
173  arg_dim_tags,
174  arg_number_of_states,
175  arg_this_state
176  )
177  {}
178 
179  // WORKAROUND 5/19/2010 [DGB]: intel 10.? and pgi do not link if this is made virtual
180  // virtual ~FieldBase();
181 
182  impl::FieldBaseImpl m_impl;
183 
184  //the following functions are declared but not defined
185  FieldBase();
186  FieldBase( const FieldBase & );
187  FieldBase & operator = ( const FieldBase & );
188 };
189 
191 std::ostream & operator << ( std::ostream & , const FieldBase & );
192 
194 std::ostream & print( std::ostream & ,
195  const char * const , const FieldBase & );
196 
197 } //namespace mesh
198 } //namespace stk_classic
199 
200 #endif //stk_mesh_base_FieldBase_hpp
unsigned number_of_states() const
Number of states of this field.
Definition: FieldBase.hpp:78
std::ostream & print(std::ostream &os, const std::string &indent, const Bucket &bucket)
Print the parts and entities of this bucket.
Definition: Bucket.cpp:259
Field base class with an anonymous data type and anonymous multi-dimension.
Definition: FieldBase.hpp:53
The manager of an integrated collection of parts and fields.
Definition: MetaData.hpp:56
const Restriction & restriction(unsigned entity_rank, const Part &part) const
Query a field restriction, result is volatile until the owning meta data manager is committed...
Definition: FieldBase.hpp:127
unsigned rank() const
Multi-dimensional array rank of this field, which is zero for a scalar field.
Definition: FieldBase.hpp:86
const RestrictionVector & restrictions() const
Vector of field restriction which is volatile until the owning meta data manager is committed...
Definition: FieldBase.hpp:116
MetaData & mesh_meta_data() const
The meta data manager that owns this field.
Definition: FieldBase.hpp:59
An application-defined subset of a problem domain.
Definition: Part.hpp:49
const std::string & name() const
Application-defined text name of this field.
Definition: FieldBase.hpp:66
const shards::ArrayDimTag *const * dimension_tags() const
Multi-dimensional array dimension tags of this field.
Definition: FieldBase.hpp:92
Sierra Toolkit.
unsigned mesh_meta_data_ordinal() const
Internally generated ordinal of this field that is unique within the owning meta data manager...
Definition: FieldBase.hpp:63
unsigned max_size(EntityRank entity_rank) const
Maximum field data allocation size declared for this field for the given entity rank.
Definition: FieldBase.hpp:98
const A * attribute() const
Query attribute that has been attached to this field.
Definition: FieldBase.hpp:106
FieldState state() const
FieldState of this field.
Definition: FieldBase.hpp:81
bool type_is() const
Query if the type is Type.
Definition: FieldBase.hpp:69
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
FieldRestrictionVector RestrictionVector
A fields&#39; restrictions are maintained in a std::vector.
Definition: FieldBase.hpp:111
const DataTraits & data_traits() const
Return the data traits for this field&#39;s type.
Definition: FieldBase.hpp:75
FieldState
Enumeration of states for multi-state fields.
Definition: FieldState.hpp:34