From 92f0e9cdaf9fe9f75b018abb8b010ec6c3998027 Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 15:59:42 +0100 Subject: [PATCH 1/9] solve ambigous call problem in win --- .../HDF5Application/custom_io/hdf5_connectivities_data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From a68a5161f540d0bf8cad469d73293f77623becd6 Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 16:09:19 +0100 Subject: [PATCH 2/9] Default template arguments should only appear on headers --- applications/HDF5Application/custom_io/hdf5_file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 6f69b963b33d5af6582833616c1fe87f36d0a58c Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 16:16:01 +0100 Subject: [PATCH 3/9] Fixing problems with bools. Do not works with bools in collectives --- .../custom_io/hdf5_container_component_io.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp index a99a0f0c256a..8a9b140ab74d 100644 --- a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp +++ b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp @@ -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."; From 785ec22e6f9528a83bf5e96042f5d8d94fac1b5f Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 16:46:40 +0100 Subject: [PATCH 4/9] Fix partial instantiation problem --- .../custom_io/hdf5_points_data.cpp | 105 ------------------ .../custom_io/hdf5_points_data.h | 58 +++++++++- 2 files changed, 55 insertions(+), 108 deletions(-) delete mode 100644 applications/HDF5Application/custom_io/hdf5_points_data.cpp 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(""); + } ///@} From 64a8a23d98370238091b0f6b81c1d1fd3125e898 Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 16:47:19 +0100 Subject: [PATCH 5/9] Remove points_data.cpp from compilation --- applications/HDF5Application/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) 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 From 1e671a443886cc8a7fce18eca3905e0cb30bd639 Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 16:47:55 +0100 Subject: [PATCH 6/9] Do not use bools in vectors: Christmas edition --- .../HDF5Application/custom_io/hdf5_container_component_io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp index 8a9b140ab74d..4b1a4c158057 100644 --- a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp +++ b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp @@ -291,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 From 7f245bd62e300007c512532dd7396906c686d4b3 Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 19:22:35 +0100 Subject: [PATCH 7/9] Missing KRATOS_API --- applications/HDF5Application/custom_io/hdf5_properties_io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From eb043ef6de702a87c6ac47f50e81603240d3fb5c Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 19:23:20 +0100 Subject: [PATCH 8/9] Fix direct access to Get<> --- .../HDF5Application/custom_io/hdf5_vertex_container_io.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"; From 34c41543d3281a66f96e9a1fa3981c4171229420 Mon Sep 17 00:00:00 2001 From: "Carlos A. Roig Pina" Date: Tue, 23 Dec 2025 19:32:25 +0100 Subject: [PATCH 9/9] Trying overload with char --- .../custom_io/hdf5_container_component_io.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp b/applications/HDF5Application/custom_io/hdf5_container_component_io.cpp index 4b1a4c158057..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,12 +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 std::tuple 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(static_cast(availability[Index] == 1), static_cast(availability[Index] == 0)); + 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)}); + 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.";