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 #include "Ioss_CodeTypes.h" // for IntVector
8 #include "Ioss_ElementTopology.h" // for ElementTopology
9 #include <Ioss_ElementVariableType.h> // for ElementVariableType
10 #include <Ioss_TriShell3.h>
11 #include <cassert> // for assert
12
13 //------------------------------------------------------------------------
14 // Define a variable type for storage of this elements connectivity
15 namespace Ioss {
16 const char *TriShell3::name = "trishell3";
17 class St_TriShell3 : public ElementVariableType
18 {
19 public:
factory()20 static void factory() { static St_TriShell3 registerThis; }
21
22 protected:
St_TriShell3()23 St_TriShell3() : ElementVariableType(Ioss::TriShell3::name, 3) {}
24 };
25 } // namespace Ioss
26 // ========================================================================
27 namespace {
28 struct Constants
29 {
30 static const int nnode = 3;
31 static const int nedge = 3;
32 static const int nedgenode = 2;
33 static const int nface = 2;
34 static const int nfacenode = 3;
35 static const int nfaceedge = 3;
36 static int edge_node_order[nedge][nedgenode];
37 static int face_node_order[nface][nfacenode];
38 static int face_edge_order[nface][nfaceedge];
39 static int nodes_per_face[nface + 1];
40 static int edges_per_face[nface + 1];
41 };
42
43 // Edge numbers are zero-based [0..number_edges)
44 int Constants::edge_node_order[nedge][nedgenode] = // [edge][edge_node]
45 {{0, 1}, {1, 2}, {2, 0}};
46
47 // Face numbers are zero-based [0..number_faces)
48 int Constants::face_node_order[nface][nfacenode] = // [face][face_node]
49 {{0, 1, 2}, {0, 2, 1}};
50
51 int Constants::face_edge_order[nface][nfaceedge] = // [face][face_edge]
52 {{0, 1, 2}, {2, 1, 0}};
53
54 // face 0 returns number of nodes for all faces if homogeneous
55 // returns -1 if faces have differing topology
56 int Constants::nodes_per_face[nface + 1] = {3, 3, 3};
57
58 // face 0 returns number of edges for all faces if homogeneous
59 // returns -1 if faces have differing topology
60 int Constants::edges_per_face[nface + 1] = {3, 3, 3};
61 } // namespace
62
factory()63 void Ioss::TriShell3::factory()
64 {
65 static Ioss::TriShell3 registerThis;
66 Ioss::St_TriShell3::factory();
67 }
68
TriShell3()69 Ioss::TriShell3::TriShell3() : Ioss::ElementTopology(Ioss::TriShell3::name, "ShellTriangle_3")
70 {
71 Ioss::ElementTopology::alias(Ioss::TriShell3::name, "trishell");
72 Ioss::ElementTopology::alias(Ioss::TriShell3::name, "Shell_Tri_3_3D");
73 Ioss::ElementTopology::alias(Ioss::TriShell3::name, "SHELL_TRIANGLE_3");
74 Ioss::ElementTopology::alias(Ioss::TriShell3::name, "shell3");
75 }
76
77 Ioss::TriShell3::~TriShell3() = default;
78
parametric_dimension()79 int Ioss::TriShell3::parametric_dimension() const { return 2; }
spatial_dimension()80 int Ioss::TriShell3::spatial_dimension() const { return 3; }
order()81 int Ioss::TriShell3::order() const { return 1; }
82
number_corner_nodes()83 int Ioss::TriShell3::number_corner_nodes() const { return 3; }
number_nodes()84 int Ioss::TriShell3::number_nodes() const { return Constants::nnode; }
number_edges()85 int Ioss::TriShell3::number_edges() const { return Constants::nedge; }
number_faces()86 int Ioss::TriShell3::number_faces() const { return Constants::nface; }
87
number_nodes_edge(int)88 int Ioss::TriShell3::number_nodes_edge(int /* edge */) const { return Constants::nedgenode; }
89
number_nodes_face(int face)90 int Ioss::TriShell3::number_nodes_face(int face) const
91 {
92 // face is 1-based. 0 passed in for all faces.
93 assert(face >= 0 && face <= number_faces());
94 return Constants::nodes_per_face[face];
95 }
96
number_edges_face(int face)97 int Ioss::TriShell3::number_edges_face(int face) const
98 {
99 // face is 1-based. 0 passed in for all faces.
100 assert(face >= 0 && face <= number_faces());
101 return Constants::edges_per_face[face];
102 }
103
edge_connectivity(int edge_number)104 Ioss::IntVector Ioss::TriShell3::edge_connectivity(int edge_number) const
105 {
106 assert(edge_number > 0 && edge_number <= Constants::nedge);
107 Ioss::IntVector connectivity(Constants::nedgenode);
108
109 for (int i = 0; i < Constants::nedgenode; i++) {
110 connectivity[i] = Constants::edge_node_order[edge_number - 1][i];
111 }
112
113 return connectivity;
114 }
115
face_connectivity(int face_number)116 Ioss::IntVector Ioss::TriShell3::face_connectivity(int face_number) const
117 {
118 assert(face_number > 0 && face_number <= number_faces());
119 Ioss::IntVector connectivity(Constants::nodes_per_face[face_number]);
120
121 for (int i = 0; i < Constants::nodes_per_face[face_number]; i++) {
122 connectivity[i] = Constants::face_node_order[face_number - 1][i];
123 }
124
125 return connectivity;
126 }
127
element_connectivity()128 Ioss::IntVector Ioss::TriShell3::element_connectivity() const
129 {
130 Ioss::IntVector connectivity(number_nodes());
131 for (int i = 0; i < number_nodes(); i++) {
132 connectivity[i] = i;
133 }
134 return connectivity;
135 }
136
face_type(int face_number)137 Ioss::ElementTopology *Ioss::TriShell3::face_type(int face_number) const
138 {
139 assert(face_number >= 0 && face_number <= number_faces());
140 // return Ioss::ElementTopology::factory("triface3");
141 return Ioss::ElementTopology::factory("tri3");
142 }
143
edge_type(int edge_number)144 Ioss::ElementTopology *Ioss::TriShell3::edge_type(int edge_number) const
145 {
146 assert(edge_number >= 0 && edge_number <= number_edges());
147 return Ioss::ElementTopology::factory("edge2");
148 }
149
face_edge_connectivity(int face_number)150 Ioss::IntVector Ioss::TriShell3::face_edge_connectivity(int face_number) const
151 {
152 assert(face_number > 0 && face_number <= Constants::nface);
153
154 int nface_edge = number_edges_face(face_number);
155 Ioss::IntVector fcon(nface_edge);
156
157 for (int i = 0; i < nface_edge; i++) {
158 fcon[i] = Constants::face_edge_order[face_number - 1][i];
159 }
160
161 return fcon;
162 }
163