Hello,
I’m new to Fenics and there’s something that seems elementary to do to me but I didn’t manage to find anything on google or this forum:
Being given a mesh, how do I get the volume of the ith triangle of the mesh ? I’ve tried this hack by defining P0 characteristic functions of each triangle of the mesh and integrating it:
VD = FunctionSpace(mesh, 'DG', 0)
characteristic = [ Function(VD) for i in mesh.cells() ]
for i,chi in enumerate(characteristic):
tmp = np.zeros((nCells))
tmp[i] = 1
chi.vector().set_local(tmp)
tArea = []
for i,chi in enumerate(characteristic):
tAreai = chi*dx
tAreai = assemble(tAreai).array()
tArea.append(tArea)
however i get the error " AttributeError: ‘float’ object has no attribute ‘array’ "
But when I replace the wrong line by
tAreai = assemble(tAreai)
the output isn’t float but someting strange (something like [[…],[…],…] )
Also I find it weird for fenics to don’t have direct access to triangle area. Could you help me ?