Skip to content

Commit

Permalink
Fix Windows build and fix potential IO conflict in MPI with many part…
Browse files Browse the repository at this point in the history
…ititons
  • Loading branch information
loumalouomega authored Oct 4, 2023
1 parent 47f0d01 commit 00d9d5a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kratos/input_output/stl_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 00d9d5a

Please sign in to comment.