Get the nodes for a specific surface in a specific boundary entity
Hello,
I am trying to calculate the area of each wall/floor surface of the room.
The room has 6 surfaces and I would like to create a dictionary with as key the entity of the surface and as value the total area of the surface. I have a room 8x8x8 for simplicity and therefore each wall/floor surface area should be 64 m^2. I have included my code below and explained it with comments. In my opinion, the problem is in this line
face_nodes= gmsh.model.mesh.getElementFaceNodes(2, 3)
This line should get the nodes of each small triangle composing the big wall/floor surface. So, if entity number 1 (floor) is composed by 26 triangles, each with its own tag, I want to get the nodes per each face.
surface_areas = {} #dictionary for each surface area of the room.
for entity in range(0:6):
triangle_faces, _ = gmsh.model.mesh.getElementsByType(2, entity) #Get all the triangle faces for the current surface
surf_area_tot = 0
for face in triangle_faces: #for each face in all the list of triangle faces. then
face_nodes= gmsh.model.mesh.getElementFaceNodes(2, 3) #get the nodes of the face with its own tag (for example tag 37)
#Get the coordinates of the nodes of the face
c0 = gmsh.model.mesh.getNode(face_nodes[0])[0] #coordinates of vertix 0
c1 = gmsh.model.mesh.getNode(face_nodes[1])[0] #coordinates of vertix 1
c2 = gmsh.model.mesh.getNode(face_nodes[2])[0] #coordinates of vertix 2
face_area = 0.5 * np.linalg.norm(np.cross(c1 - c0, c2 - c0)) #Compute the area using half of the cross product's magnitude
surf_area_tot += face_area #add the face area in the total surface area
surface_areas[entity] = surf_area_tot #use the surface area calculated as a value in the surface_areas dictionary per each entity.
The problem with the above code is that the total surface area for each surface is 67.2 m^2. This is incorrect.
Is there a way to get the nodes for each triangle face in a surface?
Thank you