How to compute the facet normal vectors (not symbolic normals)
7 months ago by
I am attempting to compute the facet normal vectors of my mesh to dot with the gradient of a heat equation to calculate the flux (these vectors would be used in a c function to calculate neumann conditions and applied to the RHS of the equation)
In a very simple model below I try and find the normal vectors but only get "n"
from dolfin import * import time import numpy as np #define domain x_min = y_min = z_min = 0.0 x_max = y_max = 1.0 z_max = 1.98/5.0 #define number of elements nx = ny = 1 nz = 1 #define number of plot steps plot_steps=50 #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) b = FacetNormal(mesh) print('size b', len(b)) print('type b', type(b)) print('b = ', b)
this is what I get:
size b 3 type b <class 'ufl.geometry.FacetNormal'> b = n
Any help would be greatly appreciated.
Community: FEniCS Project
6 months ago by
face_numbers=mesh.num_faces() i = 0 while i < face_numbers: b_f = Facet(bmesh,i) n = [b_f.normal().x(), b_f.normal().y(), b_f.normal().z()] #print('type n', type(n)) print('node # =', i,' ','n = ', n) #print('size n', len(n)) i=i+1
7 months ago by
The notion of a FacetNormal at a node is ambiguous, that's why a FacetNormal can only be evaluated in facet integral expressions (or lines on 2D meshes).
Another idea is to evaluate an integral of the FacetNormals over the facets and normalize using the cell-size. That expression could then be projected onto the nodes.
Please login to add an answer/comment or follow this question.