Debian Codegraph @

packages/seacas/applications/conjoin/CJ_ExodusEntity.h

raw
1 // Copyright(C) 1999-2020, 2022, 2023, 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 #pragma once
7
8 #define NO_NETCDF_2
9 #include "CJ_ObjectType.h"
10 #include <array>
11 #include <copy_string_cpp.h>
12 #include <cstring>
13 #include <exodusII.h>
14 #include <fmt/ostream.h>
15 #include <iostream>
16 #include <string>
17 #include <vector>
18
19 namespace Excn {
20 using IntVector = std::vector<int>;
21 using DistVector = std::vector<char>;
22
23 template <typename INT> struct Mesh
24 {
25 size_t count(ObjectType type) const
26 {
27 switch (type) {
28 case ObjectType::EBLK: return blockCount;
29 case ObjectType::NSET: return nodesetCount;
30 case ObjectType::SSET: return sidesetCount;
31 case ObjectType::NODE: return nodeCount;
32 case ObjectType::ELEM: return elementCount;
33 case ObjectType::TIME: return timestepCount;
34 case ObjectType::DIM: return dimensionality;
35 default: return 0;
36 }
37 }
38
39 std::vector<INT> localNodeToGlobal{};
40 std::vector<INT> localElementToGlobal{};
41
42 std::string title{};
43
44 size_t dimensionality{0};
45 size_t nodeCount{0};
46 size_t elementCount{0};
47 size_t blockCount{0};
48 size_t nodesetCount{0};
49 size_t sidesetCount{0};
50 size_t timestepCount{0};
51
52 bool isActive{true};
53 };
54
55 struct Block
56 {
57 size_t entity_count() const { return elementCount; }
58
59 IntVector truthTable{};
60 std::vector<std::string> attributeNames{};
61 std::string name_{};
62 ex_entity_id id{0};
63 size_t elementCount{0};
64 size_t nodesPerElement{0};
65 size_t attributeCount{0};
66 size_t offset_{0};
67 mutable size_t position_{0};
68 std::string elType{};
69 };
70
71 template <typename INT> struct NodeSet
72 {
73 IntVector truthTable{};
74 ex_entity_id id{0};
75 size_t nodeCount{0};
76 size_t dfCount{0};
77 size_t offset_{0};
78 size_t position_{0};
79 std::string name_{};
80
81 std::vector<INT> nodeSetNodes{};
82 std::vector<INT> nodeOrderMap{};
83 DistVector distFactors{};
84
85 size_t entity_count() const { return nodeCount; }
86
87 void dump() const
88 {
89 fmt::print("NodeSet {}, Name: '{}', {} nodes, {} df,\torder = {}\n", id, name_,
90 fmt::group_digits(nodeCount), fmt::group_digits(dfCount), position_);
91 }
92
93 void dump_order() const
94 {
95 dump();
96 for (size_t i = 0; i < nodeCount; i++) {
97 fmt::print("{}, ", nodeOrderMap[i]);
98 }
99 fmt::print("\n");
100 }
101 };
102
103 template <typename INT> struct SideSet
104 {
105 IntVector truthTable{};
106 ex_entity_id id{0};
107 size_t sideCount{0};
108 size_t dfCount{0};
109 size_t offset_{0};
110 size_t position_{0};
111 std::string name_{};
112
113 std::vector<INT> elems{};
114 std::vector<INT> sides{};
115
116 // For conjoin only. Maps the location (of elems, sides, vars) within this sideset into
117 // the location in the corresponding global sideset
118 std::vector<INT> elemOrderMap{};
119 DistVector distFactors{};
120
121 size_t entity_count() const { return sideCount; }
122
123 void dump() const
124 {
125 fmt::print("SideSet {}, Name: '{}', {} sides, {} df\toffset = {}, order = {}\n", id, name_,
126 fmt::group_digits(sideCount), fmt::group_digits(dfCount), offset_, position_);
127 }
128 };
129
130 struct CommunicationMap
131 {
132 CommunicationMap(size_t the_id, size_t count, char the_type)
133 : id(the_id), entityCount(count), type(the_type)
134 {
135 }
136 ex_entity_id id{0};
137 size_t entityCount{0};
138 char type{'U'}; // 'n' for node, 'e' for element
139 };
140
141 struct CommunicationMetaData
142 {
143 CommunicationMetaData() = default;
144 CommunicationMetaData(const CommunicationMetaData &) = delete;
145
146 std::vector<CommunicationMap> nodeMap{};
147 std::vector<CommunicationMap> elementMap{};
148
149 size_t processorId{0};
150 size_t processorCount{0};
151 size_t globalNodes{0};
152 size_t globalElements{0};
153 size_t nodesInternal{0};
154 size_t nodesBorder{0};
155 size_t nodesExternal{0};
156 size_t elementsInternal{0};
157 size_t elementsBorder{0};
158 };
159 } // namespace Excn