This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to read material data as a function from hdf5 files in parallel?

0 votes

I am doing a simulation on a heterogeneous material. The material properties are defined in a function and stored together with mesh in a hdf5 file. The file was created using a single processor.

I am trying to implement parallel, by:

    MPI_Comm comm( MPI_COMM_WORLD );
    HDF5File g(comm, "mesh_and_material.h5", "r" ); 
    Mesh mesh0(comm );
    g.read( mesh0, "mesh", use_partition_from_file );
    Poisson::FunctionSpace V_0(mesh0);
    Function u_1(V_0);
    Function materials_in(V_0);  // the material property function, scalar labels.
    g.read( materials_in, "materials" );

    // output, check mesh and material, see if read correctly.
    File file( comm, "solution.pvd", "compressed");
    File file2( comm, "materials_in.pvd", "compressed");
    file << u_1;
    file2 << materials_in;

and I ran the code:

mpirun -np 4 ./main

Unfortunately the result was disappointing with mesh distorted. I guess it is due to the fact that the file was created using a single core. I can run the code with

mpirun -np 1 ./main

which gives the correct answer. But I need to run in parallel.

Any suggestions? Thanks!

closed with the note: solved
asked Jun 19, 2015 by qiangzini FEniCS Novice (760 points)
closed Jun 26, 2015 by qiangzini

1 Answer

0 votes
 
Best answer

I've not seen any mesh distortions with this method. What kind of distortions are you seeing?

It could be that the pvd output has some distracting artefacts at process boundaries.

If you try to save using XDMF format, in parallel, you may find it works better.

answered Jun 19, 2015 by chris_richardson FEniCS Expert (31,740 points)
selected Jun 20, 2015 by qiangzini

Thanks.

The mesh is so distorted that one can not imagine what the original geometry looks like...

Do you mean I can read the data using a single core, write to XDMF format using a single core, and then read in parallel?

Thanks.

No, I mean use XDMF instead of PVD to visualise in parallel.

Anyway, the mesh should not get distorted badly. Maybe you can post your h5 file somewhere and I can try it.

Thanks.

I double checked my file, it was due to the mesh in the original hdf5 file was distorted. Thanks for your help.

...