Hi,
I am trying to set a condition for where to refine the mesh and I'm getting the following error message:
if phi0(p) < 0.05 and phi0(p) > -0.05:
File "C:\FEniCS\lib\site-packages\dolfin\functions\function.py", line 342, in
__call__
raise TypeError, "expected scalar arguments for the coordinates"
TypeError: expected scalar arguments for the coordinates
I have obtained the function phi0 by solving a PDE, and I would like to refine the mesh in all cells where this function attains values between -0.05 and 0.05. The corresponding piece of code is:
cell_markers = CellFunction("bool", mesh)
cell_markers.set_all(False)
for cell in cells(mesh):
p = cell.midpoint()
if phi0(p) < 0.05 and phi0(p) > -0.05:
cell_markers[cell] = True
mesh = refine(mesh, cell_markers)
Should I be addressing the cells in a different way? I could use a subdomain definition to cover the range for phi0 but the problem is it would overlap with my defined subdomains. Is there a way out?
Many thanks,