From 4609d77404256456b045f8250d6064d70d7bfc99 Mon Sep 17 00:00:00 2001 From: Daniel Garcia-Sanchez Date: Wed, 21 Nov 2018 20:40:25 +0100 Subject: [PATCH] Add get_name() --- include/deal.II/base/hdf5.h | 14 +++++++++++++- source/base/hdf5.cc | 8 ++++++++ tests/base/hdf5_01.cc | 1 + ...1.with_hdf5=true.with_complex_values=off.output | 1 + ...01.with_hdf5=true.with_complex_values=on.output | 1 + tests/base/hdf5_02.cc | 1 + ...f5=true.with_complex_values=off.mpirun=1.output | 1 + ...f5=true.with_complex_values=off.mpirun=4.output | 1 + ...df5=true.with_complex_values=on.mpirun=1.output | 1 + ...df5=true.with_complex_values=on.mpirun=4.output | 1 + 10 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/deal.II/base/hdf5.h b/include/deal.II/base/hdf5.h index 5215324273..cf3a3b29d0 100644 --- a/include/deal.II/base/hdf5.h +++ b/include/deal.II/base/hdf5.h @@ -354,10 +354,22 @@ namespace HDF5 void set_attribute(const std::string &attr_name, const T value); + /** + * Returns the #name of the object. In the case of File, #name corresponds + * to the file name. In the case of Group and DataSet, #name corresponds to + * the name of the object in the HDF5 file. + */ + std::string + get_name() const; + protected: + /** + * Name of the HDF5Oject. In the case of File, @p name corresponds to the + * file name. In the case of Group and DataSet @p name corresponds to the + * name of the object in the HDF5 file. + */ const std::string name; - protected: /** * HDF5 identifier for the objects File, Group and DataSet. The * `std::shared_ptr<>` pointer allows the object to be copied. For example diff --git a/source/base/hdf5.cc b/source/base/hdf5.cc index 0191383254..6e3b2817e5 100644 --- a/source/base/hdf5.cc +++ b/source/base/hdf5.cc @@ -513,6 +513,14 @@ namespace HDF5 + std::string + HDF5Object::get_name() const + { + return name; + } + + + DataSet::DataSet(const std::string &name, const hid_t & parent_group_id, const bool mpi) diff --git a/tests/base/hdf5_01.cc b/tests/base/hdf5_01.cc index f1ab88dc97..3429929db1 100644 --- a/tests/base/hdf5_01.cc +++ b/tests/base/hdf5_01.cc @@ -88,6 +88,7 @@ test() // Read attributes attached to a group auto test_group = data_file.open_group("test_group"); + deallog << "group_name: " << test_group.get_name() << std::endl; #ifdef DEAL_II_WITH_COMPLEX_VALUES auto group_complex_float = diff --git a/tests/base/hdf5_01.with_hdf5=true.with_complex_values=off.output b/tests/base/hdf5_01.with_hdf5=true.with_complex_values=off.output index 520572466e..be163eeb19 100644 --- a/tests/base/hdf5_01.with_hdf5=true.with_complex_values=off.output +++ b/tests/base/hdf5_01.with_hdf5=true.with_complex_values=off.output @@ -1,6 +1,7 @@ DEAL::root_total calculated:-3.10361e+08 DEAL::root_total read:-3.10361e+08 +DEAL::group_name: test_group DEAL::group_string read:test_string_attribute DEAL::dataset_double read:20.2000 DEAL::dataset_string read:test_dataset_attribute diff --git a/tests/base/hdf5_01.with_hdf5=true.with_complex_values=on.output b/tests/base/hdf5_01.with_hdf5=true.with_complex_values=on.output index 2885b923d3..593c225d87 100644 --- a/tests/base/hdf5_01.with_hdf5=true.with_complex_values=on.output +++ b/tests/base/hdf5_01.with_hdf5=true.with_complex_values=on.output @@ -1,6 +1,7 @@ DEAL::root_total calculated:-3.10361e+08 DEAL::root_total read:-3.10361e+08 +DEAL::group_name: test_group DEAL::group_complex_total calculated:(1.53171e+09,2.85468e+07) DEAL::group_complex_total read:(1.53171e+09,2.85468e+07) DEAL::group_string read:test_string_attribute diff --git a/tests/base/hdf5_02.cc b/tests/base/hdf5_02.cc index c5d2618449..28afafd9e8 100644 --- a/tests/base/hdf5_02.cc +++ b/tests/base/hdf5_02.cc @@ -92,6 +92,7 @@ test() // Read attributes attached to a group auto test_group = data_file.open_group("test_group"); + deallog << "group_name: " << test_group.get_name() << std::endl; #ifdef DEAL_II_WITH_COMPLEX_VALUES auto group_complex_float = diff --git a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=1.output b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=1.output index 520572466e..be163eeb19 100644 --- a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=1.output +++ b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=1.output @@ -1,6 +1,7 @@ DEAL::root_total calculated:-3.10361e+08 DEAL::root_total read:-3.10361e+08 +DEAL::group_name: test_group DEAL::group_string read:test_string_attribute DEAL::dataset_double read:20.2000 DEAL::dataset_string read:test_dataset_attribute diff --git a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=4.output b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=4.output index 520572466e..be163eeb19 100644 --- a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=4.output +++ b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=off.mpirun=4.output @@ -1,6 +1,7 @@ DEAL::root_total calculated:-3.10361e+08 DEAL::root_total read:-3.10361e+08 +DEAL::group_name: test_group DEAL::group_string read:test_string_attribute DEAL::dataset_double read:20.2000 DEAL::dataset_string read:test_dataset_attribute diff --git a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=1.output b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=1.output index 2885b923d3..593c225d87 100644 --- a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=1.output +++ b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=1.output @@ -1,6 +1,7 @@ DEAL::root_total calculated:-3.10361e+08 DEAL::root_total read:-3.10361e+08 +DEAL::group_name: test_group DEAL::group_complex_total calculated:(1.53171e+09,2.85468e+07) DEAL::group_complex_total read:(1.53171e+09,2.85468e+07) DEAL::group_string read:test_string_attribute diff --git a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=4.output b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=4.output index 2885b923d3..593c225d87 100644 --- a/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=4.output +++ b/tests/base/hdf5_02.with_hdf5=true.with_complex_values=on.mpirun=4.output @@ -1,6 +1,7 @@ DEAL::root_total calculated:-3.10361e+08 DEAL::root_total read:-3.10361e+08 +DEAL::group_name: test_group DEAL::group_complex_total calculated:(1.53171e+09,2.85468e+07) DEAL::group_complex_total read:(1.53171e+09,2.85468e+07) DEAL::group_string read:test_string_attribute -- 2.39.5