Debian Codegraph @

packages/seacas/libraries/ioss/src/generated/Iogn_DatabaseIO.h

raw
1 // Copyright(C) 1999-2020, 2022, 2023, 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 "Ioss_CodeTypes.h"
10 #include "Ioss_DBUsage.h" // for DatabaseUsage
11 #include "Ioss_DatabaseIO.h" // for DatabaseIO
12 #include "Ioss_IOFactory.h" // for IOFactory
13 #include "Ioss_Map.h" // for Map
14 #include <cstddef> // for size_t
15 #include <cstdint> // for int64_t
16 #include <string> // for string
17 #include <vector> // for vector
18
19 #include "Ioss_State.h" // for State
20 #include "iogn_export.h"
21
22 namespace Iogn {
23 class GeneratedMesh;
24 } // namespace Iogn
25 namespace Ioss {
26 class CommSet;
27 class EdgeBlock;
28 class EdgeSet;
29 class ElementBlock;
30 class ElementSet;
31 class FaceBlock;
32 class FaceSet;
33 class Field;
34 class GroupingEntity;
35 class NodeBlock;
36 class NodeSet;
37 class PropertyManager;
38 class Region;
39 class SideBlock;
40 class SideSet;
41 class StructuredBlock;
42 } // namespace Ioss
43
44 namespace Ioss {
45 class EntityBlock;
46 class Assembly;
47 class Blob;
48 class Map;
49 } // namespace Ioss
50
51 /** \brief A namespace for the generated database format.
52 */
53 namespace Iogn {
54
55 class IOGN_EXPORT IOFactory : public Ioss::IOFactory
56 {
57 public:
58 static const IOFactory *factory();
59
60 private:
61 IOFactory();
62 Ioss::DatabaseIO *make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage,
63 Ioss_MPI_Comm communicator,
64 const Ioss::PropertyManager &props) const override;
65 };
66
67 class IOGN_EXPORT DatabaseIO : public Ioss::DatabaseIO
68 {
69 public:
70 /**
71 The `filename` string for the generated mesh specifies the option string that will be passed
72 to GeneratedMesh to generate the mesh. For example
73 \code
74 DatabaseIO(region, "10x12x8|shell:xX|nodeset:xyz|sideset:XYZ", ...);
75 \endcode
76 Would generate a cube mesh with sides of 10 elements in X, 12 elements in Y, and 8 elements
77 in Z with shells on the min and max X extent. There would be a nodeset on each of the
78 minimum x, y, and z faces and sidesets on the maximum x, y, z faces. See the
79 Iogn::GeneratedMesh::GeneratedMesh documentation for more details.
80 */
81 DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage,
82 Ioss_MPI_Comm communicator, const Ioss::PropertyManager &props);
83 ~DatabaseIO() override;
84
85 std::string get_format() const override { return "Generated"; }
86
87 // Check capabilities of input/output database... Returns an
88 // unsigned int with the supported Ioss::EntityTypes or'ed
89 // together. If "return_value & Ioss::EntityType" is set, then the
90 // database supports that type (e.g. return_value & Ioss::FACESET)
91 unsigned entity_field_support() const override;
92
93 int int_byte_size_db() const override { return int_byte_size_api(); }
94
95 const GeneratedMesh *get_generated_mesh() const { return m_generatedMesh; }
96
97 void setGeneratedMesh(Iogn::GeneratedMesh *generatedMesh) { m_generatedMesh = generatedMesh; }
98
99 const Ioss::NameList &get_sideset_names() const { return m_sideset_names; }
100
101 private:
102 void read_meta_data_nl() override;
103
104 bool begin_nl(Ioss::State state) override;
105 bool end_nl(Ioss::State state) override;
106
107 bool begin_state_nl(int state, double time) override;
108
109 void get_step_times_nl() override;
110
111 std::vector<double> get_db_step_times_nl() override;
112
113 void get_nodeblocks();
114 void get_elemblocks();
115 void get_nodesets();
116 void get_sidesets();
117 void get_commsets();
118 std::string get_sideset_topology() const;
119
120 const Ioss::Map &get_node_map() const;
121 const Ioss::Map &get_element_map() const;
122
123 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
124 size_t data_size) const override;
125 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
126 size_t data_size) const override;
127 int64_t get_field_internal(const Ioss::ElementBlock *ns, const Ioss::Field &field, void *data,
128 size_t data_size) const override;
129 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
130 size_t data_size) const override;
131 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
132 size_t data_size) const override;
133 int64_t get_field_internal(const Ioss::SideBlock *ns, const Ioss::Field &field, void *data,
134 size_t data_size) const override;
135
136 IOSS_NOOP_GFI(Ioss::EdgeBlock)
137 IOSS_NOOP_GFI(Ioss::FaceBlock)
138 IOSS_NOOP_GFI(Ioss::StructuredBlock)
139 IOSS_NOOP_GFI(Ioss::EdgeSet)
140 IOSS_NOOP_GFI(Ioss::FaceSet)
141 IOSS_NOOP_GFI(Ioss::ElementSet)
142 IOSS_NOOP_GFI(Ioss::SideSet)
143 IOSS_NOOP_GFI(Ioss::Assembly)
144 IOSS_NOOP_GFI(Ioss::Blob)
145
146 // Input only database -- these will never be called...
147 IOSS_NOOP_PFI(Ioss::Region)
148 IOSS_NOOP_PFI(Ioss::NodeBlock)
149 IOSS_NOOP_PFI(Ioss::EdgeBlock)
150 IOSS_NOOP_PFI(Ioss::FaceBlock)
151 IOSS_NOOP_PFI(Ioss::ElementBlock)
152 IOSS_NOOP_PFI(Ioss::StructuredBlock)
153 IOSS_NOOP_PFI(Ioss::SideBlock)
154 IOSS_NOOP_PFI(Ioss::NodeSet)
155 IOSS_NOOP_PFI(Ioss::EdgeSet)
156 IOSS_NOOP_PFI(Ioss::FaceSet)
157 IOSS_NOOP_PFI(Ioss::ElementSet)
158 IOSS_NOOP_PFI(Ioss::SideSet)
159 IOSS_NOOP_PFI(Ioss::CommSet)
160 IOSS_NOOP_PFI(Ioss::Assembly)
161 IOSS_NOOP_PFI(Ioss::Blob)
162
163 void add_transient_fields(Ioss::GroupingEntity *entity);
164
165 GeneratedMesh *m_generatedMesh{nullptr};
166 Ioss::NameList m_sideset_names{};
167
168 double currentTime{0.0};
169 int spatialDimension{3};
170
171 int elementBlockCount{0};
172 int nodesetCount{0};
173 int sidesetCount{0};
174
175 bool m_useVariableDf{true};
176 };
177 } // namespace Iogn