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