serial_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_SERIAL_MESH_H
21 #define LIBMESH_SERIAL_MESH_H
22 
23 // Local Includes -----------------------------------
25 #include "libmesh/boundary_info.h"
26 
27 // C++ Includes -----------------------------------
28 #include <cstddef>
29 
30 namespace libMesh
31 {
32 
33 
34 
35 
36 
37 
45 // ------------------------------------------------------------
46 // Mesh class definition
48 {
49  public:
50 
56  explicit
58  unsigned int dim=1);
59 
60 #ifndef LIBMESH_DISABLE_COMMWORLD
61 
66  explicit
67  SerialMesh (unsigned int dim=1);
68 #endif
69 
70 
75  SerialMesh (const UnstructuredMesh& other_mesh);
76 
81  SerialMesh (const SerialMesh& other_mesh);
82 
86  virtual AutoPtr<MeshBase> clone () const
87  { return AutoPtr<MeshBase>(new SerialMesh(*this)); }
88 
92  virtual ~SerialMesh();
93 
97  virtual void clear();
98 
102  virtual void renumber_nodes_and_elements ();
103 
104  virtual dof_id_type n_nodes () const
105  { return libmesh_cast_int<dof_id_type>(_nodes.size()); }
106 
107  virtual dof_id_type parallel_n_nodes () const
108  { return libmesh_cast_int<dof_id_type>(_nodes.size()); }
109 
110  virtual dof_id_type max_node_id () const
111  { return libmesh_cast_int<dof_id_type>(_nodes.size()); }
112 
113  virtual void reserve_nodes (const dof_id_type nn)
114  { _nodes.reserve (nn); }
115 
116  virtual dof_id_type n_elem () const
117  { return libmesh_cast_int<dof_id_type>(_elements.size()); }
118 
119  virtual dof_id_type parallel_n_elem () const
120  { return libmesh_cast_int<dof_id_type>(_elements.size()); }
121 
122  virtual dof_id_type n_active_elem () const;
123 
124  virtual dof_id_type max_elem_id () const
125  { return libmesh_cast_int<dof_id_type>(_elements.size()); }
126 
127  virtual void reserve_elem (const dof_id_type ne) { _elements.reserve (ne); }
128 
129  // SerialMesh has no caches to update
130  virtual void update_parallel_id_counts () {}
131 
132  virtual const Point& point (const dof_id_type i) const ;
133  virtual const Node& node (const dof_id_type i) const ;
134  virtual Node& node (const dof_id_type i) ;
135  virtual const Node* node_ptr (const dof_id_type i) const ;
136  virtual Node* node_ptr (const dof_id_type i) ;
137  virtual const Node* query_node_ptr (const dof_id_type i) const ;
138  virtual Node* query_node_ptr (const dof_id_type i) ;
139  virtual const Elem* elem (const dof_id_type i) const ;
140  virtual Elem* elem (const dof_id_type i) ;
141  virtual const Elem* query_elem (const dof_id_type i) const ;
142  virtual Elem* query_elem (const dof_id_type i) ;
143 
147  virtual Node* add_point (const Point& p,
148  const dof_id_type id =
150  const processor_id_type proc_id =
152  virtual Node* add_node (Node* n) ;
153 
165  virtual Node* insert_node(Node* n);
166 
167  virtual void delete_node (Node* n) ;
168  virtual void renumber_node (dof_id_type old_id, dof_id_type new_id);
169  virtual Elem* add_elem (Elem* e) ;
170  virtual Elem* insert_elem (Elem* e) ;
171  virtual void delete_elem (Elem* e) ;
172  virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id);
173 
181 
197  void stitch_meshes (SerialMesh& other_mesh,
198  boundary_id_type this_mesh_boundary,
199  boundary_id_type other_mesh_boundary,
200  Real tol=TOLERANCE,
201  bool clear_stitched_boundary_ids=false,
202  bool verbose=true,
203  bool use_binary_search=true,
204  bool enforce_all_nodes_match_on_boundaries=false);
205 
209  void stitch_surfaces (boundary_id_type boundary_id_1,
210  boundary_id_type boundary_id_2,
211  Real tol=TOLERANCE,
212  bool clear_stitched_boundary_ids=false,
213  bool verbose=true,
214  bool use_binary_search=true,
215  bool enforce_all_nodes_match_on_boundaries=false);
216 
217 public:
221  element_iterator elements_begin ();
222  element_iterator elements_end ();
223 
224  element_iterator active_elements_begin ();
225  element_iterator active_elements_end ();
226 
227  element_iterator ancestor_elements_begin ();
228  element_iterator ancestor_elements_end ();
229 
230  element_iterator subactive_elements_begin ();
231  element_iterator subactive_elements_end ();
232 
233  element_iterator not_active_elements_begin ();
234  element_iterator not_active_elements_end ();
235 
236  element_iterator not_ancestor_elements_begin ();
237  element_iterator not_ancestor_elements_end ();
238 
239  element_iterator not_subactive_elements_begin ();
240  element_iterator not_subactive_elements_end ();
241 
242  element_iterator local_elements_begin ();
243  element_iterator local_elements_end ();
244 
245  element_iterator not_local_elements_begin ();
246  element_iterator not_local_elements_end ();
247 
248  element_iterator active_local_elements_begin ();
249  element_iterator active_local_elements_end ();
250 
251  element_iterator active_not_local_elements_begin ();
252  element_iterator active_not_local_elements_end ();
253 
254  element_iterator level_elements_begin (const unsigned int level);
255  element_iterator level_elements_end (const unsigned int level);
256 
257  element_iterator not_level_elements_begin (const unsigned int level);
258  element_iterator not_level_elements_end (const unsigned int level);
259 
260  element_iterator local_level_elements_begin (const unsigned int level);
261  element_iterator local_level_elements_end (const unsigned int level);
262 
263  element_iterator local_not_level_elements_begin (const unsigned int level);
264  element_iterator local_not_level_elements_end (const unsigned int level);
265 
266  element_iterator pid_elements_begin (const processor_id_type proc_id);
267  element_iterator pid_elements_end (const processor_id_type proc_id);
268 
269  element_iterator type_elements_begin (const ElemType type);
270  element_iterator type_elements_end (const ElemType type);
271 
272  element_iterator active_type_elements_begin (const ElemType type);
273  element_iterator active_type_elements_end (const ElemType type);
274 
275  element_iterator active_pid_elements_begin (const processor_id_type proc_id);
276  element_iterator active_pid_elements_end (const processor_id_type proc_id);
277 
278  element_iterator unpartitioned_elements_begin ();
279  element_iterator unpartitioned_elements_end ();
280 
281  element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id);
282  element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id);
283 
284  element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id);
285  element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id);
286 
290  const_element_iterator elements_begin() const;
291  const_element_iterator elements_end() const;
292 
293  const_element_iterator active_elements_begin() const;
294  const_element_iterator active_elements_end() const;
295 
296  const_element_iterator ancestor_elements_begin() const;
297  const_element_iterator ancestor_elements_end() const;
298 
299  const_element_iterator subactive_elements_begin() const;
300  const_element_iterator subactive_elements_end() const;
301 
302  const_element_iterator not_active_elements_begin() const;
303  const_element_iterator not_active_elements_end() const;
304 
305  const_element_iterator not_ancestor_elements_begin() const;
306  const_element_iterator not_ancestor_elements_end() const;
307 
308  const_element_iterator not_subactive_elements_begin() const;
309  const_element_iterator not_subactive_elements_end() const;
310 
311  const_element_iterator local_elements_begin () const;
312  const_element_iterator local_elements_end () const;
313 
314  const_element_iterator not_local_elements_begin () const;
315  const_element_iterator not_local_elements_end () const;
316 
317  const_element_iterator active_local_elements_begin () const;
318  const_element_iterator active_local_elements_end () const;
319 
320  const_element_iterator active_not_local_elements_begin () const;
321  const_element_iterator active_not_local_elements_end () const;
322 
323  const_element_iterator level_elements_begin (const unsigned int level) const;
324  const_element_iterator level_elements_end (const unsigned int level) const;
325 
326  const_element_iterator not_level_elements_begin (const unsigned int level) const;
327  const_element_iterator not_level_elements_end (const unsigned int level) const;
328 
329  const_element_iterator local_level_elements_begin (const unsigned int level) const;
330  const_element_iterator local_level_elements_end (const unsigned int level) const;
331 
332  const_element_iterator local_not_level_elements_begin (const unsigned int level) const;
333  const_element_iterator local_not_level_elements_end (const unsigned int level) const;
334 
335  const_element_iterator pid_elements_begin (const processor_id_type proc_id) const;
336  const_element_iterator pid_elements_end (const processor_id_type proc_id) const;
337 
338  const_element_iterator type_elements_begin (const ElemType type) const;
339  const_element_iterator type_elements_end (const ElemType type) const;
340 
341  const_element_iterator active_type_elements_begin (const ElemType type) const;
342  const_element_iterator active_type_elements_end (const ElemType type) const;
343 
344  const_element_iterator active_pid_elements_begin (const processor_id_type proc_id) const;
345  const_element_iterator active_pid_elements_end (const processor_id_type proc_id) const;
346 
347  const_element_iterator unpartitioned_elements_begin () const;
348  const_element_iterator unpartitioned_elements_end () const;
349 
350  const_element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id) const;
351  const_element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id) const;
352 
353  const_element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id) const;
354  const_element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id) const;
355 
356 
357 
358 
359 
360 
364  node_iterator nodes_begin();
365  node_iterator nodes_end();
366 
367  node_iterator active_nodes_begin();
368  node_iterator active_nodes_end();
369 
370  node_iterator local_nodes_begin ();
371  node_iterator local_nodes_end ();
372 
373  node_iterator pid_nodes_begin (const processor_id_type proc_id);
374  node_iterator pid_nodes_end (const processor_id_type proc_id);
375 
379  const_node_iterator nodes_begin() const;
380  const_node_iterator nodes_end() const;
381 
382  const_node_iterator active_nodes_begin() const;
383  const_node_iterator active_nodes_end() const;
384 
385  const_node_iterator local_nodes_begin () const;
386  const_node_iterator local_nodes_end () const;
387 
388  const_node_iterator pid_nodes_begin (const processor_id_type proc_id) const;
389  const_node_iterator pid_nodes_end (const processor_id_type proc_id) const;
390 
391 protected:
392 
393 #ifdef LIBMESH_ENABLE_UNIQUE_ID
394 
398  virtual void assign_unique_ids();
399 #endif
400 
404  std::vector<Node*> _nodes;
405 
409  std::vector<Elem*> _elements;
410 
411 private:
412 
417  void stitching_helper (SerialMesh* other_mesh,
418  boundary_id_type boundary_id_1,
419  boundary_id_type boundary_id_2,
420  Real tol,
421  bool clear_stitched_boundary_ids,
422  bool verbose,
423  bool use_binary_search,
424  bool enforce_all_nodes_match_on_boundaries);
425 
430  typedef std::vector<Elem*>::iterator elem_iterator_imp;
431  typedef std::vector<Elem*>::const_iterator const_elem_iterator_imp;
432 
437  typedef std::vector<Node*>::iterator node_iterator_imp;
438  typedef std::vector<Node*>::const_iterator const_node_iterator_imp;
439 };
440 
441 
442 
443 } // namespace libMesh
444 
445 
446 
447 #endif // LIBMESH_SERIAL_MESH_H

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

Hosted By:
SourceForge.net Logo