mesh_base.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_MESH_BASE_H
21 #define LIBMESH_MESH_BASE_H
22 
23 
24 
25 // Local Includes -----------------------------------
26 #include "libmesh/auto_ptr.h"
27 #include "libmesh/boundary_info.h"
28 #include "libmesh/dof_object.h" // for invalid_processor_id
29 #include "libmesh/enum_elem_type.h"
30 #include "libmesh/libmesh_common.h"
32 #include "libmesh/partitioner.h" // AutoPtr needs a real declaration
36 
37 // C++ Includes -----------------------------------
38 #include <cstddef>
39 #include <string>
40 
41 namespace libMesh
42 {
43 
44 // forward declarations
45 class Elem;
46 class Node;
47 class Point;
48 class MeshData;
49 
50 
51 
67 // ------------------------------------------------------------
68 // MeshBase class definition
69 class MeshBase : public ParallelObject
70 {
71 public:
72 
79  unsigned int dim=1);
80 
81 #ifndef LIBMESH_DISABLE_COMMWORLD
82 
87  MeshBase (unsigned int dim=1);
88 #endif
89 
93  MeshBase (const MeshBase& other_mesh);
94 
98  virtual AutoPtr<MeshBase> clone() const = 0;
99 
103  virtual ~MeshBase ();
104 
111 
116 
120  virtual void clear ();
121 
126  bool is_prepared () const
127  { return _is_prepared; }
128 
133  virtual bool is_serial () const
134  { return true; }
135 
140  virtual void allgather () {}
141 
147  virtual void delete_remote_elements () {}
148 
155  unsigned int mesh_dimension () const
156  { return static_cast<unsigned int>(_dim); }
157 
161  void set_mesh_dimension (unsigned int d)
162  { _dim = d; }
163 
168  unsigned int spatial_dimension () const
169  { return static_cast<unsigned int>(LIBMESH_DIM); }
170 
178  virtual dof_id_type n_nodes () const = 0;
179 
187  virtual dof_id_type parallel_n_nodes () const = 0;
188 
192  dof_id_type n_nodes_on_proc (const processor_id_type proc) const;
193 
198  { return this->n_nodes_on_proc (this->processor_id()); }
199 
205 
210  virtual dof_id_type max_node_id () const = 0;
211 
212 #ifdef LIBMESH_ENABLE_UNIQUE_ID
213 
217 
222 #endif
223 
231  virtual void reserve_nodes (const dof_id_type nn) = 0;
232 
238  virtual dof_id_type n_elem () const = 0;
239 
246  virtual dof_id_type parallel_n_elem () const = 0;
247 
252  virtual dof_id_type max_elem_id () const = 0;
253 
261  virtual void reserve_elem (const dof_id_type ne) = 0;
262 
267  virtual void update_parallel_id_counts () = 0;
268 
273  virtual dof_id_type n_active_elem () const = 0;
274 
278  dof_id_type n_elem_on_proc (const processor_id_type proc) const;
279 
284  { return this->n_elem_on_proc (this->processor_id()); }
285 
291 
296 
301  { return this->n_active_elem_on_proc (this->processor_id()); }
302 
310  dof_id_type n_sub_elem () const;
311 
316 
322  virtual const Point& point (const dof_id_type i) const = 0;
323 
329  virtual const Node& node (const dof_id_type i) const = 0;
330 
335  virtual Node& node (const dof_id_type i) = 0;
336 
341  virtual const Node* node_ptr (const dof_id_type i) const = 0;
342 
348  virtual Node* node_ptr (const dof_id_type i) = 0;
349 
354  virtual const Node* query_node_ptr (const dof_id_type i) const = 0;
355 
360  virtual Node* query_node_ptr (const dof_id_type i) = 0;
361 
366  virtual const Elem* elem (const dof_id_type i) const = 0;
367 
373  virtual Elem* elem (const dof_id_type i) = 0;
374 
379  virtual const Elem* query_elem (const dof_id_type i) const = 0;
380 
385  virtual Elem* query_elem (const dof_id_type i) = 0;
386 
397  virtual Node* add_point (const Point& p,
399  const processor_id_type proc_id =
401 
405  virtual Node* add_node (Node* n) = 0;
406 
414  virtual Node* insert_node(Node* n) = 0;
415 
419  virtual void delete_node (Node* n) = 0;
420 
426  virtual void renumber_node (dof_id_type old_id, dof_id_type new_id) = 0;
427 
434  virtual Elem* add_elem (Elem* e) = 0;
435 
440  virtual Elem* insert_elem (Elem* e) = 0;
441 
448  virtual void delete_elem (Elem* e) = 0;
449 
455  virtual void renumber_elem (dof_id_type old_id, dof_id_type new_id) = 0;
456 
469  virtual void find_neighbors (const bool reset_remote_elements = false,
470  const bool reset_current_list = true) = 0;
471 
477  virtual void renumber_nodes_and_elements () = 0;
478 
485  virtual void fix_broken_node_and_element_numbering () = 0;
486 
487 
488 #ifdef LIBMESH_ENABLE_AMR
489 
494  virtual bool contract () = 0;
495 #endif
496 
507  void prepare_for_use (const bool skip_renumber_nodes_and_elements=false);
508 
512  virtual void partition (const unsigned int n_parts);
513 
514  void partition ()
515  { this->partition(this->n_processors()); }
516 
522  virtual void redistribute () {}
523 
528  virtual void update_post_partitioning () {}
529 
538 
551  void skip_partitioning(bool skip) { _skip_partitioning = skip; }
552  bool skip_partitioning() const { return _skip_partitioning; }
553 
561  void subdomain_ids (std::set<subdomain_id_type> &ids) const;
562 
571 
578  unsigned int n_partitions () const
579  { return _n_parts; }
580 
585  std::string get_info () const;
586 
590  void print_info (std::ostream& os=libMesh::out) const;
591 
597  friend std::ostream& operator << (std::ostream& os, const MeshBase& m);
598 
603  virtual void read (const std::string& name, MeshData* mesh_data=NULL,
604  bool skip_renumber_nodes_and_elements=false) = 0;
605  virtual void write (const std::string& name, MeshData* mesh_data=NULL) = 0;
606 
613  virtual void all_first_order () = 0;
614 
626  virtual void all_second_order (const bool full_ordered=true) = 0;
627 
633 
640  struct element_iterator;
641  struct const_element_iterator;
642 
649  struct node_iterator;
650  struct const_node_iterator;
651 
661  unsigned int recalculate_n_partitions();
662 
669  const PointLocatorBase& point_locator () const;
670 
679 
683  void clear_point_locator ();
684 
692  virtual void libmesh_assert_valid_parallel_ids() const {}
693 
698  std::string& subdomain_name(subdomain_id_type id);
699  const std::string& subdomain_name(subdomain_id_type id) const;
700 
705  subdomain_id_type get_id_by_name(const std::string& name) const;
706 
707 public:
708 
709 
710 
715  virtual element_iterator elements_begin () = 0;
716  virtual element_iterator elements_end () = 0;
717  virtual element_iterator active_elements_begin () = 0;
718  virtual element_iterator active_elements_end () = 0;
719  virtual element_iterator ancestor_elements_begin () = 0;
720  virtual element_iterator ancestor_elements_end () = 0;
721  virtual element_iterator subactive_elements_begin () = 0;
722  virtual element_iterator subactive_elements_end () = 0;
723  virtual element_iterator not_active_elements_begin () = 0;
724  virtual element_iterator not_active_elements_end () = 0;
725  virtual element_iterator not_ancestor_elements_begin () = 0;
726  virtual element_iterator not_ancestor_elements_end () = 0;
727  virtual element_iterator not_subactive_elements_begin () = 0;
728  virtual element_iterator not_subactive_elements_end () = 0;
729  virtual element_iterator local_elements_begin () = 0;
730  virtual element_iterator local_elements_end () = 0;
731  virtual element_iterator not_local_elements_begin () = 0;
732  virtual element_iterator not_local_elements_end () = 0;
733  virtual element_iterator active_local_elements_begin () = 0;
734  virtual element_iterator active_local_elements_end () = 0;
735  virtual element_iterator active_not_local_elements_begin () = 0;
736  virtual element_iterator active_not_local_elements_end () = 0;
737  virtual element_iterator level_elements_begin (const unsigned int level ) = 0;
738  virtual element_iterator level_elements_end (const unsigned int level ) = 0;
739  virtual element_iterator not_level_elements_begin (const unsigned int level ) = 0;
740  virtual element_iterator not_level_elements_end (const unsigned int level ) = 0;
741  virtual element_iterator local_level_elements_begin (const unsigned int level ) = 0;
742  virtual element_iterator local_level_elements_end (const unsigned int level ) = 0;
743  virtual element_iterator local_not_level_elements_begin (const unsigned int level ) = 0;
744  virtual element_iterator local_not_level_elements_end (const unsigned int level ) = 0;
745  virtual element_iterator pid_elements_begin (const processor_id_type proc_id) = 0;
746  virtual element_iterator pid_elements_end (const processor_id_type proc_id) = 0;
747  virtual element_iterator type_elements_begin (const ElemType type ) = 0;
748  virtual element_iterator type_elements_end (const ElemType type ) = 0;
749  virtual element_iterator active_type_elements_begin (const ElemType type ) = 0;
750  virtual element_iterator active_type_elements_end (const ElemType type ) = 0;
751  virtual element_iterator active_pid_elements_begin (const processor_id_type proc_id) = 0;
752  virtual element_iterator active_pid_elements_end (const processor_id_type proc_id) = 0;
753  virtual element_iterator unpartitioned_elements_begin () = 0;
754  virtual element_iterator unpartitioned_elements_end () = 0;
755  virtual element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id) = 0;
756  virtual element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id) = 0;
757  virtual element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id) = 0;
758  virtual element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id) = 0;
759 
760 
761 
762 
766  virtual const_element_iterator elements_begin () const = 0;
767  virtual const_element_iterator elements_end () const = 0;
768  virtual const_element_iterator active_elements_begin () const = 0;
769  virtual const_element_iterator active_elements_end () const = 0;
770  virtual const_element_iterator ancestor_elements_begin () const = 0;
771  virtual const_element_iterator ancestor_elements_end () const = 0;
772  virtual const_element_iterator subactive_elements_begin () const = 0;
773  virtual const_element_iterator subactive_elements_end () const = 0;
774  virtual const_element_iterator not_active_elements_begin () const = 0;
775  virtual const_element_iterator not_active_elements_end () const = 0;
776  virtual const_element_iterator not_ancestor_elements_begin () const = 0;
777  virtual const_element_iterator not_ancestor_elements_end () const = 0;
778  virtual const_element_iterator not_subactive_elements_begin () const = 0;
779  virtual const_element_iterator not_subactive_elements_end () const = 0;
780  virtual const_element_iterator local_elements_begin () const = 0;
781  virtual const_element_iterator local_elements_end () const = 0;
782  virtual const_element_iterator not_local_elements_begin () const = 0;
783  virtual const_element_iterator not_local_elements_end () const = 0;
784  virtual const_element_iterator active_local_elements_begin () const = 0;
785  virtual const_element_iterator active_local_elements_end () const = 0;
786  virtual const_element_iterator active_not_local_elements_begin () const = 0;
787  virtual const_element_iterator active_not_local_elements_end () const = 0;
788  virtual const_element_iterator level_elements_begin (const unsigned int level) const = 0;
789  virtual const_element_iterator level_elements_end (const unsigned int level) const = 0;
790  virtual const_element_iterator not_level_elements_begin (const unsigned int level) const = 0;
791  virtual const_element_iterator not_level_elements_end (const unsigned int level) const = 0;
792  virtual const_element_iterator local_level_elements_begin (const unsigned int level) const = 0;
793  virtual const_element_iterator local_level_elements_end (const unsigned int level) const = 0;
794  virtual const_element_iterator local_not_level_elements_begin (const unsigned int level) const = 0;
795  virtual const_element_iterator local_not_level_elements_end (const unsigned int level) const = 0;
796  virtual const_element_iterator pid_elements_begin (const processor_id_type proc_id) const = 0;
797  virtual const_element_iterator pid_elements_end (const processor_id_type proc_id) const = 0;
798  virtual const_element_iterator type_elements_begin (const ElemType type) const = 0;
799  virtual const_element_iterator type_elements_end (const ElemType type) const = 0;
800  virtual const_element_iterator active_type_elements_begin (const ElemType type) const = 0;
801  virtual const_element_iterator active_type_elements_end (const ElemType type) const = 0;
802  virtual const_element_iterator active_pid_elements_begin (const processor_id_type proc_id) const = 0;
803  virtual const_element_iterator active_pid_elements_end (const processor_id_type proc_id) const = 0;
804  virtual const_element_iterator unpartitioned_elements_begin () const = 0;
805  virtual const_element_iterator unpartitioned_elements_end () const = 0;
806  virtual const_element_iterator active_local_subdomain_elements_begin (const subdomain_id_type subdomain_id) const = 0;
807  virtual const_element_iterator active_local_subdomain_elements_end (const subdomain_id_type subdomain_id) const = 0;
808  virtual const_element_iterator active_subdomain_elements_begin (const subdomain_id_type subdomain_id) const = 0;
809  virtual const_element_iterator active_subdomain_elements_end (const subdomain_id_type subdomain_id) const = 0;
810 
811 
815  virtual node_iterator nodes_begin () = 0;
816  virtual node_iterator nodes_end () = 0;
817  virtual node_iterator active_nodes_begin () = 0;
818  virtual node_iterator active_nodes_end () = 0;
819  virtual node_iterator local_nodes_begin () = 0;
820  virtual node_iterator local_nodes_end () = 0;
821  virtual node_iterator pid_nodes_begin (const processor_id_type proc_id) = 0;
822  virtual node_iterator pid_nodes_end (const processor_id_type proc_id) = 0;
823 
824 
828  virtual const_node_iterator nodes_begin () const = 0;
829  virtual const_node_iterator nodes_end () const = 0;
830  virtual const_node_iterator active_nodes_begin () const = 0;
831  virtual const_node_iterator active_nodes_end () const = 0;
832  virtual const_node_iterator local_nodes_begin () const = 0;
833  virtual const_node_iterator local_nodes_end () const = 0;
834  virtual const_node_iterator pid_nodes_begin (const processor_id_type proc_id) const = 0;
835  virtual const_node_iterator pid_nodes_end (const processor_id_type proc_id) const = 0;
836 
837 
841  std::map<subdomain_id_type, std::string>& set_subdomain_name_map ()
842  { return _block_id_to_name; }
843  const std::map<subdomain_id_type, std::string>& get_subdomain_name_map () const
844  { return _block_id_to_name; }
845 
846 protected:
847 
852 #ifdef LIBMESH_ENABLE_UNIQUE_ID
853  virtual void assign_unique_ids() = 0;
854 #endif
855 
859  unsigned int& set_n_partitions ()
860  { return _n_parts; }
861 
871  unsigned int _n_parts;
872 
876  unsigned int _dim;
877 
882 
891 
899 
900 #ifdef LIBMESH_ENABLE_UNIQUE_ID
901 
905 #endif
906 
911 
918 
924  std::map<subdomain_id_type, std::string> _block_id_to_name;
925 
930  friend class Partitioner;
931 
936  friend class BoundaryInfo;
937 
938 private:
945  MeshBase& operator= (const MeshBase& other);
946 };
947 
948 
949 
950 
951 
952 
953 
954 
955 
956 
957 
961 struct
964  Elem*>
965 {
966  // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
967  template <typename PredType, typename IterType>
968  element_iterator (const IterType& d,
969  const IterType& e,
970  const PredType& p ) :
972  Elem*>(d,e,p) {}
973 };
974 
975 
976 
977 
982 struct
985  Elem* const,
986  Elem* const&,
987  Elem* const*>
988 {
989  // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
990  template <typename PredType, typename IterType>
991  const_element_iterator (const IterType& d,
992  const IterType& e,
993  const PredType& p ) :
995  Elem* const,
996  Elem* const&,
997  Elem* const*>(d,e,p) {}
998 
999 
1000  // The conversion-to-const ctor. Takes a regular iterator and calls the appropriate
1001  // variant_filter_iterator copy constructor. Note that this one is *not* templated!
1004  Elem* const,
1005  Elem* const&,
1006  Elem* const*>(rhs)
1007  {
1008  // libMesh::out << "Called element_iterator conversion-to-const ctor." << std::endl;
1009  }
1010 };
1011 
1012 
1013 
1014 
1015 
1016 
1017 
1021 struct
1024  Node*>
1025 {
1026  // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
1027  template <typename PredType, typename IterType>
1028  node_iterator (const IterType& d,
1029  const IterType& e,
1030  const PredType& p ) :
1032  Node*>(d,e,p) {}
1033 };
1034 
1035 
1036 
1037 
1042 struct
1045  Node* const,
1046  Node* const &,
1047  Node* const *>
1048 {
1049  // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
1050  template <typename PredType, typename IterType>
1051  const_node_iterator (const IterType& d,
1052  const IterType& e,
1053  const PredType& p ) :
1055  Node* const,
1056  Node* const &,
1057  Node* const *>(d,e,p) {}
1058 
1059 
1060  // The conversion-to-const ctor. Takes a regular iterator and calls the appropriate
1061  // variant_filter_iterator copy constructor. Note that this one is *not* templated!
1064  Node* const,
1065  Node* const &,
1066  Node* const *>(rhs)
1067  {
1068  // libMesh::out << "Called node_iterator conversion-to-const ctor." << std::endl;
1069  }
1070 };
1071 
1072 
1073 } // namespace libMesh
1074 
1075 #endif // LIBMESH_MESH_BASE_H

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

Hosted By:
SourceForge.net Logo