Hi,
I was trying to test some solid mechanics problems with fenicsx/dolfinx, and I ran into a problem when trying to approximate roller-type boundary conditions. For the older versions of DirichletBC, I was able to find the post below in the old q&a.

https://fenicsproject.org/qa/1478/roller-boundary-condition/

I tried something like

u_bcl = Function(V)
with u_bcl.vector.localForm() as bc_local:
bc_local.set(0.0)

bcl = fem.DirichletBC(u_bcl,fem.locate_dofs_geometrical(V,lambda x:np.isclose(x[0],0.0)),V.sub(0))

Here V is the FunctionSpace

But this seems to be wrong. Is there a way to do this?

Thanks,
Subramanya

dokken
April 2, 2020, 12:46pm
2
The QA you looked at has a really outdated interface. Consider something like this:

```
V0 = V.sub(0).collapse()
zero = dolfinx.Function(V0)
with zero.vector.localForm() as zero_local:
zero_local.set(0.0)
def in_corner(x):
return np.logical_or(np.isclose(x.T, [0, 2, 0]).all(axis=1),
np.isclose(x.T, [1, 2, 0]).all(axis=1))
dofs = fem.locate_dofs_geometrical((V.sub(0), V0), in_corner)
bc_corner = dolfinx.DirichletBC(zero, dofs, V.sub(0))
```

Of course modify the `in_corner_expression`

to your own lambda function.

Thanks Dokken!
I will try that approach too. I ended up doing something like this, and this worked.

```
facetdim = mesh.topology.dim - 1
mf = MeshFunction("size_t", mesh, facetdim, 0)
mf.mark(lambda x: np.isclose(x[0], 1.0), 1)
bndry_facets = np.where(mf.values == 1)[0]
bdofs_y = fem.locate_dofs_topological(V.sub(0), facetdim, bndry_facets)
```

dokken
April 2, 2020, 4:03pm
4
MeshFunction is in the process of being deprecated (it is replaced by MeshTags) in dolfinx master branch, just so you know.

Ah. I will move to those. I am still in the process of parsing the various available demos and figuring things out.