CellSize(mesh) value for each mesh element


101
views
0
4 months ago by
Hello,
I am trying to get CellSize(mesh) value for each single cell by:

mesh = UnitSquareMesh(2, 2)
h = []
for i in range(mesh.num_cells()):
h[i] = CellSize(mesh)[i]
print h​

But it returns error
Thanks in advance for help!

Community: FEniCS Project

1 Answer


3
4 months ago by
Hi,
the CellSize() method returns you a ufl object of the mesh sizes to easily implement in your variational forms but is not iterable. To get what you are after, consider the following MWE
from dolfin import *
mesh = UnitSquareMesh(2,2)

# Iterate over cells to get circumradius/area/...
h = []
for cell in cells(mesh):
    h.append(cell.circumradius())

print(h)
Applying your code, I get this error:
AttributeError: 'Cell' object has no attribute 'circumradius'
written 4 months ago by Mohammad Sarraf Joshaghani  
Hmm, which dolfin version are you using?
written 4 months ago by Jakob Maljaars  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »