| 1 |
// Copyright(C) 1999-2021, 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 |
#include <cstddef> |
| 8 |
#include <tokenize.h> |
| 9 |
|
| 10 |
#include "Ioss_CodeTypes.h" // for IOSS_SCALAR() |
| 11 |
#include "Ioss_CommSet.h" // for CommSet |
| 12 |
#include "Ioss_DBUsage.h" // for DatabaseUsage, etc |
| 13 |
#include "Ioss_DatabaseIO.h" // for DatabaseIO |
| 14 |
#include "Ioss_EdgeBlock.h" // for EdgeBlock |
| 15 |
#include "Ioss_EdgeSet.h" // for EdgeSet |
| 16 |
#include "Ioss_ElementBlock.h" // for ElementBlock |
| 17 |
#include "Ioss_ElementSet.h" // for ElementSet |
| 18 |
#include "Ioss_EntityType.h" // for EntityType::ELEMENTBLOCK |
| 19 |
#include "Ioss_FaceBlock.h" // for FaceBlock |
| 20 |
#include "Ioss_FaceSet.h" // for FaceSet |
| 21 |
#include "Ioss_FileInfo.h" // for FileInfo |
| 22 |
#include "Ioss_Map.h" // for Map, MapContainer |
| 23 |
#include "Ioss_NodeBlock.h" // for NodeBlock |
| 24 |
#include "Ioss_NodeSet.h" // for NodeSet |
| 25 |
#include "Ioss_Property.h" // for Property |
| 26 |
#include "Ioss_SideBlock.h" // for SideBlock |
| 27 |
#include <Ioss_Assembly.h> // for Assembly |
| 28 |
#include <Ioss_Blob.h> // for Blob |
| 29 |
#include <Ioss_CodeTypes.h> // for HAVE_MPI |
| 30 |
#include <Ioss_ElementTopology.h> // for NameList |
| 31 |
#include <Ioss_ParallelUtils.h> // for ParallelUtils, etc |
| 32 |
#include <Ioss_Region.h> // for Region |
| 33 |
#include <Ioss_SerializeIO.h> // for SerializeIO |
| 34 |
#include <Ioss_StructuredBlock.h> // for StructuredBlock |
| 35 |
|
| 36 |
#include <Ioss_Utils.h> // for Utils, IOSS_ERROR, etc |
| 37 |
#include <algorithm> |
| 38 |
#include <climits> |
| 39 |
#include <cstdlib> |
| 40 |
#include <fmt/ostream.h> |
| 41 |
#include <map> |
| 42 |
|
| 43 |
#include <catalyst.hpp> |
| 44 |
#include <catalyst/Iocatalyst_DatabaseIO.h> |
| 45 |
|
| 46 |
namespace Ioss { |
| 47 |
class PropertyManager; |
| 48 |
} |
| 49 |
|
| 50 |
namespace Iocatalyst { |
| 51 |
|
| 52 |
namespace detail { |
| 53 |
|
| 54 |
inline static const std::string ASSEMBLIES = "assemblies"; |
| 55 |
inline static const std::string BLOBS = "blobs"; |
| 56 |
inline static const std::string COMMSETS = "commsets"; |
| 57 |
inline static const std::string EDGEBLOCKS = "edgeblocks"; |
| 58 |
inline static const std::string EDGESETS = "edgesets"; |
| 59 |
inline static const std::string ELEMENTBLOCKS = "elementblocks"; |
| 60 |
inline static const std::string ELEMENTSETS = "elementsets"; |
| 61 |
inline static const std::string FACEBLOCKS = "faceblocks"; |
| 62 |
inline static const std::string FACESETS = "facesets"; |
| 63 |
inline static const std::string NODEBLOCKS = "nodeblocks"; |
| 64 |
inline static const std::string NODESETS = "nodesets"; |
| 65 |
inline static const std::string REGION = "region"; |
| 66 |
inline static const std::string SIDESETS = "sidesets"; |
| 67 |
inline static const std::string STRUCTUREDBLOCKS = "structuredblocks"; |
| 68 |
|
| 69 |
inline static const std::string BLOCKLOCNODEIND = "blocklocalnodeindex"; |
| 70 |
inline static const std::string BOUNDARYCONDS = "boundaryconditions"; |
| 71 |
inline static const std::string CATCONDNODE = "CATALYST_CONDUIT_NODE"; |
| 72 |
inline static const std::string CATDUMPDIR = "CATALYST_DATA_DUMP_DIRECTORY"; |
| 73 |
inline static const std::string CATREADTIMESTEP = "CATALYST_READER_TIME_STEP"; |
| 74 |
inline static const std::string CELLIDS = "cell_ids"; |
| 75 |
inline static const std::string CELLNODEIDS = "cell_node_ids"; |
| 76 |
inline static const std::string COMPONENTCOUNT = "component_count"; |
| 77 |
inline static const std::string COMPONENTDEGREE = "component_degree"; |
| 78 |
inline static const std::string COUNT = "count"; |
| 79 |
inline static const std::string CONNECTIVITY = "connectivity"; |
| 80 |
inline static const std::string CONNECTIVITYRAW = "connectivity_raw"; |
| 81 |
inline static const char DASH_CHAR = '-'; |
| 82 |
inline static const std::string DATABASE = "database"; |
| 83 |
inline static const std::string DOT = "."; |
| 84 |
inline static const std::string ENTITYCOUNT = "entity_count"; |
| 85 |
inline static const std::string ENTITYTYPE = "entity_type"; |
| 86 |
inline static const std::string EXECUTE_INVC = "execute_invc"; |
| 87 |
inline static const std::string FIELDS = "fields"; |
| 88 |
inline static const std::string FS = "/"; |
| 89 |
inline static const char FS_CHAR = '/'; |
| 90 |
inline static const std::string GLOBALIDMAP = "globalidmap"; |
| 91 |
inline static const std::string KEY = "key"; |
| 92 |
inline static const std::string INTBYTESIZEAPI = "int_byte_size_api"; |
| 93 |
inline static const std::string IOSSCONTAINEDIN = "IOSS_INTERNAL_CONTAINED_IN"; |
| 94 |
inline static const std::string MEMBERS = "members"; |
| 95 |
inline static const std::string MEMBER_TYPE = "member_type"; |
| 96 |
inline static const std::string MESHMODCO = "mesh_model_coordinates"; |
| 97 |
inline static const std::string MESHMODCOX = "mesh_model_coordinates_x"; |
| 98 |
inline static const std::string MESHMODCOY = "mesh_model_coordinates_y"; |
| 99 |
inline static const std::string MESHMODCOZ = "mesh_model_coordinates_z"; |
| 100 |
inline static const std::string NAME = "name"; |
| 101 |
inline static const std::string NI = "ni"; |
| 102 |
inline static const std::string NJ = "nj"; |
| 103 |
inline static const std::string NK = "nk"; |
| 104 |
inline static const std::string NIGLOBAL = "ni_global"; |
| 105 |
inline static const std::string NJGLOBAL = "nj_global"; |
| 106 |
inline static const std::string NKGLOBAL = "nk_global"; |
| 107 |
inline static const std::string NODEBLOCKONE = "nodeblock_1"; |
| 108 |
inline static const std::string IDS = "ids"; |
| 109 |
inline static const std::string INDEX = "index"; |
| 110 |
inline static const std::string OFFSET_I = "offset_i"; |
| 111 |
inline static const std::string OFFSET_J = "offset_j"; |
| 112 |
inline static const std::string OFFSET_K = "offset_k"; |
| 113 |
inline static const std::string ORIGIN = "origin"; |
| 114 |
inline static const std::string PARAMS_CONDUIT_BIN = "_params.conduit_bin."; |
| 115 |
inline static const std::string PARENTTOPOLOGYTYPE = "parent_topology_type"; |
| 116 |
inline static const std::string PROPERTIES = "properties"; |
| 117 |
inline static const std::string REGION_ZERO = "region_0"; |
| 118 |
inline static const std::string ROLE = "role"; |
| 119 |
inline static const std::string SHALLOWCOPYFIELDS = "SHALLOW_COPY_FIELDS"; |
| 120 |
inline static const std::string SIDEBLOCKS = "sideblocks"; |
| 121 |
inline static const std::string STORAGE = "storage"; |
| 122 |
inline static const std::string TIME = "time"; |
| 123 |
inline static const std::string TOPOLOGYTYPE = "topology_type"; |
| 124 |
inline static const std::string TYPE = "type"; |
| 125 |
inline static const std::string VALUE = "value"; |
| 126 |
inline static const std::string ZONECONNECTIVITY = "zoneconnectivity"; |
| 127 |
|
| 128 |
inline static const std::string CONNECTIONNAME = "m_connectionName"; |
| 129 |
inline static const std::string DONORNAME = "m_donorName"; |
| 130 |
inline static const std::string TRANSFORM = "m_transform"; |
| 131 |
inline static const std::string OWNERRANGEBEG = "m_ownerRangeBeg"; |
| 132 |
inline static const std::string OWNERRANGEEND = "m_ownerRangeEnd"; |
| 133 |
inline static const std::string OWNEROFFSET = "m_ownerOffset"; |
| 134 |
inline static const std::string DONORRANGEBEG = "m_donorRangeBeg"; |
| 135 |
inline static const std::string DONORRANGEEND = "m_donorRangeEnd"; |
| 136 |
inline static const std::string DONOROFFSET = "m_donorOffset"; |
| 137 |
inline static const std::string OWNERZONE = "m_ownerZone"; |
| 138 |
inline static const std::string DONORZONE = "m_donorZone"; |
| 139 |
inline static const std::string FROMDECOMP = "m_fromDecomp"; |
| 140 |
|
| 141 |
inline static const std::string BCNAME = "m_bcName"; |
| 142 |
inline static const std::string FAMNAME = "m_famName"; |
| 143 |
inline static const std::string RANGEBEG = "m_rangeBeg"; |
| 144 |
inline static const std::string RANGEEND = "m_rangeEnd"; |
| 145 |
inline static const std::string FACE = "m_face"; |
| 146 |
|
| 147 |
inline static const std::string SURFACESPLITTYPE = "surface_split_type"; |
| 148 |
|
| 149 |
std::string getValuePath(const std::string &prop) |
| 150 |
{ |
| 151 |
return detail::PROPERTIES + detail::FS + prop + detail::FS + detail::VALUE; |
| 152 |
} |
| 153 |
|
| 154 |
std::string getAPISizePath() { return detail::DATABASE + detail::FS + detail::INTBYTESIZEAPI; } |
| 155 |
|
| 156 |
template <typename GroupingEntityT> |
| 157 |
GroupingEntityT *createEntityGroup(const conduit_cpp::Node &node, Ioss::DatabaseIO *dbase); |
| 158 |
|
| 159 |
template <> |
| 160 |
Ioss::NodeBlock *createEntityGroup<Ioss::NodeBlock>(const conduit_cpp::Node &node, |
| 161 |
Ioss::DatabaseIO *dbase) |
| 162 |
{ |
| 163 |
return new Ioss::NodeBlock(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 164 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64(), |
| 165 |
node[getValuePath(detail::COMPONENTDEGREE)].as_int64()); |
| 166 |
} |
| 167 |
|
| 168 |
template <> |
| 169 |
Ioss::ElementBlock *createEntityGroup<Ioss::ElementBlock>(const conduit_cpp::Node &node, |
| 170 |
Ioss::DatabaseIO *dbase) |
| 171 |
{ |
| 172 |
return new Ioss::ElementBlock(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 173 |
node[getValuePath(detail::TOPOLOGYTYPE)].as_string(), |
| 174 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 175 |
} |
| 176 |
|
| 177 |
template <> |
| 178 |
Ioss::NodeSet *createEntityGroup<Ioss::NodeSet>(const conduit_cpp::Node &node, |
| 179 |
Ioss::DatabaseIO *dbase) |
| 180 |
{ |
| 181 |
return new Ioss::NodeSet(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 182 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 183 |
} |
| 184 |
|
| 185 |
template <> |
| 186 |
Ioss::SideBlock *createEntityGroup<Ioss::SideBlock>(const conduit_cpp::Node &node, |
| 187 |
Ioss::DatabaseIO *dbase) |
| 188 |
{ |
| 189 |
return new Ioss::SideBlock(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 190 |
node[getValuePath(detail::TOPOLOGYTYPE)].as_string(), |
| 191 |
node[getValuePath(detail::PARENTTOPOLOGYTYPE)].as_string(), |
| 192 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 193 |
} |
| 194 |
|
| 195 |
template <> |
| 196 |
Ioss::SideSet *createEntityGroup<Ioss::SideSet>(const conduit_cpp::Node &node, |
| 197 |
Ioss::DatabaseIO *dbase) |
| 198 |
{ |
| 199 |
return new Ioss::SideSet(dbase, node[getValuePath(detail::NAME)].as_string()); |
| 200 |
} |
| 201 |
|
| 202 |
template <> |
| 203 |
Ioss::StructuredBlock *createEntityGroup<Ioss::StructuredBlock>(const conduit_cpp::Node &node, |
| 204 |
Ioss::DatabaseIO *dbase) |
| 205 |
{ |
| 206 |
Ioss::IJK_t localSizes = {{(int)node[getValuePath(detail::NI)].as_int64(), |
| 207 |
(int)node[getValuePath(detail::NJ)].as_int64(), |
| 208 |
(int)node[getValuePath(detail::NK)].as_int64()}}; |
| 209 |
Ioss::IJK_t globalSizes = {{(int)node[getValuePath(detail::NIGLOBAL)].as_int64(), |
| 210 |
(int)node[getValuePath(detail::NJGLOBAL)].as_int64(), |
| 211 |
(int)node[getValuePath(detail::NKGLOBAL)].as_int64()}}; |
| 212 |
Ioss::IJK_t parentOffsets = {{(int)node[getValuePath(detail::OFFSET_I)].as_int64(), |
| 213 |
(int)node[getValuePath(detail::OFFSET_J)].as_int64(), |
| 214 |
(int)node[getValuePath(detail::OFFSET_K)].as_int64()}}; |
| 215 |
return new Ioss::StructuredBlock(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 216 |
node[getValuePath(detail::COMPONENTDEGREE)].as_int64(), |
| 217 |
localSizes, parentOffsets, globalSizes); |
| 218 |
} |
| 219 |
|
| 220 |
template <> |
| 221 |
Ioss::Assembly *createEntityGroup<Ioss::Assembly>(const conduit_cpp::Node &node, |
| 222 |
Ioss::DatabaseIO *dbase) |
| 223 |
{ |
| 224 |
return new Ioss::Assembly(dbase, node[getValuePath(detail::NAME)].as_string()); |
| 225 |
} |
| 226 |
|
| 227 |
template <> |
| 228 |
Ioss::Blob *createEntityGroup<Ioss::Blob>(const conduit_cpp::Node &node, |
| 229 |
Ioss::DatabaseIO *dbase) |
| 230 |
{ |
| 231 |
return new Ioss::Blob(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 232 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 233 |
} |
| 234 |
|
| 235 |
template <> |
| 236 |
Ioss::EdgeBlock *createEntityGroup<Ioss::EdgeBlock>(const conduit_cpp::Node &node, |
| 237 |
Ioss::DatabaseIO *dbase) |
| 238 |
{ |
| 239 |
return new Ioss::EdgeBlock(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 240 |
node[getValuePath(detail::TOPOLOGYTYPE)].as_string(), |
| 241 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 242 |
} |
| 243 |
|
| 244 |
template <> |
| 245 |
Ioss::FaceBlock *createEntityGroup<Ioss::FaceBlock>(const conduit_cpp::Node &node, |
| 246 |
Ioss::DatabaseIO *dbase) |
| 247 |
{ |
| 248 |
return new Ioss::FaceBlock(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 249 |
node[getValuePath(detail::TOPOLOGYTYPE)].as_string(), |
| 250 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 251 |
} |
| 252 |
|
| 253 |
template <> |
| 254 |
Ioss::ElementSet *createEntityGroup<Ioss::ElementSet>(const conduit_cpp::Node &node, |
| 255 |
Ioss::DatabaseIO *dbase) |
| 256 |
{ |
| 257 |
return new Ioss::ElementSet(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 258 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 259 |
} |
| 260 |
|
| 261 |
template <> |
| 262 |
Ioss::EdgeSet *createEntityGroup<Ioss::EdgeSet>(const conduit_cpp::Node &node, |
| 263 |
Ioss::DatabaseIO *dbase) |
| 264 |
{ |
| 265 |
return new Ioss::EdgeSet(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 266 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 267 |
} |
| 268 |
|
| 269 |
template <> |
| 270 |
Ioss::FaceSet *createEntityGroup<Ioss::FaceSet>(const conduit_cpp::Node &node, |
| 271 |
Ioss::DatabaseIO *dbase) |
| 272 |
{ |
| 273 |
return new Ioss::FaceSet(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 274 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 275 |
} |
| 276 |
|
| 277 |
template <> |
| 278 |
Ioss::CommSet *createEntityGroup<Ioss::CommSet>(const conduit_cpp::Node &node, |
| 279 |
Ioss::DatabaseIO *dbase) |
| 280 |
{ |
| 281 |
return new Ioss::CommSet(dbase, node[getValuePath(detail::NAME)].as_string(), |
| 282 |
node[getValuePath(detail::ENTITYTYPE)].as_string(), |
| 283 |
node[getValuePath(detail::ENTITYCOUNT)].as_int64()); |
| 284 |
} |
| 285 |
|
| 286 |
} // namespace detail |
| 287 |
|
| 288 |
class DatabaseIO::ImplementationT |
| 289 |
{ |
| 290 |
conduit_cpp::Node Root; |
| 291 |
conduit_cpp::Node DBNode; |
| 292 |
mutable Ioss::Map NodeMap; |
| 293 |
std::map<std::string, Ioss::SideBlock *> sideBlocks; |
| 294 |
char read_db_field_separator; |
| 295 |
|
| 296 |
public: |
| 297 |
conduit_cpp::Node &databaseNode() { return this->DBNode; } |
| 298 |
void *catalystConduitNode() { return conduit_cpp::c_node(&this->DBNode); } |
| 299 |
void setDatabaseNode(conduit_node *c_node) |
| 300 |
{ |
| 301 |
this->DBNode = conduit_cpp::Node(); |
| 302 |
conduit_node_set_external_node(conduit_cpp::c_node(&this->DBNode), c_node); |
| 303 |
} |
| 304 |
conduit_cpp::Node &root() { return this->Root; } |
| 305 |
|
| 306 |
void print() |
| 307 |
{ |
| 308 |
auto &node = this->DBNode; |
| 309 |
node.print_detailed(); |
| 310 |
} |
| 311 |
|
| 312 |
bool defineModel(Ioss::Region *region) |
| 313 |
{ |
| 314 |
if (!region->model_defined()) { |
| 315 |
std::ostringstream errmsg; |
| 316 |
errmsg << "Catalyst Write in defineModel(): model isn't defined in region" |
| 317 |
<< "\n"; |
| 318 |
IOSS_ERROR(errmsg); |
| 319 |
} |
| 320 |
|
| 321 |
auto &node = this->DBNode; |
| 322 |
node = conduit_cpp::Node(); |
| 323 |
|
| 324 |
node[detail::getAPISizePath()].set_int8(region->get_database()->int_byte_size_api()); |
| 325 |
node[detail::SURFACESPLITTYPE].set_int8(region->get_database()->get_surface_split_type()); |
| 326 |
RegionContainer rc; |
| 327 |
rc.push_back(region); |
| 328 |
this->defineEntityGroup(node[detail::REGION], rc); |
| 329 |
this->defineEntityGroup(node[detail::NODEBLOCKS], region->get_node_blocks()); |
| 330 |
this->defineEntityGroup(node[detail::EDGEBLOCKS], region->get_edge_blocks()); |
| 331 |
this->defineEntityGroup(node[detail::FACEBLOCKS], region->get_face_blocks()); |
| 332 |
this->defineEntityGroup(node[detail::ELEMENTBLOCKS], region->get_element_blocks()); |
| 333 |
this->defineEntityGroup(node[detail::SIDESETS], region->get_sidesets()); |
| 334 |
this->defineEntityGroup(node[detail::NODESETS], region->get_nodesets()); |
| 335 |
this->defineEntityGroup(node[detail::EDGESETS], region->get_edgesets()); |
| 336 |
this->defineEntityGroup(node[detail::FACESETS], region->get_facesets()); |
| 337 |
this->defineEntityGroup(node[detail::ELEMENTSETS], region->get_elementsets()); |
| 338 |
this->defineEntityGroup(node[detail::STRUCTUREDBLOCKS], region->get_structured_blocks()); |
| 339 |
this->defineEntityGroup(node[detail::ASSEMBLIES], region->get_assemblies()); |
| 340 |
this->defineEntityGroup(node[detail::BLOBS], region->get_blobs()); |
| 341 |
this->defineEntityGroup(node[detail::COMMSETS], region->get_commsets()); |
| 342 |
return true; |
| 343 |
} |
| 344 |
|
| 345 |
void readZoneConnectivity(conduit_cpp::Node &&parent, Ioss::StructuredBlock *sb); |
| 346 |
void readBoundaryConditions(conduit_cpp::Node &&parent, Ioss::StructuredBlock *sb); |
| 347 |
Ioss::IJK_t readIJK(conduit_cpp::Node &&parent); |
| 348 |
|
| 349 |
bool readModel(Ioss::Region *region); |
| 350 |
|
| 351 |
bool readTime(Ioss::Region *region) |
| 352 |
{ |
| 353 |
auto &node = this->DBNode; |
| 354 |
if (node.has_path(getTimePath())) { |
| 355 |
region->add_state(node[getTimePath()].as_float64()); |
| 356 |
} |
| 357 |
return true; |
| 358 |
} |
| 359 |
|
| 360 |
std::vector<double> getTime() |
| 361 |
{ |
| 362 |
std::vector<double> times; |
| 363 |
auto &node = this->DBNode; |
| 364 |
if (node.has_path(getTimePath())) { |
| 365 |
times.push_back(node[getTimePath()].as_float64()); |
| 366 |
} |
| 367 |
return times; |
| 368 |
} |
| 369 |
|
| 370 |
int64_t putField(const std::string &containerName, const Ioss::GroupingEntity *entityGroup, |
| 371 |
const Ioss::Field &field, void *data, size_t data_size, bool deep_copy) |
| 372 |
{ |
| 373 |
const auto groupName = getName(entityGroup); |
| 374 |
const auto num_to_get = field.verify(data_size); |
| 375 |
const auto num_components = field.raw_storage()->component_count(); |
| 376 |
if (num_to_get > 0) { |
| 377 |
auto &&node = this->DBNode[getFieldPath(containerName, groupName, field.get_name())]; |
| 378 |
node[detail::ROLE].set(static_cast<std::int8_t>(field.get_role())); |
| 379 |
node[detail::TYPE].set(static_cast<std::int8_t>(field.get_type())); |
| 380 |
node[detail::COUNT].set(static_cast<std::int64_t>(field.verify(data_size))); |
| 381 |
node[detail::INDEX].set(static_cast<std::int64_t>(field.get_index())); |
| 382 |
node[detail::COMPONENTCOUNT].set(static_cast<std::int64_t>(num_components)); |
| 383 |
node[detail::STORAGE].set(field.raw_storage()->name()); |
| 384 |
switch (field.get_type()) { |
| 385 |
case Ioss::Field::BasicType::DOUBLE: |
| 386 |
if (deep_copy) { |
| 387 |
node[detail::VALUE].set(static_cast<double *>(data), num_to_get * num_components); |
| 388 |
} |
| 389 |
else { |
| 390 |
node[detail::VALUE].set_external(static_cast<double *>(data), |
| 391 |
num_to_get * num_components); |
| 392 |
} |
| 393 |
break; |
| 394 |
case Ioss::Field::BasicType::INT32: |
| 395 |
if (deep_copy) { |
| 396 |
node[detail::VALUE].set(static_cast<std::int32_t *>(data), num_to_get * num_components); |
| 397 |
} |
| 398 |
else { |
| 399 |
node[detail::VALUE].set_external(static_cast<std::int32_t *>(data), |
| 400 |
num_to_get * num_components); |
| 401 |
} |
| 402 |
break; |
| 403 |
case Ioss::Field::BasicType::INT64: |
| 404 |
if (deep_copy) { |
| 405 |
node[detail::VALUE].set(static_cast<std::int64_t *>(data), num_to_get * num_components); |
| 406 |
} |
| 407 |
else { |
| 408 |
node[detail::VALUE].set_external(static_cast<std::int64_t *>(data), |
| 409 |
num_to_get * num_components); |
| 410 |
} |
| 411 |
break; |
| 412 |
case Ioss::Field::BasicType::CHARACTER: |
| 413 |
if (deep_copy) { |
| 414 |
node[detail::VALUE].set(static_cast<std::int8_t *>(data), num_to_get * num_components); |
| 415 |
} |
| 416 |
else { |
| 417 |
node[detail::VALUE].set_external(static_cast<std::int8_t *>(data), |
| 418 |
num_to_get * num_components); |
| 419 |
} |
| 420 |
break; |
| 421 |
default: |
| 422 |
std::ostringstream errmsg; |
| 423 |
fmt::print(errmsg, "ERROR in {} {}: {} ({}), unsupported field type: {}\n", __func__, |
| 424 |
containerName, field.get_name(), num_to_get, field.type_string()); |
| 425 |
IOSS_ERROR(errmsg); |
| 426 |
} |
| 427 |
} |
| 428 |
return num_to_get; |
| 429 |
} |
| 430 |
|
| 431 |
int64_t getField(const std::string &containerName, const Ioss::GroupingEntity *entityGroup, |
| 432 |
const Ioss::Field &field, void *data, size_t data_size) |
| 433 |
{ |
| 434 |
const auto groupName = getName(entityGroup); |
| 435 |
auto num_to_get = field.verify(data_size); |
| 436 |
const auto num_components = field.raw_storage()->component_count(); |
| 437 |
if (num_to_get > 0) { |
| 438 |
auto path = |
| 439 |
getFieldPath(containerName, groupName, field.get_name()) + detail::FS + detail::VALUE; |
| 440 |
const auto &&node = this->DBNode[path]; |
| 441 |
switch (field.get_type()) { |
| 442 |
case Ioss::Field::BasicType::DOUBLE: |
| 443 |
std::copy_n(reinterpret_cast<const double *>(node.element_ptr(0)), |
| 444 |
num_to_get * num_components, reinterpret_cast<double *>(data)); |
| 445 |
break; |
| 446 |
|
| 447 |
case Ioss::Field::BasicType::INT32: |
| 448 |
std::copy_n(reinterpret_cast<const int32_t *>(node.element_ptr(0)), |
| 449 |
num_to_get * num_components, reinterpret_cast<int32_t *>(data)); |
| 450 |
break; |
| 451 |
|
| 452 |
case Ioss::Field::BasicType::INT64: |
| 453 |
std::copy_n(reinterpret_cast<const int64_t *>(node.element_ptr(0)), |
| 454 |
num_to_get * num_components, reinterpret_cast<int64_t *>(data)); |
| 455 |
break; |
| 456 |
|
| 457 |
case Ioss::Field::BasicType::CHARACTER: |
| 458 |
std::copy_n(reinterpret_cast<const char *>(node.element_ptr(0)), |
| 459 |
num_to_get * num_components, reinterpret_cast<char *>(data)); |
| 460 |
break; |
| 461 |
default: |
| 462 |
std::ostringstream errmsg; |
| 463 |
fmt::print(errmsg, "ERROR in {} {}: {} ({}), unsupported field type: {}\n", __func__, |
| 464 |
containerName, field.get_name(), num_to_get, field.type_string()); |
| 465 |
IOSS_ERROR(errmsg); |
| 466 |
} |
| 467 |
} |
| 468 |
return num_to_get; |
| 469 |
} |
| 470 |
|
| 471 |
int64_t getFieldZeroCopy(const std::string &containerName, |
| 472 |
const Ioss::GroupingEntity *entityGroup, const Ioss::Field &field, |
| 473 |
void **data, size_t *data_size) |
| 474 |
|
| 475 |
{ |
| 476 |
*data = nullptr; |
| 477 |
*data_size = 0; |
| 478 |
if (!hasField(containerName, entityGroup, field.get_name())) { |
| 479 |
fmt::print(Ioss::OUTPUT(), "WARNING in {} : {}\n", __func__, |
| 480 |
"field not available, " + field.get_name() + ", in container " + containerName + |
| 481 |
"\n"); |
| 482 |
return -1; |
| 483 |
} |
| 484 |
|
| 485 |
const auto groupName = getName(entityGroup); |
| 486 |
auto num_to_get = field.verify(0); |
| 487 |
const auto num_components = field.raw_storage()->component_count(); |
| 488 |
if (num_to_get > 0) { |
| 489 |
auto path = |
| 490 |
getFieldPath(containerName, groupName, field.get_name()) + detail::FS + detail::VALUE; |
| 491 |
|
| 492 |
const auto &&node = this->DBNode[path]; |
| 493 |
*data_size = num_to_get * num_components; |
| 494 |
switch (field.get_type()) { |
| 495 |
case Ioss::Field::BasicType::DOUBLE: |
| 496 |
*data = const_cast<double *>(node.as_double_ptr()); |
| 497 |
break; |
| 498 |
|
| 499 |
case Ioss::Field::BasicType::INT32: |
| 500 |
*data = const_cast<int32_t *>(node.as_int32_ptr()); |
| 501 |
break; |
| 502 |
|
| 503 |
case Ioss::Field::BasicType::INT64: |
| 504 |
*data = const_cast<int64_t *>(node.as_int64_ptr()); |
| 505 |
break; |
| 506 |
|
| 507 |
case Ioss::Field::BasicType::CHARACTER: |
| 508 |
*data = const_cast<char *>(node.as_char_ptr()); |
| 509 |
break; |
| 510 |
default: |
| 511 |
std::ostringstream errmsg; |
| 512 |
fmt::print(errmsg, "ERROR in {} {}: {} ({}), unsupported field type: {}\n", __func__, |
| 513 |
containerName, field.get_name(), num_to_get, field.type_string()); |
| 514 |
IOSS_ERROR(errmsg); |
| 515 |
} |
| 516 |
} |
| 517 |
return num_to_get; |
| 518 |
} |
| 519 |
|
| 520 |
int64_t getMeshModelCoordinates(const std::string &containerName, |
| 521 |
const Ioss::GroupingEntity *entityGroup, |
| 522 |
const Ioss::Field &field, void *data, size_t data_size) |
| 523 |
{ |
| 524 |
const auto groupName = getName(entityGroup); |
| 525 |
auto num_to_get = field.verify(data_size); |
| 526 |
const auto num_components = field.raw_storage()->component_count(); |
| 527 |
if (num_to_get > 0) { |
| 528 |
auto path = getPropertyPath(containerName, groupName, detail::COMPONENTDEGREE) + |
| 529 |
detail::FS + detail::VALUE; |
| 530 |
int64_t component_degree = this->DBNode[path].as_int64(); |
| 531 |
double *rdata = static_cast<double *>(data); |
| 532 |
|
| 533 |
auto coord_lambda = [&](const std::string &coord_name, int ordinal) { |
| 534 |
path = getFieldPath(containerName, groupName, coord_name) + detail::FS + detail::COUNT; |
| 535 |
int64_t count = this->DBNode[path].as_int64(); |
| 536 |
|
| 537 |
path = getFieldPath(containerName, groupName, coord_name) + detail::FS + detail::VALUE; |
| 538 |
const double *mesh_coords = |
| 539 |
reinterpret_cast<const double *>(this->DBNode[path].element_ptr(0)); |
| 540 |
|
| 541 |
for (size_t i = 0; i < count; i++) { |
| 542 |
rdata[component_degree * i + ordinal] = mesh_coords[i]; |
| 543 |
} |
| 544 |
}; |
| 545 |
|
| 546 |
coord_lambda(detail::MESHMODCOX, 0); |
| 547 |
|
| 548 |
if (component_degree >= 2) { |
| 549 |
coord_lambda(detail::MESHMODCOY, 1); |
| 550 |
} |
| 551 |
|
| 552 |
if (component_degree == 3) { |
| 553 |
coord_lambda(detail::MESHMODCOZ, 2); |
| 554 |
} |
| 555 |
} |
| 556 |
return num_to_get; |
| 557 |
} |
| 558 |
|
| 559 |
bool hasField(const std::string &containerName, const Ioss::GroupingEntity *entityGroup, |
| 560 |
const std::string &fieldName) |
| 561 |
{ |
| 562 |
const auto groupName = getName(entityGroup); |
| 563 |
return this->DBNode.has_path(getFieldPath(containerName, groupName, fieldName)); |
| 564 |
} |
| 565 |
|
| 566 |
std::string getFieldPath(const std::string &containerName, const std::string &groupName, |
| 567 |
const std::string &fieldName) |
| 568 |
{ |
| 569 |
return containerName + detail::FS + groupName + detail::FS + detail::FIELDS + detail::FS + |
| 570 |
fieldName; |
| 571 |
} |
| 572 |
|
| 573 |
bool hasProperty(const std::string &containerName, const Ioss::GroupingEntity *entityGroup, |
| 574 |
const std::string &propertyName) |
| 575 |
{ |
| 576 |
const auto groupName = getName(entityGroup); |
| 577 |
return this->DBNode.has_path(getPropertyPath(containerName, groupName, propertyName)); |
| 578 |
} |
| 579 |
|
| 580 |
std::string getPropertyPath(const std::string &containerName, const std::string &groupName, |
| 581 |
const std::string &propertyName) |
| 582 |
{ |
| 583 |
return containerName + detail::FS + groupName + detail::FS + detail::PROPERTIES + detail::FS + |
| 584 |
propertyName; |
| 585 |
} |
| 586 |
|
| 587 |
std::string getName(const Ioss::GroupingEntity *entityGroup) |
| 588 |
{ |
| 589 |
std::string retVal = entityGroup->name(); |
| 590 |
if (dynamic_cast<const Ioss::Region *>(entityGroup) != nullptr) { |
| 591 |
retVal = detail::REGION_ZERO; |
| 592 |
} |
| 593 |
else if (retVal.empty()) { |
| 594 |
retVal = entityGroup->generic_name(); |
| 595 |
} |
| 596 |
std::replace(retVal.begin(), retVal.end(), detail::FS_CHAR, detail::DASH_CHAR); |
| 597 |
return retVal; |
| 598 |
} |
| 599 |
|
| 600 |
std::string getTimePath() { return detail::DATABASE + detail::FS + detail::TIME; } |
| 601 |
|
| 602 |
int64_t getStructuredBlockIDS(const Ioss::StructuredBlock *sb, const Ioss::Field &field, |
| 603 |
void *data, size_t data_size) |
| 604 |
{ |
| 605 |
auto num_to_get = field.verify(data_size); |
| 606 |
|
| 607 |
if (num_to_get > 0) { |
| 608 |
switch (field.get_type()) { |
| 609 |
case Ioss::Field::BasicType::INT32: |
| 610 |
copyIDS(sb, field, reinterpret_cast<int32_t *>(data)); |
| 611 |
break; |
| 612 |
|
| 613 |
case Ioss::Field::BasicType::INT64: |
| 614 |
copyIDS(sb, field, reinterpret_cast<int64_t *>(data)); |
| 615 |
break; |
| 616 |
default: |
| 617 |
std::ostringstream errmsg; |
| 618 |
fmt::print(errmsg, "ERROR in {}: {} ({}), unsupported field type: {}\n", __func__, |
| 619 |
field.get_name(), num_to_get, field.type_string()); |
| 620 |
IOSS_ERROR(errmsg); |
| 621 |
} |
| 622 |
} |
| 623 |
return num_to_get; |
| 624 |
} |
| 625 |
|
| 626 |
template <typename INT_t> |
| 627 |
void copyIDS(const Ioss::StructuredBlock *sb, const Ioss::Field &field, INT_t *data) |
| 628 |
{ |
| 629 |
if (field.get_name() == detail::CELLIDS) { |
| 630 |
sb->get_cell_ids(data, true); |
| 631 |
} |
| 632 |
else { |
| 633 |
sb->get_cell_node_ids(data, true); |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
Ioss::Map &get_node_map(const Ioss::DatabaseIO *dbase) const |
| 638 |
{ |
| 639 |
if (this->NodeMap.defined()) { |
| 640 |
return this->NodeMap; |
| 641 |
} |
| 642 |
|
| 643 |
auto nbone_path = detail::NODEBLOCKS + detail::FS + detail::NODEBLOCKONE + detail::FS + |
| 644 |
detail::FIELDS + detail::FS + detail::IDS; |
| 645 |
auto &&idsNode = this->DBNode[nbone_path]; |
| 646 |
auto node_ids = const_cast<void *>(idsNode[detail::VALUE].element_ptr(0)); |
| 647 |
this->NodeMap.set_size(idsNode[detail::COUNT].as_int64()); |
| 648 |
if (idsNode[detail::TYPE].as_int8() == Ioss::Field::BasicType::INT32) { |
| 649 |
this->NodeMap.set_map(reinterpret_cast<int32_t *>(node_ids), |
| 650 |
idsNode[detail::COUNT].as_int64(), 0); |
| 651 |
} |
| 652 |
if (idsNode[detail::TYPE].as_int8() == Ioss::Field::BasicType::INT64) { |
| 653 |
this->NodeMap.set_map(reinterpret_cast<int64_t *>(node_ids), |
| 654 |
idsNode[detail::COUNT].as_int64(), 0); |
| 655 |
} |
| 656 |
|
| 657 |
this->NodeMap.set_defined(true); |
| 658 |
return this->NodeMap; |
| 659 |
} |
| 660 |
|
| 661 |
private: |
| 662 |
template <typename GroupingEntityT> |
| 663 |
bool defineEntityGroup(conduit_cpp::Node parent, |
| 664 |
const std::vector<GroupingEntityT *> &container) |
| 665 |
{ |
| 666 |
for (auto group : container) { |
| 667 |
this->addProperties(parent[getName(group)], group); |
| 668 |
} |
| 669 |
return true; |
| 670 |
} |
| 671 |
|
| 672 |
bool defineEntityGroup(conduit_cpp::Node parent, const Ioss::SideSetContainer &container) |
| 673 |
{ |
| 674 |
for (auto group : container) { |
| 675 |
this->addProperties(parent[getName(group)], group); |
| 676 |
for (auto sb : group->get_side_blocks()) { |
| 677 |
parent[getName(group) + detail::FS + detail::SIDEBLOCKS].append().set(sb->name()); |
| 678 |
} |
| 679 |
auto &node = this->DBNode; |
| 680 |
this->defineEntityGroup(node[detail::SIDEBLOCKS], group->get_side_blocks()); |
| 681 |
} |
| 682 |
return true; |
| 683 |
} |
| 684 |
|
| 685 |
bool defineEntityGroup(conduit_cpp::Node parent, const Ioss::AssemblyContainer &container) |
| 686 |
{ |
| 687 |
for (auto group : container) { |
| 688 |
this->addProperties(parent[getName(group)], group); |
| 689 |
parent[getName(group) + detail::FS + detail::MEMBER_TYPE].set(group->get_member_type()); |
| 690 |
for (auto as : group->get_members()) { |
| 691 |
parent[getName(group) + detail::FS + detail::MEMBERS].append().set(as->name()); |
| 692 |
} |
| 693 |
} |
| 694 |
return true; |
| 695 |
} |
| 696 |
|
| 697 |
bool defineEntityGroup(conduit_cpp::Node parent, |
| 698 |
const Ioss::StructuredBlockContainer &container) |
| 699 |
{ |
| 700 |
for (auto group : container) { |
| 701 |
this->addProperties(parent[getName(group)], group); |
| 702 |
conduit_cpp::Node n; |
| 703 |
for (auto zc : group->m_zoneConnectivity) { |
| 704 |
defineZoneConnectivity(n, zc); |
| 705 |
} |
| 706 |
parent[getName(group) + detail::FS + detail::ZONECONNECTIVITY].set(n); |
| 707 |
|
| 708 |
n.set_node(conduit_cpp::Node()); |
| 709 |
for (auto bc : group->m_boundaryConditions) { |
| 710 |
defineBoundaryCondition(n, bc); |
| 711 |
} |
| 712 |
parent[getName(group) + detail::FS + detail::BOUNDARYCONDS].set(n); |
| 713 |
|
| 714 |
parent[getName(group) + detail::FS + detail::BLOCKLOCNODEIND].set( |
| 715 |
group->m_blockLocalNodeIndex); |
| 716 |
|
| 717 |
n.set_node(conduit_cpp::Node()); |
| 718 |
for (auto gm : group->m_globalIdMap) { |
| 719 |
conduit_cpp::Node m; |
| 720 |
m[detail::KEY] = gm.first; |
| 721 |
m[detail::VALUE] = gm.second; |
| 722 |
m.append().set(n); |
| 723 |
} |
| 724 |
parent[getName(group) + detail::FS + detail::GLOBALIDMAP].set(n); |
| 725 |
} |
| 726 |
return true; |
| 727 |
} |
| 728 |
|
| 729 |
void defineZoneConnectivity(conduit_cpp::Node parent, Ioss::ZoneConnectivity &zc) |
| 730 |
{ |
| 731 |
conduit_cpp::Node n; |
| 732 |
n[detail::CONNECTIONNAME] = zc.m_connectionName; |
| 733 |
n[detail::DONORNAME] = zc.m_donorName; |
| 734 |
n[detail::TRANSFORM] = defineIJK(zc.m_transform); |
| 735 |
n[detail::OWNERRANGEBEG] = defineIJK(zc.m_ownerRangeBeg); |
| 736 |
n[detail::OWNERRANGEEND] = defineIJK(zc.m_ownerRangeEnd); |
| 737 |
n[detail::OWNEROFFSET] = defineIJK(zc.m_ownerOffset); |
| 738 |
n[detail::DONORRANGEBEG] = defineIJK(zc.m_donorRangeBeg); |
| 739 |
n[detail::DONORRANGEEND] = defineIJK(zc.m_donorRangeEnd); |
| 740 |
n[detail::DONOROFFSET] = defineIJK(zc.m_donorOffset); |
| 741 |
n[detail::OWNERZONE] = zc.m_ownerZone; |
| 742 |
n[detail::DONORZONE] = zc.m_donorZone; |
| 743 |
n[detail::FROMDECOMP] = zc.m_fromDecomp; |
| 744 |
parent.append().set(n); |
| 745 |
} |
| 746 |
|
| 747 |
void defineBoundaryCondition(conduit_cpp::Node parent, Ioss::BoundaryCondition &bc) |
| 748 |
{ |
| 749 |
conduit_cpp::Node n; |
| 750 |
n[detail::BCNAME] = bc.m_bcName; |
| 751 |
n[detail::FAMNAME] = bc.m_famName; |
| 752 |
n[detail::RANGEBEG] = defineIJK(bc.m_rangeBeg); |
| 753 |
n[detail::RANGEEND] = defineIJK(bc.m_rangeEnd); |
| 754 |
n[detail::FACE] = bc.m_face; |
| 755 |
parent.append().set(n); |
| 756 |
} |
| 757 |
|
| 758 |
conduit_cpp::Node defineIJK(Ioss::IJK_t &a) |
| 759 |
{ |
| 760 |
conduit_cpp::Node n; |
| 761 |
for (auto v : a) { |
| 762 |
n.append().set(v); |
| 763 |
} |
| 764 |
return n; |
| 765 |
} |
| 766 |
|
| 767 |
template <typename GroupingEntityT> |
| 768 |
bool addProperties(conduit_cpp::Node parent, GroupingEntityT *entityGroup) |
| 769 |
{ |
| 770 |
Ioss::NameList names; |
| 771 |
// skip implicit properties. |
| 772 |
entityGroup->property_describe(Ioss::Property::INTERNAL, &names); |
| 773 |
entityGroup->property_describe(Ioss::Property::EXTERNAL, &names); |
| 774 |
entityGroup->property_describe(Ioss::Property::ATTRIBUTE, &names); |
| 775 |
entityGroup->property_describe(Ioss::Property::IMPLICIT, &names); |
| 776 |
|
| 777 |
auto &&propertiesNode = parent[detail::PROPERTIES]; |
| 778 |
for (const auto &name : names) { |
| 779 |
auto property = entityGroup->get_property(name); |
| 780 |
|
| 781 |
auto &&node = propertiesNode[name]; |
| 782 |
node[detail::TYPE].set(static_cast<std::int8_t>(property.get_type())); |
| 783 |
node[detail::ORIGIN].set(static_cast<std::int8_t>(property.get_origin())); |
| 784 |
switch (property.get_type()) { |
| 785 |
case Ioss::Property::BasicType::REAL: node[detail::VALUE].set(property.get_real()); break; |
| 786 |
|
| 787 |
case Ioss::Property::BasicType::INTEGER: node[detail::VALUE].set(property.get_int()); break; |
| 788 |
|
| 789 |
case Ioss::Property::BasicType::STRING: |
| 790 |
node[detail::VALUE].set(property.get_string()); |
| 791 |
break; |
| 792 |
|
| 793 |
case Ioss::Property::BasicType::VEC_INTEGER: |
| 794 |
node[detail::VALUE].set(property.get_vec_int()); |
| 795 |
break; |
| 796 |
|
| 797 |
case Ioss::Property::BasicType::VEC_DOUBLE: |
| 798 |
node[detail::VALUE].set(property.get_vec_double()); |
| 799 |
break; |
| 800 |
|
| 801 |
case Ioss::Property::BasicType::POINTER: |
| 802 |
case Ioss::Property::BasicType::INVALID: |
| 803 |
default: return false; |
| 804 |
} |
| 805 |
} |
| 806 |
return true; |
| 807 |
} |
| 808 |
|
| 809 |
template <typename GroupingEntityT> |
| 810 |
bool readEntityGroup(conduit_cpp::Node &&parent, Ioss::Region *region) |
| 811 |
{ |
| 812 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 813 |
auto &&child = parent[idx]; |
| 814 |
auto block = detail::createEntityGroup<GroupingEntityT>(child, region->get_database()); |
| 815 |
region->add(block); |
| 816 |
this->readProperties(child[detail::PROPERTIES], block); |
| 817 |
|
| 818 |
// read fields (meta-data only) |
| 819 |
this->readFields(child[detail::FIELDS], block); |
| 820 |
} |
| 821 |
return true; |
| 822 |
} |
| 823 |
|
| 824 |
template <typename GroupingEntityT> |
| 825 |
bool readProperties(const conduit_cpp::Node &&parent, GroupingEntityT *block) const |
| 826 |
{ |
| 827 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 828 |
auto &&child = parent[idx]; |
| 829 |
const auto name = child.name(); |
| 830 |
const auto origin = static_cast<Ioss::Property::Origin>(child[detail::ORIGIN].as_int8()); |
| 831 |
if (block->property_exists(name) && block->get_property(name).is_implicit()) { |
| 832 |
continue; |
| 833 |
} |
| 834 |
switch (child[detail::TYPE].as_int8()) { |
| 835 |
// TODO: missing origin |
| 836 |
case Ioss::Property::BasicType::REAL: |
| 837 |
block->property_add(Ioss::Property(name, child[detail::VALUE].as_float64(), origin)); |
| 838 |
break; |
| 839 |
|
| 840 |
case Ioss::Property::BasicType::INTEGER: |
| 841 |
block->property_add(Ioss::Property(name, child[detail::VALUE].as_int64(), origin)); |
| 842 |
break; |
| 843 |
|
| 844 |
case Ioss::Property::BasicType::STRING: |
| 845 |
block->property_add(Ioss::Property(name, child[detail::VALUE].as_string(), origin)); |
| 846 |
break; |
| 847 |
|
| 848 |
case Ioss::Property::BasicType::VEC_INTEGER: { |
| 849 |
std::vector<int> v(child[detail::VALUE].as_int_ptr(), |
| 850 |
child[detail::VALUE].as_int_ptr() + |
| 851 |
child[detail::VALUE].number_of_children()); |
| 852 |
block->property_add(Ioss::Property(name, v, origin)); |
| 853 |
break; |
| 854 |
} |
| 855 |
|
| 856 |
case Ioss::Property::BasicType::VEC_DOUBLE: { |
| 857 |
std::vector<double> v(child[detail::VALUE].as_double_ptr(), |
| 858 |
child[detail::VALUE].as_double_ptr() + |
| 859 |
child[detail::VALUE].number_of_children()); |
| 860 |
block->property_add(Ioss::Property(name, v, origin)); |
| 861 |
break; |
| 862 |
} |
| 863 |
} |
| 864 |
} |
| 865 |
return true; |
| 866 |
} |
| 867 |
|
| 868 |
std::vector<std::string> getScalarNamesFromNonScalarField(const Ioss::Field &field) const |
| 869 |
{ |
| 870 |
int ncomp = field.get_component_count(Ioss::Field::InOut::INPUT); |
| 871 |
std::vector<std::string> fnames; |
| 872 |
for (int i = 1; i <= ncomp; i++) { |
| 873 |
if (read_db_field_separator == '\0') { |
| 874 |
fnames.push_back( |
| 875 |
field.get_component_name(i, Ioss::Field::InOut::INPUT, read_db_field_separator)); |
| 876 |
} |
| 877 |
else { |
| 878 |
fnames.push_back(field.get_component_name(i, Ioss::Field::InOut::INPUT)); |
| 879 |
} |
| 880 |
} |
| 881 |
return fnames; |
| 882 |
} |
| 883 |
|
| 884 |
template <typename T> |
| 885 |
std::vector<T> getInterweavedScalarDataFromConduitNode(const std::vector<std::string> fnames, |
| 886 |
conduit_cpp::Node &node) const |
| 887 |
{ |
| 888 |
int ncomp = fnames.size(); |
| 889 |
auto &&t_node = node[fnames[0] + detail::FS + detail::VALUE]; |
| 890 |
int num_get = t_node.number_of_elements(); |
| 891 |
std::vector<T> vals(ncomp * num_get); |
| 892 |
|
| 893 |
for (int i = 0; i < num_get; i++) { |
| 894 |
for (int j = 0; j < ncomp; j++) { |
| 895 |
std::string path_to_value = fnames[j] + detail::FS + detail::VALUE; |
| 896 |
auto &&child_value = node[path_to_value]; |
| 897 |
vals[i * ncomp + j] = reinterpret_cast<const T *>(child_value.element_ptr(0))[i]; |
| 898 |
} |
| 899 |
} |
| 900 |
return vals; |
| 901 |
} |
| 902 |
|
| 903 |
template <typename T> |
| 904 |
void addFieldNodeAndDataToConduitNode(const Ioss::Field &field, void *data, |
| 905 |
conduit_cpp::Node &node) const |
| 906 |
{ |
| 907 |
int ncomp = field.get_component_count(Ioss::Field::InOut::INPUT); |
| 908 |
int num_get = field.raw_count(); |
| 909 |
node[field.get_name()] = conduit_cpp::Node(); |
| 910 |
auto &&f_node = node[field.get_name()]; |
| 911 |
f_node[detail::ROLE].set(static_cast<std::int8_t>(field.get_role())); |
| 912 |
f_node[detail::TYPE].set(static_cast<std::int8_t>(field.get_type())); |
| 913 |
f_node[detail::COUNT].set(static_cast<std::int64_t>(field.raw_count())); |
| 914 |
f_node[detail::INDEX].set(static_cast<std::int64_t>(field.get_index())); |
| 915 |
f_node[detail::COMPONENTCOUNT].set(static_cast<std::int64_t>(ncomp)); |
| 916 |
f_node[detail::STORAGE].set(field.raw_storage()->name()); |
| 917 |
f_node[detail::VALUE].set(static_cast<T *>(data), ncomp * num_get); |
| 918 |
} |
| 919 |
|
| 920 |
void combineScalarFieldsInConduitNodeToNonScalarField(const Ioss::Field &field, |
| 921 |
conduit_cpp::Node &node) const |
| 922 |
{ |
| 923 |
std::vector<std::string> fnames = this->getScalarNamesFromNonScalarField(field); |
| 924 |
|
| 925 |
switch (field.get_type()) { |
| 926 |
case Ioss::Field::BasicType::DOUBLE: |
| 927 |
this->addFieldNodeAndDataToConduitNode<double>( |
| 928 |
field, this->getInterweavedScalarDataFromConduitNode<double>(fnames, node).data(), |
| 929 |
node); |
| 930 |
break; |
| 931 |
|
| 932 |
case Ioss::Field::BasicType::INT32: |
| 933 |
this->addFieldNodeAndDataToConduitNode<std::int32_t>( |
| 934 |
field, this->getInterweavedScalarDataFromConduitNode<std::int32_t>(fnames, node).data(), |
| 935 |
node); |
| 936 |
break; |
| 937 |
|
| 938 |
case Ioss::Field::BasicType::INT64: |
| 939 |
this->addFieldNodeAndDataToConduitNode<std::int64_t>( |
| 940 |
field, this->getInterweavedScalarDataFromConduitNode<std::int64_t>(fnames, node).data(), |
| 941 |
node); |
| 942 |
break; |
| 943 |
|
| 944 |
case Ioss::Field::BasicType::CHARACTER: |
| 945 |
this->addFieldNodeAndDataToConduitNode<std::int8_t>( |
| 946 |
field, this->getInterweavedScalarDataFromConduitNode<char>(fnames, node).data(), node); |
| 947 |
break; |
| 948 |
default: |
| 949 |
std::ostringstream errmsg; |
| 950 |
fmt::print(errmsg, "ERROR in {} on read: {}, unsupported field type: {}\n", __func__, |
| 951 |
field.get_name(), field.type_string()); |
| 952 |
IOSS_ERROR(errmsg); |
| 953 |
} |
| 954 |
|
| 955 |
// Remove Related Scalars from Conduit Node |
| 956 |
for (int i = 0; i < fnames.size(); i++) { |
| 957 |
node.remove(fnames[i]); |
| 958 |
} |
| 959 |
} |
| 960 |
|
| 961 |
template <typename GroupingEntityT> |
| 962 |
bool readFields(conduit_cpp::Node &&parent, GroupingEntityT *block) const |
| 963 |
{ |
| 964 |
// Assumption: count = entity_count (in block) |
| 965 |
Ioss::DatabaseIO *dbase = block->get_database(); |
| 966 |
Ioss::EntityType b_t = block->type(); |
| 967 |
bool is_entity_block = false; |
| 968 |
if (b_t == Ioss::EntityType::ELEMENTBLOCK || b_t == Ioss::EntityType::EDGEBLOCK || |
| 969 |
b_t == Ioss::EntityType::FACEBLOCK || b_t == Ioss::EntityType::NODEBLOCK || |
| 970 |
b_t == Ioss::EntityType::SIDEBLOCK || b_t == Ioss::EntityType::STRUCTUREDBLOCK) { |
| 971 |
is_entity_block = true; |
| 972 |
} |
| 973 |
Ioss::NameList field_names; |
| 974 |
field_names.reserve(parent.number_of_children()); |
| 975 |
size_t entity_count = 0; |
| 976 |
|
| 977 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 978 |
auto &&child = parent[idx]; |
| 979 |
const auto name = child.name(); |
| 980 |
const auto type = static_cast<Ioss::Field::BasicType>(child[detail::TYPE].as_int8()); |
| 981 |
const auto role = static_cast<Ioss::Field::RoleType>(child[detail::ROLE].as_int8()); |
| 982 |
const auto count = child[detail::COUNT].as_int64(); |
| 983 |
const auto index = child[detail::INDEX].as_int64(); |
| 984 |
const auto storage = child[detail::STORAGE].as_string(); |
| 985 |
if (!block->field_exists(name)) { |
| 986 |
if (storage == IOSS_SCALAR() && role == Ioss::Field::TRANSIENT && is_entity_block) { |
| 987 |
// Add to get_fields() call |
| 988 |
field_names.push_back(name); |
| 989 |
if (entity_count == 0) |
| 990 |
entity_count = count; |
| 991 |
} |
| 992 |
else { |
| 993 |
block->field_add( |
| 994 |
Ioss::Field(name, type, storage, role, count, index).set_zero_copy_enabled()); |
| 995 |
} |
| 996 |
} |
| 997 |
else { |
| 998 |
// Verify field details. |
| 999 |
auto field_block = block->get_fieldref(name); |
| 1000 |
if (!field_block.has_transform()) { |
| 1001 |
block->get_fieldref(name).set_zero_copy_enabled(); |
| 1002 |
} |
| 1003 |
auto field_conduit = |
| 1004 |
Ioss::Field(name, type, storage, role, count, index).set_zero_copy_enabled(); |
| 1005 |
if (field_block != field_conduit) { |
| 1006 |
std::ostringstream errmsg; |
| 1007 |
errmsg << "Catalyst Read: Field '" << name << "' from conduit " |
| 1008 |
<< "already exists in block '" << block->name().c_str() << "' of type '" |
| 1009 |
<< block->type_string() << "' and differs from it\n"; |
| 1010 |
IOSS_ERROR(errmsg); |
| 1011 |
} |
| 1012 |
} |
| 1013 |
} |
| 1014 |
|
| 1015 |
// Apply Exodus Properties to Scalar Fields in Entity Blocks |
| 1016 |
if (!field_names.empty()) { |
| 1017 |
std::vector<Ioss::Field> fields; |
| 1018 |
Ioss::Utils::get_fields(entity_count, field_names, Ioss::Field::TRANSIENT, dbase, nullptr, |
| 1019 |
fields); |
| 1020 |
for (const auto &field : fields) { |
| 1021 |
block->field_add(field.set_zero_copy_enabled()); |
| 1022 |
} |
| 1023 |
|
| 1024 |
for (const auto &field : fields) { |
| 1025 |
if (field.raw_storage()->name() != IOSS_SCALAR()) { |
| 1026 |
this->combineScalarFieldsInConduitNodeToNonScalarField(field, parent); |
| 1027 |
} |
| 1028 |
} |
| 1029 |
} |
| 1030 |
|
| 1031 |
return true; |
| 1032 |
} |
| 1033 |
}; |
| 1034 |
|
| 1035 |
template <> |
| 1036 |
bool DatabaseIO::ImplementationT::readEntityGroup<Ioss::Region>(conduit_cpp::Node &&parent, |
| 1037 |
Ioss::Region *region) |
| 1038 |
{ |
| 1039 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1040 |
auto &&child = parent[idx]; |
| 1041 |
|
| 1042 |
this->readProperties(child[detail::PROPERTIES], region); |
| 1043 |
|
| 1044 |
// read fields (meta-data only) |
| 1045 |
this->readFields(child[detail::FIELDS], region); |
| 1046 |
} |
| 1047 |
return true; |
| 1048 |
} |
| 1049 |
|
| 1050 |
template <> |
| 1051 |
bool DatabaseIO::ImplementationT::readEntityGroup<Ioss::SideBlock>(conduit_cpp::Node &&parent, |
| 1052 |
Ioss::Region *region) |
| 1053 |
{ |
| 1054 |
sideBlocks.clear(); |
| 1055 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1056 |
auto &&child = parent[idx]; |
| 1057 |
auto block = detail::createEntityGroup<Ioss::SideBlock>(child, region->get_database()); |
| 1058 |
if (sideBlocks.find(block->name()) == sideBlocks.end()) { |
| 1059 |
sideBlocks[block->name()] = block; |
| 1060 |
} |
| 1061 |
else { |
| 1062 |
std::ostringstream errmsg; |
| 1063 |
fmt::print(errmsg, "ERROR in {} {}: side block name used twice.\n", __func__, |
| 1064 |
block->name()); |
| 1065 |
IOSS_ERROR(errmsg); |
| 1066 |
} |
| 1067 |
|
| 1068 |
this->readProperties(child[detail::PROPERTIES], block); |
| 1069 |
|
| 1070 |
// read fields (meta-data only) |
| 1071 |
this->readFields(child[detail::FIELDS], block); |
| 1072 |
} |
| 1073 |
return true; |
| 1074 |
} |
| 1075 |
|
| 1076 |
template <> |
| 1077 |
bool DatabaseIO::ImplementationT::readEntityGroup<Ioss::SideSet>(conduit_cpp::Node &&parent, |
| 1078 |
Ioss::Region *region) |
| 1079 |
{ |
| 1080 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1081 |
auto &&child = parent[idx]; |
| 1082 |
auto block = detail::createEntityGroup<Ioss::SideSet>(child, region->get_database()); |
| 1083 |
for (int i = 0; i < child[detail::SIDEBLOCKS].number_of_children(); i++) { |
| 1084 |
auto name = child[detail::SIDEBLOCKS].child(i).as_string(); |
| 1085 |
if (sideBlocks.find(name) != sideBlocks.end()) { |
| 1086 |
block->add(sideBlocks[name]); |
| 1087 |
} |
| 1088 |
else { |
| 1089 |
std::ostringstream errmsg; |
| 1090 |
fmt::print(errmsg, "ERROR in {} {}: side block name not available.\n", __func__, name); |
| 1091 |
IOSS_ERROR(errmsg); |
| 1092 |
} |
| 1093 |
} |
| 1094 |
region->add(block); |
| 1095 |
this->readProperties(child[detail::PROPERTIES], block); |
| 1096 |
|
| 1097 |
// read fields (meta-data only) |
| 1098 |
this->readFields(child[detail::FIELDS], block); |
| 1099 |
} |
| 1100 |
sideBlocks.clear(); |
| 1101 |
return true; |
| 1102 |
} |
| 1103 |
|
| 1104 |
template <> |
| 1105 |
bool DatabaseIO::ImplementationT::readEntityGroup<Ioss::Assembly>(conduit_cpp::Node &&parent, |
| 1106 |
Ioss::Region *region) |
| 1107 |
{ |
| 1108 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1109 |
auto &&child = parent[idx]; |
| 1110 |
auto block = detail::createEntityGroup<Ioss::Assembly>(child, region->get_database()); |
| 1111 |
auto member_type = child[detail::MEMBER_TYPE].as_int(); |
| 1112 |
for (int i = 0; i < child[detail::MEMBERS].number_of_children(); i++) { |
| 1113 |
auto name = child[detail::MEMBERS].child(i).as_string(); |
| 1114 |
Ioss::GroupingEntity *ge = nullptr; |
| 1115 |
switch (member_type) { |
| 1116 |
case Ioss::EntityType::NODEBLOCK: ge = region->get_node_block(name); break; |
| 1117 |
case Ioss::EntityType::EDGEBLOCK: ge = region->get_edge_block(name); break; |
| 1118 |
case Ioss::EntityType::EDGESET: ge = region->get_edgeset(name); break; |
| 1119 |
case Ioss::EntityType::FACEBLOCK: ge = region->get_face_block(name); break; |
| 1120 |
case Ioss::EntityType::ELEMENTBLOCK: ge = region->get_element_block(name); break; |
| 1121 |
case Ioss::EntityType::NODESET: ge = region->get_nodeset(name); break; |
| 1122 |
case Ioss::EntityType::FACESET: ge = region->get_faceset(name); break; |
| 1123 |
case Ioss::EntityType::ELEMENTSET: ge = region->get_elementset(name); break; |
| 1124 |
case Ioss::EntityType::SIDESET: ge = region->get_sideset(name); break; |
| 1125 |
case Ioss::EntityType::COMMSET: ge = region->get_commset(name); break; |
| 1126 |
case Ioss::EntityType::SIDEBLOCK: ge = region->get_sideblock(name); break; |
| 1127 |
case Ioss::EntityType::ASSEMBLY: ge = region->get_assembly(name); break; |
| 1128 |
case Ioss::EntityType::BLOB: ge = region->get_blob(name); break; |
| 1129 |
default: |
| 1130 |
std::ostringstream errmsg; |
| 1131 |
fmt::print(stderr, "ERROR in {} {}: unknown grouping entity type.\n", __func__, name); |
| 1132 |
IOSS_ERROR(errmsg); |
| 1133 |
} |
| 1134 |
if (ge) { |
| 1135 |
block->add(ge); |
| 1136 |
} |
| 1137 |
else { |
| 1138 |
std::ostringstream errmsg; |
| 1139 |
fmt::print(errmsg, "ERROR in {} {}: grouping entity not found.\n", __func__, name); |
| 1140 |
IOSS_ERROR(errmsg); |
| 1141 |
} |
| 1142 |
} |
| 1143 |
region->add(block); |
| 1144 |
this->readProperties(child[detail::PROPERTIES], block); |
| 1145 |
|
| 1146 |
// read fields (meta-data only) |
| 1147 |
this->readFields(child[detail::FIELDS], block); |
| 1148 |
} |
| 1149 |
return true; |
| 1150 |
} |
| 1151 |
|
| 1152 |
template <> |
| 1153 |
bool |
| 1154 |
DatabaseIO::ImplementationT::readEntityGroup<Ioss::StructuredBlock>(conduit_cpp::Node &&parent, |
| 1155 |
Ioss::Region *region) |
| 1156 |
{ |
| 1157 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1158 |
auto &&child = parent[idx]; |
| 1159 |
auto block = detail::createEntityGroup<Ioss::StructuredBlock>(child, region->get_database()); |
| 1160 |
region->add(block); |
| 1161 |
auto parent = block->get_node_block().get_property(detail::IOSSCONTAINEDIN); |
| 1162 |
this->readProperties(child[detail::PROPERTIES], block); |
| 1163 |
this->readProperties( |
| 1164 |
child[getName(&block->get_node_block()) + detail::FS + detail::PROPERTIES], |
| 1165 |
&block->get_node_block()); |
| 1166 |
block->get_node_block().property_add(parent); |
| 1167 |
|
| 1168 |
// read fields (meta-data only) |
| 1169 |
this->readFields(child[detail::FIELDS], block); |
| 1170 |
this->readFields(child[getName(&block->get_node_block()) + detail::FS + detail::FIELDS], |
| 1171 |
&block->get_node_block()); |
| 1172 |
|
| 1173 |
readZoneConnectivity(child[detail::ZONECONNECTIVITY], block); |
| 1174 |
readBoundaryConditions(child[detail::BOUNDARYCONDS], block); |
| 1175 |
|
| 1176 |
conduit_uint64 *my_vals = child[detail::BLOCKLOCNODEIND].as_uint64_ptr(); |
| 1177 |
block->m_blockLocalNodeIndex.clear(); |
| 1178 |
for (int i = 0; i < child[detail::BLOCKLOCNODEIND].number_of_children(); i++) { |
| 1179 |
block->m_blockLocalNodeIndex.push_back(my_vals[i]); |
| 1180 |
} |
| 1181 |
|
| 1182 |
conduit_cpp::Node &&n = child[detail::GLOBALIDMAP]; |
| 1183 |
block->m_globalIdMap.clear(); |
| 1184 |
for (conduit_index_t i = 0, m = n.number_of_children(); i < m; ++i) { |
| 1185 |
auto &&c = n[i]; |
| 1186 |
block->m_globalIdMap.push_back( |
| 1187 |
std::pair<size_t, size_t>(c[detail::KEY].as_int(), c[detail::VALUE].as_int())); |
| 1188 |
} |
| 1189 |
} |
| 1190 |
return true; |
| 1191 |
} |
| 1192 |
|
| 1193 |
void DatabaseIO::ImplementationT::readZoneConnectivity(conduit_cpp::Node &&parent, |
| 1194 |
Ioss::StructuredBlock *sb) |
| 1195 |
{ |
| 1196 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1197 |
auto &&child = parent[idx]; |
| 1198 |
Ioss::ZoneConnectivity zc( |
| 1199 |
child[detail::CONNECTIONNAME].as_string(), child[detail::OWNERZONE].as_int(), |
| 1200 |
child[detail::DONORNAME].as_string(), child[detail::DONORZONE].as_int(), |
| 1201 |
readIJK(child[detail::TRANSFORM]), readIJK(child[detail::OWNERRANGEBEG]), |
| 1202 |
readIJK(child[detail::OWNERRANGEEND]), readIJK(child[detail::OWNEROFFSET]), |
| 1203 |
readIJK(child[detail::DONORRANGEBEG]), readIJK(child[detail::DONORRANGEEND]), |
| 1204 |
readIJK(child[detail::DONOROFFSET])); |
| 1205 |
zc.m_fromDecomp = child[detail::FROMDECOMP].as_int(); |
| 1206 |
sb->m_zoneConnectivity.push_back(zc); |
| 1207 |
} |
| 1208 |
} |
| 1209 |
|
| 1210 |
void DatabaseIO::ImplementationT::readBoundaryConditions(conduit_cpp::Node &&parent, |
| 1211 |
Ioss::StructuredBlock *sb) |
| 1212 |
{ |
| 1213 |
for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { |
| 1214 |
|
| 1215 |
auto &&child = parent[idx]; |
| 1216 |
Ioss::BoundaryCondition bc( |
| 1217 |
child[detail::BCNAME].as_string(), child[detail::FAMNAME].as_string(), |
| 1218 |
readIJK(child[detail::RANGEBEG]), readIJK(child[detail::RANGEEND])); |
| 1219 |
bc.m_face = child[detail::FACE].as_int(); |
| 1220 |
sb->m_boundaryConditions.push_back(bc); |
| 1221 |
} |
| 1222 |
} |
| 1223 |
|
| 1224 |
Ioss::IJK_t DatabaseIO::ImplementationT::readIJK(conduit_cpp::Node &&parent) |
| 1225 |
{ |
| 1226 |
Ioss::IJK_t a{{0, 0, 0}}; |
| 1227 |
for (auto i = 0; i < parent.number_of_children(); i++) { |
| 1228 |
a[i] = parent[i].as_int(); |
| 1229 |
} |
| 1230 |
return a; |
| 1231 |
} |
| 1232 |
|
| 1233 |
bool DatabaseIO::ImplementationT::readModel(Ioss::Region *region) |
| 1234 |
{ |
| 1235 |
auto &node = this->DBNode; |
| 1236 |
region->get_database()->set_int_byte_size_api( |
| 1237 |
static_cast<Ioss::DataSize>(node[detail::getAPISizePath()].as_int8())); |
| 1238 |
const auto write_split_type = |
| 1239 |
static_cast<Ioss::SurfaceSplitType>(node[detail::SURFACESPLITTYPE].as_int8()); |
| 1240 |
if (write_split_type != region->get_database()->get_surface_split_type()) { |
| 1241 |
static_cast<DatabaseIO *>(region->get_database())->set_split_type_changed(true); |
| 1242 |
} |
| 1243 |
read_db_field_separator = region->get_database()->get_field_separator(); |
| 1244 |
|
| 1245 |
if (node.has_path(getTimePath())) { |
| 1246 |
region->add_state(node[getTimePath()].to_float64()); |
| 1247 |
} |
| 1248 |
this->readEntityGroup<Ioss::Region>(node[detail::REGION], region); |
| 1249 |
this->readEntityGroup<Ioss::NodeBlock>(node[detail::NODEBLOCKS], region); |
| 1250 |
this->readEntityGroup<Ioss::ElementBlock>(node[detail::ELEMENTBLOCKS], region); |
| 1251 |
this->readEntityGroup<Ioss::EdgeBlock>(node[detail::EDGEBLOCKS], region); |
| 1252 |
this->readEntityGroup<Ioss::FaceBlock>(node[detail::FACEBLOCKS], region); |
| 1253 |
|
| 1254 |
bool surface_split_changed = |
| 1255 |
static_cast<DatabaseIO *>(region->get_database())->split_type_changed(); |
| 1256 |
if (!surface_split_changed) { |
| 1257 |
this->readEntityGroup<Ioss::SideBlock>(node[detail::SIDEBLOCKS], region); |
| 1258 |
this->readEntityGroup<Ioss::SideSet>(node[detail::SIDESETS], region); |
| 1259 |
} |
| 1260 |
|
| 1261 |
this->readEntityGroup<Ioss::NodeSet>(node[detail::NODESETS], region); |
| 1262 |
this->readEntityGroup<Ioss::EdgeSet>(node[detail::EDGESETS], region); |
| 1263 |
this->readEntityGroup<Ioss::FaceSet>(node[detail::FACESETS], region); |
| 1264 |
this->readEntityGroup<Ioss::ElementSet>(node[detail::ELEMENTSETS], region); |
| 1265 |
this->readEntityGroup<Ioss::StructuredBlock>(node[detail::STRUCTUREDBLOCKS], region); |
| 1266 |
this->readEntityGroup<Ioss::Assembly>(node[detail::ASSEMBLIES], region); |
| 1267 |
this->readEntityGroup<Ioss::Blob>(node[detail::BLOBS], region); |
| 1268 |
this->readEntityGroup<Ioss::CommSet>(node[detail::COMMSETS], region); |
| 1269 |
return true; |
| 1270 |
} |
| 1271 |
|
| 1272 |
DatabaseIO::DatabaseIO(Ioss::Region *region, const std::string &filename, |
| 1273 |
Ioss::DatabaseUsage db_usage, Ioss_MPI_Comm communicator, |
| 1274 |
const Ioss::PropertyManager &props) |
| 1275 |
: Ioss::DatabaseIO(region, filename, db_usage, communicator, props), |
| 1276 |
Impl(new DatabaseIO::ImplementationT()), useDeepCopy(true) |
| 1277 |
|
| 1278 |
{ |
| 1279 |
dbState = Ioss::STATE_UNKNOWN; |
| 1280 |
|
| 1281 |
bool shallowCopy = false; |
| 1282 |
if (Ioss::Utils::check_set_bool_property(properties, detail::SHALLOWCOPYFIELDS, shallowCopy)) { |
| 1283 |
this->useDeepCopy = !shallowCopy; |
| 1284 |
} |
| 1285 |
|
| 1286 |
if (is_input()) { |
| 1287 |
auto &pm = get_property_manager(); |
| 1288 |
if (pm.exists(detail::CATCONDNODE)) { |
| 1289 |
auto c_node_ptr = |
| 1290 |
reinterpret_cast<conduit_node *>(pm.get(detail::CATCONDNODE).get_pointer()); |
| 1291 |
this->Impl->setDatabaseNode(c_node_ptr); |
| 1292 |
} |
| 1293 |
else { |
| 1294 |
int timestep = 0; |
| 1295 |
if (pm.exists(detail::CATREADTIMESTEP)) { |
| 1296 |
timestep = pm.get(detail::CATREADTIMESTEP).get_int(); |
| 1297 |
} |
| 1298 |
else if (const char *ts = std::getenv(detail::CATREADTIMESTEP.c_str())) { |
| 1299 |
timestep = std::stoi(std::string(ts)); |
| 1300 |
} |
| 1301 |
|
| 1302 |
int proc_count = util().parallel_size(); |
| 1303 |
int my_proc = util().parallel_rank(); |
| 1304 |
if (properties.exists("processor_count") && properties.exists("my_processor")) { |
| 1305 |
proc_count = properties.get("processor_count").get_int(); |
| 1306 |
my_proc = properties.get("my_processor").get_int(); |
| 1307 |
} |
| 1308 |
|
| 1309 |
std::ostringstream path; |
| 1310 |
path << get_catalyst_dump_dir() << detail::EXECUTE_INVC << timestep |
| 1311 |
<< detail::PARAMS_CONDUIT_BIN << proc_count << detail::DOT << my_proc; |
| 1312 |
auto &root = this->Impl->root(); |
| 1313 |
auto &dbase = this->Impl->databaseNode(); |
| 1314 |
conduit_node_load(conduit_cpp::c_node(&root), path.str().c_str(), "conduit_bin"); |
| 1315 |
auto dp = CatalystManager::getInstance().getCatDataPath(props); |
| 1316 |
conduit_node_set_external_node(conduit_cpp::c_node(&dbase), |
| 1317 |
conduit_node_fetch(conduit_cpp::c_node(&root), dp.c_str())); |
| 1318 |
} |
| 1319 |
} |
| 1320 |
else { |
| 1321 |
catPipeID = CatalystManager::getInstance().initialize(props, this->util()); |
| 1322 |
} |
| 1323 |
} |
| 1324 |
|
| 1325 |
DatabaseIO::~DatabaseIO() |
| 1326 |
{ |
| 1327 |
if (!is_input()) { |
| 1328 |
CatalystManager::getInstance().finalize(catPipeID); |
| 1329 |
} |
| 1330 |
} |
| 1331 |
|
| 1332 |
bool DatabaseIO::begin_nl(Ioss::State state) |
| 1333 |
{ |
| 1334 |
this->dbState = state; |
| 1335 |
return true; |
| 1336 |
} |
| 1337 |
|
| 1338 |
bool DatabaseIO::end_nl(Ioss::State state) |
| 1339 |
{ |
| 1340 |
if (this->dbState != state) { |
| 1341 |
std::ostringstream errmsg; |
| 1342 |
errmsg << "Catalyst: dbState != state in end_nl" |
| 1343 |
<< "\n"; |
| 1344 |
IOSS_ERROR(errmsg); |
| 1345 |
} |
| 1346 |
|
| 1347 |
if (!is_input()) { |
| 1348 |
auto region = this->get_region(); |
| 1349 |
if (region == nullptr) { |
| 1350 |
std::ostringstream errmsg; |
| 1351 |
errmsg << "Catalyst: region is nullptr in end_nl" |
| 1352 |
<< "\n"; |
| 1353 |
IOSS_ERROR(errmsg); |
| 1354 |
} |
| 1355 |
|
| 1356 |
auto &impl = (*this->Impl.get()); |
| 1357 |
switch (state) { |
| 1358 |
case Ioss::STATE_DEFINE_MODEL: |
| 1359 |
// here the basic structure for the model is defined i.e. |
| 1360 |
// number of blocks/sets/names etc. |
| 1361 |
if (!impl.defineModel(region)) { |
| 1362 |
return false; |
| 1363 |
} |
| 1364 |
break; |
| 1365 |
|
| 1366 |
case Ioss::STATE_MODEL: |
| 1367 |
// here the model has meshdata e.g mesh fields, ids, coordinates etc. |
| 1368 |
break; |
| 1369 |
|
| 1370 |
case Ioss::STATE_DEFINE_TRANSIENT: break; |
| 1371 |
|
| 1372 |
case Ioss::STATE_TRANSIENT: break; |
| 1373 |
|
| 1374 |
case Ioss::STATE_LAST_ENTRY: break; |
| 1375 |
case Ioss::STATE_UNKNOWN: |
| 1376 |
case Ioss::STATE_INVALID: |
| 1377 |
case Ioss::STATE_READONLY: |
| 1378 |
case Ioss::STATE_CLOSED: break; |
| 1379 |
} |
| 1380 |
} |
| 1381 |
|
| 1382 |
dbState = Ioss::STATE_UNKNOWN; |
| 1383 |
return true; |
| 1384 |
} |
| 1385 |
|
| 1386 |
bool DatabaseIO::begin_state_nl(int state, double time) { return true; } |
| 1387 |
|
| 1388 |
// common |
| 1389 |
bool DatabaseIO::end_state_nl(int state, double time) |
| 1390 |
{ |
| 1391 |
if (this->is_input()) {} |
| 1392 |
else { |
| 1393 |
// invoke catalyst. |
| 1394 |
auto &impl = (*this->Impl.get()); |
| 1395 |
auto &dbaseNode = this->Impl->databaseNode(); |
| 1396 |
dbaseNode[this->Impl->getTimePath()].set_float64(time); |
| 1397 |
conduit_cpp::Node node; |
| 1398 |
CatalystManager::getInstance().execute(catPipeID, state, time, impl.databaseNode()); |
| 1399 |
} |
| 1400 |
return true; |
| 1401 |
} |
| 1402 |
|
| 1403 |
unsigned DatabaseIO::entity_field_support() const |
| 1404 |
{ |
| 1405 |
return Ioss::NODEBLOCK | Ioss::EDGEBLOCK | Ioss::FACEBLOCK | Ioss::ELEMENTBLOCK | |
| 1406 |
Ioss::COMMSET | Ioss::NODESET | Ioss::EDGESET | Ioss::FACESET | Ioss::ELEMENTSET | |
| 1407 |
Ioss::SIDESET | Ioss::SIDEBLOCK | Ioss::STRUCTUREDBLOCK | Ioss::ASSEMBLY | Ioss::REGION | |
| 1408 |
Ioss::BLOB; |
| 1409 |
} |
| 1410 |
|
| 1411 |
void DatabaseIO::read_meta_data_nl() |
| 1412 |
{ |
| 1413 |
auto region = this->get_region(); |
| 1414 |
if (region == nullptr) { |
| 1415 |
std::ostringstream errmsg; |
| 1416 |
errmsg << "Catalyst: region is nullptr in read_meta_data_nl()" |
| 1417 |
<< "\n"; |
| 1418 |
IOSS_ERROR(errmsg); |
| 1419 |
} |
| 1420 |
|
| 1421 |
auto &impl = (*this->Impl.get()); |
| 1422 |
impl.readModel(region); |
| 1423 |
} |
| 1424 |
|
| 1425 |
void DatabaseIO::get_step_times_nl() |
| 1426 |
{ |
| 1427 |
auto region = this->get_region(); |
| 1428 |
if (region == nullptr) { |
| 1429 |
std::ostringstream errmsg; |
| 1430 |
errmsg << "Catalyst: region is nullptr in get_step_times_nl()" |
| 1431 |
<< "\n"; |
| 1432 |
IOSS_ERROR(errmsg); |
| 1433 |
} |
| 1434 |
|
| 1435 |
auto &impl = (*this->Impl.get()); |
| 1436 |
impl.readTime(region); |
| 1437 |
} |
| 1438 |
|
| 1439 |
std::vector<double> DatabaseIO::get_db_step_times_nl() |
| 1440 |
{ |
| 1441 |
auto &impl = (*this->Impl.get()); |
| 1442 |
return impl.getTime(); |
| 1443 |
} |
| 1444 |
|
| 1445 |
void *DatabaseIO::get_catalyst_conduit_node() |
| 1446 |
{ |
| 1447 |
auto &impl = (*this->Impl.get()); |
| 1448 |
return impl.catalystConduitNode(); |
| 1449 |
} |
| 1450 |
|
| 1451 |
void DatabaseIO::print_catalyst_conduit_node() |
| 1452 |
{ |
| 1453 |
auto &impl = (*this->Impl.get()); |
| 1454 |
impl.print(); |
| 1455 |
} |
| 1456 |
|
| 1457 |
std::string DatabaseIO::get_catalyst_dump_dir() const |
| 1458 |
{ |
| 1459 |
std::string retVal; |
| 1460 |
auto catalystDumpDir = std::getenv(detail::CATDUMPDIR.c_str()); |
| 1461 |
if (catalystDumpDir) { |
| 1462 |
retVal = catalystDumpDir; |
| 1463 |
} |
| 1464 |
if (!retVal.empty() && retVal.back() != detail::FS_CHAR) { |
| 1465 |
retVal += detail::FS_CHAR; |
| 1466 |
} |
| 1467 |
return retVal; |
| 1468 |
} |
| 1469 |
|
| 1470 |
int64_t DatabaseIO::put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, |
| 1471 |
void *data, size_t data_size) const |
| 1472 |
{ |
| 1473 |
auto &impl = (*this->Impl.get()); |
| 1474 |
return impl.putField(detail::REGION, reg, field, data, data_size, this->deep_copy()); |
| 1475 |
} |
| 1476 |
|
| 1477 |
int64_t DatabaseIO::put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, |
| 1478 |
void *data, size_t data_size) const |
| 1479 |
{ |
| 1480 |
auto &impl = (*this->Impl.get()); |
| 1481 |
std::string blockPath = detail::NODEBLOCKS; |
| 1482 |
if (nb->is_nonglobal_nodeblock()) { |
| 1483 |
blockPath = detail::STRUCTUREDBLOCKS + detail::FS + impl.getName(nb->contained_in()); |
| 1484 |
} |
| 1485 |
return impl.putField(blockPath, nb, field, data, data_size, this->deep_copy()); |
| 1486 |
} |
| 1487 |
|
| 1488 |
int64_t DatabaseIO::put_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, |
| 1489 |
void *data, size_t data_size) const |
| 1490 |
{ |
| 1491 |
auto &impl = (*this->Impl.get()); |
| 1492 |
return impl.putField(detail::EDGEBLOCKS, eb, field, data, data_size, this->deep_copy()); |
| 1493 |
} |
| 1494 |
|
| 1495 |
int64_t DatabaseIO::put_field_internal(const Ioss::FaceBlock *fb, const Ioss::Field &field, |
| 1496 |
void *data, size_t data_size) const |
| 1497 |
{ |
| 1498 |
auto &impl = (*this->Impl.get()); |
| 1499 |
return impl.putField(detail::FACEBLOCKS, fb, field, data, data_size, this->deep_copy()); |
| 1500 |
} |
| 1501 |
|
| 1502 |
int64_t DatabaseIO::put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, |
| 1503 |
void *data, size_t data_size) const |
| 1504 |
{ |
| 1505 |
auto &impl = (*this->Impl.get()); |
| 1506 |
return impl.putField(detail::ELEMENTBLOCKS, eb, field, data, data_size, this->deep_copy()); |
| 1507 |
} |
| 1508 |
|
| 1509 |
int64_t DatabaseIO::put_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field, |
| 1510 |
void *data, size_t data_size) const |
| 1511 |
{ |
| 1512 |
auto &impl = (*this->Impl.get()); |
| 1513 |
return impl.putField(detail::SIDEBLOCKS, sb, field, data, data_size, this->deep_copy()); |
| 1514 |
} |
| 1515 |
|
| 1516 |
int64_t DatabaseIO::put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, |
| 1517 |
void *data, size_t data_size) const |
| 1518 |
{ |
| 1519 |
auto &impl = (*this->Impl.get()); |
| 1520 |
return impl.putField(detail::NODESETS, ns, field, data, data_size, this->deep_copy()); |
| 1521 |
} |
| 1522 |
|
| 1523 |
int64_t DatabaseIO::put_field_internal(const Ioss::EdgeSet *es, const Ioss::Field &field, |
| 1524 |
void *data, size_t data_size) const |
| 1525 |
{ |
| 1526 |
auto &impl = (*this->Impl.get()); |
| 1527 |
return impl.putField(detail::EDGESETS, es, field, data, data_size, this->deep_copy()); |
| 1528 |
} |
| 1529 |
|
| 1530 |
int64_t DatabaseIO::put_field_internal(const Ioss::FaceSet *fs, const Ioss::Field &field, |
| 1531 |
void *data, size_t data_size) const |
| 1532 |
{ |
| 1533 |
auto &impl = (*this->Impl.get()); |
| 1534 |
return impl.putField(detail::FACESETS, fs, field, data, data_size, this->deep_copy()); |
| 1535 |
} |
| 1536 |
|
| 1537 |
int64_t DatabaseIO::put_field_internal(const Ioss::ElementSet *es, const Ioss::Field &field, |
| 1538 |
void *data, size_t data_size) const |
| 1539 |
{ |
| 1540 |
auto &impl = (*this->Impl.get()); |
| 1541 |
return impl.putField(detail::ELEMENTSETS, es, field, data, data_size, this->deep_copy()); |
| 1542 |
} |
| 1543 |
|
| 1544 |
int64_t DatabaseIO::put_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field, |
| 1545 |
void *data, size_t data_size) const |
| 1546 |
{ |
| 1547 |
auto &impl = (*this->Impl.get()); |
| 1548 |
return impl.putField(detail::SIDESETS, ss, field, data, data_size, this->deep_copy()); |
| 1549 |
} |
| 1550 |
|
| 1551 |
int64_t DatabaseIO::put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, |
| 1552 |
void *data, size_t data_size) const |
| 1553 |
{ |
| 1554 |
auto &impl = (*this->Impl.get()); |
| 1555 |
return impl.putField(detail::COMMSETS, cs, field, data, data_size, this->deep_copy()); |
| 1556 |
} |
| 1557 |
|
| 1558 |
int64_t DatabaseIO::put_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, |
| 1559 |
void *data, size_t data_size) const |
| 1560 |
{ |
| 1561 |
auto &impl = (*this->Impl.get()); |
| 1562 |
return impl.putField(detail::ASSEMBLIES, as, field, data, data_size, this->deep_copy()); |
| 1563 |
} |
| 1564 |
|
| 1565 |
int64_t DatabaseIO::put_field_internal(const Ioss::Blob *bl, const Ioss::Field &field, void *data, |
| 1566 |
size_t data_size) const |
| 1567 |
{ |
| 1568 |
auto &impl = (*this->Impl.get()); |
| 1569 |
return impl.putField(detail::BLOBS, bl, field, data, data_size, this->deep_copy()); |
| 1570 |
} |
| 1571 |
|
| 1572 |
int64_t DatabaseIO::put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, |
| 1573 |
void *data, size_t data_size) const |
| 1574 |
{ |
| 1575 |
auto &impl = (*this->Impl.get()); |
| 1576 |
return impl.putField(detail::STRUCTUREDBLOCKS, sb, field, data, data_size, this->deep_copy()); |
| 1577 |
} |
| 1578 |
|
| 1579 |
int64_t DatabaseIO::get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, |
| 1580 |
void *data, size_t data_size) const |
| 1581 |
{ |
| 1582 |
auto &impl = (*this->Impl.get()); |
| 1583 |
return impl.getField(detail::REGION, reg, field, data, data_size); |
| 1584 |
} |
| 1585 |
|
| 1586 |
int64_t DatabaseIO::get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, |
| 1587 |
void *data, size_t data_size) const |
| 1588 |
{ |
| 1589 |
auto &impl = (*this->Impl.get()); |
| 1590 |
|
| 1591 |
std::string blockPath = detail::NODEBLOCKS; |
| 1592 |
if (nb->is_nonglobal_nodeblock()) { |
| 1593 |
blockPath = detail::STRUCTUREDBLOCKS + detail::FS + impl.getName(nb->contained_in()); |
| 1594 |
} |
| 1595 |
|
| 1596 |
if (impl.hasField(blockPath, nb, field.get_name())) { |
| 1597 |
return impl.getField(blockPath, nb, field, data, data_size); |
| 1598 |
} |
| 1599 |
else if ((field.get_name() == detail::MESHMODCO) && |
| 1600 |
(impl.hasField(blockPath, nb, detail::MESHMODCOX) && |
| 1601 |
impl.hasField(blockPath, nb, detail::MESHMODCOY) && |
| 1602 |
impl.hasField(blockPath, nb, detail::MESHMODCOZ))) { |
| 1603 |
return impl.getMeshModelCoordinates(blockPath, nb, field, data, data_size); |
| 1604 |
} |
| 1605 |
else { |
| 1606 |
fmt::print(Ioss::OUTPUT(), "WARNING in {} : {}\n", __func__, |
| 1607 |
"field not available, " + field.get_name() + ", in container " + blockPath + "\n"); |
| 1608 |
return -1; |
| 1609 |
} |
| 1610 |
} |
| 1611 |
|
| 1612 |
int64_t DatabaseIO::get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, |
| 1613 |
void *data, size_t data_size) const |
| 1614 |
{ |
| 1615 |
auto &impl = (*this->Impl.get()); |
| 1616 |
if (impl.hasField(detail::ELEMENTBLOCKS, eb, field.get_name())) { |
| 1617 |
return impl.getField(detail::ELEMENTBLOCKS, eb, field, data, data_size); |
| 1618 |
} |
| 1619 |
else { |
| 1620 |
if (field.get_name() == detail::CONNECTIVITYRAW && |
| 1621 |
impl.hasField(detail::ELEMENTBLOCKS, eb, detail::CONNECTIVITY)) { |
| 1622 |
// maybe the data has 'connectivity' provided, so we convert it to 'connectivity_raw'. |
| 1623 |
auto count = |
| 1624 |
this->get_field_internal(eb, eb->get_field(detail::CONNECTIVITY), data, data_size); |
| 1625 |
if (count <= 0) { |
| 1626 |
return count; |
| 1627 |
} |
| 1628 |
|
| 1629 |
impl.get_node_map(this).reverse_map_data( |
| 1630 |
data, field, field.verify(data_size) * field.raw_storage()->component_count()); |
| 1631 |
return count; |
| 1632 |
} |
| 1633 |
else if (field.get_name() == detail::CONNECTIVITY && |
| 1634 |
impl.hasField(detail::ELEMENTBLOCKS, eb, detail::CONNECTIVITYRAW)) { |
| 1635 |
// maybe the data has 'connectivity_raw' is provided, so we convert it to 'connectivity. |
| 1636 |
auto count = |
| 1637 |
this->get_field_internal(eb, eb->get_field(detail::CONNECTIVITYRAW), data, data_size); |
| 1638 |
if (count <= 0) { |
| 1639 |
return count; |
| 1640 |
} |
| 1641 |
|
| 1642 |
impl.get_node_map(this).map_data( |
| 1643 |
data, field, field.verify(data_size) * field.raw_storage()->component_count()); |
| 1644 |
return count; |
| 1645 |
} |
| 1646 |
|
| 1647 |
fmt::print(Ioss::OUTPUT(), "WARNING in {} : {}\n", __func__, |
| 1648 |
"field not available, " + field.get_name() + ", in container " + |
| 1649 |
detail::ELEMENTBLOCKS + "\n"); |
| 1650 |
return -1; |
| 1651 |
} |
| 1652 |
} |
| 1653 |
|
| 1654 |
int64_t DatabaseIO::get_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, |
| 1655 |
void *data, size_t data_size) const |
| 1656 |
{ |
| 1657 |
auto &impl = (*this->Impl.get()); |
| 1658 |
return impl.getField(detail::EDGEBLOCKS, eb, field, data, data_size); |
| 1659 |
} |
| 1660 |
|
| 1661 |
int64_t DatabaseIO::get_field_internal(const Ioss::FaceBlock *fb, const Ioss::Field &field, |
| 1662 |
void *data, size_t data_size) const |
| 1663 |
{ |
| 1664 |
auto &impl = (*this->Impl.get()); |
| 1665 |
return impl.getField(detail::FACEBLOCKS, fb, field, data, data_size); |
| 1666 |
} |
| 1667 |
int64_t DatabaseIO::get_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field, |
| 1668 |
void *data, size_t data_size) const |
| 1669 |
{ |
| 1670 |
if (split_type_changed()) { |
| 1671 |
return -1; |
| 1672 |
} |
| 1673 |
auto &impl = (*this->Impl.get()); |
| 1674 |
return impl.getField(detail::SIDEBLOCKS, sb, field, data, data_size); |
| 1675 |
} |
| 1676 |
int64_t DatabaseIO::get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, |
| 1677 |
void *data, size_t data_size) const |
| 1678 |
{ |
| 1679 |
auto &impl = (*this->Impl.get()); |
| 1680 |
return impl.getField(detail::NODESETS, ns, field, data, data_size); |
| 1681 |
} |
| 1682 |
int64_t DatabaseIO::get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, |
| 1683 |
void *data, size_t data_size) const |
| 1684 |
{ |
| 1685 |
auto &impl = (*this->Impl.get()); |
| 1686 |
return impl.getField(detail::EDGESETS, ns, field, data, data_size); |
| 1687 |
} |
| 1688 |
int64_t DatabaseIO::get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, |
| 1689 |
void *data, size_t data_size) const |
| 1690 |
{ |
| 1691 |
auto &impl = (*this->Impl.get()); |
| 1692 |
return impl.getField(detail::FACESETS, ns, field, data, data_size); |
| 1693 |
} |
| 1694 |
int64_t DatabaseIO::get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, |
| 1695 |
void *data, size_t data_size) const |
| 1696 |
{ |
| 1697 |
auto &impl = (*this->Impl.get()); |
| 1698 |
return impl.getField(detail::ELEMENTSETS, ns, field, data, data_size); |
| 1699 |
} |
| 1700 |
int64_t DatabaseIO::get_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field, |
| 1701 |
void *data, size_t data_size) const |
| 1702 |
{ |
| 1703 |
if (split_type_changed()) { |
| 1704 |
return -1; |
| 1705 |
} |
| 1706 |
auto &impl = (*this->Impl.get()); |
| 1707 |
return impl.getField(detail::SIDESETS, ss, field, data, data_size); |
| 1708 |
} |
| 1709 |
int64_t DatabaseIO::get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, |
| 1710 |
void *data, size_t data_size) const |
| 1711 |
{ |
| 1712 |
auto &impl = (*this->Impl.get()); |
| 1713 |
return impl.getField(detail::COMMSETS, cs, field, data, data_size); |
| 1714 |
} |
| 1715 |
int64_t DatabaseIO::get_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, |
| 1716 |
void *data, size_t data_size) const |
| 1717 |
{ |
| 1718 |
auto &impl = (*this->Impl.get()); |
| 1719 |
return impl.getField(detail::ASSEMBLIES, as, field, data, data_size); |
| 1720 |
} |
| 1721 |
int64_t DatabaseIO::get_field_internal(const Ioss::Blob *bl, const Ioss::Field &field, void *data, |
| 1722 |
size_t data_size) const |
| 1723 |
{ |
| 1724 |
auto &impl = (*this->Impl.get()); |
| 1725 |
return impl.getField(detail::BLOBS, bl, field, data, data_size); |
| 1726 |
} |
| 1727 |
int64_t DatabaseIO::get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, |
| 1728 |
void *data, size_t data_size) const |
| 1729 |
{ |
| 1730 |
std::string blockPath = detail::STRUCTUREDBLOCKS; |
| 1731 |
auto &impl = (*this->Impl.get()); |
| 1732 |
if (impl.hasField(blockPath, sb, field.get_name())) { |
| 1733 |
return impl.getField(blockPath, sb, field, data, data_size); |
| 1734 |
} |
| 1735 |
else if (field.get_name() == detail::CELLIDS || field.get_name() == detail::CELLNODEIDS) { |
| 1736 |
return impl.getStructuredBlockIDS(sb, field, data, data_size); |
| 1737 |
} |
| 1738 |
else if ((field.get_name() == detail::MESHMODCO) && |
| 1739 |
(impl.hasField(blockPath, sb, detail::MESHMODCOX) && |
| 1740 |
impl.hasField(blockPath, sb, detail::MESHMODCOY) && |
| 1741 |
impl.hasField(blockPath, sb, detail::MESHMODCOZ))) { |
| 1742 |
return impl.getMeshModelCoordinates(blockPath, sb, field, data, data_size); |
| 1743 |
} |
| 1744 |
else { |
| 1745 |
fmt::print(Ioss::OUTPUT(), "WARNING in {} : {}\n", __func__, |
| 1746 |
"field not available, " + field.get_name() + ", in container " + |
| 1747 |
detail::STRUCTUREDBLOCKS + "\n"); |
| 1748 |
return -1; |
| 1749 |
} |
| 1750 |
} |
| 1751 |
|
| 1752 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::Region *reg, const Ioss::Field &field, |
| 1753 |
void **data, size_t *data_size) const |
| 1754 |
{ |
| 1755 |
auto &impl = (*this->Impl.get()); |
| 1756 |
return impl.getFieldZeroCopy(detail::REGION, reg, field, data, data_size); |
| 1757 |
} |
| 1758 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, |
| 1759 |
void **data, size_t *data_size) const |
| 1760 |
{ |
| 1761 |
|
| 1762 |
auto &impl = (*this->Impl.get()); |
| 1763 |
std::string blockPath = detail::NODEBLOCKS; |
| 1764 |
if (nb->is_nonglobal_nodeblock()) { |
| 1765 |
blockPath = detail::STRUCTUREDBLOCKS + detail::FS + impl.getName(nb->contained_in()); |
| 1766 |
} |
| 1767 |
return impl.getFieldZeroCopy(blockPath, nb, field, data, data_size); |
| 1768 |
} |
| 1769 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, |
| 1770 |
void **data, size_t *data_size) const |
| 1771 |
{ |
| 1772 |
auto &impl = (*this->Impl.get()); |
| 1773 |
return impl.getFieldZeroCopy(detail::EDGEBLOCKS, eb, field, data, data_size); |
| 1774 |
} |
| 1775 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::FaceBlock *fb, const Ioss::Field &field, |
| 1776 |
void **data, size_t *data_size) const |
| 1777 |
{ |
| 1778 |
auto &impl = (*this->Impl.get()); |
| 1779 |
return impl.getFieldZeroCopy(detail::FACEBLOCKS, fb, field, data, data_size); |
| 1780 |
} |
| 1781 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, |
| 1782 |
void **data, size_t *data_size) const |
| 1783 |
{ |
| 1784 |
auto &impl = (*this->Impl.get()); |
| 1785 |
return impl.getFieldZeroCopy(detail::ELEMENTBLOCKS, eb, field, data, data_size); |
| 1786 |
} |
| 1787 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field, |
| 1788 |
void **data, size_t *data_size) const |
| 1789 |
{ |
| 1790 |
if (split_type_changed()) { |
| 1791 |
return -1; |
| 1792 |
} |
| 1793 |
auto &impl = (*this->Impl.get()); |
| 1794 |
return impl.getFieldZeroCopy(detail::SIDEBLOCKS, sb, field, data, data_size); |
| 1795 |
} |
| 1796 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, |
| 1797 |
void **data, size_t *data_size) const |
| 1798 |
{ |
| 1799 |
auto &impl = (*this->Impl.get()); |
| 1800 |
return impl.getFieldZeroCopy(detail::NODESETS, ns, field, data, data_size); |
| 1801 |
} |
| 1802 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::EdgeSet *es, const Ioss::Field &field, |
| 1803 |
void **data, size_t *data_size) const |
| 1804 |
{ |
| 1805 |
auto &impl = (*this->Impl.get()); |
| 1806 |
return impl.getFieldZeroCopy(detail::EDGESETS, es, field, data, data_size); |
| 1807 |
} |
| 1808 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::FaceSet *fs, const Ioss::Field &field, |
| 1809 |
void **data, size_t *data_size) const |
| 1810 |
{ |
| 1811 |
auto &impl = (*this->Impl.get()); |
| 1812 |
return impl.getFieldZeroCopy(detail::FACESETS, fs, field, data, data_size); |
| 1813 |
} |
| 1814 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::ElementSet *es, const Ioss::Field &field, |
| 1815 |
void **data, size_t *data_size) const |
| 1816 |
{ |
| 1817 |
auto &impl = (*this->Impl.get()); |
| 1818 |
return impl.getFieldZeroCopy(detail::ELEMENTSETS, es, field, data, data_size); |
| 1819 |
} |
| 1820 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field, |
| 1821 |
void **data, size_t *data_size) const |
| 1822 |
{ |
| 1823 |
if (split_type_changed()) { |
| 1824 |
return -1; |
| 1825 |
} |
| 1826 |
auto &impl = (*this->Impl.get()); |
| 1827 |
return impl.getFieldZeroCopy(detail::SIDESETS, ss, field, data, data_size); |
| 1828 |
} |
| 1829 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, |
| 1830 |
void **data, size_t *data_size) const |
| 1831 |
{ |
| 1832 |
auto &impl = (*this->Impl.get()); |
| 1833 |
return impl.getFieldZeroCopy(detail::COMMSETS, cs, field, data, data_size); |
| 1834 |
} |
| 1835 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, |
| 1836 |
void **data, size_t *data_size) const |
| 1837 |
{ |
| 1838 |
auto &impl = (*this->Impl.get()); |
| 1839 |
return impl.getFieldZeroCopy(detail::ASSEMBLIES, as, field, data, data_size); |
| 1840 |
} |
| 1841 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::Blob *bl, const Ioss::Field &field, |
| 1842 |
void **data, size_t *data_size) const |
| 1843 |
{ |
| 1844 |
auto &impl = (*this->Impl.get()); |
| 1845 |
return impl.getFieldZeroCopy(detail::BLOBS, bl, field, data, data_size); |
| 1846 |
} |
| 1847 |
int64_t DatabaseIO::get_zc_field_internal(const Ioss::StructuredBlock *sb, |
| 1848 |
const Ioss::Field &field, void **data, |
| 1849 |
size_t *data_size) const |
| 1850 |
{ |
| 1851 |
auto &impl = (*this->Impl.get()); |
| 1852 |
return impl.getFieldZeroCopy(detail::STRUCTUREDBLOCKS, sb, field, data, data_size); |
| 1853 |
} |
| 1854 |
|
| 1855 |
} // namespace Iocatalyst |