From 47182f3fa7c52156c101b521e6fd3179ee12c41e Mon Sep 17 00:00:00 2001 From: Daniel Garcia-Sanchez Date: Thu, 15 Nov 2018 15:52:25 +0100 Subject: [PATCH] Use make_array_view(container_object).data() Obtain a pointer to the container raw data using make_array_view(container_object).data(). Remove the functions get_container_pointer(). --- source/base/hdf5.cc | 91 +++++---------------------------------------- 1 file changed, 9 insertions(+), 82 deletions(-) diff --git a/source/base/hdf5.cc b/source/base/hdf5.cc index 315f3f9604..5d6dd6cd41 100644 --- a/source/base/hdf5.cc +++ b/source/base/hdf5.cc @@ -17,6 +17,7 @@ #ifdef DEAL_II_WITH_HDF5 +# include # include # include @@ -171,80 +172,6 @@ namespace HDF5 - // This function returns the pointer to the raw data of a container - template - void * - get_container_pointer(std::vector &data) - { - // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong - return data.data(); - } - - - - template - void * - get_container_pointer(Vector &data) - { - // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong. - // Use the first element of FullMatrix to get the pointer to the raw data - return &data[0]; - } - - - - template - void * - get_container_pointer(FullMatrix &data) - { - // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong. - // Use the first element of FullMatrix to get the pointer to the raw data - return &data[0][0]; - } - - - - // This function returns the pointer to the raw data of a container - // The returned pointer is const, which means that it can be used only to - // read the data - template - const void * - get_container_const_pointer(const std::vector &data) - { - // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong - return data.data(); - } - - - - template - const void * - get_container_const_pointer(const Vector &data) - { - // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong. - // Use the first element of FullMatrix to get the pointer to the raw data - return &*data.begin(); - } - - - - template - const void * - get_container_const_pointer(const FullMatrix &data) - { - // It is very important to pass the variable "data" by reference otherwise - // the pointer will be wrong. - // Use the first element of FullMatrix to get the pointer to the raw data - return &data[0][0]; - } - - - // This function initializes and returns a container of type std::vector, // Vector or FullMatrix. The function does not set the values of the // elements of the container. The container can store data of a HDF5 dataset @@ -707,7 +634,7 @@ namespace HDF5 H5S_ALL, H5S_ALL, plist, - internal::get_container_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcInternalError()); if (mpi) @@ -774,7 +701,7 @@ namespace HDF5 memory_dataspace, *dataspace, plist, - internal::get_container_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dread")); if (mpi) @@ -843,7 +770,7 @@ namespace HDF5 memory_dataspace, *dataspace, plist, - internal::get_container_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dread")); if (mpi) @@ -915,7 +842,7 @@ namespace HDF5 memory_dataspace, *dataspace, plist, - internal::get_container_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dread")); if (mpi) @@ -1029,7 +956,7 @@ namespace HDF5 H5S_ALL, H5S_ALL, plist, - internal::get_container_const_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dwrite")); if (mpi) @@ -1093,7 +1020,7 @@ namespace HDF5 memory_dataspace, *dataspace, plist, - internal::get_container_const_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dwrite")); if (mpi) @@ -1163,7 +1090,7 @@ namespace HDF5 memory_dataspace, *dataspace, plist, - internal::get_container_const_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dwrite")); if (mpi) @@ -1232,7 +1159,7 @@ namespace HDF5 memory_dataspace, *dataspace, plist, - internal::get_container_const_pointer(data)); + make_array_view(data).data()); Assert(ret >= 0, ExcMessage("Error at H5Dwrite")); if (mpi) -- 2.39.5