values of Function at specific points
I have a simple question, that is due to my inexperience with both Python and FEniCS. The following code causes the error shown. I am expecting the result from eval should be a scalar value for the Function evaluated at the specified point, but the eval function requires a numpy.array(float) according to the documentation, which I can not seem to initialize correctly.
In the end, I want an array of the values of phi for each vertex in the cell, from which I can perform a test to assign the cell to a subdomain. I would appreciate any help or suggestions getting this working.
--- ERROR -------
TypeError: contiguous numpy array of 'double' expected. Make sure that the numpy array is contiguous and uses dtype='d'.
--- CODE -------
from dolfin import *
import numpy
# Create mesh and phi Function
mesh = Rectangle(-1.0, -1.0, 1.0, 1.0, 1, 1)
phi_space = FunctionSpace(mesh, "DG", 1)
phi_init = Expression("x[0]")
phi_old = Function(phi_space)
phi_old.
# Locate the interface, label cells as subdomain 1
for c in cells(mesh):
for v in vertices(c):
values = numpy.array([0])
phi_old.
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
This question was reopened
Can you help with this problem?
Provide an answer of your own, or ask Andrew E Slaughter for more information if necessary.