Skip to content

Commit

Permalink
Merge pull request #11656 from KratosMultiphysics/core/stl-io-mpi-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
loumalouomega authored Oct 5, 2023
2 parents 970d762 + 00d9d5a commit 0fb47b9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 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 @@ -230,8 +236,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
unsigned int 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) {
Expand Down Expand Up @@ -278,8 +288,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
unsigned int 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) {
Expand Down

0 comments on commit 0fb47b9

Please sign in to comment.