IOSS 2.0
Loading...
Searching...
No Matches
Ioss_ElementPermutation.h
Go to the documentation of this file.
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 <assert.h>
11#include <limits>
12#include <map> // for map, map<>::value_compare
13#include <stdint.h>
14#include <string> // for string, operator<
15#include <vector> // for vector
16
17#include "ioss_export.h"
18
19namespace Ioss {
20 class ElementTopology;
21 class ElementPermutation;
22} // namespace Ioss
23
24namespace Ioss {
25
26 using Ordinal = uint16_t;
27 using Permutation = uint32_t;
28
29 static constexpr Ordinal InvalidOrdinal = std::numeric_limits<Ordinal>::max();
30 static constexpr Permutation InvalidPermutation = std::numeric_limits<Permutation>::max();
31
32 using ElementPermutationMap = std::map<std::string, ElementPermutation *, std::less<>>;
33 using EPM_VP = ElementPermutationMap::value_type;
34
35 class IOSS_EXPORT EPRegistry
36 {
37 public:
38 void insert(const Ioss::EPM_VP &value, bool delete_me);
39 IOSS_NODISCARD ElementPermutationMap::iterator begin() { return m_registry.begin(); }
40 IOSS_NODISCARD ElementPermutationMap::iterator end() { return m_registry.end(); }
41 IOSS_NODISCARD ElementPermutationMap::iterator find(const std::string &type)
42 {
43 return m_registry.find(type);
44 }
45
47
48 private:
50 std::vector<Ioss::ElementPermutation *> m_deleteThese;
51 };
52
53 // Permutation data is stored such that the positive permutations are listed first ... the order
54 // of the positive permutations within that group is irrelevant. The remaining permutations listed
55 // after the positive ones are the negative permutations hence, any permutation index outside of
56 // the positive range is a negative permutation. By convention, the first permutation listed
57 // matches the default listed in the Exodus manual
58
59 class IOSS_EXPORT ElementPermutation
60 {
61 public:
62 IOSS_NODISCARD unsigned num_permutations() const;
63
64 // The number of positive permutations must be less than or equal to the total number of
65 // permutations
66 IOSS_NODISCARD unsigned num_positive_permutations() const;
67
68 IOSS_NODISCARD bool is_positive_polarity(Permutation permutation) const;
69
70 // Permutation type is unsigned so only need to check upper bound
71 IOSS_NODISCARD bool valid_permutation(Permutation permutation) const;
72
73 // For a validated permutation, return the node ordinals
74 bool fill_permutation_indices(Permutation permutation,
75 std::vector<Ordinal> &nodeOrdinalVector) const;
76
77 // For a given permutation, return the node ordinals
78 IOSS_NODISCARD std::vector<Ordinal> permutation_indices(Permutation permutation) const;
79
80 IOSS_NODISCARD Permutation num_permutation_nodes() const;
81
82 IOSS_NODISCARD const std::string &type() const;
83
84 IOSS_NODISCARD static ElementPermutation *factory(const std::string &type);
85
86 /** \brief Get the names of element permutations known to Ioss.
87 *
88 * \param[out] names The list of known element topology names.
89 * \returns The number of known element topologies.
90 */
91 static int describe(NameList *names);
92
93 /** \brief Get the names of element permutations known to Ioss.
94 *
95 * \returns The list of known element topology names.
96 */
97 IOSS_NODISCARD static NameList describe();
98
99 IOSS_NODISCARD bool operator==(const Ioss::ElementPermutation &rhs) const;
100 IOSS_NODISCARD bool operator!=(const Ioss::ElementPermutation &rhs) const;
101 IOSS_NODISCARD bool equal(const Ioss::ElementPermutation &rhs) const;
102
103 protected:
104 explicit ElementPermutation(std::string type, bool delete_me = false);
105
106 // Store low order permutation data regarding this topology .. the positive permutations are
107 // listed first If this topology is a high order topology, the data is only for the nodes of the
108 // associated low order topology. This implies that any usage of this assumes that the higher
109 // order nodes are numbered correctly relative to the low order nodes.
110 //
111 // {{0, 1, 2, 3, 4, 5}, {{0, 1, 2},
112 // {2, 0, 1, 5, 3, 4}, {2, 0, 1},
113 // Tri6 {1, 2, 0, 4, 5, 3}, --> Tri3 {1, 2, 0},
114 // {0, 2, 1, 5, 4, 3}, {0, 2, 1},
115 // {2, 1, 0, 4, 3, 5}, {2, 1, 0},
116 // {1, 0, 2, 3, 5, 4}} {1, 0, 2}}
117
118 void set_permutation(Permutation numPermutationNodes_, Permutation numPermutations_,
119 Permutation numPositivePermutations_,
120 const std::vector<std::vector<Permutation>> &permutationNodeOrdinals_);
121
122 static EPRegistry &registry();
123
124 private:
125 bool equal_(const Ioss::ElementPermutation &rhs, bool quiet) const;
126
127 std::string m_type{};
128 Permutation m_numPermutations{0};
129 Permutation m_numPositivePermutations{0};
130 Permutation m_numPermutationNodes{0};
131 std::vector<std::vector<Permutation>> m_permutationNodeOrdinals{};
132 };
133
134 class IOSS_EXPORT NullPermutation : public ElementPermutation
135 {
136 public:
137 static void factory();
138
139 protected:
141 };
142
143 class IOSS_EXPORT SpherePermutation : public ElementPermutation
144 {
145 public:
146 static void factory();
147
148 protected:
150 };
151
152 class IOSS_EXPORT LinePermutation : public ElementPermutation
153 {
154 public:
155 static void factory();
156
157 protected:
159 };
160
161 class IOSS_EXPORT SpringPermutation : public ElementPermutation
162 {
163 public:
164 static void factory();
165
166 protected:
168 };
169
170 class IOSS_EXPORT TriPermutation : public ElementPermutation
171 {
172 public:
173 static void factory();
174
175 protected:
177 };
178
179 class IOSS_EXPORT QuadPermutation : public ElementPermutation
180 {
181 public:
182 static void factory();
183
184 protected:
186 };
187
188 class IOSS_EXPORT TetPermutation : public ElementPermutation
189 {
190 public:
191 static void factory();
192
193 protected:
195 };
196
197 class IOSS_EXPORT PyramidPermutation : public ElementPermutation
198 {
199 public:
200 static void factory();
201
202 protected:
204 };
205
206 class IOSS_EXPORT WedgePermutation : public ElementPermutation
207 {
208 public:
209 static void factory();
210
211 protected:
213 };
214
215 class IOSS_EXPORT HexPermutation : public ElementPermutation
216 {
217 public:
218 static void factory();
219
220 protected:
222 };
223
224 class IOSS_EXPORT SuperPermutation : public ElementPermutation
225 {
226 public:
227 static void make_super(const std::string &type);
228 static void factory();
229 static void factory(unsigned n);
230
231 static std::string get_name(unsigned n);
232
233 protected:
235 explicit SuperPermutation(unsigned n);
236
237 static std::vector<std::vector<Permutation>> get_super_permutations(unsigned n);
238 };
239} // namespace Ioss
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
Definition Ioss_ElementPermutation.h:36
Ioss::ElementPermutationMap m_registry
Definition Ioss_ElementPermutation.h:49
IOSS_NODISCARD ElementPermutationMap::iterator find(const std::string &type)
Definition Ioss_ElementPermutation.h:41
IOSS_NODISCARD ElementPermutationMap::iterator begin()
Definition Ioss_ElementPermutation.h:39
IOSS_NODISCARD ElementPermutationMap::iterator end()
Definition Ioss_ElementPermutation.h:40
std::vector< Ioss::ElementPermutation * > m_deleteThese
Definition Ioss_ElementPermutation.h:50
Definition Ioss_ElementPermutation.h:60
Definition Ioss_ElementPermutation.h:216
Definition Ioss_ElementPermutation.h:153
Definition Ioss_ElementPermutation.h:135
Definition Ioss_ElementPermutation.h:198
Definition Ioss_ElementPermutation.h:180
Definition Ioss_ElementPermutation.h:144
Definition Ioss_ElementPermutation.h:162
Definition Ioss_ElementPermutation.h:225
Definition Ioss_ElementPermutation.h:189
Definition Ioss_ElementPermutation.h:171
Definition Ioss_ElementPermutation.h:207
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
static constexpr Permutation InvalidPermutation
Definition Ioss_ElementPermutation.h:30
ElementPermutationMap::value_type EPM_VP
Definition Ioss_ElementPermutation.h:33
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
static constexpr Ordinal InvalidOrdinal
Definition Ioss_ElementPermutation.h:29
uint32_t Permutation
Definition Ioss_ElementPermutation.h:27
uint16_t Ordinal
Definition Ioss_ElementPermutation.h:26
std::map< std::string, ElementPermutation *, std::less<> > ElementPermutationMap
Definition Ioss_ElementPermutation.h:32