IOSS 2.0
Loading...
Searching...
No Matches
Iogn_DatabaseIO.h
Go to the documentation of this file.
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
22namespace Iogn {
23 class GeneratedMesh;
24} // namespace Iogn
25namespace 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
44namespace 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 */
53namespace 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 std::vector<std::string> &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 void get_nodeblocks();
111 void get_elemblocks();
112 void get_nodesets();
113 void get_sidesets();
114 void get_commsets();
115 std::string get_sideset_topology() const;
116
117 const Ioss::Map &get_node_map() const;
118 const Ioss::Map &get_element_map() const;
119
120 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
121 size_t data_size) const override;
122 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
123 size_t data_size) const override;
124 int64_t get_field_internal(const Ioss::ElementBlock *ns, const Ioss::Field &field, void *data,
125 size_t data_size) const override;
126 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
127 size_t data_size) const override;
128 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
129 size_t data_size) const override;
130 int64_t get_field_internal(const Ioss::SideBlock *ns, const Ioss::Field &field, void *data,
131 size_t data_size) const override;
132
142
143 // Input only database -- these will never be called...
159
160 void add_transient_fields(Ioss::GroupingEntity *entity);
161
162 GeneratedMesh *m_generatedMesh{nullptr};
163 std::vector<std::string> m_sideset_names{};
164
165 double currentTime{0.0};
166 int spatialDimension{3};
167
168 int elementBlockCount{0};
169 int nodesetCount{0};
170 int sidesetCount{0};
171
172 bool m_useVariableDf{true};
173 };
174} // namespace Iogn
#define IOSS_NOOP_PFI(type)
Definition Ioss_CodeTypes.h:118
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:63
#define IOSS_NOOP_GFI(type)
Definition Ioss_CodeTypes.h:113
Definition Iogn_DatabaseIO.h:68
int int_byte_size_db() const override
Definition Iogn_DatabaseIO.h:93
std::string get_format() const override
Definition Iogn_DatabaseIO.h:85
void setGeneratedMesh(Iogn::GeneratedMesh *generatedMesh)
Definition Iogn_DatabaseIO.h:97
const std::vector< std::string > & get_sideset_names() const
Definition Iogn_DatabaseIO.h:99
const GeneratedMesh * get_generated_mesh() const
Definition Iogn_DatabaseIO.h:95
Definition Iogn_GeneratedMesh.h:23
Definition Iogn_DatabaseIO.h:56
A homogeneous collection of other GroupingEntities.
Definition Ioss_Assembly.h:31
A homogeneous collection of other GroupingEntities.
Definition Ioss_Blob.h:31
Definition Ioss_CommSet.h:27
An input or output Database.
Definition Ioss_DatabaseIO.h:63
A collection of element edges with the same topology.
Definition Ioss_EdgeBlock.h:29
A collection of element edges.
Definition Ioss_EdgeSet.h:30
A collection of elements having the same topology.
Definition Ioss_ElementBlock.h:29
A collection of elements.
Definition Ioss_ElementSet.h:30
A collection of element faces with the same topology.
Definition Ioss_FaceBlock.h:29
A collection of element faces.
Definition Ioss_FaceSet.h:30
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
The main public user interface for creating Ioss::DatabaseIO objects.
Definition Ioss_IOFactory.h:35
Definition Ioss_Map.h:46
A collection of all nodes in the region.
Definition Ioss_NodeBlock.h:33
A collection of nodes.
Definition Ioss_NodeSet.h:29
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
A grouping entity that contains other grouping entities.
Definition Ioss_Region.h:90
A collection of element sides having the same topology.
Definition Ioss_SideBlock.h:37
A collection of element sides.
Definition Ioss_SideSet.h:29
A structured zone – i,j,k.
Definition Ioss_StructuredBlock.h:104
A namespace for the generated database format.
Definition Iogn_DashSurfaceMesh.C:12
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
State
Access states for a database.
Definition Ioss_State.h:15
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition Ioss_DBUsage.h:13