Debian Codegraph @

packages/seacas/applications/conjoin/CJ_Variables.h

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