Get a modified displacement vector

Hello,

I have a function that computes a bundary such as:

def mors(x):
    return np.logical_and(x[0]> L-L_MORS/2, 
                         np.logical_or(np.isclose(x[1], D_MORS/2),
                                       np.isclose(x[1], -D_MORS/2)
                                      )
                         )

and I would like to get a modified displacement Function ud that have the same values as the displacement Function u on this boundary and is zero elsewhere. I thought about using interpolate but is there a more elegant/direct way?
Thanks a lot.

Use dirichletbc and dolfinx.fem.set_bc, see: DirichletBC with mesh tags in dolfinx - weird behavior - #2 by dokken

i see that you use locate_dofs_topological. Shouldn’t I use locate_dofs_geometrical with my boundary function mors?
thanks again.

You can of course use locate_dofs_geometrical if you want to do that.
You can also use locate_boundary_entities with your mors function, and then use locate_dofs_topological.

1 Like