]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add bool type to HDF5
authorDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Fri, 2 Apr 2021 09:53:20 +0000 (11:53 +0200)
committerDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Fri, 2 Apr 2021 09:53:20 +0000 (11:53 +0200)
include/deal.II/base/hdf5.h

index 57e89492f8a7d7a110c5fb09da16887ed1816a12..5d357b36bde33fa012f8936bd5ba5f1860aebc60 100644 (file)
@@ -1252,6 +1252,7 @@ namespace HDF5
       static_assert(std::is_same<number, float>::value ||
                       std::is_same<number, double>::value ||
                       std::is_same<number, int>::value ||
+                      std::is_same<number, bool>::value ||
                       std::is_same<number, unsigned int>::value ||
                       std::is_same<number, std::complex<float>>::value ||
                       std::is_same<number, std::complex<double>>::value,
@@ -1274,6 +1275,10 @@ namespace HDF5
         {
           return std::make_shared<hid_t>(H5T_NATIVE_UINT);
         }
+      else if (std::is_same<number, bool>::value)
+        {
+          return std::make_shared<hid_t>(H5T_NATIVE_HBOOL);
+        }
       else if (std::is_same<number, std::complex<float>>::value)
         {
           std::shared_ptr<hid_t> t_type =
@@ -1587,29 +1592,6 @@ namespace HDF5
 
 
 
-  template <>
-  inline bool
-  HDF5Object::get_attribute(const std::string &attr_name) const
-  {
-    // The enum field generated by h5py can be casted to int
-    int    int_value;
-    hid_t  attr;
-    herr_t ret;
-
-    attr = H5Aopen(*hdf5_reference, attr_name.data(), H5P_DEFAULT);
-    Assert(attr >= 0, ExcMessage("Error at H5Aopen"));
-    ret = H5Aread(attr, H5T_NATIVE_INT, &int_value);
-    (void)ret;
-    Assert(ret >= 0, ExcMessage("Error at H5Aread"));
-    ret = H5Aclose(attr);
-    (void)ret;
-    Assert(ret >= 0, ExcMessage("Error at H5Aclose"));
-
-    return (int_value != 0);
-  }
-
-
-
   template <>
   inline std::string
   HDF5Object::get_attribute(const std::string &attr_name) const

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.