calculate boundary mesh facet area cell by cell. Currently getting error message
6 months ago by
from dolfin import * import time import numpy as np #define domain x_min = y_min = z_min = 0.0 x_max = y_max = z_max = 1.0 #define number of elements nx = ny = 1 nz = 1 #create mesh mesh = BoxMesh(Point(x_min, y_min, z_min), Point(x_max, y_max, z_max), nx, ny, nz) # define function space V = FunctionSpace(mesh, 'P', 1) #define boundary def boundary_sides(x, on_boundary): return near(x,x_min) or near(x,x_max) or near(x,y_max) or near(x,y_min) bmesh = BoundaryMesh(mesh, 'exterior') # calculate array of boundary faces normal vectors cell_map = bmesh.entity_map(2) norm_array =  f_area =  msg = 'Cell %d in bmesh(%d in mesh) has normal %r' for bci, cell in enumerate(cells(bmesh)): n = cell.cell_normal().array() print(msg % (bci, cell_map[bci], list(n))) norm_array.append(list(n)) #**problem calculate area of boundary faces cell by cell for i, cell in enumerate(cells(bmesh)): area = cell.facet_area().array() f_area.append(list(area))
TypeError: Cell_facet_area expected 2 arguments, got 1
I am unsure as to the second argument required.
The end goal is to have an array of boundary areas stored to correspond with the array of normals so I can push these to a C function
Thanks in advance!
Community: FEniCS Project
6 months ago by
seems to work for me, and give the correct answer of all 0.5s for the 12 outer triangular facets of the 1x1x1 box mesh. Since it's already a boundary mesh, you want the "generalized volume" of the cells, which is area for 2D boundary facets.
#**problem calculate area of boundary faces cell by cell for i, cell in enumerate(cells(bmesh)): area = cell.volume() f_area += [area,] print f_area
Please login to add an answer/comment or follow this question.