Sierra Toolkit  Version of the Day
generic_mesh_functions.hpp
1 #ifndef STK_UTIL_GENERIC_MESH_FUNCTIONS_HPP
2 #define STK_UTIL_GENERIC_MESH_FUNCTIONS_HPP
3 
4 namespace stk_classic {
5 
6 // Generic API: add_entity that uses default constructable entity_value type.
7 template <typename Mesh>
8 inline typename generic_mesh_traits<Mesh>::entity_local_id
9 add_entity( Mesh & mesh );
10 
11 // Generic API: Generic add_entity that takes a pre-constructed entity_value type.
12 template <typename Mesh>
13 inline typename generic_mesh_traits<Mesh>::entity_local_id
14 add_entity( const typename generic_mesh_traits<Mesh>::entity_value & entity_value,
15  Mesh & mesh );
16 
17 
18 // Convenience function that also adds the entity to the range of parts.
19 template <typename Mesh, typename PartInputIterator>
20 inline typename generic_mesh_traits<Mesh>::entity_local_id
21 add_entity( PartInputIterator first, PartInputIterator last,
22  Mesh & mesh );
23 
24 
25 // Convenience function that also adds the entity to the range of parts.
26 template <typename Mesh, typename PartInputIterator>
27 inline typename generic_mesh_traits<Mesh>::entity_local_id
28 add_entity( const typename generic_mesh_traits<Mesh>::entity_value & entity_value,
29  PartInputIterator first, PartInputIterator last,
30  Mesh & mesh );
31 
32 
33 
34 // Generic API: remove this entity from the Mesh.
35 template <typename Mesh>
36 inline void
37 remove_entity( typename generic_mesh_traits<Mesh>::entity_local_id entity_lid,
38  Mesh & mesh );
39 
40 // Generic API: add this relation to the Mesh with default-constructed relation_value type.
41 template <typename Mesh>
42 inline generic_mesh_traits<Mesh>::relation_descriptor add_relation(
43  generic_mesh_traits<Mesh>::entity_local_id entity_from,
44  generic_mesh_traits<Mesh>::entity_local_id entity_to,
45  Mesh & mesh
46  );
47 
48 // Generic API: add this relation to the Mesh with pre-constructed relation_value type.
49 template <typename Mesh>
50 inline generic_mesh_traits<Mesh>::relation_descriptor add_relation(
51  generic_mesh_traits<Mesh>::entity_local_id entity_from,
52  generic_mesh_traits<Mesh>::entity_local_id entity_to,
53  const generic_mesh_traits<Mesh>::relation_value & relation,
54  Mesh & mesh
55  );
56 
57 
58 // Generic API: Remove this relation from the mesh.
59 template <typename Mesh>
60 inline void remove_relation( generic_mesh_traits<Mesh>::relation_descriptor relation_d, Mesh & mesh );
61 
62 
63 // Generic API: Get a const reference to the Entity from the entity_local_id.
64 template <typename Mesh>
65 inline const generic_mesh_traits<Mesh>::entity_value & get_entity(
66  generic_mesh_traits<Mesh>::entity_local_id entity_lid,
67  const Mesh & Mesh
68  );
69 
70 
71 // Generic API: Get a const reference to the Entity from the entity_descriptor.
72 template <typename Mesh>
73 inline const generic_mesh_traits<Mesh>::entity_value & get_entity(
74  generic_mesh_traits<Mesh>::entity_descriptor entity_d,
75  const Mesh & Mesh
76  );
77 
78 
79 // Generic API: Get an entity_descriptor from an entity_local_id
80 template <typename Mesh>
81 inline typename generic_mesh_traits<Mesh>::entity_local_id entity_descriptor_to_local_id(
82  typename generic_mesh_traits<Mesh>::entity_descriptor entity_d,
83  const Mesh & mesh
84  );
85 
86 
87 // Generic API: Get an entity_local_id from an entity_descriptor.
88 template <typename Mesh>
89 inline typename generic_mesh_traits<Mesh>::entity_descriptor entity_local_id_to_descriptor(
90  typename generic_mesh_traits<Mesh>::entity_local_id entity_lid,
91  const Mesh & mesh
92  );
93 
94 
95 
96 // Generic API: Get a range to all entities in the mesh.
97 template <typename Mesh>
98 inline std::pair<
99  typename generic_mesh_traits<Mesh>::entity_descriptor_iterator,
100  typename generic_mesh_traits<Mesh>::entity_descriptor_iterator
101  >
102  get_entities(Mesh & mesh);
103 
104 
105 // Generic API:
106 template <typename Mesh>
107 inline
108 std::pair<
109  typename generic_mesh_traits<Mesh>::bucket_entity_descriptor_iterator,
110  typename generic_mesh_traits<Mesh>::bucket_entity_descriptor_iterator
111  >
112  get_entities( typename generic_mesh_traits<Mesh>::bucket_descriptor bucket_descriptor,
113  Mesh & mesh
114  );
115 
116 
117 
118 // Generic API: Get a range to all the relations for this entity_local_id
119 template <typename Mesh>
120 inline std::pair<
121  typename generic_mesh_traits<Mesh>::relation_descriptor_iterator,
122  typename generic_mesh_traits<Mesh>::relation_descriptor_iterator
123  >
124  get_relations( generic_mesh_traits<Mesh>::entity_local_id entity_lid, Mesh & mesh );
125 
126 
127 // Generic API: Get a range to all the relations for this entity_descriptor
128 template <typename Mesh>
129 inline std::pair<generic_mesh_traits<Mesh>::relation_descriptor_iterator, generic_mesh_traits<Mesh>::relation_descriptor_iterator>
130  get_relations( generic_mesh_traits<Mesh>::entity_descriptor entity_d, Mesh & mesh );
131 
132 
133 
134 // Generic API: Get a range to selected relations for this entity_local_id
135 // Selector is a unary-predicate that takes a relation_descriptor and returns true/false
136 template <typename Mesh, typename Selector>
137 inline std::pair<generic_mesh_traits<Mesh>::selected_relation_descriptor_iterator,generic_mesh_traits<Mesh>::selected_relation_descriptor_iterator>
138  get_relations(
139  generic_mesh_traits<Mesh>::entity_local_id entity_lid,
140  Selector & selector,
141  Mesh & mesh
142  );
143 
144 
145 // Generic API: Get a range to selected relations for this entity_descriptor
146 // Selector is a unary-predicate that takes a relation_descriptor and returns true/false
147 template <typename Mesh, typename Selector>
148 inline std::pair<generic_mesh_traits<Mesh>::selected_relation_descriptor_iterator,generic_mesh_traits<Mesh>::selected_relation_descriptor_iterator>
149  get_relations(
150  generic_mesh_traits<Mesh>::entity_descriptor entity_d,
151  Selector & selector,
152  Mesh & mesh
153  );
154 
155 
156 // Generic API: Get a bucket for an entity_descriptor
157 template <typename Mesh>
158 inline typename generic_mesh_traits<Mesh>::bucket_descriptor
159 get_bucket( typename generic_mesh_traits<Mesh>::entity_descriptor entity,
160  Mesh & mesh );
161 
162 
163 // Generic API: Get all buckets for the mesh
164 template <typename Mesh>
165 inline
166 std::pair<
167  typename generic_mesh_traits<Mesh>::bucket_descriptor_iterator,
168  typename generic_mesh_traits<Mesh>::bucket_descriptor_iterator
169  >
170 get_buckets( const Mesh & mesh );
171 
172 
173 // Generic API: Get buckets associated with a Selector.
174 // Selector is a unary-predicate that takes a bucket_descriptor and returns true/false
175 template <typename Mesh, typename Selector >
176 inline
177 std::pair<
178  typename generic_mesh_traits<Mesh>::selected_bucket_descriptor_iterator,
179  typename generic_mesh_traits<Mesh>::selected_bucket_descriptor_iterator
180  >
181 get_buckets( const Selector & selector, Mesh & mesh );
182 
183 
184 // Generic API: Get buckets for a particular part_descriptor.
185 template <typename Mesh>
186 inline
187 std::pair<
188  typename generic_mesh_traits<Mesh>::part_bucket_descriptor_iterator,
189  typename generic_mesh_traits<Mesh>::part_bucket_descriptor_iterator
190  >
191 get_buckets( typename generic_mesh_traits<Mesh>::part_descriptor part_descriptor,
192  Mesh & mesh );
193 
194 
195 
196 // Generic API: add this part to the Mesh.
197 template <typename Mesh>
198 inline typename generic_mesh_traits<Mesh>::part_descriptor
199 add_part( const typename generic_mesh_traits<Mesh>::part_value & part_value,
200  Mesh & mesh );
201 
202 
203 // Generic API: remove this part from the Mesh.
204 template <typename Mesh>
205 inline void
206 remove_part( typename generic_mesh_traits<Mesh>::part_descriptor part_descriptor,
207  Mesh & mesh );
208 
209 
210 
211 // Generic API: Move entity so it
212 // sits in Parts defined by AddPartInputIterator and
213 // so it does not sit in Parts defined by RemovePartInputIterator
214 template <typename Mesh, typename AddPartInputIterator, typename RemovePartInputIterator>
215 inline typename generic_mesh_traits<Mesh>::bucket_descriptor
216 move_entity( typename generic_mesh_traits<Mesh>::entity_descriptor entity_descriptor,
217  AddPartInputIterator add_first, AddPartInputIterator add_last,
218  RemovePartInputIterator remove_first, RemovePartInputIterator remove_last,
219  Mesh & mesh );
220 
221 
222 
223 // Generic API: Get all parts on the mesh.
224 template <typename Mesh>
225 inline
226 std::pair<
227  typename generic_mesh_traits<Mesh>::part_descriptor_iterator,
228  typename generic_mesh_traits<Mesh>::part_descriptor_iterator
229  >
230 get_parts( const Mesh & mesh );
231 
232 
233 // Generic API: Get all Parts associated with a bucket.
234 template <typename Mesh>
235 inline
236 std::pair<
237  typename generic_mesh_traits<Mesh>::bucket_part_descriptor_iterator,
238  typename generic_mesh_traits<Mesh>::bucket_part_descriptor_iterator
239  >
240 get_parts(
241  typename generic_mesh_traits<Mesh>::bucket_descriptor bucket_descriptor,
242  Mesh & mesh
243  );
244 
245 // Generic API: Begin modification cycle. Returns true if cycle was not already in progress
246 template <typename Mesh>
247 inline
248 bool
249 modification_begin( Mesh & mesh );
250 
251 // Generic API: End modification cycle. Returns true if cycle was in progress.
252 template <typename Mesh>
253 inline
254 bool
255 modification_end( Mesh & mesh );
256 
257 // Generic API: Query if we are in a modification cycle
258 template <typename Mesh>
259 inline
260 bool
261 is_modifiable( const Mesh & mesh );
262 
263 // Generic API: Rotate the field data of multistate fields.
264 template <typename Mesh>
265 inline
266 void
267 rotate_multistate_fields( Mesh & mesh );
268 
269 } // namespace stk_classic
270 
271 #endif // STK_UTIL_GENERIC_MESH_FUNCTIONS_HPP
void get_entities(const BulkData &mesh, EntityRank entity_rank, std::vector< Entity *> &entities)
Get all entities of the specified type, sorted by ID.
Definition: GetEntities.cpp:25
Sierra Toolkit.
AllSelectedBucketsRange get_buckets(const Selector &selector, const BulkData &mesh)
Definition: GetBuckets.cpp:26