How to implement Neumann BC on points or vertices?

Hi everyone

I am solving a basic elasticity equation where I have to apply forces on some points (or some vertices) on the boundary \Gamma. Precisely,

\sigma \cdot n = g on \Gamma=\{p_1, p_2, p_3, ...\}

If you know how to implement this, please let me know.

Best regards

1 Like

Hi,

One way to do this is to modify the corresponding DOFs on the vector. I assumed you have something like
\int_{\partial\Omega} \sigma\cdot \hat{n} \, \mathrm{d} s = \int_{\partial\Omega} g \, \mathrm{d} s,
in the variational form to model the neumann boundary condition. Then in Fenics you can create the boundary force as

g = dolfin.Function(YourVectorFunctionSpace)

You can directly assign to the components of g at given points using indexing to the underlying vector i.e.

g.vector()[22] = 5.1 # If the vector function space is 2D, this assigns to the x component of the 22nd DOF
g.vector()[23] = 5.3 # this then assigns to the y component of 22nd DOF

Indexes to the function are in DOF order, so if you want to assign to specific vertices, you have to convert the vertex index to the DOF index. See
https://fenicsproject.org/qa/13595/interpret-vertex_to_dof_map-dof_to_vertex_map-function/
to see how it works.

Hope that helps

Hi Jon-Deng

Thank you very much. I will try it.

Best regards