| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020, 2022, 2023, 2024 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
#pragma once |
| 9 |
|
| 10 |
#define NO_NETCDF_2 |
| 11 |
#include "EP_ObjectType.h" |
| 12 |
#include <copy_string_cpp.h> |
| 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 Int64Vector = std::vector<int64_t>; |
| 22 |
using DistVector = std::vector<char>; |
| 23 |
|
| 24 |
class Mesh |
| 25 |
{ |
| 26 |
public: |
| 27 |
size_t count(ObjectType type) const |
| 28 |
{ |
| 29 |
switch (type) { |
| 30 |
case Excn::ObjectType::EBLK: return blockCount; |
| 31 |
case Excn::ObjectType::NSET: return nodesetCount; |
| 32 |
case Excn::ObjectType::SSET: return sidesetCount; |
| 33 |
case Excn::ObjectType::NODE: return nodeCount; |
| 34 |
case Excn::ObjectType::ELEM: return elementCount; |
| 35 |
case Excn::ObjectType::EDGE: return edgeCount; |
| 36 |
case Excn::ObjectType::FACE: return faceCount; |
| 37 |
case Excn::ObjectType::ASSM: return assemblyCount; |
| 38 |
case Excn::ObjectType::EDBLK: return edgeBlockCount; |
| 39 |
case Excn::ObjectType::FABLK: return faceBlockCount; |
| 40 |
default: return 0; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
IntVector truthTable[5]; |
| 45 |
|
| 46 |
std::string title{}; |
| 47 |
int dimensionality{0}; |
| 48 |
int64_t nodeCount{0}; |
| 49 |
int64_t elementCount{0}; |
| 50 |
int64_t edgeCount{0}; |
| 51 |
int64_t faceCount{0}; |
| 52 |
int blockCount{0}; |
| 53 |
int nodesetCount{0}; |
| 54 |
int sidesetCount{0}; |
| 55 |
int assemblyCount{0}; |
| 56 |
int edgeBlockCount{0}; |
| 57 |
int faceBlockCount{0}; |
| 58 |
bool needNodeMap{true}; |
| 59 |
bool needElementMap{true}; |
| 60 |
}; |
| 61 |
|
| 62 |
class Assembly |
| 63 |
{ |
| 64 |
public: |
| 65 |
size_t entity_count() const { return entityCount; } |
| 66 |
ObjectType entity_type() const { return type_; } |
| 67 |
|
| 68 |
ex_entity_id id{0}; |
| 69 |
std::string name_; |
| 70 |
ObjectType type_{Excn::ObjectType::UNSET}; |
| 71 |
int entityCount{0}; |
| 72 |
std::vector<int64_t> entityList; |
| 73 |
}; |
| 74 |
|
| 75 |
class Block |
| 76 |
{ |
| 77 |
public: |
| 78 |
Block() { copy_string(elType, ""); } |
| 79 |
|
| 80 |
Block(const Block &other) |
| 81 |
: name_(other.name_), id(other.id), elementCount(other.elementCount), |
| 82 |
nodesPerElement(other.nodesPerElement), attributeCount(other.attributeCount), |
| 83 |
offset_(other.offset_), position_(other.position_) |
| 84 |
{ |
| 85 |
copy_string(elType, other.elType); |
| 86 |
} |
| 87 |
|
| 88 |
size_t entity_count() const { return elementCount; } |
| 89 |
|
| 90 |
char elType[MAX_STR_LENGTH + 1]{}; |
| 91 |
std::string name_; |
| 92 |
std::vector<std::string> attributeNames{}; |
| 93 |
ex_entity_id id{0}; |
| 94 |
int64_t elementCount{0}; |
| 95 |
int nodesPerElement{0}; |
| 96 |
int attributeCount{0}; |
| 97 |
int64_t offset_{0}; |
| 98 |
int position_{0}; |
| 99 |
|
| 100 |
Block &operator=(const Block &other) |
| 101 |
{ |
| 102 |
copy_string(elType, other.elType); |
| 103 |
name_ = other.name_; |
| 104 |
id = other.id; |
| 105 |
elementCount = other.elementCount; |
| 106 |
nodesPerElement = other.nodesPerElement; |
| 107 |
attributeCount = other.attributeCount; |
| 108 |
attributeNames = other.attributeNames; |
| 109 |
offset_ = other.offset_; |
| 110 |
position_ = other.position_; |
| 111 |
return *this; |
| 112 |
} |
| 113 |
}; |
| 114 |
|
| 115 |
template <typename INT> class NodeSet |
| 116 |
{ |
| 117 |
public: |
| 118 |
ex_entity_id id{0}; |
| 119 |
int64_t nodeCount{0}; |
| 120 |
int64_t dfCount{0}; |
| 121 |
int64_t offset_{0}; |
| 122 |
int position_{-1}; |
| 123 |
std::string name_; |
| 124 |
|
| 125 |
std::vector<INT> nodeSetNodes{}; |
| 126 |
std::vector<INT> nodeOrderMap{}; |
| 127 |
DistVector distFactors{}; |
| 128 |
|
| 129 |
size_t entity_count() const { return nodeCount; } |
| 130 |
|
| 131 |
void dump() const |
| 132 |
{ |
| 133 |
fmt::print(stderr, "NodeSet {}, Name: {}, {} nodes, {} df,\torder = {}\n", id, name_, |
| 134 |
nodeCount, dfCount, position_); |
| 135 |
} |
| 136 |
|
| 137 |
void dump_order() const |
| 138 |
{ |
| 139 |
dump(); |
| 140 |
for (int64_t i = 0; i < nodeCount; i++) { |
| 141 |
fmt::print(stderr, "{}, ", nodeOrderMap[i]); |
| 142 |
} |
| 143 |
fmt::print("\n"); |
| 144 |
} |
| 145 |
}; |
| 146 |
|
| 147 |
template <typename INT> class SideSet |
| 148 |
{ |
| 149 |
public: |
| 150 |
ex_entity_id id{0}; |
| 151 |
int64_t sideCount{0}; |
| 152 |
int64_t dfCount{0}; |
| 153 |
int64_t offset_{-1}; |
| 154 |
int position_{-1}; |
| 155 |
std::string name_; |
| 156 |
|
| 157 |
std::vector<INT> elems{}; |
| 158 |
std::vector<INT> sides{}; |
| 159 |
DistVector distFactors{}; |
| 160 |
|
| 161 |
size_t entity_count() const { return sideCount; } |
| 162 |
|
| 163 |
void dump() const |
| 164 |
{ |
| 165 |
fmt::print(stderr, "SideSet {}, Name: {}, {} sides, {} df\toffset = {}, order = {}\n", id, |
| 166 |
name_, sideCount, dfCount, offset_, position_); |
| 167 |
} |
| 168 |
}; |
| 169 |
|
| 170 |
template <typename INT> class EdgeBlock |
| 171 |
{ |
| 172 |
public: |
| 173 |
EdgeBlock() { copy_string(elType, ""); } |
| 174 |
|
| 175 |
EdgeBlock(const EdgeBlock &other) |
| 176 |
: name_(other.name_), id(other.id), edgeCount(other.edgeCount), |
| 177 |
nodesPerEdge(other.nodesPerEdge), attributeCount(other.attributeCount), |
| 178 |
offset_(other.offset_), position_(other.position_) |
| 179 |
{ |
| 180 |
copy_string(elType, other.elType); |
| 181 |
} |
| 182 |
|
| 183 |
char elType[MAX_STR_LENGTH + 1]{}; |
| 184 |
std::string name_; |
| 185 |
std::vector<std::string> attributeNames{}; |
| 186 |
ex_entity_id id{0}; |
| 187 |
int64_t edgeCount{0}; |
| 188 |
int nodesPerEdge{0}; |
| 189 |
int attributeCount{0}; |
| 190 |
int64_t offset_{0}; |
| 191 |
int position_{0}; |
| 192 |
|
| 193 |
size_t entity_count() const { return edgeCount; } |
| 194 |
|
| 195 |
void dump() const |
| 196 |
{ |
| 197 |
fmt::print(stderr, "EdgeBlock {}, Name: {}, {} edges\n", id, name_, edgeCount); |
| 198 |
} |
| 199 |
|
| 200 |
EdgeBlock &operator=(const EdgeBlock &other) |
| 201 |
{ |
| 202 |
copy_string(elType, other.elType); |
| 203 |
name_ = other.name_; |
| 204 |
id = other.id; |
| 205 |
edgeCount = other.edgeCount; |
| 206 |
nodesPerEdge = other.nodesPerEdge; |
| 207 |
attributeCount = other.attributeCount; |
| 208 |
attributeNames = other.attributeNames; |
| 209 |
offset_ = other.offset_; |
| 210 |
position_ = other.position_; |
| 211 |
return *this; |
| 212 |
} |
| 213 |
}; |
| 214 |
|
| 215 |
template <typename INT> class FaceBlock |
| 216 |
{ |
| 217 |
public: |
| 218 |
FaceBlock() { copy_string(elType, ""); } |
| 219 |
|
| 220 |
FaceBlock(const FaceBlock &other) |
| 221 |
: name_(other.name_), id(other.id), faceCount(other.faceCount), |
| 222 |
nodesPerFace(other.nodesPerFace), attributeCount(other.attributeCount), |
| 223 |
offset_(other.offset_), position_(other.position_) |
| 224 |
{ |
| 225 |
copy_string(elType, other.elType); |
| 226 |
} |
| 227 |
|
| 228 |
char elType[MAX_STR_LENGTH + 1]{}; |
| 229 |
std::string name_; |
| 230 |
std::vector<std::string> attributeNames{}; |
| 231 |
ex_entity_id id{0}; |
| 232 |
int64_t faceCount{0}; |
| 233 |
int nodesPerFace{0}; |
| 234 |
int attributeCount{0}; |
| 235 |
int64_t offset_{0}; |
| 236 |
int position_{0}; |
| 237 |
|
| 238 |
size_t entity_count() const { return faceCount; } |
| 239 |
|
| 240 |
void dump() const |
| 241 |
{ |
| 242 |
fmt::print(stderr, "FaceBlock {}, Name: {}, {} faces\n", id, name_, faceCount); |
| 243 |
} |
| 244 |
|
| 245 |
FaceBlock &operator=(const FaceBlock &other) |
| 246 |
{ |
| 247 |
copy_string(elType, other.elType); |
| 248 |
name_ = other.name_; |
| 249 |
id = other.id; |
| 250 |
faceCount = other.faceCount; |
| 251 |
nodesPerFace = other.nodesPerFace; |
| 252 |
attributeCount = other.attributeCount; |
| 253 |
attributeNames = other.attributeNames; |
| 254 |
offset_ = other.offset_; |
| 255 |
position_ = other.position_; |
| 256 |
return *this; |
| 257 |
} |
| 258 |
}; |
| 259 |
|
| 260 |
class CommunicationMap |
| 261 |
{ |
| 262 |
public: |
| 263 |
CommunicationMap(int the_id, int64_t count, char the_type) |
| 264 |
: id(the_id), entityCount(count), type(the_type) |
| 265 |
{ |
| 266 |
} |
| 267 |
ex_entity_id id{0}; |
| 268 |
int64_t entityCount{0}; |
| 269 |
char type{'U'}; // 'n' for node, 'e' for element |
| 270 |
}; |
| 271 |
|
| 272 |
class CommunicationMetaData |
| 273 |
{ |
| 274 |
public: |
| 275 |
CommunicationMetaData() = default; |
| 276 |
CommunicationMetaData(const CommunicationMetaData &) = delete; |
| 277 |
CommunicationMetaData &operator=(const CommunicationMetaData &other) = delete; |
| 278 |
|
| 279 |
std::vector<CommunicationMap> nodeMap{}; |
| 280 |
std::vector<CommunicationMap> elementMap{}; |
| 281 |
|
| 282 |
int processorId{0}; |
| 283 |
int processorCount{0}; |
| 284 |
int64_t globalNodes{0}; |
| 285 |
int64_t globalElements{0}; |
| 286 |
int64_t nodesInternal{0}; |
| 287 |
int64_t nodesBorder{0}; |
| 288 |
int64_t nodesExternal{0}; |
| 289 |
int64_t elementsInternal{0}; |
| 290 |
int64_t elementsBorder{0}; |
| 291 |
}; |
| 292 |
} // namespace Excn |