Cannot import and plot a ".xml" file

4 months ago by

File attached: parallel_plate.xml (68.29 KB)
File attached: hollow_factor3.xml (11.41 KB)

Hi, all,

I just want to read in a *.xml file and plot it in the python interface using the following codes:

#import the required modules
from dolfin import *
#load the mesh
mesh = Mesh("parallel_plate.xml")
#mesh = Mesh("hollow_factor3.xml") 


The xml file is converted from a *.msh file (generated by Gmsh). Note that the "dolfin-convert" command gives me three xml files successfully. However, the codes above gives me the following error:

*** -------------------------------------------------------------------------
*** Error: Unable to read data from XML file.
*** Reason: Unable to open file "parallel_plate.xml".
*** Where: This error was encountered inside XMLFile.cpp.
*** Process: 0
*** DOLFIN version: 2017.2.0
*** Git changeset: unknown

Can anybody kindly give some hints where could be the problem?

Here I also attach two *.xml files I used.

Thanks in advance.

Jianan Zhang
Community: FEniCS Project

1 Answer

4 months ago by
If your xml mesh is in correct format and if you  just want to see the plot of you mesh through any possible means...
you can try ...

from dolfin import *

mesh = Mesh("xyz.xml")
file = File("abc.pvd")
file << mesh

The mesh could then be opened in paraview as a pvd file. You can easily download and install paraview.
Hi, Ovais,

My problem has been solved just now. Thanks for the help.

written 4 months ago by Jianan Zhang  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »