| 1 |
// Copyright(C) 1999-2022 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 |
#include "ED_SystemInterface.h" // for SystemInterface, etc |
| 8 |
#include "edge_block.h" |
| 9 |
#include "exodusII.h" // for ex_set, etc |
| 10 |
#include "iqsort.h" // for index_qsort |
| 11 |
#include "smart_assert.h" // for SMART_ASSERT |
| 12 |
#include <cstdlib> // for exit |
| 13 |
#include <vector> // for vector |
| 14 |
|
| 15 |
template <typename INT> Edge_Block<INT>::Edge_Block() : Exo_Entity() {} |
| 16 |
|
| 17 |
template <typename INT> |
| 18 |
Edge_Block<INT>::Edge_Block(int file_id, size_t id) : Exo_Entity(file_id, id) |
| 19 |
{ |
| 20 |
SMART_ASSERT((int)id != EX_INVALID_ID); |
| 21 |
} |
| 22 |
|
| 23 |
template <typename INT> |
| 24 |
Edge_Block<INT>::Edge_Block(int file_id, size_t id, size_t ne) : Exo_Entity(file_id, id, ne) |
| 25 |
{ |
| 26 |
SMART_ASSERT(id > 0); |
| 27 |
} |
| 28 |
|
| 29 |
template <typename INT> Edge_Block<INT>::~Edge_Block() { SMART_ASSERT(Check_State()); } |
| 30 |
|
| 31 |
template <typename INT> EXOTYPE Edge_Block<INT>::exodus_type() const { return EX_EDGE_BLOCK; } |
| 32 |
|
| 33 |
template <typename INT> void Edge_Block<INT>::entity_load_params() |
| 34 |
{ |
| 35 |
int num_attr; |
| 36 |
ex_block block{}; |
| 37 |
block.id = id_; |
| 38 |
block.type = EX_EDGE_BLOCK; |
| 39 |
int err = ex_get_block_param(fileId, &block); |
| 40 |
|
| 41 |
if (err < 0) { |
| 42 |
Error("Edge_Block<INT>::entity_load_params(): Failed to get edge" |
| 43 |
" block parameters! Aborting...\n"); |
| 44 |
} |
| 45 |
|
| 46 |
numEntity = block.num_entry; |
| 47 |
num_edges_per_elmt = block.num_edges_per_entry; |
| 48 |
num_attr = block.num_attribute; |
| 49 |
elmt_type = block.topology; |
| 50 |
|
| 51 |
if (num_edges_per_elmt < 0 || num_attr < 0) { |
| 52 |
Error(fmt::format( |
| 53 |
fmt::runtime( |
| 54 |
"Edge_Block<INT>::entity_load_params(): Data appears corrupt for edge block {}!\n" |
| 55 |
"\tnum elmts = {}\n" |
| 56 |
"\tnum edges per elmt = {}\n" |
| 57 |
"\tnum attributes = {}\n" |
| 58 |
" ... Aborting...\n"), |
| 59 |
fmt::group_digits(numEntity), num_edges_per_elmt, num_attr)); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
template <typename INT> size_t Edge_Block<INT>::Edge_Index(size_t position) const |
| 64 |
{ |
| 65 |
SMART_ASSERT(position < numEntity); |
| 66 |
return position; |
| 67 |
} |
| 68 |
|
| 69 |
template <typename INT> int Edge_Block<INT>::Check_State() const |
| 70 |
{ |
| 71 |
SMART_ASSERT(id_ >= EX_INVALID_ID); |
| 72 |
SMART_ASSERT(!(id_ == EX_INVALID_ID && numEntity > 0)); |
| 73 |
|
| 74 |
return 1; |
| 75 |
} |
| 76 |
|
| 77 |
template class Edge_Block<int>; |
| 78 |
template class Edge_Block<int64_t>; |