IOSS  2.0
Ioss_ElementTopology.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6 
7 #ifndef IOSS_Ioss_Element_Topology_h
8 #define IOSS_Ioss_Element_Topology_h
9 
10 #include <Ioss_CodeTypes.h>
11 #include <map> // for map, map<>::value_compare
12 #include <string> // for string, operator<
13 #include <vector> // for vector
14 namespace Ioss {
15  class ElementTopology;
16 } // namespace Ioss
17 
18 namespace Ioss {
19  enum class ElementShape { UNKNOWN, POINT, LINE, TRI, QUAD, TET, PYRAMID, WEDGE, HEX };
20 
21  using ElementTopologyMap = std::map<std::string, ElementTopology *, std::less<std::string>>;
22  using ETM_VP = ElementTopologyMap::value_type;
23 
24  class ETRegistry
25  {
26  public:
27  void insert(const Ioss::ETM_VP &value, bool delete_me);
28  ElementTopologyMap::iterator begin() { return m_registry.begin(); }
29  ElementTopologyMap::iterator end() { return m_registry.end(); }
30  ElementTopologyMap::iterator find(const std::string &type) { return m_registry.find(type); }
31 
32  ~ETRegistry();
33  std::map<std::string, std::string> customFieldTypes;
34 
35  private:
37  std::vector<Ioss::ElementTopology *> m_deleteThese;
38  };
39 
40  // ========================================================================
41 
42  /** \brief Represents an element topology.
43  *
44  * Defines node, edge, and face connectivity information of an element.
45  */
47  {
48  public:
49  void alias(const std::string &base, const std::string &syn);
50  bool is_alias(const std::string &my_alias) const;
51 
52  ElementTopology(const ElementTopology &) = delete;
54 
55  virtual ~ElementTopology();
56 
57  const std::string &name() const { return name_; }
58 
59  //: Return the Sierra master element name corresponding to this
60  //: element topology. Somewhat klugy coupling between IO subsystem
61  //: and Sierra, but least klugy I could think of...
62  std::string master_element_name() const { return masterElementName_; }
63 
64  //: Return basic shape...
65  virtual ElementShape shape() const = 0;
66 
67  //: Return whether the topology describes an "element". If it
68  //: isn't an element, then it is a component of an element. For
69  // example, a quadrilater Shell is an element, but a QuadFace is
70  // not.
71  //
72  // Default implementation returns true if spatial_dimension() ==
73  // parametric_dimension(), otherwise returns false;
74  // "Structural" elements (shells, rods, trusses, particles) need
75  // to override.
76  virtual bool is_element() const;
77  virtual int spatial_dimension() const = 0;
78  virtual int parametric_dimension() const = 0;
79  virtual int order() const = 0;
80 
81  virtual bool edges_similar() const; // true if all edges have same topology
82  virtual bool faces_similar() const; // true if all faces have same topology
83 
84  virtual int number_corner_nodes() const = 0;
85  virtual int number_nodes() const = 0;
86  virtual int number_edges() const = 0;
87  virtual int number_faces() const = 0;
88  int number_boundaries() const;
89 
90  virtual int number_nodes_edge(int edge = 0) const = 0;
91  virtual int number_nodes_face(int face = 0) const = 0;
92  virtual int number_edges_face(int face = 0) const = 0;
93 
94  IntVector boundary_connectivity(int edge_number) const;
95  virtual IntVector edge_connectivity(int edge_number) const = 0;
96  virtual IntVector face_connectivity(int face_number) const = 0;
97  virtual IntVector element_connectivity() const = 0;
98 
99  // These have default implementations in ElementTopology.
100  // The defaults simply fill in the vector with 0..num.
101  // For 'face_edge_connectivity', this is sufficient for 2d
102  // elements, 3d need to override.
103  // For 'element_edge_connectivity', this works for all elements.
104  virtual IntVector face_edge_connectivity(int face_number) const;
106 
107  ElementTopology * boundary_type(int face_number = 0) const;
108  virtual ElementTopology *face_type(int face_number = 0) const = 0;
109  virtual ElementTopology *edge_type(int edge_number = 0) const = 0;
110 
111  static ElementTopology *factory(const std::string &type, bool ok_to_fail = false);
112  static ElementTopology *factory(unsigned int unique_id);
113  static unsigned int get_unique_id(const std::string &type);
114  static int describe(NameList *names);
115 
116  protected:
117  ElementTopology(std::string type, std::string master_elem_name, bool delete_me = false);
118 
119  private:
120  const std::string name_;
121  const std::string masterElementName_;
122 
123  static ETRegistry &registry();
124  };
125 } // namespace Ioss
126 #endif
Ioss::ETRegistry::insert
void insert(const Ioss::ETM_VP &value, bool delete_me)
Definition: Ioss_ElementTopology.C:20
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:27
Ioss::ElementTopology::number_corner_nodes
virtual int number_corner_nodes() const =0
Ioss::ElementTopology::number_faces
virtual int number_faces() const =0
Ioss::ElementTopology::get_unique_id
static unsigned int get_unique_id(const std::string &type)
Definition: Ioss_ElementTopology.C:123
Ioss::ElementTopology::boundary_connectivity
IntVector boundary_connectivity(int edge_number) const
Definition: Ioss_ElementTopology.C:235
Ioss::ElementTopology::face_edge_connectivity
virtual IntVector face_edge_connectivity(int face_number) const
Definition: Ioss_ElementTopology.C:159
Ioss::ElementTopology::name_
const std::string name_
Definition: Ioss_ElementTopology.h:120
Ioss::ETRegistry::begin
ElementTopologyMap::iterator begin()
Definition: Ioss_ElementTopology.h:28
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:25
Ioss::ElementTopology::element_connectivity
virtual IntVector element_connectivity() const =0
Ioss::ElementTopology::describe
static int describe(NameList *names)
Get the names of element topologies known to Ioss.
Definition: Ioss_ElementTopology.C:149
Ioss::ETRegistry::m_deleteThese
std::vector< Ioss::ElementTopology * > m_deleteThese
Definition: Ioss_ElementTopology.h:37
Ioss::ETRegistry::m_registry
Ioss::ElementTopologyMap m_registry
Definition: Ioss_ElementTopology.h:36
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
Ioss::ETRegistry::customFieldTypes
std::map< std::string, std::string > customFieldTypes
Definition: Ioss_ElementTopology.h:33
Ioss::ElementShape::UNKNOWN
@ UNKNOWN
Ioss::ElementTopology::master_element_name
std::string master_element_name() const
Definition: Ioss_ElementTopology.h:62
Ioss::ElementTopology::edge_type
virtual ElementTopology * edge_type(int edge_number=0) const =0
Ioss::ETRegistry::~ETRegistry
~ETRegistry()
Definition: Ioss_ElementTopology.C:28
Ioss::ElementTopology::number_nodes_edge
virtual int number_nodes_edge(int edge=0) const =0
Ioss::ElementTopology::faces_similar
virtual bool faces_similar() const
Definition: Ioss_ElementTopology.C:66
Ioss::ElementTopology::number_edges
virtual int number_edges() const =0
Ioss::ElementTopology::number_nodes_face
virtual int number_nodes_face(int face=0) const =0
Ioss::ElementTopology::edges_similar
virtual bool edges_similar() const
Definition: Ioss_ElementTopology.C:65
Ioss::ETRegistry::find
ElementTopologyMap::iterator find(const std::string &type)
Definition: Ioss_ElementTopology.h:30
Ioss::ETRegistry
Definition: Ioss_ElementTopology.h:25
Ioss::ElementTopology::parametric_dimension
virtual int parametric_dimension() const =0
Ioss::ElementTopology::operator=
ElementTopology & operator=(const ElementTopology &)=delete
Ioss::ElementTopology::number_boundaries
int number_boundaries() const
Definition: Ioss_ElementTopology.C:202
Ioss::ElementTopology::order
virtual int order() const =0
Ioss::ElementTopology::edge_connectivity
virtual IntVector edge_connectivity(int edge_number) const =0
Ioss::ElementTopology::number_edges_face
virtual int number_edges_face(int face=0) const =0
Ioss::ElementTopology::face_connectivity
virtual IntVector face_connectivity(int face_number) const =0
Ioss::ElementTopology::shape
virtual ElementShape shape() const =0
Ioss::ElementTopology
Represents an element topology.
Definition: Ioss_ElementTopology.h:47
Ioss::ElementTopology::is_alias
bool is_alias(const std::string &my_alias) const
Definition: Ioss_ElementTopology.C:185
Ioss::ElementTopology::name
const std::string & name() const
Definition: Ioss_ElementTopology.h:57
Ioss::ElementTopology::element_edge_connectivity
IntVector element_edge_connectivity() const
Definition: Ioss_ElementTopology.C:174
Ioss::ElementTopology::boundary_type
ElementTopology * boundary_type(int face_number=0) const
Definition: Ioss_ElementTopology.C:273
Ioss::ElementTopology::number_nodes
virtual int number_nodes() const =0
Ioss::ElementTopology::masterElementName_
const std::string masterElementName_
Definition: Ioss_ElementTopology.h:121
Ioss::ElementTopologyMap
std::map< std::string, ElementTopology *, std::less< std::string > > ElementTopologyMap
Definition: Ioss_ElementTopology.h:21
Ioss::ETRegistry::end
ElementTopologyMap::iterator end()
Definition: Ioss_ElementTopology.h:29
Ioss::ElementShape
ElementShape
Definition: Ioss_ElementTopology.h:19
Ioss::ETM_VP
ElementTopologyMap::value_type ETM_VP
Definition: Ioss_ElementTopology.h:22
Ioss::ElementTopology::registry
static ETRegistry & registry()
Definition: Ioss_ElementTopology.C:57
Ioss::ElementTopology::factory
static ElementTopology * factory(const std::string &type, bool ok_to_fail=false)
Definition: Ioss_ElementTopology.C:68
Ioss::ElementTopology::spatial_dimension
virtual int spatial_dimension() const =0
Ioss::ElementTopology::is_element
virtual bool is_element() const
Definition: Ioss_ElementTopology.C:195
Ioss_CodeTypes.h
Ioss::ElementTopology::ElementTopology
ElementTopology(const ElementTopology &)=delete
Ioss::ElementTopology::alias
void alias(const std::string &base, const std::string &syn)
Definition: Ioss_ElementTopology.C:48
Ioss::ElementTopology::face_type
virtual ElementTopology * face_type(int face_number=0) const =0
Ioss::ElementTopology::~ElementTopology
virtual ~ElementTopology()