MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / add_group

Method add_group

cpp/dolfinx/io/HDF5Interface.cpp:256–286  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

254}
255//-----------------------------------------------------------------------------
256void io::hdf5::add_group(hid_t handle, const std::string& group_name)
257{
258 std::string _group_name(group_name);
259
260 // Cannot create the root level group
261 if (_group_name.size() == 0 or _group_name == "/")
262 return;
263
264 // Prepend a slash if missing
265 if (_group_name[0] != '/')
266 _group_name = "/" + _group_name;
267
268 // Starting from the root level, check and create groups if needed
269 std::size_t pos = 0;
270 while (pos != std::string::npos)
271 {
272 pos++;
273 pos = _group_name.find('/', pos);
274 const std::string parent_name(_group_name, 0, pos);
275 if (!has_group(handle, parent_name))
276 {
277 const hid_t group_id_vis = H5Gcreate2(
278 handle, parent_name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
279 if (group_id_vis < 0)
280 throw std::runtime_error("Failed to add HDF5 group");
281
282 if (H5Gclose(group_id_vis) < 0)
283 throw std::runtime_error("Failed to close HDF5 group");
284 }
285 }
286}
287//-----------------------------------------------------------------------------
288std::vector<std::int64_t>
289io::hdf5::get_dataset_shape(hid_t handle, const std::string& dataset_path)

Callers

nothing calls this directly

Calls 3

has_groupFunction · 0.85
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected