IOSS 2.0
Loading...
Searching...
No Matches
Iogn_DashSurfaceMesh.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_Beam2.h"
10#include "Ioss_CodeTypes.h"
11#include "Ioss_Hex8.h"
12#include "Ioss_Shell4.h"
13#include "generated/Iogn_GeneratedMesh.h" // for GeneratedMesh
14#include <cstddef> // for size_t
15#include <cstdint> // for int64_t
16#include <exception> // for exception
17#include <string> // for string
18#include <utility> // for pair
19#include <vector> // for vector
20
21#include "iogn_export.h"
22
23namespace Iogn {
24
26
27 struct IOGN_EXPORT SharedNode
28 {
29 SharedNode() = default;
30 int nodeId{-1};
31 int procId{-1};
32 };
33
34 enum Topology { Beam2 = 2, Shell4 = 4, Hex8 = 8 };
35
36 IOSS_NODISCARD inline std::string getTopologyName(Topology topology)
37 {
38 switch (topology) {
39 case Shell4: return {Ioss::Shell4::name};
40 case Hex8: return {Ioss::Hex8::name};
41 case Beam2: return {Ioss::Beam2::name};
42 }
43 throw std::exception();
44 }
45
46 struct IOGN_EXPORT ExodusData
47 {
48 std::vector<double> coordinates{};
49 const std::vector<std::vector<int>> elementBlockConnectivity;
50 const std::vector<int> globalNumberOfElementsInBlock{};
51 const std::vector<int> localNumberOfElementsInBlock{};
52 const std::vector<Topology> blockTopologicalData{};
53
54 const int globalNumberOfNodes{0};
55
56 const std::vector<int> globalIdsOfLocalElements{};
57 const std::vector<int> globalIdsOfLocalNodes{};
58
59 std::vector<SharedNode> sharedNodes{};
60
61 // A sideset' is basically an exodus sideset. A
62 // sideset has a list of elements and a corresponding local
63 // element side (1-based) The side id is: side_id =
64 // 10*element_id + local_side_number This assumes that all
65 // sides in a sideset are boundary sides.
66 std::vector<std::vector<int>> sidesetConnectivity;
67 std::vector<Ioss::NameList> sidesetTouchingBlocks;
68
69 ExodusData() = delete;
70 ExodusData(std::vector<double> coords, std::vector<std::vector<int>> elemBlockConnectivity,
71 std::vector<int> globalNumOfElemsInBlock, std::vector<int> localNumOfElemsInBlock,
72 std::vector<Topology> blockTopoData, int globalNumNodes,
73 std::vector<int> globalIdsOfLocalElems, std::vector<int> globalIdsLocalNodes,
74 std::vector<std::vector<int>> sidesetConn = std::vector<std::vector<int>>(),
75 std::vector<Ioss::NameList> sidesetBlocks = std::vector<Ioss::NameList>())
76 : coordinates(std::move(coords)),
77 elementBlockConnectivity(std::move(elemBlockConnectivity)),
78 globalNumberOfElementsInBlock(std::move(globalNumOfElemsInBlock)),
79 localNumberOfElementsInBlock(std::move(localNumOfElemsInBlock)),
80 blockTopologicalData(std::move(blockTopoData)), globalNumberOfNodes(globalNumNodes),
81 globalIdsOfLocalElements(std::move(globalIdsOfLocalElems)),
82 globalIdsOfLocalNodes(std::move(globalIdsLocalNodes)),
83 sidesetConnectivity(std::move(sidesetConn)),
84 sidesetTouchingBlocks(std::move(sidesetBlocks))
85 {
86 }
87 };
88
89 struct IOGN_EXPORT DashSurfaceData
90 {
91 const std::vector<double> coordinates{};
92 const std::vector<int> surfaceAConnectivity{};
93 const std::vector<int> surfaceBConnectivity{};
94
95 int globalNumberOfNodes{};
96 int globalNumberOfElements{};
97
98 int globalNumberOfElementsSurface1{};
99 int globalNumberOfElementsSurface2{};
100
101 std::vector<int> globalIdsOfLocalElements{};
102 std::vector<int> globalIdsOfLocalNodes{};
103
104 std::vector<SharedNode> sharedNodes{};
105
106 DashSurfaceData(std::vector<double> coords, std::vector<int> connectivity1,
107 std::vector<int> connectivity2)
108 : coordinates(std::move(coords)), surfaceAConnectivity(std::move(connectivity1)),
109 surfaceBConnectivity(std::move(connectivity2))
110 {
111 this->setSerialDefaults();
112 }
113
114 private:
116 {
117 globalNumberOfNodes = coordinates.size() / SPATIAL_DIMENSION;
118
119 globalNumberOfElementsSurface1 = surfaceBConnectivity.size() / NUM_NODES_PER_QUAD_FACE;
120 globalNumberOfElementsSurface2 = surfaceAConnectivity.size() / NUM_NODES_PER_QUAD_FACE;
121 globalNumberOfElements = globalNumberOfElementsSurface1 + globalNumberOfElementsSurface2;
122
123 globalIdsOfLocalElements.resize(globalNumberOfElements);
124 globalIdsOfLocalNodes.resize(globalNumberOfNodes);
125
126 for (size_t i = 0; i < globalIdsOfLocalElements.size(); i++) {
127 globalIdsOfLocalElements[i] = i + 1;
128 }
129
130 for (size_t i = 0; i < globalIdsOfLocalNodes.size(); i++) {
131 globalIdsOfLocalNodes[i] = i + 1;
132 }
133 }
134 };
135
136 class IOGN_EXPORT DashSurfaceMesh : public GeneratedMesh
137 {
138 public:
139 explicit DashSurfaceMesh(DashSurfaceData &dashSurfaceData) : mDashSurfaceData(dashSurfaceData)
140 {
141 }
142
143 IOSS_NODISCARD int64_t node_count() const override;
144 IOSS_NODISCARD int64_t node_count_proc() const override;
145
146 IOSS_NODISCARD int64_t element_count() const override;
147 IOSS_NODISCARD int64_t element_count(int64_t surfaceNumber) const override;
148 IOSS_NODISCARD int64_t element_count_proc() const override;
149 IOSS_NODISCARD int64_t element_count_proc(int64_t block_number) const override;
150
151 IOSS_NODISCARD int block_count() const override;
152
153 IOSS_NODISCARD int nodeset_count() const override;
154 IOSS_NODISCARD int64_t nodeset_node_count_proc(int64_t id) const override;
155
156 IOSS_NODISCARD int sideset_count() const override;
157 IOSS_NODISCARD int64_t sideset_side_count_proc(int64_t id) const override;
158
159 IOSS_NODISCARD int64_t communication_node_count_proc() const override;
160
161 void coordinates(double *coord) const override;
162 void coordinates(std::vector<double> &coord) const override;
163 void coordinates(int component, std::vector<double> &xyz) const override;
164 void coordinates(int component, double *xyz) const override;
165 void coordinates(std::vector<double> &x, std::vector<double> &y,
166 std::vector<double> &z) const override;
167
168 void connectivity(int64_t block_number, int *connect) const override;
169
170 IOSS_NODISCARD std::pair<std::string, int> topology_type(int64_t block_number) const override;
171
172 void sideset_elem_sides(int64_t setId, std::vector<int64_t> &elem_sides) const override;
173
174 void nodeset_nodes(int64_t nset_id, std::vector<int64_t> &nodes) const override;
175
176 void node_communication_map(std::vector<int64_t> &map, std::vector<int> &proc) override;
177
178 void node_map(std::vector<int> &map) const override;
179 void node_map(std::vector<int64_t> &map) const override;
180
181 void element_map(int64_t block_number, std::vector<int> &map) const override;
182 void element_map(int64_t block_number, std::vector<int64_t> &map) const override;
183 void element_map(std::vector<int64_t> &map) const override;
184 void element_map(std::vector<int> &map) const override;
185
186 private:
187 std::string get_sideset_topology() const override;
188
190 };
191
192 class IOGN_EXPORT ExodusMesh : public GeneratedMesh
193 {
194 public:
195 explicit ExodusMesh(const ExodusData &exodusData);
196
197 IOSS_NODISCARD int64_t node_count() const override;
198 IOSS_NODISCARD int64_t node_count_proc() const override;
199
200 IOSS_NODISCARD int64_t element_count() const override;
201 IOSS_NODISCARD int64_t element_count(int64_t blockNumber) const override;
202 IOSS_NODISCARD int64_t element_count_proc() const override;
203 IOSS_NODISCARD int64_t element_count_proc(int64_t blockNumber) const override;
204
205 IOSS_NODISCARD int block_count() const override;
206
207 IOSS_NODISCARD int nodeset_count() const override;
208 IOSS_NODISCARD int64_t nodeset_node_count_proc(int64_t id) const override;
209
210 IOSS_NODISCARD int sideset_count() const override;
211 IOSS_NODISCARD int64_t sideset_side_count_proc(int64_t id) const override;
212
213 IOSS_NODISCARD int64_t communication_node_count_proc() const override;
214
215 void coordinates(double *coord) const override;
216 void coordinates(std::vector<double> &coord) const override;
217 void coordinates(int component, std::vector<double> &xyz) const override;
218 void coordinates(int component, double *xyz) const override;
219 void coordinates(std::vector<double> &x, std::vector<double> &y,
220 std::vector<double> &z) const override;
221
222 void connectivity(int64_t blockNumber, int *connectivityForBlock) const override;
223
224 IOSS_NODISCARD std::pair<std::string, int> topology_type(int64_t blockNumber) const override;
225
226 void sideset_elem_sides(int64_t setId, std::vector<int64_t> &elem_sides) const override;
227
228 Ioss::NameList sideset_touching_blocks(int64_t setId) const override;
229
230 void nodeset_nodes(int64_t nset_id, std::vector<int64_t> &nodes) const override;
231
232 void node_communication_map(std::vector<int64_t> &map, std::vector<int> &proc) override;
233
234 void node_map(std::vector<int> &map) const override;
235 void node_map(std::vector<int64_t> &map) const override;
236
237 void element_map(int64_t blockNumber, std::vector<int> &map) const override;
238 void element_map(int64_t blockNumber, std::vector<int64_t> &map) const override;
239 void element_map(std::vector<int64_t> &map) const override;
240 void element_map(std::vector<int> &map) const override;
241
242 private:
243 std::string get_sideset_topology() const override;
244
247
249 std::vector<int64_t> mElementOffsetForBlock;
250 };
251} // namespace Iogn
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
Definition Iogn_DashSurfaceMesh.h:137
DashSurfaceMesh(DashSurfaceData &dashSurfaceData)
Definition Iogn_DashSurfaceMesh.h:139
DashSurfaceData mDashSurfaceData
Definition Iogn_DashSurfaceMesh.h:189
Definition Iogn_DashSurfaceMesh.h:193
int64_t mLocalNumberOfElements
Definition Iogn_DashSurfaceMesh.h:246
int64_t mGlobalNumberOfElements
Definition Iogn_DashSurfaceMesh.h:245
std::vector< int64_t > mElementOffsetForBlock
Definition Iogn_DashSurfaceMesh.h:249
const ExodusData & mExodusData
Definition Iogn_DashSurfaceMesh.h:248
Definition Iogn_GeneratedMesh.h:23
static const char * name
Definition Ioss_Beam2.h:19
static const char * name
Definition Ioss_Hex8.h:19
static const char * name
Definition Ioss_Shell4.h:19
A namespace for the generated database format.
Definition Iogn_DashSurfaceMesh.C:12
Topology
Definition Iogn_DashSurfaceMesh.h:34
@ Hex8
Definition Iogn_DashSurfaceMesh.h:34
@ Beam2
Definition Iogn_DashSurfaceMesh.h:34
@ Shell4
Definition Iogn_DashSurfaceMesh.h:34
@ NUMBER_OF_SURFACES
Definition Iogn_DashSurfaceMesh.h:25
@ NUM_NODES_PER_QUAD_FACE
Definition Iogn_DashSurfaceMesh.h:25
@ SPATIAL_DIMENSION
Definition Iogn_DashSurfaceMesh.h:25
@ INVALID
Definition Iogn_DashSurfaceMesh.h:25
IOSS_NODISCARD std::string getTopologyName(Topology topology)
Definition Iogn_DashSurfaceMesh.h:36
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
Definition Iogn_DashSurfaceMesh.h:90
DashSurfaceData(std::vector< double > coords, std::vector< int > connectivity1, std::vector< int > connectivity2)
Definition Iogn_DashSurfaceMesh.h:106
void setSerialDefaults()
Definition Iogn_DashSurfaceMesh.h:115
Definition Iogn_DashSurfaceMesh.h:47
std::vector< Ioss::NameList > sidesetTouchingBlocks
Definition Iogn_DashSurfaceMesh.h:67
ExodusData()=delete
std::vector< std::vector< int > > sidesetConnectivity
Definition Iogn_DashSurfaceMesh.h:66
ExodusData(std::vector< double > coords, std::vector< std::vector< int > > elemBlockConnectivity, std::vector< int > globalNumOfElemsInBlock, std::vector< int > localNumOfElemsInBlock, std::vector< Topology > blockTopoData, int globalNumNodes, std::vector< int > globalIdsOfLocalElems, std::vector< int > globalIdsLocalNodes, std::vector< std::vector< int > > sidesetConn=std::vector< std::vector< int > >(), std::vector< Ioss::NameList > sidesetBlocks=std::vector< Ioss::NameList >())
Definition Iogn_DashSurfaceMesh.h:70
const std::vector< std::vector< int > > elementBlockConnectivity
Definition Iogn_DashSurfaceMesh.h:49
Definition Iogn_DashSurfaceMesh.h:28
SharedNode()=default