parallel_mesh.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_PARALLEL_MESH_H
21 #define LIBMESH_PARALLEL_MESH_H
22 
23 // Local Includes -----------------------------------
24 #include "libmesh/mapvector.h"
26 
27 // C++ Includes -----------------------------------
28 #include <cstddef>
29 #include <set>
30 
31 namespace libMesh
32 {
33 
34 // Forward declarations
35 class Elem;
36 class Node;
37 
38 
47 // ------------------------------------------------------------
48 // UnstructuredMesh class definition
50 {
51  public:
52 
58  explicit
60  unsigned int dim=1);
61 
62 #ifndef LIBMESH_DISABLE_COMMWORLD
63 
68  explicit
69  ParallelMesh (unsigned int dim=1);
70 #endif
71 
72 
77  ParallelMesh (const UnstructuredMesh& other_mesh);
78 
83  ParallelMesh (const ParallelMesh& other_mesh);
84 
88  virtual AutoPtr<MeshBase> clone () const
89  { return AutoPtr<MeshBase>(new ParallelMesh(*this)); }
90 
94  virtual ~ParallelMesh();
95 
99  virtual void clear();
100 
106  virtual void redistribute ();
107 
112  virtual void update_post_partitioning ();
113 
118  virtual bool is_serial () const
119  { return _is_serial; }
120 
126  template <typename T>
128 
134  virtual void libmesh_assert_valid_parallel_ids() const;
135 
142 
148  template <typename T>
150 
154  virtual void renumber_nodes_and_elements ();
155 
160  virtual void allgather();
161 
167  virtual void delete_remote_elements();
168 
174  virtual void add_extra_ghost_elem(Elem* e);
175 
179  virtual void clear_extra_ghost_elems() { _extra_ghost_elems.clear(); }
180 
181  // Cached methods that can be called in serial
182  virtual dof_id_type n_nodes () const { return _n_nodes; }
183  virtual dof_id_type max_node_id () const { return _max_node_id; }
184  virtual void reserve_nodes (const dof_id_type) { }
185  virtual dof_id_type n_elem () const { return _n_elem; }
186  virtual dof_id_type n_active_elem () const;
187  virtual dof_id_type max_elem_id () const { return _max_elem_id; }
188  virtual void reserve_elem (const dof_id_type) { }
189 
190  // Parallel only method to update the caches
191  virtual void update_parallel_id_counts ();
192 
193  // And more parallel only methods to test non-cached values
194  dof_id_type parallel_n_nodes () const;
196  dof_id_type parallel_n_elem () const;
198 
199  virtual const Point& point (const dof_id_type i) const ;
200  virtual const Node& node (const dof_id_type i) const ;
201  virtual Node& node (const dof_id_type i) ;
202  virtual const Node* node_ptr (const dof_id_type i) const ;
203  virtual Node* node_ptr (const dof_id_type i) ;
204  virtual const Node* query_node_ptr (const dof_id_type i) const ;
205  virtual Node* query_node_ptr (const dof_id_type i) ;
206  virtual const Elem* elem (const dof_id_type i) const ;
207  virtual Elem* elem (const dof_id_type i) ;
208  virtual const Elem* query_elem (const dof_id_type i) const ;
209  virtual Elem* query_elem (const dof_id_type i) ;
210 
214  virtual Node* add_point (const Point& p,
215  const dof_id_type id =
217  const processor_id_type proc_id =
219  virtual Node* add_node (Node* n) ;
220 
224  virtual Node* insert_node(Node* n);
225 
226  virtual void delete_node (Node* n) ;
227  virtual void renumber_node (dof_id_type old_id, dof_id_type new_id);
228  virtual Elem* add_elem (Elem* e) ;
229  virtual Elem* insert_elem (Elem* e) ;
230  virtual void delete_elem (Elem* e) ;
231  virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id);
232 
240 
241 public:
245  element_iterator elements_begin ();
246  element_iterator elements_end ();
247 
248  element_iterator active_elements_begin ();
249  element_iterator active_elements_end ();
250 
251  element_iterator ancestor_elements_begin ();
252  element_iterator ancestor_elements_end ();
253 
254  element_iterator subactive_elements_begin ();
255  element_iterator subactive_elements_end ();
256 
257  element_iterator not_active_elements_begin ();
258  element_iterator not_active_elements_end ();
259 
260  element_iterator not_ancestor_elements_begin ();
261  element_iterator not_ancestor_elements_end ();
262 
263  element_iterator not_subactive_elements_begin ();
264  element_iterator not_subactive_elements_end ();
265 
266  element_iterator local_elements_begin ();
267  element_iterator local_elements_end ();
268 
269  element_iterator not_local_elements_begin ();
270  element_iterator not_local_elements_end ();
271 
272  element_iterator active_local_elements_begin ();
273  element_iterator active_local_elements_end ();
274 
275  element_iterator active_not_local_elements_begin ();
276  element_iterator active_not_local_elements_end ();
277 
278  element_iterator level_elements_begin (const unsigned int level);
279  element_iterator level_elements_end (const unsigned int level);
280 
281  element_iterator not_level_elements_begin (const unsigned int level);
282  element_iterator not_level_elements_end (const unsigned int level);
283 
284  element_iterator local_level_elements_begin (const unsigned int level);
285  element_iterator local_level_elements_end (const unsigned int level);
286 
287  element_iterator local_not_level_elements_begin (const unsigned int level);
288  element_iterator local_not_level_elements_end (const unsigned int level);
289 
290  element_iterator pid_elements_begin (const processor_id_type proc_id);
291  element_iterator pid_elements_end (const processor_id_type proc_id);
292 
293  element_iterator type_elements_begin (const ElemType type);
294  element_iterator type_elements_end (const ElemType type);
295 
296  element_iterator active_type_elements_begin (const ElemType type);
297  element_iterator active_type_elements_end (const ElemType type);
298 
299  element_iterator active_pid_elements_begin (const processor_id_type proc_id);
300  element_iterator active_pid_elements_end (const processor_id_type proc_id);
301 
302  element_iterator unpartitioned_elements_begin ();
303  element_iterator unpartitioned_elements_end ();
304 
305  element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id);
306  element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id);
307 
308  element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id);
309  element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id);
310 
311 
315  const_element_iterator elements_begin() const;
316  const_element_iterator elements_end() const;
317 
318  const_element_iterator active_elements_begin() const;
319  const_element_iterator active_elements_end() const;
320 
321  const_element_iterator ancestor_elements_begin() const;
322  const_element_iterator ancestor_elements_end() const;
323 
324  const_element_iterator subactive_elements_begin() const;
325  const_element_iterator subactive_elements_end() const;
326 
327  const_element_iterator not_active_elements_begin() const;
328  const_element_iterator not_active_elements_end() const;
329 
330  const_element_iterator not_ancestor_elements_begin() const;
331  const_element_iterator not_ancestor_elements_end() const;
332 
333  const_element_iterator not_subactive_elements_begin() const;
334  const_element_iterator not_subactive_elements_end() const;
335 
336  const_element_iterator local_elements_begin () const;
337  const_element_iterator local_elements_end () const;
338 
339  const_element_iterator not_local_elements_begin () const;
340  const_element_iterator not_local_elements_end () const;
341 
342  const_element_iterator active_local_elements_begin () const;
343  const_element_iterator active_local_elements_end () const;
344 
345  const_element_iterator active_not_local_elements_begin () const;
346  const_element_iterator active_not_local_elements_end () const;
347 
348  const_element_iterator level_elements_begin (const unsigned int level) const;
349  const_element_iterator level_elements_end (const unsigned int level) const;
350 
351  const_element_iterator not_level_elements_begin (const unsigned int level) const;
352  const_element_iterator not_level_elements_end (const unsigned int level) const;
353 
354  const_element_iterator local_level_elements_begin (const unsigned int level) const;
355  const_element_iterator local_level_elements_end (const unsigned int level) const;
356 
357  const_element_iterator local_not_level_elements_begin (const unsigned int level) const;
358  const_element_iterator local_not_level_elements_end (const unsigned int level) const;
359 
360  const_element_iterator pid_elements_begin (const processor_id_type proc_id) const;
361  const_element_iterator pid_elements_end (const processor_id_type proc_id) const;
362 
363  const_element_iterator type_elements_begin (const ElemType type) const;
364  const_element_iterator type_elements_end (const ElemType type) const;
365 
366  const_element_iterator active_type_elements_begin (const ElemType type) const;
367  const_element_iterator active_type_elements_end (const ElemType type) const;
368 
369  const_element_iterator active_pid_elements_begin (const processor_id_type proc_id) const;
370  const_element_iterator active_pid_elements_end (const processor_id_type proc_id) const;
371 
372  const_element_iterator unpartitioned_elements_begin () const;
373  const_element_iterator unpartitioned_elements_end () const;
374 
375  const_element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id) const;
376  const_element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id) const;
377 
378  const_element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id) const;
379  const_element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id) const;
380 
381 
382 
383 
384 
388  node_iterator nodes_begin();
389  node_iterator nodes_end();
390 
391  node_iterator active_nodes_begin();
392  node_iterator active_nodes_end();
393 
394  node_iterator local_nodes_begin ();
395  node_iterator local_nodes_end ();
396 
397  node_iterator pid_nodes_begin (const processor_id_type proc_id);
398  node_iterator pid_nodes_end (const processor_id_type proc_id);
399 
403  const_node_iterator nodes_begin() const;
404  const_node_iterator nodes_end() const;
405 
406  const_node_iterator active_nodes_begin() const;
407  const_node_iterator active_nodes_end() const;
408 
409  const_node_iterator local_nodes_begin () const;
410  const_node_iterator local_nodes_end () const;
411 
412  const_node_iterator pid_nodes_begin (const processor_id_type proc_id) const;
413  const_node_iterator pid_nodes_end (const processor_id_type proc_id) const;
414 
415 protected:
416 
421 #ifdef LIBMESH_ENABLE_UNIQUE_ID
422  virtual void assign_unique_ids();
423 #endif
424 
429 
434 
439 
444 
453 
458  std::set<Elem *> _extra_ghost_elems;
459 
460 private:
461 
468 
475 };
476 
477 
478 } // namespace libMesh
479 
480 #endif // LIBMESH_PARALLEL_MESH_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo