Hey guys
For different reasons, I need to generate the mesh using my own program. I write two Dolfin XML files, one for the mesh itself:
<?xml version="1.0" encoding="UTF-8"?>
<dolfin xmlns:dolfin="http://www.fenicsproject.org">
<mesh celltype="tetrahedron" dim="3">
<vertices size="428868">
<vertex index="0" x="0.0" y="0.0" z="413.54"/>
<vertex index="1" x="2200.0" y="0.0" z="272.73"/>
...
And one for the boundaries (boundary.xml
, gzipped boundary.xml.gz
). I'm marking them on every vertex using a 0-dimensional mesh_function
:
<?xml version="1.0" encoding="UTF-8"?>
<dolfin xmlns:dolfin="http://fenicsproject.org">
<mesh_function type="uint" dim="0" size="428868">
<entity index="0" value="1"/>
<entity index="1" value="1"/>
...
Now I would like to apply DirichletBC
on every DOF where my boundary mesh function is set ==2
. I tried it like this:
subdomains = MeshFunction('size_t', mesh, boundary.xml.gz')
bc = DirichletBC(V, Constant(0), subdomains, 2)
But I can clearly see in my solution, that the DirichletBC
is not being applied. I also tried pointwise
:
subdomains = MeshFunction('size_t', mesh, 'boundary.xml.gz')
bc = DirichletBC(V, zero, subdomains, 2, 'pointwise')
But then I get this error:
*** Error: Unable to computing Dirichlet boundary values, pointwise search.
*** Reason: A SubDomain is required for pointwise search.
*** Where: This error was encountered inside DirichletBC.cpp.
Do I have to create a FacetFunction
using my mesh function for use in DirichletBC
? How would I do that? I know that the boundary meshes provided by gmsh are of dimension (mesh-1), hence Facets.
There could be other ways marking my boundary tough. I have an irregular 3D domain decomposed into tetraedra. I need to mark all boundary points except the boundary with the lowest z coordinates. Since I know which points are the lowest when generating the mesh, I thought it would be best to mark them and import this definition into FEniCS.
Related Questions that I read but still cannot put together my puzzle:
- http://fenicsproject.org/qa/8780/what-is-the-best-way-to-set-a-subdomain-to-a-given-value
- http://fenicsproject.org/qa/6267/dirichlet-boundary-condition-element-from-imported-xml-mesh
- http://fenicsproject.org/qa/2986/how-to-define-boundary-condition-for-mesh-generated-by-gmsh
- http://fenicsproject.org/qa/8918/dolfin-xml-subdomain-format