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:
64
65 virtual ~ElementPermutation() = default;
66
67 IOSS_NODISCARD unsigned num_permutations() const;
68
69 // The number of positive permutations must be less than or equal to the total number of
70 // permutations
71 IOSS_NODISCARD unsigned num_positive_permutations() const;
72
73 IOSS_NODISCARD bool is_positive_polarity(Permutation permutation) const;
74
75 // Permutation type is unsigned so only need to check upper bound
76 IOSS_NODISCARD bool valid_permutation(Permutation permutation) const;
77
78 // For a validated permutation, return the node ordinals
79 bool fill_permutation_indices(Permutation permutation,
80 std::vector<Ordinal> &nodeOrdinalVector) const;
81
82 // For a given permutation, return the node ordinals
83 IOSS_NODISCARD std::vector<Ordinal> permutation_indices(Permutation permutation) const;
84
85 IOSS_NODISCARD Permutation num_permutation_nodes() const;
86
87 IOSS_NODISCARD const std::string &type() const;
88
89 IOSS_NODISCARD static ElementPermutation *factory(const std::string &type);
90
91 /** \brief Get the names of element permutations known to Ioss.
92 *
93 * \param[out] names The list of known element topology names.
94 * \returns The number of known element topologies.
95 */
96 static int describe(NameList *names);
97
98 /** \brief Get the names of element permutations known to Ioss.
99 *
100 * \returns The list of known element topology names.
101 */
102 IOSS_NODISCARD static NameList describe();
103
104 IOSS_NODISCARD bool operator==(const Ioss::ElementPermutation &rhs) const;
105 IOSS_NODISCARD bool operator!=(const Ioss::ElementPermutation &rhs) const;
106 IOSS_NODISCARD bool equal(const Ioss::ElementPermutation &rhs) const;
107
108 protected:
109 explicit ElementPermutation(std::string type, bool delete_me = false);
110
111 // Store low order permutation data regarding this topology .. the positive permutations are
112 // listed first If this topology is a high order topology, the data is only for the nodes of the
113 // associated low order topology. This implies that any usage of this assumes that the higher
114 // order nodes are numbered correctly relative to the low order nodes.
115 //
116 // {{0, 1, 2, 3, 4, 5}, {{0, 1, 2},
117 // {2, 0, 1, 5, 3, 4}, {2, 0, 1},
118 // Tri6 {1, 2, 0, 4, 5, 3}, --> Tri3 {1, 2, 0},
119 // {0, 2, 1, 5, 4, 3}, {0, 2, 1},
120 // {2, 1, 0, 4, 3, 5}, {2, 1, 0},
121 // {1, 0, 2, 3, 5, 4}} {1, 0, 2}}
122
123 void set_permutation(Permutation numPermutationNodes_, Permutation numPermutations_,
124 Permutation numPositivePermutations_,
125 const std::vector<std::vector<Permutation>> &permutationNodeOrdinals_);
126
127 static EPRegistry &registry();
128
129 private:
130 bool equal_(const Ioss::ElementPermutation &rhs, bool quiet) const;
131
132 std::string m_type{};
133 Permutation m_numPermutations{0};
134 Permutation m_numPositivePermutations{0};
135 Permutation m_numPermutationNodes{0};
136 std::vector<std::vector<Permutation>> m_permutationNodeOrdinals{};
137 };
138
139 class IOSS_EXPORT NullPermutation : public ElementPermutation
140 {
141 public:
142 static const char *name;
143
144 static void factory();
146
147 protected:
149 };
150
151 class IOSS_EXPORT SpherePermutation : public ElementPermutation
152 {
153 public:
154 static const char *name;
155
156 static void factory();
158
159 protected:
161 };
162
163 class IOSS_EXPORT LinePermutation : public ElementPermutation
164 {
165 public:
166 static const char *name;
167
168 static void factory();
170
171 protected:
173 };
174
175 class IOSS_EXPORT SpringPermutation : public ElementPermutation
176 {
177 public:
178 static const char *name;
179
180 static void factory();
182
183 protected:
185 };
186
187 class IOSS_EXPORT TriPermutation : public ElementPermutation
188 {
189 public:
190 static const char *name;
191
192 static void factory();
194
195 protected:
197 };
198
199 class IOSS_EXPORT QuadPermutation : public ElementPermutation
200 {
201 public:
202 static const char *name;
203
204 static void factory();
206
207 protected:
209 };
210
211 class IOSS_EXPORT TetPermutation : public ElementPermutation
212 {
213 public:
214 static const char *name;
215
216 static void factory();
218
219 protected:
221 };
222
223 class IOSS_EXPORT PyramidPermutation : public ElementPermutation
224 {
225 public:
226 static const char *name;
227
228 static void factory();
230
231 protected:
233 };
234
235 class IOSS_EXPORT WedgePermutation : public ElementPermutation
236 {
237 public:
238 static const char *name;
239
240 static void factory();
242
243 protected:
245 };
246
247 class IOSS_EXPORT HexPermutation : public ElementPermutation
248 {
249 public:
250 static const char *name;
251
252 static void factory();
254
255 protected:
257 };
258
259 class IOSS_EXPORT SuperPermutation : public ElementPermutation
260 {
261 public:
262 static const char *basename;
263
264 static void make_super(const std::string &type);
265 static void factory();
266 static void factory(unsigned n);
268
269 static std::string get_name(unsigned n);
270
271 protected:
273 explicit SuperPermutation(unsigned n);
274
275 static std::vector<std::vector<Permutation>> get_super_permutations(unsigned n);
276 };
277} // namespace Ioss
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:54
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
ElementPermutation & operator=(const ElementPermutation &)=delete
ElementPermutation(const ElementPermutation &)=delete
virtual ~ElementPermutation()=default
Definition Ioss_ElementPermutation.h:248
HexPermutation(const HexPermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:250
Definition Ioss_ElementPermutation.h:164
LinePermutation(const LinePermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:166
Definition Ioss_ElementPermutation.h:140
NullPermutation(const NullPermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:142
Definition Ioss_ElementPermutation.h:224
PyramidPermutation(const PyramidPermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:226
Definition Ioss_ElementPermutation.h:200
QuadPermutation(const QuadPermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:202
Definition Ioss_ElementPermutation.h:152
SpherePermutation(const SpherePermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:154
Definition Ioss_ElementPermutation.h:176
SpringPermutation(const SpringPermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:178
Definition Ioss_ElementPermutation.h:260
static const char * basename
Definition Ioss_ElementPermutation.h:262
SuperPermutation(const SuperPermutation &)=delete
Definition Ioss_ElementPermutation.h:212
static const char * name
Definition Ioss_ElementPermutation.h:214
TetPermutation(const TetPermutation &)=delete
Definition Ioss_ElementPermutation.h:188
TriPermutation(const TriPermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:190
Definition Ioss_ElementPermutation.h:236
WedgePermutation(const WedgePermutation &)=delete
static const char * name
Definition Ioss_ElementPermutation.h:238
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
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
std::vector< std::string > NameList
Definition Ioss_CodeTypes.h:23