diff --git a/applications/HDF5Application/CMakeLists.txt b/applications/HDF5Application/CMakeLists.txt index b37c2bcbe930..5faee61a5551 100644 --- a/applications/HDF5Application/CMakeLists.txt +++ b/applications/HDF5Application/CMakeLists.txt @@ -10,7 +10,6 @@ set( KRATOS_HDF5_APPLICATION_CORE ${CMAKE_CURRENT_SOURCE_DIR}/hdf5_application_variables.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_file.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_nd_data_io.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_points_data.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_connectivities_data.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_data_value_container_io.cpp ${CMAKE_CURRENT_SOURCE_DIR}/custom_io/hdf5_container_component_io.cpp diff --git a/applications/HDF5Application/custom_io/hdf5_connectivities_data.cpp b/applications/HDF5Application/custom_io/hdf5_connectivities_data.cpp index ced49d623564..b2cf770dc528 100644 --- a/applications/HDF5Application/custom_io/hdf5_connectivities_data.cpp +++ b/applications/HDF5Application/custom_io/hdf5_connectivities_data.cpp @@ -109,7 +109,7 @@ void ConnectivitiesData::Write( { KRATOS_TRY; - if (mpFile->GetDataCommunicator().SumAll(rEntities.size()) == 0) { + if (mpFile->GetDataCommunicator().SumAll(static_cast(rEntities.size())) == 0) { // do nothing if the all the ranks have no entities. return; } diff --git a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp index a99a0f0c256a..6b0f8e7eb9b2 100644 --- a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp +++ b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp @@ -250,7 +250,7 @@ bool ContainerComponentIO::Wri std::vector shape(value_type_traits::Dimension); // first we have to check the availability - Vector availability(rLocalContainer.size(), 1); + Vector availability(rLocalContainer.size(), 1); Internals::DataAvailabilityStatesList container_data_availability = TContainerDataIO::DataAvailability; // check for the availability. Here we do not check for the case CONSISTENTLY_UNAVAILABLE @@ -260,11 +260,12 @@ bool ContainerComponentIO::Wri if constexpr(TContainerDataIO::DataAvailability == Internals::DataAvailabilityStatesList::INCONCLUSIVE) { // the entities in the rContainer may or may not contain the rComponent. Hence, for this // type we need to compute the availability. - const auto availability_local_counts_pair = IndexPartition(rLocalContainer.size()).for_each, SumReduction>>([&rContainerDataIO, &rLocalContainer, &r_component, &availability](const auto Index) { + const std::tuple availability_local_counts_pair = IndexPartition(rLocalContainer.size()).for_each, SumReduction>>([&rContainerDataIO, &rLocalContainer, &r_component, &availability](const auto Index) { availability[Index] = rContainerDataIO.HasValue(*(rLocalContainer.begin() + Index), r_component); - return std::make_tuple(availability[Index] == true, availability[Index] == false); + return std::make_tuple(static_cast(availability[Index] == 1), static_cast(availability[Index] == 0)); }); - const auto& availability_global_counts_pair = mpFile->GetDataCommunicator().SumAll(std::vector{std::get<0>(availability_local_counts_pair), std::get<1>(availability_local_counts_pair), rLocalContainer.size()}); + + const auto& availability_global_counts_pair = mpFile->GetDataCommunicator().SumAll(std::vector{std::get<0>(availability_local_counts_pair), std::get<1>(availability_local_counts_pair)}); KRATOS_ERROR_IF(availability_global_counts_pair[1] == availability_global_counts_pair[2]) << "None of the entities in the container have \"" << rComponentName << "\" defined."; @@ -290,7 +291,7 @@ bool ContainerComponentIO::Wri value_type value_prototype{}; // identifying the shape of the component by looking at the first entity which has the component defined. - auto first_available_pos = std::find(availability.begin(), availability.end(), true); + auto first_available_pos = std::find(availability.begin(), availability.end(), 1); if (first_available_pos != availability.end()) { // if the value type is not static, then we need to get the shape // of the first element assuming all the entities will have the same diff --git a/applications/HDF5Application/custom_io/hdf5_file.cpp b/applications/HDF5Application/custom_io/hdf5_file.cpp index 3689fc77b86f..30c8a4b97a65 100644 --- a/applications/HDF5Application/custom_io/hdf5_file.cpp +++ b/applications/HDF5Application/custom_io/hdf5_file.cpp @@ -905,7 +905,7 @@ void File::SetFileDriver(const std::string& rDriver, hid_t FaplId) const KRATOS_CATCH(""); } -template +template void File::WriteDataSetImpl( const std::string& rPath, TDataType const * pData, diff --git a/applications/HDF5Application/custom_io/hdf5_points_data.cpp b/applications/HDF5Application/custom_io/hdf5_points_data.cpp deleted file mode 100644 index 885fe78d5d5c..000000000000 --- a/applications/HDF5Application/custom_io/hdf5_points_data.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// | / | -// ' / __| _` | __| _ \ __| -// . \ | ( | | ( |\__ ` -// _|\_\_| \__,_|\__|\___/ ____/ -// Multi-Physics -// -// License: BSD License -// license: HDF5Application/license.txt -// -// Main author: Michael Andre, https://github.com/msandre -// Suneth Warnakulasuriya -// - -// System includes - -// Project includes - -// Application includes -#include "custom_io/hdf5_file.h" -#include "custom_utilities/container_io_utils.h" -#include "custom_utilities/hdf5_data_set_partition_utility.h" - -// Include base h -#include "custom_io/hdf5_points_data.h" - -namespace Kratos -{ -namespace HDF5 -{ -namespace Internals -{ - -template -PointsData::PointsData( - const std::string& rPrefix, - File::Pointer pFile) - : mpFile(pFile), - mPrefix(rPrefix) -{ -} - -template -Parameters PointsData::Read( - typename TContainerDataIO::ContainerType& rContainer, - const TContainerDataIO& rContainerDataIO) -{ - KRATOS_TRY; - - IndexType start_index, block_size; - std::tie(start_index, block_size) = StartIndexAndBlockSize(*mpFile, mPrefix); - - Vector ids; - Vector> coords; - - mpFile->ReadDataSet(mPrefix + "/Ids", ids, start_index, block_size); - mpFile->ReadDataSet(mPrefix + "/Coordinates", coords, start_index, block_size); - auto attributes = mpFile->ReadAttribute(mPrefix); - - const unsigned num_new_nodes = ids.size(); - rContainer.reserve(rContainer.size() + num_new_nodes); - - for (unsigned i = 0; i < num_new_nodes; ++i) { - rContainerDataIO.AddPoint(rContainer, ids[i], coords[i]); - } - - return attributes; - - KRATOS_CATCH(""); -} - -template -void PointsData::Write( - const typename TContainerDataIO::ContainerType& rContainer, - const TContainerDataIO& rContainerDataIO, - const Parameters Attributes) -{ - KRATOS_TRY; - - const unsigned num_nodes = rContainer.size(); - - Vector ids(num_nodes); - Vector> coords(num_nodes); - - IndexPartition(num_nodes).for_each([&rContainer, &rContainerDataIO, &ids, &coords](const auto Index) { - const auto& r_point = *(rContainer.begin() + Index); - rContainerDataIO.GetData(ids[Index], coords[Index], r_point); - }); - - WriteInfo info; - mpFile->WriteDataSet(mPrefix + "/Ids", ids, info); - mpFile->WriteDataSet(mPrefix + "/Coordinates", coords, info); - mpFile->WriteAttribute(mPrefix, Attributes); - - WritePartitionTable(*mpFile, mPrefix, info); - - KRATOS_CATCH(""); -} - -// template instantiations -template class KRATOS_API(HDF5_APPLICATION) PointsData; -template class KRATOS_API(HDF5_APPLICATION) PointsData; - -} // namespace Internals. -} // namespace HDF5. -} // namespace Kratos. diff --git a/applications/HDF5Application/custom_io/hdf5_points_data.h b/applications/HDF5Application/custom_io/hdf5_points_data.h index 0fd1e009cfad..f89021321c12 100644 --- a/applications/HDF5Application/custom_io/hdf5_points_data.h +++ b/applications/HDF5Application/custom_io/hdf5_points_data.h @@ -24,6 +24,7 @@ // Application includes #include "custom_io/hdf5_file.h" #include "hdf5_application_define.h" +#include "custom_utilities/hdf5_data_set_partition_utility.h" namespace Kratos { @@ -57,7 +58,12 @@ class PointsData PointsData( const std::string& rPrefix, - File::Pointer mpFile); + File::Pointer pFile) + : mpFile(pFile), + mPrefix(rPrefix) + { + + } ///@} ///@name Operations @@ -65,12 +71,58 @@ class PointsData Parameters Read( typename TContainerDataIO::ContainerType& rContainer, - const TContainerDataIO& rContainerDataIO); + const TContainerDataIO& rContainerDataIO) + { + KRATOS_TRY; + + IndexType start_index, block_size; + std::tie(start_index, block_size) = StartIndexAndBlockSize(*mpFile, mPrefix); + + Vector ids; + Vector> coords; + + mpFile->ReadDataSet(mPrefix + "/Ids", ids, start_index, block_size); + mpFile->ReadDataSet(mPrefix + "/Coordinates", coords, start_index, block_size); + auto attributes = mpFile->ReadAttribute(mPrefix); + + const unsigned num_new_nodes = ids.size(); + rContainer.reserve(rContainer.size() + num_new_nodes); + + for (unsigned i = 0; i < num_new_nodes; ++i) { + rContainerDataIO.AddPoint(rContainer, ids[i], coords[i]); + } + + return attributes; + + KRATOS_CATCH(""); + } void Write( const typename TContainerDataIO::ContainerType& rContainer, const TContainerDataIO& rContainerDataIO, - const Parameters Attributes); + const Parameters Attributes) + { + KRATOS_TRY; + + const unsigned num_nodes = rContainer.size(); + + Vector ids(num_nodes); + Vector> coords(num_nodes); + + IndexPartition(num_nodes).for_each([&rContainer, &rContainerDataIO, &ids, &coords](const auto Index) { + const auto& r_point = *(rContainer.begin() + Index); + rContainerDataIO.GetData(ids[Index], coords[Index], r_point); + }); + + WriteInfo info; + mpFile->WriteDataSet(mPrefix + "/Ids", ids, info); + mpFile->WriteDataSet(mPrefix + "/Coordinates", coords, info); + mpFile->WriteAttribute(mPrefix, Attributes); + + WritePartitionTable(*mpFile, mPrefix, info); + + KRATOS_CATCH(""); + } ///@} diff --git a/applications/HDF5Application/custom_io/hdf5_properties_io.h b/applications/HDF5Application/custom_io/hdf5_properties_io.h index 7ba4971570a3..13318d4b925e 100644 --- a/applications/HDF5Application/custom_io/hdf5_properties_io.h +++ b/applications/HDF5Application/custom_io/hdf5_properties_io.h @@ -33,12 +33,12 @@ namespace Kratos::HDF5::Internals ///@addtogroup HDF5Application ///@{ -void ReadProperties( +void KRATOS_API(HDF5_APPLICATION) ReadProperties( File& rFile, const std::string& rPrefix, PropertiesContainerType& rProperties); -void WriteProperties( +void KRATOS_API(HDF5_APPLICATION) WriteProperties( File& rFile, const std::string& rPrefix, const PropertiesContainerType& rProperties); diff --git a/applications/HDF5Application/custom_io/hdf5_vertex_container_io.cpp b/applications/HDF5Application/custom_io/hdf5_vertex_container_io.cpp index 75cbd9a7f2a7..78161c02a97b 100644 --- a/applications/HDF5Application/custom_io/hdf5_vertex_container_io.cpp +++ b/applications/HDF5Application/custom_io/hdf5_vertex_container_io.cpp @@ -25,7 +25,7 @@ namespace HDF5 namespace Internals { -std::string AddMissingAndGetPrefix(Parameters Settings) +std::string AddMissingAndGetPrefix(Parameters & Settings) { Parameters default_params(R"( { @@ -44,7 +44,7 @@ VertexContainerCoordinateIO::VertexContainerCoordinateIO( { KRATOS_TRY - const std::string prefix = Settings["prefix"].Get(); + const std::string prefix = Settings["prefix"].GetString(); KRATOS_ERROR_IF(!prefix.empty() && prefix.back() == '/') << "The prefix for vertex coordinates assumed to be a group hence no need to have an ending \"/\" [ prefix = \"" << Settings["prefix"].GetString() << "\" ].\n";