This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Get normal component of a 3D vector field.

+1 vote

Hello,

I have extracted the boundary of a vector field from a 3D mesh, and need the normal component of this field. Unfortunately, the FacetNormal is only defined over the edge of the 2D mesh, and I do not see a way to convert the FacetNormal from the 3D mesh to a numpy array or Function which I can then interpolate onto the 2D mesh.

Does anyone know how I can get the component of the vector field normal to the 3D mesh?

Thanks!

Here is the vector field on the 2D mesh :

output

asked Dec 25, 2015 by pf4d FEniCS User (2,970 points)

1 Answer

+1 vote

Hi!

Answering my own question, as shown here in 2012, we can get the normal component by solving the projection manually. The important step is to set the diagonal of the matrix of all interior nodes to 1.

# d3model.V is a 3D VectorFunctionSpace
phi  = TestFunction(d3model.V)
du   = TrialFunction(d3model.V)

n    = d3model.N          # normal vector
u    = d3model.U3         # computed velocity vector
dLat = d3model.dLat_d     # lateral boundary of interest
u_t  = u - dot(u, n)*n    # tangential component of velocity
a_n  = inner(du,  phi) * dLat
L_n  = inner(u_t, phi) * dLat
A_n  = assemble(a_n, keep_diagonal=True)
B_n  = assemble(L_n)
A_n.ident_zeros()         # set interior dofs from 0 to 1
u_t  = Function(d3model.V)
solve(A_n, u_t.vector(), B_n)

As I really only needed the normal component to determine the tangential component, this is what I've computed and shown here, after using LagrangeInterpolator to interpolate onto a SubMesh of the 3D BoundaryMesh :

output

answered Dec 25, 2015 by pf4d FEniCS User (2,970 points)
edited Dec 26, 2015 by pf4d
...