Skip to content
Snippets Groups Projects
Commit d041a05e authored by Boris Martin's avatar Boris Martin
Browse files

Preparing for splitting of the two cases

parent 2137c323
No related branches found
No related tags found
No related merge requests found
......@@ -261,15 +261,27 @@ namespace gmshfem::field
void DistributedField< T_Scalar, T_Form >::_computeToSend(const std::optional<std::vector<int>>& neighborRanks)
{
#ifdef HAVE_MPI
// What I have to send is what others have to read
// Create temporary MPI Type for the struct
const int nitems = 2;
int blocklengths[2] = {1, 1};
MPI_Datatype types[2] = {MPI_INT, MPI_UNSIGNED_LONG};
MPI_Datatype mpi_struct_type;
MPI_Aint offsets[2];
offsets[0] = 0;
offsets[1] = sizeof(int);
MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_struct_type);
MPI_Type_commit(&mpi_struct_type);
// Send all owned interfaces and inner dofs that are read by someone else
std::vector< DofGlobalIndex > local, global;
local.reserve(_sharedDofs.size());
unsigned commSize = gmshfem::common::GmshFem::getMPISize();
// Fill the local list
// Fill the local list of what I read
for(dofs::Dof *dof : _toRead) {
local.push_back({dof->numType(), dof->entity()});
}
......@@ -285,19 +297,7 @@ namespace gmshfem::field
total_size += sizes[i];
}
// Create temporary MPI Type for the struct
const int nitems = 2;
int blocklengths[2] = {1, 1};
MPI_Datatype types[2] = {MPI_INT, MPI_UNSIGNED_LONG};
MPI_Datatype mpi_struct_type;
MPI_Aint offsets[2];
//offsets[0] = offsetof(DofGlobalIndex, type);
//offsets[1] = offsetof(DofGlobalIndex, entity);
offsets[0] = 0;
offsets[1] = sizeof(int);
MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_struct_type);
MPI_Type_commit(&mpi_struct_type);
// Synchronize the full array
global.resize(total_size);
......@@ -306,7 +306,6 @@ namespace gmshfem::field
MPI_COMM_WORLD);
// Free the type
MPI_Type_free(&mpi_struct_type);
_toSend.clear();
// Global is the list of dof indices someone is reading
......@@ -321,6 +320,9 @@ namespace gmshfem::field
_toSend.insert(dof);
}
}
MPI_Type_free(&mpi_struct_type);
#else
throw common::Exception("MPI is not available");
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment