Commit 613ca953 authored by crosetto's avatar crosetto
Browse files

The communicator becomes a shared_ptr

parent 878688ed
...@@ -273,8 +273,8 @@ struct laplacian::Private ...@@ -273,8 +273,8 @@ struct laplacian::Private
typedef boost::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& )> fct_type; typedef boost::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& )> fct_type;
std::string data_file_name; std::string data_file_name;
Epetra_MpiComm* comm; boost::shared_ptr<Epetra_MpiComm> comm;
/** /**
* *
...@@ -317,9 +317,9 @@ laplacian::laplacian( int argc, ...@@ -317,9 +317,9 @@ laplacian::laplacian( int argc,
#ifdef EPETRA_MPI #ifdef EPETRA_MPI
std::cout << "Epetra Initialization" << std::endl; std::cout << "Epetra Initialization" << std::endl;
Members->comm = new Epetra_MpiComm( MPI_COMM_WORLD ); Members->comm.reset( new Epetra_MpiComm( MPI_COMM_WORLD ) );
#else #else
Members->comm = new Epetra_SerialComm(); Members->comm.reset( new Epetra_SerialComm() );
#endif #endif
} }
...@@ -387,7 +387,7 @@ laplacian::run() ...@@ -387,7 +387,7 @@ laplacian::run()
RegionMesh3D<LinearTetra> mesh; RegionMesh3D<LinearTetra> mesh;
//dataADR.mesh()->orderMesh( Members->comm->Comm() ); //dataADR.mesh()->orderMesh( Members->comm->Comm() );
partitionMesh< RegionMesh> meshPart(mesh, *Members->comm); partitionMesh< RegionMesh> meshPart(mesh, Members->comm);
//dataADR.setMesh(meshPart.mesh()); //dataADR.setMesh(meshPart.mesh());
if(verbose) dataADR.showMe(); if(verbose) dataADR.showMe();
...@@ -468,7 +468,7 @@ laplacian::run() ...@@ -468,7 +468,7 @@ laplacian::run()
adr laplacian (dataADR, adr laplacian (dataADR,
adrFESpace, adrFESpace,
betaFESpace, betaFESpace,
*Members->comm); Members->comm);
Chrono chrono; Chrono chrono;
......
...@@ -124,7 +124,7 @@ struct Cylinder::Private ...@@ -124,7 +124,7 @@ struct Cylinder::Private
void setLambda(boost::shared_ptr< std::vector<Real> >& lam) { lambda = lam;} void setLambda(boost::shared_ptr< std::vector<Real> >& lam) { lambda = lam;}
Epetra_Comm* comm; boost::shared_ptr<Epetra_Comm> comm;
/** /**
* get the characteristic velocity * get the characteristic velocity
* *
...@@ -223,11 +223,11 @@ Cylinder::Cylinder( int argc, ...@@ -223,11 +223,11 @@ Cylinder::Cylinder( int argc,
#ifdef EPETRA_MPI #ifdef EPETRA_MPI
std::cout << "mpi initialization ... " << std::endl; std::cout << "mpi initialization ... " << std::endl;
d->comm = new Epetra_MpiComm( MPI_COMM_WORLD ); d->comm.reset( new Epetra_MpiComm( MPI_COMM_WORLD ) );
int ntasks; int ntasks;
int err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); int err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
#else #else
d->comm = new Epetra_SerialComm(); d->comm.reset( new Epetra_SerialComm() );
#endif #endif
if (!d->comm->MyPID()) if (!d->comm->MyPID())
...@@ -296,7 +296,7 @@ Cylinder::run() ...@@ -296,7 +296,7 @@ Cylinder::run()
RegionMesh3D<LinearTetra> mesh; RegionMesh3D<LinearTetra> mesh;
partitionMesh< RegionMesh3D<LinearTetra> > meshPart(mesh, *d->comm); partitionMesh< RegionMesh3D<LinearTetra> > meshPart(mesh, d->comm);
if (verbose) std::cout << std::endl; if (verbose) std::cout << std::endl;
if (verbose) std::cout << " Time discretization order " << dataNavierStokes.dataTime()->getBDF_order() << std::endl; if (verbose) std::cout << " Time discretization order " << dataNavierStokes.dataTime()->getBDF_order() << std::endl;
...@@ -364,13 +364,13 @@ Cylinder::run() ...@@ -364,13 +364,13 @@ Cylinder::run()
Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes, Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes,
uFESpace, uFESpace,
pFESpace, pFESpace,
*d->comm, d->comm,
lagrangeMultipliers.size()); lagrangeMultipliers.size());
#else #else
Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes, Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes,
uFESpace, uFESpace,
pFESpace, pFESpace,
*d->comm); d->comm);
#endif #endif
if (verbose) std::cout << "ok." << std::endl; if (verbose) std::cout << "ok." << std::endl;
......
...@@ -172,7 +172,7 @@ struct Cylinder::Private ...@@ -172,7 +172,7 @@ struct Cylinder::Private
std::string initial_sol; std::string initial_sol;
Epetra_Comm* comm; boost::shared_ptr<Epetra_Comm> comm;
/** /**
* get the characteristic velocity * get the characteristic velocity
* *
...@@ -336,7 +336,7 @@ Cylinder::Cylinder( int argc, ...@@ -336,7 +336,7 @@ Cylinder::Cylinder( int argc,
// MPI_Init(&argc,&argv); // MPI_Init(&argc,&argv);
int ntasks = 0; int ntasks = 0;
d->comm = new Epetra_MpiComm( MPI_COMM_WORLD ); d->comm.reset( new Epetra_MpiComm( MPI_COMM_WORLD ) );
if (!d->comm->MyPID()) { if (!d->comm->MyPID()) {
std::cout << "My PID = " << d->comm->MyPID() << " out of " << ntasks << " running." << std::endl; std::cout << "My PID = " << d->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
std::cout << "Re = " << d->Re << std::endl std::cout << "Re = " << d->Re << std::endl
...@@ -346,7 +346,7 @@ Cylinder::Cylinder( int argc, ...@@ -346,7 +346,7 @@ Cylinder::Cylinder( int argc,
} }
// int err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); // int err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
#else #else
d->comm = new Epetra_SerialComm(); d->comm.reset( new Epetra_SerialComm() );
#endif #endif
} }
...@@ -393,7 +393,7 @@ Cylinder::run() ...@@ -393,7 +393,7 @@ Cylinder::run()
dataNavierStokes.setup( dataFile ); dataNavierStokes.setup( dataFile );
partitionMesh< RegionMesh3D<LinearTetra> > meshPart; partitionMesh< RegionMesh3D<LinearTetra> > meshPart;
meshPart.setup(4, *(d->comm)); meshPart.setup(4, (d->comm));
HDF5Filter3DMesh<RegionMesh3D<LinearTetra> > HDF5Input(dataFile, "cylinderPart"); HDF5Filter3DMesh<RegionMesh3D<LinearTetra> > HDF5Input(dataFile, "cylinderPart");
HDF5Input.loadGraph(meshPart.graph(), d->comm); HDF5Input.loadGraph(meshPart.graph(), d->comm);
...@@ -439,7 +439,7 @@ Cylinder::run() ...@@ -439,7 +439,7 @@ Cylinder::run()
Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes, Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes,
uFESpace, uFESpace,
pFESpace, pFESpace,
*d->comm, numLM); d->comm, numLM);
EpetraMap fullMap(fluid.getMap()); EpetraMap fullMap(fluid.getMap());
if (verbose) std::cout << "ok." << std::endl; if (verbose) std::cout << "ok." << std::endl;
......
...@@ -75,10 +75,10 @@ int main( int argc, char** argv ) ...@@ -75,10 +75,10 @@ int main( int argc, char** argv )
#ifdef HAVE_MPI #ifdef HAVE_MPI
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
Epetra_MpiComm comm(MPI_COMM_WORLD); boost::shared_ptr<Epetra_MpiComm> comm(new Epetra_MpiComm(MPI_COMM_WORLD) );
std::cout << "% using MPI version" << std::endl; std::cout << "% using MPI version" << std::endl;
#else #else
Epetra_SerialComm comm; boost::shared_ptr<Epetra_SerialComm> comm( new Epetra_SerialComm() );
std::cout << "% using serial version" << std::end; std::cout << "% using serial version" << std::end;
#endif #endif
...@@ -103,9 +103,9 @@ int main( int argc, char** argv ) ...@@ -103,9 +103,9 @@ int main( int argc, char** argv )
meshPart.doPartitionMesh(); meshPart.doPartitionMesh();
HDF5Filter3DMesh<RegionMesh3D<LinearTetra> > HDF5Output(dataFile, meshPart.mesh(), "cylinderPart", HDF5Filter3DMesh<RegionMesh3D<LinearTetra> > HDF5Output(dataFile, meshPart.mesh(), "cylinderPart",
comm.MyPID()); comm->MyPID());
HDF5Output.addPartitionGraph(meshPart.graph(), &comm); HDF5Output.addPartitionGraph(meshPart.graph(), comm);
HDF5Output.addMeshPartitionAll(meshPart.meshAllPartitions(), &comm); HDF5Output.addMeshPartitionAll(meshPart.meshAllPartitions(), comm);
HDF5Output.postProcess(0); HDF5Output.postProcess(0);
HDF5Output.CloseFile(); HDF5Output.CloseFile();
......
...@@ -160,7 +160,7 @@ struct Cylinder::Private ...@@ -160,7 +160,7 @@ struct Cylinder::Private
std::string initial_sol; std::string initial_sol;
Epetra_Comm* comm; boost::shared_ptr<Epetra_Comm> comm;
/** /**
* get the characteristic velocity * get the characteristic velocity
* *
...@@ -324,7 +324,7 @@ Cylinder::Cylinder( int argc, ...@@ -324,7 +324,7 @@ Cylinder::Cylinder( int argc,
// MPI_Init(&argc,&argv); // MPI_Init(&argc,&argv);
int ntasks = 0; int ntasks = 0;
d->comm = new Epetra_MpiComm( MPI_COMM_WORLD ); d->comm.reset( new Epetra_MpiComm( MPI_COMM_WORLD ) );
if (!d->comm->MyPID()) { if (!d->comm->MyPID()) {
std::cout << "My PID = " << d->comm->MyPID() << " out of " << ntasks << " running." << std::endl; std::cout << "My PID = " << d->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
std::cout << "Re = " << d->Re << std::endl std::cout << "Re = " << d->Re << std::endl
...@@ -334,7 +334,7 @@ Cylinder::Cylinder( int argc, ...@@ -334,7 +334,7 @@ Cylinder::Cylinder( int argc,
} }
// int err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); // int err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
#else #else
d->comm = new Epetra_SerialComm(); d->comm.reset( new Epetra_SerialComm() );
#endif #endif
} }
...@@ -382,7 +382,7 @@ Cylinder::run() ...@@ -382,7 +382,7 @@ Cylinder::run()
Mesh mesh; Mesh mesh;
readMesh(mesh, dataMesh); readMesh(mesh, dataMesh);
partitionMesh< Mesh > meshPart(mesh, *d->comm); partitionMesh< Mesh > meshPart(mesh, d->comm);
if (verbose) std::cout << std::endl; if (verbose) std::cout << std::endl;
if (verbose) std::cout << "Time discretization order " << dataNavierStokes.dataTime()->getBDF_order() << std::endl; if (verbose) std::cout << "Time discretization order " << dataNavierStokes.dataTime()->getBDF_order() << std::endl;
...@@ -423,7 +423,7 @@ Cylinder::run() ...@@ -423,7 +423,7 @@ Cylinder::run()
Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes, Oseen< RegionMesh3D<LinearTetra> > fluid (dataNavierStokes,
uFESpace, uFESpace,
pFESpace, pFESpace,
*d->comm, numLM); d->comm, numLM);
EpetraMap fullMap(fluid.getMap()); EpetraMap fullMap(fluid.getMap());
if (verbose) std::cout << "ok." << std::endl; if (verbose) std::cout << "ok." << std::endl;
......
...@@ -102,11 +102,11 @@ main( int argc, char** argv ) ...@@ -102,11 +102,11 @@ main( int argc, char** argv )
#ifdef HAVE_MPI #ifdef HAVE_MPI
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
Epetra_MpiComm Comm(MPI_COMM_WORLD); boost::shared_ptr<Epetra_MpiComm> Comm(new Epetra_MpiComm( MPI_COMM_WORLD ) );
if ( Comm.MyPID() == 0 ) if ( Comm->MyPID() == 0 )
cout << "% using MPI" << endl; cout << "% using MPI" << endl;
#else #else
Epetra_SerialComm Comm; boost::shared_ptr<Epetra_SerialComm> Comm( new Epetra_SerialComm() );
cout << "% using serial Version" << endl; cout << "% using serial Version" << endl;
#endif #endif
......
...@@ -121,14 +121,14 @@ struct Structure::Private ...@@ -121,14 +121,14 @@ struct Structure::Private
std::string data_file_name; std::string data_file_name;
Epetra_Comm* comm; boost::shared_ptr<Epetra_Comm> comm;
}; };
Structure::Structure( int argc, Structure::Structure( int argc,
char** argv, char** argv,
Epetra_Comm & structComm, boost::shared_ptr<Epetra_Comm> structComm,
LifeV::AboutData const& ad, LifeV::AboutData const& ad,
LifeV::po::options_description const& od ): LifeV::po::options_description const& od ):
parameters( new Private() ) parameters( new Private() )
...@@ -146,7 +146,7 @@ Structure::Structure( int argc, ...@@ -146,7 +146,7 @@ Structure::Structure( int argc,
<< "young = " << parameters->young << std::endl << "young = " << parameters->young << std::endl
<< "poisson = " << parameters->poisson << std::endl; << "poisson = " << parameters->poisson << std::endl;
parameters->comm = &structComm; parameters->comm = structComm;
int ntasks = parameters->comm->NumProc(); int ntasks = parameters->comm->NumProc();
if (!parameters->comm->MyPID()) std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl; if (!parameters->comm->MyPID()) std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
...@@ -187,7 +187,7 @@ Structure::run3d() ...@@ -187,7 +187,7 @@ Structure::run3d()
readMesh(mesh, dataMesh); readMesh(mesh, dataMesh);
partitionMesh< RegionMesh3D<LinearTetra> > meshPart( mesh, *parameters->comm ); partitionMesh< RegionMesh3D<LinearTetra> > meshPart( mesh, parameters->comm );
// meshPart.rebuildMesh(); // meshPart.rebuildMesh();
...@@ -210,7 +210,7 @@ Structure::run3d() ...@@ -210,7 +210,7 @@ Structure::run3d()
VenantKirchhofSolver< RegionMesh3D<LinearTetra> > solid( dataStructure, VenantKirchhofSolver< RegionMesh3D<LinearTetra> > solid( dataStructure,
dFESpace, dFESpace,
*parameters->comm); parameters->comm);
solid.setUp(dataFile); solid.setUp(dataFile);
solid.buildSystem(); solid.buildSystem();
// //
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
Structure( int argc, Structure( int argc,
char** argv, char** argv,
Epetra_Comm & structComm, boost::shared_ptr<Epetra_Comm> structComm,
LifeV::AboutData const& ad, LifeV::AboutData const& ad,
LifeV::po::options_description const& od ); LifeV::po::options_description const& od );
......
Supports Markdown
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