Commit 6919cf0b authored by Robert K's avatar Robert K

Merge branch 'feature/python-mpi-comm' into 'master'

Cleanup  mix of default mpi communicators.

See merge request !107
parents 31573248 1a55811e
Pipeline #31399 passed with stage
in 30 minutes
......@@ -32,6 +32,10 @@ namespace Dune
No_Comm noComm_;
ALUGridNoComm() : noComm_() {}
ALUGridNoComm( const No_Comm& comm ) : noComm_( comm ) {}
#if ALU3DGRID_PARALLEL
ALUGridNoComm( MPI_Comm comm ) : noComm_() {}
operator MPI_Comm () const { return MPI_COMM_SELF; }
#endif
operator No_Comm () const { return noComm_; }
};
......
......@@ -322,19 +322,19 @@ namespace Dune
testfile.close();
return true;
}
static int rank( MPICommunicatorType MPICOMM )
static int rank( MPICommunicatorType mpiComm )
{
int rank = 0;
#if HAVE_MPI
MPI_Comm_rank( MPICOMM, &rank );
MPI_Comm_rank( mpiComm, &rank );
#endif
return rank;
}
static int size( MPICommunicatorType MPICOMM )
static int size( MPICommunicatorType mpiComm )
{
int size = 1;
#if HAVE_MPI
MPI_Comm_size( MPICOMM, &size );
MPI_Comm_size( mpiComm, &size );
#endif
return size;
}
......@@ -355,8 +355,18 @@ namespace Dune
using BaseType :: callDirectly;
public:
explicit DGFGridFactory ( std::istream &input,
MPICommunicatorType comm = MPIHelper::getCommunicator() )
: BaseType( comm )
MPICommunicatorType mpiComm )
: DGFGridFactory( input, Comm(mpiComm) )
{}
explicit DGFGridFactory ( const std::string &filename,
MPICommunicatorType mpiComm )
: DGFGridFactory( filename, Comm(mpiComm) )
{}
DGFGridFactory ( std::istream &input,
Comm comm = Comm() ) // casts from and to MPI_Comm
: BaseType( MPICommunicatorType(comm) )
{
input.clear();
input.seekg( 0 );
......@@ -366,8 +376,8 @@ namespace Dune
}
explicit DGFGridFactory ( const std::string &filename,
MPICommunicatorType comm = MPIHelper::getCommunicator())
: BaseType( comm )
Comm comm = Comm() ) // casts from and to MPI_Comm
: BaseType( MPICommunicatorType(comm) )
{
std::ifstream input( filename.c_str() );
bool fileFound = input.is_open() ;
......
......@@ -2,6 +2,7 @@
#define MPACCESS_MPI_H_INCLUDED
#include <memory>
#include <dune/common/parallel/communication.hh>
#include "mpAccess.h"
......@@ -58,6 +59,12 @@ namespace ALUGrid
public :
// constructor taking MPI_Comm
explicit MpAccessMPI ( MPI_Comm mpicomm ) ;
// constructor taking Dune::No_Comm and creating MpAccessMPI with MPI_COMM_SELF
explicit MpAccessMPI ( const Dune::No_Comm& )
: MpAccessMPI( MPI_COMM_SELF )
{}
// copy constructor
MpAccessMPI (const MpAccessMPI &);
// destructor
......
......@@ -9,7 +9,7 @@ from dune.common.checkconfiguration import assertHave, ConfigurationError
try:
assertHave("HAVE_DUNE_ALUGRID")
def aluGrid(constructor, dimgrid=None, dimworld=None, elementType=None, serial=False, **parameters):
def aluGrid(constructor, dimgrid=None, dimworld=None, elementType=None, comm=None, serial=False, **parameters):
from dune.grid.grid_generator import module, getDimgrid
if not dimgrid:
......@@ -42,19 +42,23 @@ try:
includes = ["dune/alugrid/grid.hh", "dune/alugrid/dgf.hh"]
gridModule = module(includes, typeName)
return gridModule.LeafGrid(gridModule.reader(constructor))
if comm is not None:
raise Exception("Passing communicator to grid construction is not yet implemented in Python bindings of dune-grid")
return gridModule.LeafGrid(gridModule.reader(constructor, comm))
else:
return gridModule.LeafGrid(gridModule.reader(constructor))
def aluConformGrid(constructor, dimgrid=None, dimworld=None, serial=False, **parameters):
return aluGrid(constructor, dimgrid, dimworld, elementType="Dune::simplex", refinement="Dune::conforming", serial=serial)
def aluConformGrid(constructor, dimgrid=None, dimworld=None, comm=None, serial=False, **parameters):
return aluGrid(constructor, dimgrid, dimworld, elementType="Dune::simplex", refinement="Dune::conforming", comm=comm, serial=serial)
def aluCubeGrid(constructor, dimgrid=None, dimworld=None, serial=False, **parameters):
return aluGrid(constructor, dimgrid, dimworld, elementType="Dune::cube", refinement="Dune::nonconforming", serial=serial)
def aluCubeGrid(constructor, dimgrid=None, dimworld=None, comm=None, serial=False, **parameters):
return aluGrid(constructor, dimgrid, dimworld, elementType="Dune::cube", refinement="Dune::nonconforming", comm=comm, serial=serial)
def aluSimplexGrid(constructor, dimgrid=None, dimworld=None, serial=False, **parameters):
return aluGrid(constructor, dimgrid, dimworld, elementType="Dune::simplex", refinement="Dune::nonconforming", serial=serial)
def aluSimplexGrid(constructor, dimgrid=None, dimworld=None, comm=None, serial=False, **parameters):
return aluGrid(constructor, dimgrid, dimworld, elementType="Dune::simplex", refinement="Dune::nonconforming", comm=comm, serial=serial)
grid_registry = {
"ALU" : aluGrid,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment