From: John P. <jwp...@gm...> - 2018-06-13 16:01:54
|
On Tue, Jun 12, 2018 at 7:48 PM, Povolotskyi, Mykhailo <mpo...@pu...> wrote: > Dear Libmesh develepers, > > I want to create different instances of mesh on several MPI processes. > Then I want to output the mesh from one MPI process. > > > I am facing problems with the following code: > > > #include "libmesh/libmesh.h" > #include "libmesh/mesh_generation.h" > #include "libmesh/mesh.h" > int main(int argc, char ** argv) > { > > MPI_Init(&argc, &argv); > MPI is already initialized in LibMeshInit, so no need to do this manually unless your real code does MPI communication before LibMeshInit... > { > libMesh::LibMeshInit init (argc, argv,MPI_COMM_WORLD); > 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); > > int rank; > MPI_Comm_rank(MPI_COMM_WORLD, &rank); > Again, I'd just use init.comm().rank() to find out the rank. > > if (rank == 0) > { > mesh.write("mesh1.vtu"); > } > } > MPI_Finalize(); > MPI_Finalize is called in the LibMeshInit destructor, no need to call it manually. > return 0; > } > The problems are as follows: > > Problem #1) If I run the code in serial, I'm getting warning: > > Warning: This MeshOutput subclass only supports meshes which have been > serialized! > Warning: This MeshOutput subclass only supports meshes which have been > serialized! > The .pvtu extension should be used when writing VTK files in libMesh. > > > My question: > > a) how to avoid the first waning about the mesh not being serialized? > Unless you have configured libmesh with --enable-parmesh (and therefore Mesh == DistributedMesh) this warning can be safely ignored. > > b) I tried to change the filename to mesh1.pvtu > > In this case I'm getting an error message: > > > > ERROR: Unrecognized file extension: mesh1.pvtu > I understand the following: > This is just a (possibly unnecessary) limitation of the NamebasedIO class, it should work (as in misc_ex11 and misc_ex4 if you explicitly construct a VTKIO object and then call the write() method. -- John |