Right way to evaluate a function at the vertices
1.Introduction
For a linear elastic material I want to determine the displacements at the vertices.
Using some custom code geometry (polygons) are generated, then meshed using Tetgen.
This mesh is then converted to a Dolfin XML Mesh (which is undocumented?), this is done
with some custom code (for convenience) but is otherwise identical to dolfin-convert.
The displacements are determined using the usual u(mesh.
is presented in the Fenics book. For some meshes evaluating the displacement results
in an error for one or more vertices. These meshes are all based on the same simple geometry,
errors occur when the mesh is finer (more vertices).
As usual the displacements can be found by solving the linear variational problem:
mesh = Mesh("mesh.xml") #dolfin xml mesh
V = VectorFunctionS
## As usual boundary conditions, forces are applied,
## equations for the linear elastic problem are specified,
## nothing special happening. Omitted for readability.
u = Function(V)
problem = LinearVariation
solver = LinearVariation
solver.
solver.solve()
After solving, the function u contains the displacements for functionspace(V).
Now there are a couple of ways to determine the displacements at the vertices.
2. Function evaluation
As said, the function evalution method as presented in the Fenics book (pg.192)
can be used. This is done for all vertex coordinates in the mesh:
meshCoordinates = mesh.coordinates()
for n in range(meshCoord
displacement = u(meshCoordinat
3. Errors
For fine meshes (based on the same simple geometry) with more vertices (more than
400, but might be different for other geometry) the following error occurs when
evaluating u:
*** Error: Unable to evaluate function at point.
*** Reason: The point is not inside the domain. Consider setting "allow_
*** Where: This error was encountered inside Function.cpp.
After setting parameters[
*** Error: Unable to perform call to DOLFIN function %s.
*** Reason: The function compute has not been implemented (in compute line 87118088).
*** Where: This error was encountered inside log.h.
This problem occurs always for the same vertices, though inspection of the mesh doesn't
indicate any reasons why that vertex is problematic.
4. Possible PVD / DOF method
Displacements at the vertices can also be obtained by exporting to pvd:
pvd = File("displacem
pvd << u
Similar for dolfin xml:
xml = File("displacem
xml << u
Exporting to pvd goes without errors. So I expect the file to contain the
problematic vertex displacement, although I haven't checked.
Exporting to xml gives a file with displacements at the DOFs, also without
issuing an error. I believe this is similar to u.vector()[n], but I'm unsure
how to calculate vertex values from DOF values.
5.
Can anyone reflect on why u(mesh.
and how to properly evaluate the vertex displacements? Also it would be
equally useful if I know how to convert from the DOF to vertex values.
Thank you!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Anders Logg
- Solved:
- Last query:
- Last reply: