From: Michael P. <mpo...@pu...> - 2018-06-13 19:27:38
|
On 06/13/2018 03:15 PM, John Peterson wrote: > > > On Wed, Jun 13, 2018 at 11:03 AM, Michael Povolotskyi > <mpo...@pu... <mailto:mpo...@pu...>> wrote: > > Hello John, > > I played with it, and this is what worked for me. > > #include <vector> > #include <sstream> > using namespace std; > > #define private public//to get access to > libMesh::LibMeshInit._vtk_mpi_controller > > #include "libmesh/mesh_generation.h" > #include "libmesh/mesh.h" > #include "libmesh/vtk_io.h" > #include "libmesh/libmesh.h" > #include "vtkMPIController.h" > int main(int argc, char ** argv) > { > > MPI_Init(&argc, &argv); > > { > libMesh::LibMeshInit init (argc, argv,MPI_COMM_WORLD); > int rank; > MPI_Comm_rank(MPI_COMM_WORLD, &rank); > > vtkMPICommunicator* mcomm = > vtkMPICommunicator::GetWorldCommunicator()->NewInstance (); > mcomm->SplitInitialize (mcomm, rank, 0); > > init._vtk_mpi_controller->SetCommunicator (mcomm); > > libMesh::Mesh > mesh(libMesh::Parallel::Communicator(MPI_COMM_SELF)); > libMesh::MeshTools::Generation::build_cube (mesh, > 10, 10, 5, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0,libMesh::HEX8); > > > if (rank == 0) > { > libMesh::VTKIO out(mesh); > out.write("mesh1.pvtu"); > } > } > MPI_Finalize(); > return 0; > > > > } > > > What do you think? Can you provide an access to > libMesh::LibMeshInit._vtk_mpi_controller? > Or there is a better solution? > > > I think it would be reasonable to provide a public accessor for > _vtk_mpi_controller, as long as we can still get away with a forward > declaration for vtkMPIController. > > Would it be possible to do the same algorithm from within > VTKIO::read()? At that point, we have a Communicator (mesh.comm()) for > the Mesh we are currently writing, so we could probably do the same > New/Split/Set series of steps there, but unfortunately we don't have > access to the LibMeshInit at that point... > > -- > John Would you add the access to _vtk_mpi_controller for me? I can do it myself, but I prefer to be consistent with you. It looks to me that for a regular solution you need to reset the vtkMPICommunicator before any read/write event. Can you store the vtkMPICommunicator inside the mesh class? Michael. |