From 47f0d0147e2d5055a31a22b22b6c902234a94b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 4 Oct 2023 12:12:13 +0200 Subject: [PATCH 1/2] [Core][MPI] Minor fix in STL IO in MPI write --- kratos/input_output/stl_io.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kratos/input_output/stl_io.cpp b/kratos/input_output/stl_io.cpp index 0483a0621950..161b744ed924 100644 --- a/kratos/input_output/stl_io.cpp +++ b/kratos/input_output/stl_io.cpp @@ -230,8 +230,12 @@ void StlIO::WriteEntityBlockMPI( << "Model part contained " << converted_num_degenerate_geometries << " geometries with area = 0.0, skipping these geometries." << std::endl; + // Getting number of entities + std::size_t number_of_entities = rThisEntities.size(); + number_of_entities = rDataCommunicator.SumAll(number_of_entities); + // Retrieve rank and pass to rank 0 - if (rThisEntities.size() > 0) { + if (number_of_entities > 0) { const int rank = rDataCommunicator.Rank(); const int tag = 0; if (rank == 0) { @@ -278,8 +282,12 @@ void StlIO::WriteGeometryBlockMPI( << "Model part contained " << converted_num_degenerate_geometries << " geometries with area = 0.0, skipping these geometries." << std::endl; + // Getting number of entities + std::size_t number_of_geometries = rThisGeometries.size(); + number_of_geometries = rDataCommunicator.SumAll(number_of_geometries); + // Retrieve rank and pass to rank 0 - if (rThisGeometries.size() > 0) { + if (number_of_geometries > 0) { const int rank = rDataCommunicator.Rank(); const int tag = 0; if (rank == 0) { From 00d9d5a45515235cfdd1bc729639fbb748daafec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Wed, 4 Oct 2023 13:20:03 +0200 Subject: [PATCH 2/2] Fix Windows build and fix potential IO conflict in MPI with many partititons --- kratos/input_output/stl_io.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kratos/input_output/stl_io.cpp b/kratos/input_output/stl_io.cpp index 161b744ed924..ffd7786fee99 100644 --- a/kratos/input_output/stl_io.cpp +++ b/kratos/input_output/stl_io.cpp @@ -135,6 +135,12 @@ void StlIO::WriteModelPart(const ModelPart& rThisModelPart) // Get data communicator const auto& r_data_communicator = rThisModelPart.GetCommunicator().GetDataCommunicator(); + // If rank is not zeo we remove the stream to avoid conflict + if (r_data_communicator.Rank() != 0) { + mpInputStream = nullptr; + } + r_data_communicator.Barrier(); + /* Write the solid block */ // Write header of the file if (r_data_communicator.Rank() == 0) { @@ -231,7 +237,7 @@ void StlIO::WriteEntityBlockMPI( << " geometries with area = 0.0, skipping these geometries." << std::endl; // Getting number of entities - std::size_t number_of_entities = rThisEntities.size(); + unsigned int number_of_entities = rThisEntities.size(); number_of_entities = rDataCommunicator.SumAll(number_of_entities); // Retrieve rank and pass to rank 0 @@ -283,7 +289,7 @@ void StlIO::WriteGeometryBlockMPI( << " geometries with area = 0.0, skipping these geometries." << std::endl; // Getting number of entities - std::size_t number_of_geometries = rThisGeometries.size(); + unsigned int number_of_geometries = rThisGeometries.size(); number_of_geometries = rDataCommunicator.SumAll(number_of_geometries); // Retrieve rank and pass to rank 0