Pointwise displacement in a 3 points bending test dolfinx

Hello, I am using Dolfinx and I want to apply the phase field model in a 3 points bending test. Hence, I need to use a pointwise displacement. For the moment I could not manage to do it. It executes the code but it gives zero displacements as a result. In FeniCS we used the method ‘pointwise’ but here I am quite lost about how to implement it.

V_u = VectorFunctionSpace(mesh, (“CG”, 1))

def point(x):
return np.logical_and(np.isclose(x[0], H-ag), np.isclose(x[0], 0))

points = locate_entities_boundary(mesh, 1, point)

point_dofs = locate_dofs_topological(V_u, 1, points)

bc1 = dirichletbc(Uimp, point_dofs, V_u.sub(0))

A point has dimension 0.
Thus

points = locate_entities_boundary(mesh, 0, point)

would give you vertices.

However

Should use logical_or, as you cannot be close to both 0 and H-ag, if H-ah!=0.

Thank you so much. It worked. The function point(x) had a mistake and the second part was x[1] so I kept logical_and.

Hello Sara,
I have a similar problem and tried to use your code to put a Dirichlet bc on a single vertex in my mesh. So I tried:

import numpy as np
from dolfinx import cpp, fem, mesh
from mpi4py import MPI

msh = mesh.create_rectangle(comm=MPI.COMM_WORLD,
                            points=((0.0, 0.0), (2.0, 1.0)), n=(32, 16),
                            cell_type=mesh.CellType.triangle,)
V = fem.FunctionSpace(msh, ("Lagrange", 1))

def point(x):
    return np.logical_and( np.isclose(x[0], 0.0), np.isclose(x[1], 0.0) )

point_loc = cpp.mesh.locate_entities_boundary(msh, 0, point)

However, I obtain a TypeError:

TypeError: locate_entities_boundary(): incompatible function arguments. The following argument types are supported:
    1. (mesh: dolfinx.cpp.mesh.Mesh, dim: int, marker: Callable[[numpy.ndarray[numpy.float64]], numpy.ndarray[bool]]) -> numpy.ndarray[numpy.int32]

Invoked with: <dolfinx.mesh.Mesh object at 0x7fc044c01450>, 0, <function point at 0x7fc04d1fd7e0>

It seems like there is something from with the `point(x) function. Can you please share a code snippet that works? Thank you very much.

Change this to point_loc = mesh.locate_entities_boundary(msh, 0, point)

Perfect, that solved the problem. Thanks a lot!