| 1 |
// Copyright(C) 1999-2020, 2022, 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 "iotm_export.h" |
| 10 |
|
| 11 |
#include "Ioss_CodeTypes.h" |
| 12 |
#include "Ioss_EntityType.h" // for EntityType |
| 13 |
|
| 14 |
#include <cstddef> // for size_t |
| 15 |
#include <cstdint> // for int64_t |
| 16 |
#include <map> // for map, etc |
| 17 |
#include <string> // for string |
| 18 |
#include <unordered_map> |
| 19 |
#include <utility> // for pair |
| 20 |
#include <vector> // for vector |
| 21 |
|
| 22 |
#include <assert.h> |
| 23 |
|
| 24 |
#include "Ioss_ElementPermutation.h" |
| 25 |
#include "Ioss_ElementTopology.h" |
| 26 |
#include "Ioss_StandardElementTypes.h" |
| 27 |
#include "Ioss_Utils.h" |
| 28 |
|
| 29 |
#include "Iotm_TextMeshDataTypes.h" |
| 30 |
|
| 31 |
namespace Iotm { |
| 32 |
class IOTM_EXPORT TopologyMapEntry |
| 33 |
{ |
| 34 |
public: |
| 35 |
using Ordinal = uint16_t; |
| 36 |
using Permutation = uint8_t; |
| 37 |
|
| 38 |
static constexpr Ordinal InvalidOrdinal = 65535; |
| 39 |
static constexpr Permutation InvalidPermutation = 128; |
| 40 |
|
| 41 |
using DimensionArray = bool[4]; |
| 42 |
|
| 43 |
TopologyMapEntry() |
| 44 |
: id(Ioss::ElementTopology::get_unique_id(std::string(Ioss::Unknown::name))), |
| 45 |
topology(Ioss::ElementTopology::factory(std::string(Ioss::Unknown::name))), |
| 46 |
initialized(false) |
| 47 |
{ |
| 48 |
set_valid_spatial_dimensions({false, false, false, false}); |
| 49 |
} |
| 50 |
|
| 51 |
explicit TopologyMapEntry(const std::string &name) |
| 52 |
: id(Ioss::ElementTopology::get_unique_id(name)), |
| 53 |
topology(Ioss::ElementTopology::factory(name)), initialized(false) |
| 54 |
{ |
| 55 |
set_valid_spatial_dimensions({false, false, false, false}); |
| 56 |
} |
| 57 |
|
| 58 |
TopologyMapEntry(const TopologyMapEntry &topo) = default; |
| 59 |
TopologyMapEntry &operator=(const TopologyMapEntry &topo) = default; |
| 60 |
|
| 61 |
bool operator==(const Ioss::ElementTopology *topo) const { return topo == topology; } |
| 62 |
|
| 63 |
bool defined_on_spatial_dimension(const unsigned spatialDim) const |
| 64 |
{ |
| 65 |
if (spatialDim > 3) { |
| 66 |
return false; |
| 67 |
} |
| 68 |
return validSpatialDimensions[spatialDim]; |
| 69 |
} |
| 70 |
|
| 71 |
const std::string name() const { return topology->name(); } |
| 72 |
|
| 73 |
int num_nodes() const { return topology->number_nodes(); } |
| 74 |
|
| 75 |
bool operator==(const TopologyMapEntry &rhs) const |
| 76 |
{ |
| 77 |
return id == rhs.id && topology == rhs.topology && |
| 78 |
equivalent_valid_spatial_dimensions(rhs.validSpatialDimensions); |
| 79 |
} |
| 80 |
|
| 81 |
bool operator!=(const TopologyMapEntry &rhs) const { return !(*this == rhs); } |
| 82 |
|
| 83 |
int num_face_sides() const |
| 84 |
{ |
| 85 |
if (topology->is_shell()) { |
| 86 |
// Only interested in face boundaries, not edges |
| 87 |
if (topology->parametric_dimension() == 2) { |
| 88 |
return topology->number_faces(); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
return topology->number_boundaries(); |
| 93 |
} |
| 94 |
|
| 95 |
int num_sides() const { return sideTopologies.size(); } |
| 96 |
|
| 97 |
// Side references are one-based |
| 98 |
bool valid_side(unsigned side) const |
| 99 |
{ |
| 100 |
unsigned numSides = num_sides(); |
| 101 |
if (side > 0 && side <= numSides) |
| 102 |
return true; |
| 103 |
return false; |
| 104 |
} |
| 105 |
|
| 106 |
std::string side_topology_name(unsigned side) const |
| 107 |
{ |
| 108 |
if (!valid_side(side)) |
| 109 |
return ""; |
| 110 |
|
| 111 |
Ioss::ElementTopology *sideTopology = topology->boundary_type(side); |
| 112 |
return sideTopology->name(); |
| 113 |
} |
| 114 |
|
| 115 |
const TopologyMapEntry &side_topology(unsigned side) const |
| 116 |
{ |
| 117 |
if (!valid_side(side)) |
| 118 |
return *(invalid_topology_factory()); |
| 119 |
return *sideTopologies[side - 1]; |
| 120 |
} |
| 121 |
|
| 122 |
unsigned side_topology_num_nodes(unsigned side) const |
| 123 |
{ |
| 124 |
if (!valid_side(side)) |
| 125 |
return 0; |
| 126 |
|
| 127 |
Ioss::ElementTopology *sideTopology = topology->boundary_type(side); |
| 128 |
return sideTopology->number_nodes(); |
| 129 |
} |
| 130 |
|
| 131 |
std::vector<Ordinal> side_topology_node_indices(unsigned side) const |
| 132 |
{ |
| 133 |
if (!valid_side(side)) |
| 134 |
return std::vector<Ordinal>(); |
| 135 |
|
| 136 |
Ioss::ElementTopology *sideTopology = topology->boundary_type(side); |
| 137 |
std::vector<Ordinal> elementNodeOrdinalVector(sideTopology->number_nodes()); |
| 138 |
|
| 139 |
Ioss::IntVector connectivity = topology->boundary_connectivity(side); |
| 140 |
|
| 141 |
for (int i = 0; i < sideTopology->number_nodes(); i++) { |
| 142 |
elementNodeOrdinalVector[i] = connectivity[i]; |
| 143 |
} |
| 144 |
|
| 145 |
return elementNodeOrdinalVector; |
| 146 |
} |
| 147 |
|
| 148 |
bool is_shell() const { return topology->is_shell(); } |
| 149 |
|
| 150 |
unsigned num_permutations() const { return topology->permutation()->num_permutations(); } |
| 151 |
|
| 152 |
unsigned num_positive_permutations() const |
| 153 |
{ |
| 154 |
return topology->permutation()->num_positive_permutations(); |
| 155 |
} |
| 156 |
|
| 157 |
bool is_positive_polarity(Permutation permutation) const |
| 158 |
{ |
| 159 |
return topology->permutation()->is_positive_polarity(permutation); |
| 160 |
} |
| 161 |
|
| 162 |
bool valid_permutation(Permutation permutation) const |
| 163 |
{ |
| 164 |
return topology->permutation()->valid_permutation(permutation); |
| 165 |
} |
| 166 |
|
| 167 |
bool fill_permutation_indices(Permutation permutation, |
| 168 |
std::vector<Ordinal> &nodeOrdinalVector) const |
| 169 |
{ |
| 170 |
return topology->permutation()->fill_permutation_indices(permutation, nodeOrdinalVector); |
| 171 |
} |
| 172 |
|
| 173 |
std::vector<Ordinal> permutation_indices(Permutation permutation) const |
| 174 |
{ |
| 175 |
return topology->permutation()->permutation_indices(permutation); |
| 176 |
} |
| 177 |
|
| 178 |
static TopologyMapEntry *invalid_topology_factory() |
| 179 |
{ |
| 180 |
static TopologyMapEntry entry; |
| 181 |
|
| 182 |
entry.initialized = true; |
| 183 |
|
| 184 |
return &entry; |
| 185 |
} |
| 186 |
|
| 187 |
// Node with no permutation and no sides |
| 188 |
static TopologyMapEntry *node_factory() |
| 189 |
{ |
| 190 |
static TopologyMapEntry entry(Ioss::Node::name); |
| 191 |
|
| 192 |
if (!entry.initialized) { |
| 193 |
entry.set_valid_spatial_dimensions({false, true, true, true}); |
| 194 |
entry.set_side_topologies({}); |
| 195 |
entry.initialized = true; |
| 196 |
} |
| 197 |
|
| 198 |
return &entry; |
| 199 |
} |
| 200 |
|
| 201 |
//*************************************************************************** |
| 202 |
// topology::LINE -- topology::EDGE_RANK |
| 203 |
// 2 nodes with no sides defined in 2D/3D |
| 204 |
//*************************************************************************** |
| 205 |
static TopologyMapEntry *line_2_factory() |
| 206 |
{ |
| 207 |
static TopologyMapEntry entry(Ioss::Edge2::name); |
| 208 |
|
| 209 |
if (!entry.initialized) { |
| 210 |
entry.set_valid_spatial_dimensions({false, false, true, true}); |
| 211 |
entry.set_side_topologies({}); |
| 212 |
entry.initialized = true; |
| 213 |
} |
| 214 |
|
| 215 |
return &entry; |
| 216 |
} |
| 217 |
|
| 218 |
//*************************************************************************** |
| 219 |
// topology::LINE 1D -- topology::ELEMENT_RANK |
| 220 |
// 2 nodes with no sides only defined on 1d problems |
| 221 |
//*************************************************************************** |
| 222 |
static TopologyMapEntry *line_2_1d_factory() |
| 223 |
{ |
| 224 |
static TopologyMapEntry entry(Ioss::Edge2::name); |
| 225 |
|
| 226 |
if (!entry.initialized) { |
| 227 |
entry.set_valid_spatial_dimensions({false, true, false, false}); |
| 228 |
entry.set_side_topologies({}); |
| 229 |
entry.initialized = true; |
| 230 |
} |
| 231 |
|
| 232 |
return &entry; |
| 233 |
} |
| 234 |
|
| 235 |
//*************************************************************************** |
| 236 |
// topology::LINE -- topology::EDGE_RANK |
| 237 |
// 3 nodes with no sides defined in 2D/3D |
| 238 |
//*************************************************************************** |
| 239 |
static TopologyMapEntry *line_3_factory() |
| 240 |
{ |
| 241 |
static TopologyMapEntry entry(Ioss::Edge3::name); |
| 242 |
|
| 243 |
if (!entry.initialized) { |
| 244 |
entry.set_valid_spatial_dimensions({false, false, true, true}); |
| 245 |
entry.set_side_topologies({}); |
| 246 |
entry.initialized = true; |
| 247 |
} |
| 248 |
|
| 249 |
return &entry; |
| 250 |
} |
| 251 |
|
| 252 |
//*************************************************************************** |
| 253 |
// topology::LINE 1D -- topology::ELEMENT_RANK |
| 254 |
// 3 nodes with no sides only defined on 1d problems |
| 255 |
//*************************************************************************** |
| 256 |
static TopologyMapEntry *line_3_1d_factory() |
| 257 |
{ |
| 258 |
static TopologyMapEntry entry(Ioss::Edge3::name); |
| 259 |
|
| 260 |
if (!entry.initialized) { |
| 261 |
entry.set_valid_spatial_dimensions({false, true, false, false}); |
| 262 |
entry.set_side_topologies({}); |
| 263 |
entry.initialized = true; |
| 264 |
} |
| 265 |
|
| 266 |
return &entry; |
| 267 |
} |
| 268 |
|
| 269 |
//*************************************************************************** |
| 270 |
// topology::TRIANGLE -- topology::FACE_RANK |
| 271 |
// defined on spatial dimension 3d |
| 272 |
// 3, 4, or 6 nodes with 3 edges and no sides |
| 273 |
//*************************************************************************** |
| 274 |
static TopologyMapEntry *tri_3_factory() |
| 275 |
{ |
| 276 |
static TopologyMapEntry entry(Ioss::Tri3::name); |
| 277 |
|
| 278 |
if (!entry.initialized) { |
| 279 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 280 |
entry.set_side_topologies({}); |
| 281 |
entry.initialized = true; |
| 282 |
} |
| 283 |
|
| 284 |
return &entry; |
| 285 |
} |
| 286 |
|
| 287 |
static TopologyMapEntry *tri_4_factory() |
| 288 |
{ |
| 289 |
static TopologyMapEntry entry(Ioss::Tri4::name); |
| 290 |
|
| 291 |
if (!entry.initialized) { |
| 292 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 293 |
entry.set_side_topologies({}); |
| 294 |
entry.initialized = true; |
| 295 |
} |
| 296 |
|
| 297 |
return &entry; |
| 298 |
} |
| 299 |
|
| 300 |
static TopologyMapEntry *tri_6_factory() |
| 301 |
{ |
| 302 |
static TopologyMapEntry entry(Ioss::Tri6::name); |
| 303 |
|
| 304 |
if (!entry.initialized) { |
| 305 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 306 |
entry.set_side_topologies({}); |
| 307 |
entry.initialized = true; |
| 308 |
} |
| 309 |
|
| 310 |
return &entry; |
| 311 |
} |
| 312 |
|
| 313 |
//*************************************************************************** |
| 314 |
// topology::QUADRILATERAL -- topology::FACE_RANK |
| 315 |
// defined on spatial dimension 3d |
| 316 |
// 4, 8, or 9 nodes with 4 edges and no sides |
| 317 |
//*************************************************************************** |
| 318 |
static TopologyMapEntry *quad_4_factory() |
| 319 |
{ |
| 320 |
static TopologyMapEntry entry(Ioss::Quad4::name); |
| 321 |
|
| 322 |
if (!entry.initialized) { |
| 323 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 324 |
entry.set_side_topologies({}); |
| 325 |
entry.initialized = true; |
| 326 |
} |
| 327 |
|
| 328 |
return &entry; |
| 329 |
} |
| 330 |
|
| 331 |
static TopologyMapEntry *quad_6_factory() |
| 332 |
{ |
| 333 |
static TopologyMapEntry entry(Ioss::Quad6::name); |
| 334 |
|
| 335 |
if (!entry.initialized) { |
| 336 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 337 |
entry.set_side_topologies({}); |
| 338 |
entry.initialized = true; |
| 339 |
} |
| 340 |
|
| 341 |
return &entry; |
| 342 |
} |
| 343 |
|
| 344 |
static TopologyMapEntry *quad_8_factory() |
| 345 |
{ |
| 346 |
static TopologyMapEntry entry(Ioss::Quad8::name); |
| 347 |
|
| 348 |
if (!entry.initialized) { |
| 349 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 350 |
entry.set_side_topologies({}); |
| 351 |
entry.initialized = true; |
| 352 |
} |
| 353 |
|
| 354 |
return &entry; |
| 355 |
} |
| 356 |
|
| 357 |
static TopologyMapEntry *quad_9_factory() |
| 358 |
{ |
| 359 |
static TopologyMapEntry entry(Ioss::Quad9::name); |
| 360 |
|
| 361 |
if (!entry.initialized) { |
| 362 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 363 |
entry.set_side_topologies({}); |
| 364 |
entry.initialized = true; |
| 365 |
} |
| 366 |
|
| 367 |
return &entry; |
| 368 |
} |
| 369 |
|
| 370 |
//*************************************************************************** |
| 371 |
// PARTICLE -- topology::ELEMENT_RANK |
| 372 |
// one node with no sides |
| 373 |
//*************************************************************************** |
| 374 |
static TopologyMapEntry *particle_factory() |
| 375 |
{ |
| 376 |
static TopologyMapEntry entry(Ioss::Sphere::name); |
| 377 |
|
| 378 |
if (!entry.initialized) { |
| 379 |
entry.set_valid_spatial_dimensions({false, true, true, true}); |
| 380 |
entry.set_side_topologies({}); |
| 381 |
entry.initialized = true; |
| 382 |
} |
| 383 |
|
| 384 |
return &entry; |
| 385 |
} |
| 386 |
|
| 387 |
//*************************************************************************** |
| 388 |
// topology::BEAM_2 -- topology::ELEMENT_RANK |
| 389 |
// 2 nodes with 2 sides defined in 2D/3D |
| 390 |
//*************************************************************************** |
| 391 |
static TopologyMapEntry *beam_2_factory() |
| 392 |
{ |
| 393 |
static TopologyMapEntry entry(Ioss::Beam2::name); |
| 394 |
|
| 395 |
if (!entry.initialized) { |
| 396 |
entry.set_valid_spatial_dimensions({false, false, true, true}); |
| 397 |
entry.set_side_topologies({line_2_factory(), line_2_factory()}); |
| 398 |
entry.initialized = true; |
| 399 |
} |
| 400 |
|
| 401 |
return &entry; |
| 402 |
} |
| 403 |
|
| 404 |
//*************************************************************************** |
| 405 |
// topology::BEAM_3 -- topology::ELEMENT_RANK |
| 406 |
// 3 nodes with 2 sides defined in 2D/3D |
| 407 |
//*************************************************************************** |
| 408 |
static TopologyMapEntry *beam_3_factory() |
| 409 |
{ |
| 410 |
static TopologyMapEntry entry(Ioss::Beam3::name); |
| 411 |
|
| 412 |
if (!entry.initialized) { |
| 413 |
entry.set_valid_spatial_dimensions({false, false, true, true}); |
| 414 |
entry.set_side_topologies({line_3_factory(), line_3_factory()}); |
| 415 |
entry.initialized = true; |
| 416 |
} |
| 417 |
|
| 418 |
return &entry; |
| 419 |
} |
| 420 |
|
| 421 |
//*************************************************************************** |
| 422 |
// topology::SHELL_LINE -- topology::ELEMENT_RANK |
| 423 |
// only defined on 2d problems |
| 424 |
// 2 or 3 nodes with two edges and 2 sides |
| 425 |
//*************************************************************************** |
| 426 |
|
| 427 |
static TopologyMapEntry *shell_line_2_factory() |
| 428 |
{ |
| 429 |
static TopologyMapEntry entry(Ioss::ShellLine2D2::name); |
| 430 |
|
| 431 |
if (!entry.initialized) { |
| 432 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 433 |
entry.set_side_topologies({line_2_factory(), line_2_factory()}); |
| 434 |
entry.initialized = true; |
| 435 |
} |
| 436 |
|
| 437 |
return &entry; |
| 438 |
} |
| 439 |
|
| 440 |
static TopologyMapEntry *shell_line_3_factory() |
| 441 |
{ |
| 442 |
static TopologyMapEntry entry(Ioss::ShellLine2D3::name); |
| 443 |
|
| 444 |
if (!entry.initialized) { |
| 445 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 446 |
entry.set_side_topologies({line_3_factory(), line_3_factory()}); |
| 447 |
entry.initialized = true; |
| 448 |
} |
| 449 |
|
| 450 |
return &entry; |
| 451 |
} |
| 452 |
|
| 453 |
//*************************************************************************** |
| 454 |
// topology::SPRING -- topology::ELEM_RANK |
| 455 |
// 2 or 3 nodes with no sides |
| 456 |
//*************************************************************************** |
| 457 |
|
| 458 |
static TopologyMapEntry *spring_2_factory() |
| 459 |
{ |
| 460 |
static TopologyMapEntry entry(Ioss::Spring2::name); |
| 461 |
|
| 462 |
if (!entry.initialized) { |
| 463 |
entry.set_valid_spatial_dimensions({false, true, true, true}); |
| 464 |
entry.set_side_topologies({}); |
| 465 |
entry.initialized = true; |
| 466 |
} |
| 467 |
|
| 468 |
return &entry; |
| 469 |
} |
| 470 |
|
| 471 |
static TopologyMapEntry *spring_3_factory() |
| 472 |
{ |
| 473 |
static TopologyMapEntry entry(Ioss::Spring3::name); |
| 474 |
|
| 475 |
if (!entry.initialized) { |
| 476 |
entry.set_valid_spatial_dimensions({false, true, true, true}); |
| 477 |
entry.set_side_topologies({}); |
| 478 |
entry.initialized = true; |
| 479 |
} |
| 480 |
|
| 481 |
return &entry; |
| 482 |
} |
| 483 |
|
| 484 |
//*************************************************************************** |
| 485 |
// topology::TRIANGLE 2D -- topology::ELEMENT_RANK |
| 486 |
// defined on spatial dimension 2d |
| 487 |
// 3, 4, or 6 nodes with 3 edges and 3 sides |
| 488 |
//*************************************************************************** |
| 489 |
static TopologyMapEntry *tri_3_2d_factory() |
| 490 |
{ |
| 491 |
static TopologyMapEntry entry(Ioss::Tri3::name); |
| 492 |
|
| 493 |
if (!entry.initialized) { |
| 494 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 495 |
entry.set_side_topologies({line_2_factory(), line_2_factory(), line_2_factory()}); |
| 496 |
entry.initialized = true; |
| 497 |
} |
| 498 |
|
| 499 |
return &entry; |
| 500 |
} |
| 501 |
|
| 502 |
static TopologyMapEntry *tri_4_2d_factory() |
| 503 |
{ |
| 504 |
static TopologyMapEntry entry(Ioss::Tri4::name); |
| 505 |
|
| 506 |
if (!entry.initialized) { |
| 507 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 508 |
entry.set_side_topologies({line_2_factory(), line_2_factory(), line_2_factory()}); |
| 509 |
entry.initialized = true; |
| 510 |
} |
| 511 |
|
| 512 |
return &entry; |
| 513 |
} |
| 514 |
|
| 515 |
static TopologyMapEntry *tri_6_2d_factory() |
| 516 |
{ |
| 517 |
static TopologyMapEntry entry(Ioss::Tri6::name); |
| 518 |
|
| 519 |
if (!entry.initialized) { |
| 520 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 521 |
entry.set_side_topologies({line_3_factory(), line_3_factory(), line_3_factory()}); |
| 522 |
entry.initialized = true; |
| 523 |
} |
| 524 |
|
| 525 |
return &entry; |
| 526 |
} |
| 527 |
|
| 528 |
//*************************************************************************** |
| 529 |
// topology::QUADRILATERAL 2D -- topology::ELEMENT_RANK |
| 530 |
// defined on spatial dimension 2d |
| 531 |
// 4, 8, or 9 nodes with 4 edges and 4 sides |
| 532 |
//*************************************************************************** |
| 533 |
|
| 534 |
static TopologyMapEntry *quad_4_2d_factory() |
| 535 |
{ |
| 536 |
static TopologyMapEntry entry(Ioss::Quad4::name); |
| 537 |
|
| 538 |
if (!entry.initialized) { |
| 539 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 540 |
entry.set_side_topologies( |
| 541 |
{line_2_factory(), line_2_factory(), line_2_factory(), line_2_factory()}); |
| 542 |
entry.initialized = true; |
| 543 |
} |
| 544 |
|
| 545 |
return &entry; |
| 546 |
} |
| 547 |
|
| 548 |
static TopologyMapEntry *quad_8_2d_factory() |
| 549 |
{ |
| 550 |
static TopologyMapEntry entry(Ioss::Quad8::name); |
| 551 |
|
| 552 |
if (!entry.initialized) { |
| 553 |
entry.set_valid_spatial_dimensions({false, false, true, false}); |
| 554 |
entry.set_side_topologies( |
| 555 |
{line_3_factory(), line_3_factory(), line_3_factory(), line_3_factory()}); |
| 556 |
entry.initialized = true; |
| 557 |
} |
| 558 |
|
| 559 |
return &entry; |
| 560 |
} |
| 561 |
|
| 562 |
static TopologyMapEntry *quad_9_2d_factory() |
| 563 |
{ |
| 564 |
static TopologyMapEntry entry(Ioss::Quad9::name); |
| 565 |
|
| 566 |
if (!entry.initialized) { |
| 567 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 568 |
entry.set_side_topologies( |
| 569 |
{line_3_factory(), line_3_factory(), line_3_factory(), line_3_factory()}); |
| 570 |
entry.initialized = true; |
| 571 |
} |
| 572 |
|
| 573 |
return &entry; |
| 574 |
} |
| 575 |
|
| 576 |
//*************************************************************************** |
| 577 |
// topology::SHELL topology::TRIANGLE -- topology::ELEMENT_RANK |
| 578 |
// defined on spatial dimension 3d |
| 579 |
// 3, 4, or 6 nodes with 3 edges and 2 sides |
| 580 |
//*************************************************************************** |
| 581 |
|
| 582 |
static TopologyMapEntry *shell_tri_3_factory() |
| 583 |
{ |
| 584 |
static TopologyMapEntry entry(Ioss::TriShell3::name); |
| 585 |
|
| 586 |
if (!entry.initialized) { |
| 587 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 588 |
entry.set_side_topologies({tri_3_factory(), tri_3_factory(), line_2_factory(), |
| 589 |
line_2_factory(), line_2_factory()}); |
| 590 |
entry.initialized = true; |
| 591 |
} |
| 592 |
|
| 593 |
return &entry; |
| 594 |
} |
| 595 |
|
| 596 |
static TopologyMapEntry *shell_tri_4_factory() |
| 597 |
{ |
| 598 |
static TopologyMapEntry entry(Ioss::TriShell4::name); |
| 599 |
|
| 600 |
if (!entry.initialized) { |
| 601 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 602 |
entry.set_side_topologies({tri_4_factory(), tri_4_factory(), line_2_factory(), |
| 603 |
line_2_factory(), line_2_factory()}); |
| 604 |
entry.initialized = true; |
| 605 |
} |
| 606 |
|
| 607 |
return &entry; |
| 608 |
} |
| 609 |
|
| 610 |
static TopologyMapEntry *shell_tri_6_factory() |
| 611 |
{ |
| 612 |
static TopologyMapEntry entry(Ioss::TriShell6::name); |
| 613 |
|
| 614 |
if (!entry.initialized) { |
| 615 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 616 |
entry.set_side_topologies({tri_6_factory(), tri_6_factory(), line_3_factory(), |
| 617 |
line_3_factory(), line_3_factory()}); |
| 618 |
entry.initialized = true; |
| 619 |
} |
| 620 |
|
| 621 |
return &entry; |
| 622 |
} |
| 623 |
|
| 624 |
//*************************************************************************** |
| 625 |
// topology::SHELL topology::QUADRILATERAL -- topology::ELEMENT_RANK |
| 626 |
// defined on spatial dimension 3d |
| 627 |
// 4, 8, or 9 nodes with 4 edges and 2 sides |
| 628 |
//*************************************************************************** |
| 629 |
static TopologyMapEntry *shell_quad_4_factory() |
| 630 |
{ |
| 631 |
static TopologyMapEntry entry(Ioss::Shell4::name); |
| 632 |
|
| 633 |
if (!entry.initialized) { |
| 634 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 635 |
entry.set_side_topologies({quad_4_factory(), quad_4_factory(), line_2_factory(), |
| 636 |
line_2_factory(), line_2_factory(), line_2_factory()}); |
| 637 |
entry.initialized = true; |
| 638 |
} |
| 639 |
|
| 640 |
return &entry; |
| 641 |
} |
| 642 |
|
| 643 |
static TopologyMapEntry *shell_quad_8_factory() |
| 644 |
{ |
| 645 |
static TopologyMapEntry entry(Ioss::Shell8::name); |
| 646 |
|
| 647 |
if (!entry.initialized) { |
| 648 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 649 |
entry.set_side_topologies({quad_8_factory(), quad_8_factory(), line_3_factory(), |
| 650 |
line_3_factory(), line_3_factory(), line_3_factory()}); |
| 651 |
entry.initialized = true; |
| 652 |
} |
| 653 |
|
| 654 |
return &entry; |
| 655 |
} |
| 656 |
|
| 657 |
static TopologyMapEntry *shell_quad_9_factory() |
| 658 |
{ |
| 659 |
static TopologyMapEntry entry(Ioss::Shell9::name); |
| 660 |
|
| 661 |
if (!entry.initialized) { |
| 662 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 663 |
entry.set_side_topologies({quad_9_factory(), quad_9_factory(), line_3_factory(), |
| 664 |
line_3_factory(), line_3_factory(), line_3_factory()}); |
| 665 |
entry.initialized = true; |
| 666 |
} |
| 667 |
|
| 668 |
return &entry; |
| 669 |
} |
| 670 |
|
| 671 |
//*************************************************************************** |
| 672 |
// topology::TETRAHEDRON -- topology::ELEMENT_RANK |
| 673 |
// defined on spatial dimension 3d |
| 674 |
// 4, 8, 10 or 11 nodes with 4 sides |
| 675 |
//*************************************************************************** |
| 676 |
static TopologyMapEntry *tet_4_factory() |
| 677 |
{ |
| 678 |
static TopologyMapEntry entry(Ioss::Tet4::name); |
| 679 |
|
| 680 |
if (!entry.initialized) { |
| 681 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 682 |
entry.set_side_topologies( |
| 683 |
{tri_3_factory(), tri_3_factory(), tri_3_factory(), tri_3_factory()}); |
| 684 |
entry.initialized = true; |
| 685 |
} |
| 686 |
|
| 687 |
return &entry; |
| 688 |
} |
| 689 |
|
| 690 |
static TopologyMapEntry *tet_8_factory() |
| 691 |
{ |
| 692 |
static TopologyMapEntry entry(Ioss::Tet8::name); |
| 693 |
|
| 694 |
if (!entry.initialized) { |
| 695 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 696 |
entry.set_side_topologies( |
| 697 |
{tri_4_factory(), tri_4_factory(), tri_4_factory(), tri_4_factory()}); |
| 698 |
entry.initialized = true; |
| 699 |
} |
| 700 |
|
| 701 |
return &entry; |
| 702 |
} |
| 703 |
|
| 704 |
static TopologyMapEntry *tet_10_factory() |
| 705 |
{ |
| 706 |
static TopologyMapEntry entry(Ioss::Tet10::name); |
| 707 |
|
| 708 |
if (!entry.initialized) { |
| 709 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 710 |
entry.set_side_topologies( |
| 711 |
{tri_6_factory(), tri_6_factory(), tri_6_factory(), tri_6_factory()}); |
| 712 |
entry.initialized = true; |
| 713 |
} |
| 714 |
|
| 715 |
return &entry; |
| 716 |
} |
| 717 |
|
| 718 |
static TopologyMapEntry *tet_11_factory() |
| 719 |
{ |
| 720 |
static TopologyMapEntry entry(Ioss::Tet11::name); |
| 721 |
|
| 722 |
if (!entry.initialized) { |
| 723 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 724 |
entry.set_side_topologies( |
| 725 |
{tri_6_factory(), tri_6_factory(), tri_6_factory(), tri_6_factory()}); |
| 726 |
entry.initialized = true; |
| 727 |
} |
| 728 |
|
| 729 |
return &entry; |
| 730 |
} |
| 731 |
|
| 732 |
//*************************************************************************** |
| 733 |
// topology::PYRAMID -- topology::ELEMENT_RANK |
| 734 |
// defined on spatial dimension 3d |
| 735 |
// 5, 13 or 14 nodes with 5 sides |
| 736 |
//*************************************************************************** |
| 737 |
static TopologyMapEntry *pyramid_5_factory() |
| 738 |
{ |
| 739 |
static TopologyMapEntry entry(Ioss::Pyramid5::name); |
| 740 |
|
| 741 |
if (!entry.initialized) { |
| 742 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 743 |
entry.set_side_topologies( |
| 744 |
{tri_3_factory(), tri_3_factory(), tri_3_factory(), tri_3_factory(), quad_4_factory()}); |
| 745 |
entry.initialized = true; |
| 746 |
} |
| 747 |
|
| 748 |
return &entry; |
| 749 |
} |
| 750 |
|
| 751 |
static TopologyMapEntry *pyramid_13_factory() |
| 752 |
{ |
| 753 |
static TopologyMapEntry entry(Ioss::Pyramid13::name); |
| 754 |
|
| 755 |
if (!entry.initialized) { |
| 756 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 757 |
entry.set_side_topologies( |
| 758 |
{tri_6_factory(), tri_6_factory(), tri_6_factory(), tri_6_factory(), quad_8_factory()}); |
| 759 |
entry.initialized = true; |
| 760 |
} |
| 761 |
|
| 762 |
return &entry; |
| 763 |
} |
| 764 |
|
| 765 |
static TopologyMapEntry *pyramid_14_factory() |
| 766 |
{ |
| 767 |
static TopologyMapEntry entry(Ioss::Pyramid14::name); |
| 768 |
|
| 769 |
if (!entry.initialized) { |
| 770 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 771 |
entry.set_side_topologies( |
| 772 |
{tri_6_factory(), tri_6_factory(), tri_6_factory(), tri_6_factory(), quad_9_factory()}); |
| 773 |
entry.initialized = true; |
| 774 |
} |
| 775 |
|
| 776 |
return &entry; |
| 777 |
} |
| 778 |
|
| 779 |
//*************************************************************************** |
| 780 |
// topology::WEDGE -- topology::ELEMENT_RANK |
| 781 |
// defined on spatial dimension 3d |
| 782 |
// 6, 12, 15 or 18 nodes with 5 sides |
| 783 |
//*************************************************************************** |
| 784 |
static TopologyMapEntry *wedge_6_factory() |
| 785 |
{ |
| 786 |
static TopologyMapEntry entry(Ioss::Wedge6::name); |
| 787 |
|
| 788 |
if (!entry.initialized) { |
| 789 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 790 |
entry.set_side_topologies({quad_4_factory(), quad_4_factory(), quad_4_factory(), |
| 791 |
tri_3_factory(), tri_3_factory()}); |
| 792 |
entry.initialized = true; |
| 793 |
} |
| 794 |
|
| 795 |
return &entry; |
| 796 |
} |
| 797 |
|
| 798 |
static TopologyMapEntry *wedge_12_factory() |
| 799 |
{ |
| 800 |
static TopologyMapEntry entry(Ioss::Wedge12::name); |
| 801 |
|
| 802 |
if (!entry.initialized) { |
| 803 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 804 |
entry.set_side_topologies({quad_6_factory(), quad_6_factory(), quad_6_factory(), |
| 805 |
tri_6_factory(), tri_6_factory()}); |
| 806 |
entry.initialized = true; |
| 807 |
} |
| 808 |
|
| 809 |
return &entry; |
| 810 |
} |
| 811 |
|
| 812 |
static TopologyMapEntry *wedge_15_factory() |
| 813 |
{ |
| 814 |
static TopologyMapEntry entry(Ioss::Wedge15::name); |
| 815 |
|
| 816 |
if (!entry.initialized) { |
| 817 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 818 |
entry.set_side_topologies({quad_8_factory(), quad_8_factory(), quad_8_factory(), |
| 819 |
tri_6_factory(), tri_6_factory()}); |
| 820 |
entry.initialized = true; |
| 821 |
} |
| 822 |
|
| 823 |
return &entry; |
| 824 |
} |
| 825 |
|
| 826 |
static TopologyMapEntry *wedge_18_factory() |
| 827 |
{ |
| 828 |
static TopologyMapEntry entry(Ioss::Wedge18::name); |
| 829 |
|
| 830 |
if (!entry.initialized) { |
| 831 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 832 |
entry.set_side_topologies({quad_9_factory(), quad_9_factory(), quad_9_factory(), |
| 833 |
tri_6_factory(), tri_6_factory()}); |
| 834 |
entry.initialized = true; |
| 835 |
} |
| 836 |
|
| 837 |
return &entry; |
| 838 |
} |
| 839 |
|
| 840 |
//*************************************************************************** |
| 841 |
// topology::HEXAHEDRON -- topology::ELEMENT_RANK |
| 842 |
// defined on spatial dimension 3d |
| 843 |
// 8, 20 or 27 nodes nodes with 6 sides |
| 844 |
//*************************************************************************** |
| 845 |
static TopologyMapEntry *hex_8_factory() |
| 846 |
{ |
| 847 |
static TopologyMapEntry entry(Ioss::Hex8::name); |
| 848 |
|
| 849 |
if (!entry.initialized) { |
| 850 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 851 |
entry.set_side_topologies({quad_4_factory(), quad_4_factory(), quad_4_factory(), |
| 852 |
quad_4_factory(), quad_4_factory(), quad_4_factory()}); |
| 853 |
entry.initialized = true; |
| 854 |
} |
| 855 |
|
| 856 |
return &entry; |
| 857 |
} |
| 858 |
|
| 859 |
static TopologyMapEntry *hex_20_factory() |
| 860 |
{ |
| 861 |
static TopologyMapEntry entry(Ioss::Hex20::name); |
| 862 |
|
| 863 |
if (!entry.initialized) { |
| 864 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 865 |
entry.set_side_topologies({quad_8_factory(), quad_8_factory(), quad_8_factory(), |
| 866 |
quad_8_factory(), quad_8_factory(), quad_8_factory()}); |
| 867 |
entry.initialized = true; |
| 868 |
} |
| 869 |
|
| 870 |
return &entry; |
| 871 |
} |
| 872 |
|
| 873 |
static TopologyMapEntry *hex_27_factory() |
| 874 |
{ |
| 875 |
static TopologyMapEntry entry(Ioss::Hex27::name); |
| 876 |
|
| 877 |
if (!entry.initialized) { |
| 878 |
entry.set_valid_spatial_dimensions({false, false, false, true}); |
| 879 |
entry.set_side_topologies({quad_9_factory(), quad_9_factory(), quad_9_factory(), |
| 880 |
quad_9_factory(), quad_9_factory(), quad_9_factory()}); |
| 881 |
entry.initialized = true; |
| 882 |
} |
| 883 |
|
| 884 |
return &entry; |
| 885 |
} |
| 886 |
|
| 887 |
private: |
| 888 |
bool equivalent_valid_spatial_dimensions(const DimensionArray &validSpatialDimensions_) const |
| 889 |
{ |
| 890 |
return validSpatialDimensions[0] == validSpatialDimensions_[0] && |
| 891 |
validSpatialDimensions[1] == validSpatialDimensions_[1] && |
| 892 |
validSpatialDimensions[2] == validSpatialDimensions_[2] && |
| 893 |
validSpatialDimensions[3] == validSpatialDimensions_[3]; |
| 894 |
} |
| 895 |
|
| 896 |
void set_valid_spatial_dimensions(const DimensionArray &validSpatialDimensions_) |
| 897 |
{ |
| 898 |
validSpatialDimensions[0] = validSpatialDimensions_[0]; |
| 899 |
validSpatialDimensions[1] = validSpatialDimensions_[1]; |
| 900 |
validSpatialDimensions[2] = validSpatialDimensions_[2]; |
| 901 |
validSpatialDimensions[3] = validSpatialDimensions_[3]; |
| 902 |
} |
| 903 |
|
| 904 |
// Create and set TopologyMapEntry based side topologies since some of the implementation |
| 905 |
// details of the class cannot be automatically constructed from the Ioss_ElementTopology |
| 906 |
// object .. this will not be necessary if/when they are migrated to Ioss_ElementTopology |
| 907 |
void set_side_topologies(const std::vector<TopologyMapEntry *> &sideTopologies_) |
| 908 |
{ |
| 909 |
int numSides = sideTopologies_.size(); |
| 910 |
|
| 911 |
for (int side = 1; side <= numSides; side++) { |
| 912 |
if (topology->boundary_type(side) != sideTopologies_[side - 1]->topology) { |
| 913 |
std::ostringstream errmsg; |
| 914 |
// Would be nice to use fmt:: here, but we need to avoid using fmt includes in public |
| 915 |
// headers... |
| 916 |
errmsg << "ERROR: For element topology: " << topology->name() << " on side: " << side |
| 917 |
<< ", expected topology: " << topology->boundary_type(side)->name() |
| 918 |
<< " does not match topology: " << sideTopologies_[side - 1]->topology->name(); |
| 919 |
IOSS_ERROR(errmsg); |
| 920 |
} |
| 921 |
} |
| 922 |
sideTopologies = sideTopologies_; |
| 923 |
} |
| 924 |
|
| 925 |
unsigned num_permutation_nodes() const |
| 926 |
{ |
| 927 |
return topology->permutation()->num_permutation_nodes(); |
| 928 |
} |
| 929 |
|
| 930 |
unsigned int id{0}; |
| 931 |
Ioss::ElementTopology *topology = nullptr; |
| 932 |
|
| 933 |
std::vector<TopologyMapEntry *> sideTopologies{}; |
| 934 |
|
| 935 |
// Defines what spatial dimension the topology is valid on |
| 936 |
DimensionArray validSpatialDimensions; |
| 937 |
|
| 938 |
bool initialized{false}; |
| 939 |
}; |
| 940 |
|
| 941 |
inline std::ostream &operator<<(std::ostream &out, const TopologyMapEntry &t) |
| 942 |
{ |
| 943 |
return out << t.name(); |
| 944 |
} |
| 945 |
|
| 946 |
class IOTM_EXPORT IossTopologyMapping : public text_mesh::TopologyMapping<TopologyMapEntry> |
| 947 |
{ |
| 948 |
public: |
| 949 |
TopologyMapEntry invalid_topology() const override { return TopologyMapEntry(); } |
| 950 |
|
| 951 |
// clang-format off |
| 952 |
void initialize_topology_map() override |
| 953 |
{ |
| 954 |
m_nameToTopology = { |
| 955 |
{"NODE", *TopologyMapEntry::node_factory()}, |
| 956 |
{"LINE_2", *TopologyMapEntry::line_2_factory()}, |
| 957 |
{"LINE_3", *TopologyMapEntry::line_3_factory()}, |
| 958 |
{"TRI_3", *TopologyMapEntry::tri_3_factory()}, |
| 959 |
{"TRI_4", *TopologyMapEntry::tri_4_factory()}, |
| 960 |
{"TRI_6", *TopologyMapEntry::tri_6_factory()}, |
| 961 |
{"QUAD_4", *TopologyMapEntry::quad_4_factory()}, |
| 962 |
{"QUAD_6", *TopologyMapEntry::quad_6_factory()}, |
| 963 |
{"QUAD_8", *TopologyMapEntry::quad_8_factory()}, |
| 964 |
{"QUAD_9", *TopologyMapEntry::quad_9_factory()}, |
| 965 |
{"PARTICLE", *TopologyMapEntry::particle_factory()}, |
| 966 |
{"LINE_2_1D", *TopologyMapEntry::line_2_1d_factory()}, |
| 967 |
{"LINE_3_1D", *TopologyMapEntry::line_3_1d_factory()}, |
| 968 |
{"BEAM_2", *TopologyMapEntry::beam_2_factory()}, |
| 969 |
{"BEAM_3", *TopologyMapEntry::beam_3_factory()}, |
| 970 |
{"SHELL_LINE_2", *TopologyMapEntry::shell_line_2_factory()}, |
| 971 |
{"SHELL_LINE_3", *TopologyMapEntry::shell_line_3_factory()}, |
| 972 |
{"SPRING_2", *TopologyMapEntry::spring_2_factory()}, |
| 973 |
{"SPRING_3", *TopologyMapEntry::spring_3_factory()}, |
| 974 |
{"TRI_3_2D", *TopologyMapEntry::tri_3_2d_factory()}, |
| 975 |
{"TRI_4_2D", *TopologyMapEntry::tri_4_2d_factory()}, |
| 976 |
{"TRI_6_2D", *TopologyMapEntry::tri_6_2d_factory()}, |
| 977 |
{"QUAD_4_2D", *TopologyMapEntry::quad_4_2d_factory()}, |
| 978 |
{"QUAD_8_2D", *TopologyMapEntry::quad_8_2d_factory()}, |
| 979 |
{"QUAD_9_2D", *TopologyMapEntry::quad_9_2d_factory()}, |
| 980 |
{"SHELL_TRI_3", *TopologyMapEntry::shell_tri_3_factory()}, |
| 981 |
{"SHELL_TRI_4", *TopologyMapEntry::shell_tri_4_factory()}, |
| 982 |
{"SHELL_TRI_6", *TopologyMapEntry::shell_tri_6_factory()}, |
| 983 |
{"SHELL_QUAD_4", *TopologyMapEntry::shell_quad_4_factory()}, |
| 984 |
{"SHELL_QUAD_8", *TopologyMapEntry::shell_quad_8_factory()}, |
| 985 |
{"SHELL_QUAD_9", *TopologyMapEntry::shell_quad_9_factory()}, |
| 986 |
{"TET_4", *TopologyMapEntry::tet_4_factory()}, |
| 987 |
{"TET_8", *TopologyMapEntry::tet_8_factory()}, |
| 988 |
{"TET_10", *TopologyMapEntry::tet_10_factory()}, |
| 989 |
{"TET_11", *TopologyMapEntry::tet_11_factory()}, |
| 990 |
{"PYRAMID_5", *TopologyMapEntry::pyramid_5_factory()}, |
| 991 |
{"PYRAMID_13", *TopologyMapEntry::pyramid_13_factory()}, |
| 992 |
{"PYRAMID_14", *TopologyMapEntry::pyramid_14_factory()}, |
| 993 |
{"WEDGE_6", *TopologyMapEntry::wedge_6_factory()}, |
| 994 |
{"WEDGE_12", *TopologyMapEntry::wedge_12_factory()}, |
| 995 |
{"WEDGE_15", *TopologyMapEntry::wedge_15_factory()}, |
| 996 |
{"WEDGE_18", *TopologyMapEntry::wedge_18_factory()}, |
| 997 |
{"HEX_8", *TopologyMapEntry::hex_8_factory()}, |
| 998 |
{"HEX_20", *TopologyMapEntry::hex_20_factory()}, |
| 999 |
{"HEX_27", *TopologyMapEntry::hex_27_factory()} |
| 1000 |
}; |
| 1001 |
} |
| 1002 |
// clang-format on |
| 1003 |
}; |
| 1004 |
} // namespace Iotm |