Debian Codegraph @

packages/seacas/libraries/ioss/src/Ioss_ElementTopology.h

raw
1 // Copyright(C) 1999-2024 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 #pragma once
8
9 #include "Ioss_CodeTypes.h"
10 #include "Ioss_ElementPermutation.h" // for ElementPermutation
11 #include <map> // for map, map<>::value_compare
12 #include <set> // for set
13 #include <string> // for string, operator<
14 #include <vector> // for vector
15
16 #include "ioss_export.h"
17
18 namespace Ioss {
19 class ElementTopology;
20 class ElementPermutation;
21 } // namespace Ioss
22
23 namespace Ioss {
24 enum class ElementShape : unsigned {
25 UNKNOWN,
26 POINT,
27 SPHERE,
28 LINE,
29 SPRING,
30 TRI,
31 QUAD,
32 TET,
33 PYRAMID,
34 WEDGE,
35 HEX,
36 SUPER
37 };
38
39 using ElementShapeMap = std::map<ElementShape, std::string>;
40 using ElementTopologyMap = std::map<std::string, ElementTopology *, std::less<>>;
41 using ETM_VP = ElementTopologyMap::value_type;
42
43 class IOSS_EXPORT ETRegistry
44 {
45 public:
46 void insert(const Ioss::ETM_VP &value, bool delete_me);
47 IOSS_NODISCARD ElementTopologyMap::iterator begin() { return m_registry.begin(); }
48 IOSS_NODISCARD ElementTopologyMap::iterator end() { return m_registry.end(); }
49 IOSS_NODISCARD ElementTopologyMap::iterator find(const std::string &type)
50 {
51 return m_registry.find(type);
52 }
53
54 ~ETRegistry();
55
56 private:
57 Ioss::ElementTopologyMap m_registry;
58 std::vector<Ioss::ElementTopology *> m_deleteThese;
59 };
60
61 // ========================================================================
62
63 /** \brief Represents an element topology.
64 *
65 * Defines node, edge, and face connectivity information of an element.
66 */
67 class IOSS_EXPORT ElementTopology
68 {
69 public:
70 void alias(const std::string &base, const std::string &syn);
71 IOSS_NODISCARD bool is_alias(const std::string &my_alias) const;
72
73 ElementTopology(const ElementTopology &) = delete;
74 ElementTopology &operator=(const ElementTopology &) = delete;
75
76 virtual ~ElementTopology() = default;
77
78 IOSS_NODISCARD const std::string &name() const { return name_; }
79
80 //: Return the Sierra master element name corresponding to this
81 //: element topology. Somewhat klugy coupling between IO subsystem
82 //: and Sierra, but least klugy I could think of...
83 IOSS_NODISCARD std::string master_element_name() const { return masterElementName_; }
84
85 //: Return basic shape...
86 IOSS_NODISCARD virtual ElementShape shape() const = 0;
87
88 //: Return whether the topology describes an "element". If it
89 //: isn't an element, then it is a component of an element. For
90 // example, a quadrilateral Shell is an element, but a QuadFace is
91 // not.
92 //
93 // Default implementation returns true if spatial_dimension() ==
94 // parametric_dimension(), otherwise returns false;
95 // "Structural" elements (shells, rods, trusses, particles) need
96 // to override.
97 IOSS_NODISCARD virtual bool is_element() const;
98 IOSS_NODISCARD virtual bool is_shell() const = 0;
99 IOSS_NODISCARD virtual int spatial_dimension() const = 0;
100 IOSS_NODISCARD virtual int parametric_dimension() const = 0;
101 IOSS_NODISCARD virtual int order() const = 0;
102
103 IOSS_NODISCARD virtual bool edges_similar() const; // true if all edges have same topology
104 IOSS_NODISCARD virtual bool faces_similar() const; // true if all faces have same topology
105
106 IOSS_NODISCARD virtual int number_corner_nodes() const = 0;
107 IOSS_NODISCARD virtual int number_nodes() const = 0;
108 IOSS_NODISCARD virtual int number_edges() const = 0;
109 IOSS_NODISCARD virtual int number_faces() const = 0;
110 IOSS_NODISCARD int number_boundaries() const;
111
112 IOSS_NODISCARD virtual int number_nodes_edge(int edge = 0) const = 0;
113 IOSS_NODISCARD virtual int number_nodes_face(int face = 0) const = 0;
114 IOSS_NODISCARD virtual int number_edges_face(int face = 0) const = 0;
115
116 IOSS_NODISCARD IntVector boundary_connectivity(int edge_number) const;
117 IOSS_NODISCARD virtual IntVector edge_connectivity(int edge_number) const = 0;
118 IOSS_NODISCARD virtual IntVector face_connectivity(int face_number) const = 0;
119 IOSS_NODISCARD virtual IntVector element_connectivity() const = 0;
120
121 // These have default implementations in ElementTopology.
122 // The defaults simply fill in the vector with 0..num.
123 // For 'face_edge_connectivity', this is sufficient for 2d
124 // elements, 3d need to override.
125 // For 'element_edge_connectivity', this works for all elements.
126 IOSS_NODISCARD virtual IntVector face_edge_connectivity(int face_number) const;
127 IOSS_NODISCARD IntVector element_edge_connectivity() const;
128
129 IOSS_NODISCARD ElementTopology *boundary_type(int face_number = 0) const;
130 IOSS_NODISCARD virtual ElementTopology *face_type(int face_number = 0) const = 0;
131 IOSS_NODISCARD virtual ElementTopology *edge_type(int edge_number = 0) const = 0;
132
133 IOSS_NODISCARD static ElementTopology *factory(const std::string &type,
134 bool ok_to_fail = false);
135 IOSS_NODISCARD static ElementTopology *factory(unsigned int unique_id);
136 IOSS_NODISCARD static unsigned int get_unique_id(const std::string &type);
137 static int describe(NameList *names);
138 IOSS_NODISCARD static NameList describe();
139
140 IOSS_NODISCARD bool operator==(const Ioss::ElementTopology &rhs) const;
141 IOSS_NODISCARD bool operator!=(const Ioss::ElementTopology &rhs) const;
142 IOSS_NODISCARD bool equal(const Ioss::ElementTopology &rhs) const;
143
144 IOSS_NODISCARD ElementPermutation *permutation() const;
145 IOSS_NODISCARD virtual const std::string &base_topology_permutation_name() const;
146
147 protected:
148 ElementTopology(std::string type, std::string master_elem_name, bool delete_me = false);
149 IOSS_NODISCARD virtual bool validate_permutation_nodes() const { return true; }
150
151 private:
152 IOSS_NODISCARD bool equal_(const Ioss::ElementTopology &rhs, bool quiet) const;
153 const std::string name_;
154 const std::string masterElementName_;
155
156 static const std::string &topology_shape_to_permutation_name(Ioss::ElementShape topoShape);
157
158 static ETRegistry &registry();
159 };
160 } // namespace Ioss