dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #02763
Converting to new mesh file format
I forgot to mention how to convert to the new mesh XML format.
Just use dolfin-convert which you can find in src/utils/convert.
Rename the file you want to convert to something with suffix .old
and then use dolfin-convert:
dolfin-convert mesh.xml.old mesh.xml
I also added a script in src/utils/xml called convertall that converts
all meshes in a directory by calling dolfin-convert on each mesh. Make
sure to backup your meshes if something breaks.
I only made small changes to the XML format. Here's an example:
Old format:
<?xml version="1.0" encoding="UTF-8"?>
<dolfin xmlns:dolfin="http://www.phi.chalmers.se/dolfin/">
<mesh>
<vertices size="9">
<vertex name="0" x="0.000000" y="0.000000" z="0.0"/>
<vertex name="1" x="1.000000" y="0.000000" z="0.0"/>
<vertex name="2" x="1.000000" y="1.000000" z="0.0"/>
<vertex name="3" x="0.000000" y="1.000000" z="0.0"/>
<vertex name="4" x="0.500000" y="0.000000" z="0.0"/>
<vertex name="5" x="1.000000" y="0.500000" z="0.0"/>
<vertex name="6" x="0.500000" y="1.000000" z="0.0"/>
<vertex name="7" x="0.000000" y="0.500000" z="0.0"/>
<vertex name="8" x="0.500000" y="0.500000" z="0.0"/>
</vertices>
<cells size="8">
<triangle name="0" n0="1" n1="8" n2="4"/>
<triangle name="1" n0="3" n1="8" n2="6"/>
<triangle name="2" n0="3" n1="7" n2="8"/>
<triangle name="3" n0="1" n1="5" n2="8"/>
<triangle name="4" n0="0" n1="4" n2="7"/>
<triangle name="5" n0="2" n1="6" n2="5"/>
<triangle name="6" n0="7" n1="4" n2="8"/>
<triangle name="7" n0="5" n1="6" n2="8"/>
</cells>
</mesh>
</dolfin>
New format:
<?xml version="1.0" encoding="UTF-8"?>
<dolfin xmlns:dolfin="http://www.fenics.org/dolfin/">
<mesh dim="2" celltype="triangle">
<vertices size="9">
<vertex index="0" x="0.000000" y="0.000000"/>
<vertex index="1" x="1.000000" y="0.000000"/>
<vertex index="2" x="1.000000" y="1.000000"/>
<vertex index="3" x="0.000000" y="1.000000"/>
<vertex index="4" x="0.500000" y="0.000000"/>
<vertex index="5" x="1.000000" y="0.500000"/>
<vertex index="6" x="0.500000" y="1.000000"/>
<vertex index="7" x="0.000000" y="0.500000"/>
<vertex index="8" x="0.500000" y="0.500000"/>
</vertices>
<cells size="8">
<triangle index="0" v0="1" v1="8" v2="4"/>
<triangle index="1" v0="3" v1="8" v2="6"/>
<triangle index="2" v0="3" v1="7" v2="8"/>
<triangle index="3" v0="1" v1="5" v2="8"/>
<triangle index="4" v0="0" v1="4" v2="7"/>
<triangle index="5" v0="2" v1="6" v2="5"/>
<triangle index="6" v0="7" v1="4" v2="8"/>
<triangle index="7" v0="5" v1="6" v2="8"/>
</cells>
</mesh>
</dolfin>
/Anders