IOSS 2.0

Iogn_DashSurfaceMesh.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 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 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Iogn_DashSurfaceMesh_h
34 #define IOSS_Iogn_DashSurfaceMesh_h
35
36 #include <Ioss_Hex8.h>
37 #include <Ioss_Shell4.h>
38 #include <cstddef> // for size_t
39 #include <cstdint> // for int64_t
40 #include <exception> // for exception
41 #include <generated/Iogn_GeneratedMesh.h> // for GeneratedMesh
42 #include <string> // for string
43 #include <utility> // for pair
44 #include <vector> // for vector
45
46 namespace Iogn {
47
48 enum { INVALID = -1, NUMBER_OF_SURFACES = 2, SPATIAL_DIMENSION = 3, NUM_NODES_PER_QUAD_FACE = 4 };
49
50 struct SharedNode
51 {
52 SharedNode() : nodeId(-1), procId(-1) {}
53 int nodeId;
54 int procId;
55 };
56
57 enum Topology { Shell4 = 4, Hex8 = 8 };
58
59 inline std::string getTopologyName(Topology topology)
60 {
61 switch (topology) {
62 case Shell4: return std::string(Ioss::Shell4::name);
63 case Hex8: return std::string(Ioss::Hex8::name);
64 }
65 throw std::exception();
66 }
67
68 struct ExodusData
69 {
70 std::vector<double> coordinates;
71 const std::vector<std::vector<int>> elementBlockConnectivity;
72 const std::vector<int> globalNumberOfElementsInBlock;
73 const std::vector<int> localNumberOfElementsInBlock;
74 const std::vector<Topology> blockTopologicalData;
75
76 const int globalNumberOfNodes;
77
78 const std::vector<int> globalIdsOfLocalElements;
79 const std::vector<int> globalIdsOfLocalNodes;
80
81 std::vector<SharedNode> sharedNodes;
82
83 // A sideset' is basically an exodus sideset. A
84 // sideset has a list of elements and a corresponding local
85 // element side (1-based) The side id is: side_id =
86 // 10*element_id + local_side_number This assumes that all
87 // sides in a sideset are boundary sides.
88 std::vector<std::vector<int>> sidesetConnectivity;
89 std::vector<std::vector<std::string>> sidesetTouchingBlocks;
90
91 ExodusData() : globalNumberOfNodes(0) {}
92 ExodusData(const std::vector<double> coords,
93 const std::vector<std::vector<int>> elemBlockConnectivity,
94 const std::vector<int> globalNumOfElemsInBlock,
95 const std::vector<int> localNumOfElemsInBlock,
96 const std::vector<Topology> blockTopoData, int globalNumNodes,
97 const std::vector<int> globalIdsOfLocalElems,
98 const std::vector<int> globalIdsLocalNodes,
99 std::vector<std::vector<int>> sidesetConn = std::vector<std::vector<int>>(),
100 std::vector<std::vector<std::string>> sidesetBlocks =
101 std::vector<std::vector<std::string>>())
102 : coordinates(coords), elementBlockConnectivity(elemBlockConnectivity),
103 globalNumberOfElementsInBlock(globalNumOfElemsInBlock),
104 localNumberOfElementsInBlock(localNumOfElemsInBlock), blockTopologicalData(blockTopoData),
105 globalNumberOfNodes(globalNumNodes), globalIdsOfLocalElements(globalIdsOfLocalElems),
106 globalIdsOfLocalNodes(globalIdsLocalNodes), sidesetConnectivity(std::move(sidesetConn)),
107 sidesetTouchingBlocks(std::move(sidesetBlocks))
108 {
109 }
110 };
111
112 struct DashSurfaceData
113 {
114 const std::vector<double> coordinates;
115 const std::vector<int> surfaceAConnectivity;
116 const std::vector<int> surfaceBConnectivity;
117
118 int globalNumberOfNodes{};
119 int globalNumberOfElements{};
120
121 int globalNumberOfElementsSurface1{};
122 int globalNumberOfElementsSurface2{};
123
124 std::vector<int> globalIdsOfLocalElements;
125 std::vector<int> globalIdsOfLocalNodes;
126
127 std::vector<SharedNode> sharedNodes;
128
129 DashSurfaceData(const std::vector<double> &coords, const std::vector<int> &connectivity1,
130 const std::vector<int> &connectivity2)
131 : coordinates(coords), surfaceAConnectivity(connectivity1),
132 surfaceBConnectivity(connectivity2)
133 {
134 this->setSerialDefaults();
135 }
136
137 private:
138 void setSerialDefaults()
139 {
140 globalNumberOfNodes = coordinates.size() / SPATIAL_DIMENSION;
141
142 globalNumberOfElementsSurface1 = surfaceBConnectivity.size() / NUM_NODES_PER_QUAD_FACE;
143 globalNumberOfElementsSurface2 = surfaceAConnectivity.size() / NUM_NODES_PER_QUAD_FACE;
144 globalNumberOfElements = globalNumberOfElementsSurface1 + globalNumberOfElementsSurface2;
145
146 globalIdsOfLocalElements.resize(globalNumberOfElements);
147 globalIdsOfLocalNodes.resize(globalNumberOfNodes);
148
149 for (size_t i = 0; i < globalIdsOfLocalElements.size(); i++) {
150 globalIdsOfLocalElements[i] = i + 1;
151 }
152
153 for (size_t i = 0; i < globalIdsOfLocalNodes.size(); i++) {
154 globalIdsOfLocalNodes[i] = i + 1;
155 }
156 }
157 };
158
159 class DashSurfaceMesh : public GeneratedMesh
160 {
161 public:
162 explicit DashSurfaceMesh(DashSurfaceData &dashSurfaceData) : mDashSurfaceData(dashSurfaceData)
163 {
164 }
165
166 ~DashSurfaceMesh() override = default;
167
168 int64_t node_count() const override;
169 int64_t node_count_proc() const override;
170
171 int64_t element_count() const override;
172 int64_t element_count(int64_t surfaceNumber) const override;
173 int64_t element_count_proc() const override;
174 int64_t element_count_proc(int64_t block_number) const override;
175
176 int64_t block_count() const override;
177
178 int64_t nodeset_count() const override;
179 int64_t nodeset_node_count_proc(int64_t id) const override;
180
181 int64_t sideset_count() const override;
182 int64_t sideset_side_count_proc(int64_t id) const override;
183
184 int64_t communication_node_count_proc() const override;
185
186 void coordinates(double *coord) const override;
187 void coordinates(std::vector<double> &coord) const override;
188 void coordinates(int component, std::vector<double> &xyz) const override;
189 void coordinates(std::vector<double> &x, std::vector<double> &y,
190 std::vector<double> &z) const override;
191
192 void connectivity(int64_t block_number, int *connect) const override;
193
194 std::pair<std::string, int> topology_type(int64_t block_number) const override;
195
196 void sideset_elem_sides(int64_t setId, std::vector<int64_t> &elem_sides) const override;
197
198 void nodeset_nodes(int64_t nset_id, std::vector<int64_t> &nodes) const override;
199
200 void node_communication_map(std::vector<int64_t> &map, std::vector<int> &proc) override;
201
202 void node_map(std::vector<int> &map) const override;
203 void node_map(std::vector<int64_t> &map) const override;
204
205 void element_map(int64_t block_number, std::vector<int> &map) const override;
206 void element_map(int64_t block_number, std::vector<int64_t> &map) const override;
207 void element_map(std::vector<int64_t> &map) const override;
208 void element_map(std::vector<int> &map) const override;
209
210 private:
211 DashSurfaceData mDashSurfaceData;
212 };
213
214 class ExodusMesh : public GeneratedMesh
215 {
216 public:
217 explicit ExodusMesh(const ExodusData &exodusData);
218
219 ~ExodusMesh() override = default;
220
221 int64_t node_count() const override;
222 int64_t node_count_proc() const override;
223
224 int64_t element_count() const override;
225 int64_t element_count(int64_t blockNumber) const override;
226 int64_t element_count_proc() const override;
227 int64_t element_count_proc(int64_t blockNumber) const override;
228
229 int64_t block_count() const override;
230
231 int64_t nodeset_count() const override;
232 int64_t nodeset_node_count_proc(int64_t id) const override;
233
234 int64_t sideset_count() const override;
235 int64_t sideset_side_count_proc(int64_t id) const override;
236
237 int64_t communication_node_count_proc() const override;
238
239 void coordinates(double *coord) const override;
240 void coordinates(std::vector<double> &coord) const override;
241 void coordinates(int component, std::vector<double> &xyz) const override;
242 void coordinates(std::vector<double> &x, std::vector<double> &y,
243 std::vector<double> &z) const override;
244
245 void connectivity(int64_t blockNumber, int *connectivityForBlock) const override;
246
247 std::pair<std::string, int> topology_type(int64_t blockNumber) const override;
248
249 void sideset_elem_sides(int64_t setId, std::vector<int64_t> &elem_sides) const override;
250
251 std::vector<std::string> sideset_touching_blocks(int64_t setId) const override;
252
253 void nodeset_nodes(int64_t nset_id, std::vector<int64_t> &nodes) const override;
254
255 void node_communication_map(std::vector<int64_t> &map, std::vector<int> &proc) override;
256
257 void node_map(std::vector<int> &map) const override;
258 void node_map(std::vector<int64_t> &map) const override;
259
260 void element_map(int64_t blockNumber, std::vector<int> &map) const override;
261 void element_map(int64_t blockNumber, std::vector<int64_t> &map) const override;
262 void element_map(std::vector<int64_t> &map) const override;
263 void element_map(std::vector<int> &map) const override;
264
265 private:
266 int64_t mGlobalNumberOfElements;
267 int64_t mLocalNumberOfElements;
268
269 const ExodusData & mExodusData;
270 std::vector<int64_t> mElementOffsetForBlock;
271 };
272 } // namespace Iogn
273
274 #endif
Iogn::ExodusMesh::mGlobalNumberOfElements
int64_t mGlobalNumberOfElements
Definition: Iogn_DashSurfaceMesh.h:266
Iogn::ExodusData::ExodusData
ExodusData()
Definition: Iogn_DashSurfaceMesh.h:91
Iogn::Hex8
Definition: Iogn_DashSurfaceMesh.h:57
Iogn::ExodusData::coordinates
std::vector< double > coordinates
Definition: Iogn_DashSurfaceMesh.h:70
Iogn::ExodusData::globalIdsOfLocalNodes
const std::vector< int > globalIdsOfLocalNodes
Definition: Iogn_DashSurfaceMesh.h:79
Iogn::ExodusMesh::mLocalNumberOfElements
int64_t mLocalNumberOfElements
Definition: Iogn_DashSurfaceMesh.h:267
Iogn::DashSurfaceData::DashSurfaceData
DashSurfaceData(const std::vector< double > &coords, const std::vector< int > &connectivity1, const std::vector< int > &connectivity2)
Definition: Iogn_DashSurfaceMesh.h:129
Iogn::DashSurfaceData::globalIdsOfLocalElements
std::vector< int > globalIdsOfLocalElements
Definition: Iogn_DashSurfaceMesh.h:124
Iogn_GeneratedMesh.h
Iogn::DashSurfaceData
Definition: Iogn_DashSurfaceMesh.h:112
Iogn::SharedNode::procId
int procId
Definition: Iogn_DashSurfaceMesh.h:54
Iogn::ExodusMesh
Definition: Iogn_DashSurfaceMesh.h:214
Iogn::ExodusData::elementBlockConnectivity
const std::vector< std::vector< int > > elementBlockConnectivity
Definition: Iogn_DashSurfaceMesh.h:71
Iogn::DashSurfaceData::surfaceAConnectivity
const std::vector< int > surfaceAConnectivity
Definition: Iogn_DashSurfaceMesh.h:115
Iogn::SharedNode::SharedNode
SharedNode()
Definition: Iogn_DashSurfaceMesh.h:52
Iogn::DashSurfaceData::sharedNodes
std::vector< SharedNode > sharedNodes
Definition: Iogn_DashSurfaceMesh.h:127
std
Definition: json.h:1157
Iogn::DashSurfaceData::surfaceBConnectivity
const std::vector< int > surfaceBConnectivity
Definition: Iogn_DashSurfaceMesh.h:116
Iogn::ExodusData::globalNumberOfNodes
const int globalNumberOfNodes
Definition: Iogn_DashSurfaceMesh.h:76
Iogn::ExodusData::globalNumberOfElementsInBlock
const std::vector< int > globalNumberOfElementsInBlock
Definition: Iogn_DashSurfaceMesh.h:72
Iogn::ExodusData::sidesetConnectivity
std::vector< std::vector< int > > sidesetConnectivity
Definition: Iogn_DashSurfaceMesh.h:88
Iogn::DashSurfaceMesh
Definition: Iogn_DashSurfaceMesh.h:159
Iogn::DashSurfaceData::setSerialDefaults
void setSerialDefaults()
Definition: Iogn_DashSurfaceMesh.h:138
Iogn::ExodusData::globalIdsOfLocalElements
const std::vector< int > globalIdsOfLocalElements
Definition: Iogn_DashSurfaceMesh.h:78
Iogn::getTopologyName
std::string getTopologyName(Topology topology)
Definition: Iogn_DashSurfaceMesh.h:59
Iogn::SharedNode::nodeId
int nodeId
Definition: Iogn_DashSurfaceMesh.h:53
Iogn::DashSurfaceMesh::mDashSurfaceData
DashSurfaceData mDashSurfaceData
Definition: Iogn_DashSurfaceMesh.h:211
Iogn::GeneratedMesh
Definition: Iogn_GeneratedMesh.h:48
Iogn::ExodusData::localNumberOfElementsInBlock
const std::vector< int > localNumberOfElementsInBlock
Definition: Iogn_DashSurfaceMesh.h:73
Iogn
A namespace for the generated database format.
Definition: Iogn_DashSurfaceMesh.C:38
Iogn::NUM_NODES_PER_QUAD_FACE
Definition: Iogn_DashSurfaceMesh.h:48
Iogn::DashSurfaceData::coordinates
const std::vector< double > coordinates
Definition: Iogn_DashSurfaceMesh.h:114
Iogn::NUMBER_OF_SURFACES
Definition: Iogn_DashSurfaceMesh.h:48
Iogn::INVALID
Definition: Iogn_DashSurfaceMesh.h:48
Iogn::SPATIAL_DIMENSION
Definition: Iogn_DashSurfaceMesh.h:48
Ioss_Shell4.h
Iogn::ExodusData
Definition: Iogn_DashSurfaceMesh.h:68
Iogn::ExodusData::blockTopologicalData
const std::vector< Topology > blockTopologicalData
Definition: Iogn_DashSurfaceMesh.h:74
Iogn::Shell4
Definition: Iogn_DashSurfaceMesh.h:57
Iogn::DashSurfaceData::globalIdsOfLocalNodes
std::vector< int > globalIdsOfLocalNodes
Definition: Iogn_DashSurfaceMesh.h:125
Iogn::ExodusMesh::mExodusData
const ExodusData & mExodusData
Definition: Iogn_DashSurfaceMesh.h:269
Iogn::ExodusData::sidesetTouchingBlocks
std::vector< std::vector< std::string > > sidesetTouchingBlocks
Definition: Iogn_DashSurfaceMesh.h:89
Iogn::SharedNode
Definition: Iogn_DashSurfaceMesh.h:50
Iogn::ExodusData::sharedNodes
std::vector< SharedNode > sharedNodes
Definition: Iogn_DashSurfaceMesh.h:81
Ioss::ElementTopology::name
const std::string & name() const
Definition: Ioss_ElementTopology.h:83
Iogn::Topology
Topology
Definition: Iogn_DashSurfaceMesh.h:57
Ioss_Hex8.h
Iogn::DashSurfaceMesh::DashSurfaceMesh
DashSurfaceMesh(DashSurfaceData &dashSurfaceData)
Definition: Iogn_DashSurfaceMesh.h:162
Iogn::ExodusMesh::mElementOffsetForBlock
std::vector< int64_t > mElementOffsetForBlock
Definition: Iogn_DashSurfaceMesh.h:270
Iogn::ExodusData::ExodusData
ExodusData(const std::vector< double > coords, const std::vector< std::vector< int >> elemBlockConnectivity, const std::vector< int > globalNumOfElemsInBlock, const std::vector< int > localNumOfElemsInBlock, const std::vector< Topology > blockTopoData, int globalNumNodes, const std::vector< int > globalIdsOfLocalElems, const std::vector< int > globalIdsLocalNodes, std::vector< std::vector< int >> sidesetConn=std::vector< std::vector< int >>(), std::vector< std::vector< std::string >> sidesetBlocks=std::vector< std::vector< std::string >>())
Definition: Iogn_DashSurfaceMesh.h:92