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

How can one use a Neumann boundary condition with a marked mesh?

+2 votes

How can one integrate over the single facet marked with 2 in the xml marked mesh defined below?

<?xml version="1.0"?>
<dolfin xmlns:dolfin="http://fenicsproject.org">
<mesh celltype="triangle" dim="2">
<vertices size="4">
<vertex index="0" x="0.000000000000000e+00" y="0.000000000000000e+00" />
<vertex index="1" x="1.000000000000000e+00" y="0.000000000000000e+00" />
<vertex index="2" x="0.000000000000000e+00" y="1.000000000000000e+00" />
<vertex index="3" x="1.000000000000000e+00" y="1.000000000000000e+00" />
</vertices>
<cells size="2">
<triangle index="0" v0="0" v1="1" v2="3" />
<triangle index="1" v0="0" v1="2" v2="3" />
</cells>
<domains>
<mesh_value_collection name="f" type="uint" dim="1" size="6">
<value cell_index="0" local_entity="0" value="0" />
<value cell_index="0" local_entity="1" value="0" />
<value cell_index="0" local_entity="2" value="0" />
<value cell_index="1" local_entity="0" value="0" />
<value cell_index="1" local_entity="1" value="0" />
<value cell_index="1" local_entity="2" value="2" />
</mesh_value_collection>
</domains>
</mesh>
</dolfin>

I would assume one could read the mesh function out of the file. I try this

mesh = Mesh("mesh.xml")
meshfunc = MeshFunction("size_t", mesh, "mesh.xml")

and get the error

*** -------------------------------------------------------------------------
*** Error: Unable to read DOLFIN XML data.
*** Reason: Unable to find tag <mesh_value_collection>.
*** Where: This error was encountered inside xmlutils.cpp.
*** Process: 0


*** DOLFIN version: 1.3.0

asked Mar 1, 2014 by Gabriel Balaban FEniCS User (1,210 points)

1 Answer

+1 vote
 
Best answer
mesh = Mesh("mesh.xml")
meshfunc = MeshFunction("size_t", mesh, 1, mesh.domains())
answered Mar 2, 2014 by Jan Blechta FEniCS Expert (51,420 points)
selected Mar 2, 2014 by Gabriel Balaban

djekuji moc! Thank you.

...