| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020, 2022, 2023 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 |
#include "EP_ObjectType.h" |
| 11 |
#include <cstring> |
| 12 |
#include <smart_assert.h> |
| 13 |
#include <string> |
| 14 |
#include <vector> |
| 15 |
|
| 16 |
namespace Excn { |
| 17 |
enum class InOut { IN = 1, OUT = 2 }; |
| 18 |
|
| 19 |
using IntVector = std::vector<int>; |
| 20 |
|
| 21 |
struct Variables |
| 22 |
{ |
| 23 |
explicit Variables(ObjectType otype) : objectType(otype) |
| 24 |
{ |
| 25 |
SMART_ASSERT(otype == Excn::ObjectType::EBLK || otype == Excn::ObjectType::NSET || |
| 26 |
otype == Excn::ObjectType::SSET || otype == Excn::ObjectType::NODE || |
| 27 |
otype == Excn::ObjectType::EDBLK || otype == Excn::ObjectType::FABLK || |
| 28 |
otype == Excn::ObjectType::GLOBAL); |
| 29 |
} |
| 30 |
|
| 31 |
int count(InOut in_out = InOut::IN) const |
| 32 |
{ |
| 33 |
int ret_val = 0; |
| 34 |
switch (in_out) { |
| 35 |
case InOut::IN: ret_val = index_.size() - (addProcessorId ? 1 : 0); break; |
| 36 |
case InOut::OUT: ret_val = outputCount; break; |
| 37 |
} |
| 38 |
return ret_val; |
| 39 |
} |
| 40 |
|
| 41 |
const char *label() const |
| 42 |
{ |
| 43 |
switch (objectType) { |
| 44 |
case Excn::ObjectType::EBLK: return "element"; |
| 45 |
case Excn::ObjectType::NSET: return "nodeset"; |
| 46 |
case Excn::ObjectType::GLOBAL: return "global"; |
| 47 |
case Excn::ObjectType::NODE: return "nodal"; |
| 48 |
case Excn::ObjectType::SSET: return "sideset"; |
| 49 |
case Excn::ObjectType::EDBLK: return "edgeblock"; |
| 50 |
case Excn::ObjectType::FABLK: return "faceblock"; |
| 51 |
default: return "UNKNOWN"; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
ex_entity_type type() const |
| 56 |
{ |
| 57 |
switch (objectType) { |
| 58 |
case Excn::ObjectType::EBLK: return EX_ELEM_BLOCK; |
| 59 |
case Excn::ObjectType::NSET: return EX_NODE_SET; |
| 60 |
case Excn::ObjectType::SSET: return EX_SIDE_SET; |
| 61 |
case Excn::ObjectType::NODE: return EX_NODAL; |
| 62 |
case Excn::ObjectType::GLOBAL: return EX_GLOBAL; |
| 63 |
case Excn::ObjectType::EDBLK: return EX_EDGE_BLOCK; |
| 64 |
case Excn::ObjectType::FABLK: return EX_FACE_BLOCK; |
| 65 |
default: return EX_INVALID; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
bool add_processor_id() const { return addProcessorId; } |
| 70 |
|
| 71 |
ObjectType objectType; |
| 72 |
int outputCount{0}; |
| 73 |
bool addProcessorId{false}; |
| 74 |
IntVector index_{}; |
| 75 |
std::string type_{}; |
| 76 |
}; |
| 77 |
} // namespace Excn |