Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core][MPI] Minor fix in STL IO in MPI write #11656

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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