Setting a point value

I have searched the forum, but didn’t find this topic.

I am using H1 elements in 2D and want to set my solution to have u=0 at a point in the mesh (I know this is odd but the trace of the solution is H1 on a portion of a curve in 2D and hence talking about a point value is allowed!). I could see two ways but lack a detailed knowledge of BGSpy

  1. I thought to tag a single point and use a dirichlet=“point” when building the space, but how?
  2. or I could use a Lagrange multiplier but don’t see how to build the constraint using SymbolicBFI.

Any suggestions would be gratefully received!



There is a bbnd flag for H1 space, where you can prescribe point values.
You shall add the point in your mesh, and give it a flag. Then, you can set the value using
.Set(***, definedon=mesh.BBoundaries(“…”))
See attachment for a minimal example.


Attachment: 590a61793dbf9191e380b7d47926442e

Here the point shall be the node of the mesh. I think you can postprocess the mesh to include this point.

If you generate the mesh by hand, you already have the target node id number, then the following line provide this node with a name tag,


This is a co-dimension 2 tag for a point in 2D mesh.

With H1(mesh, dirichlet_bbnd=“name”), you are restricting the H1 DOF on this node to be a dirichlet DOF.



Another note, if you are using the new python-occ interface you can set a name for the vertex in the geometry like with any other shape object (solids, faces, edges) and then call it with the syntax Gousheng posted.
This allows for a nicer syntax for example something like this:

shape.edges["leftboundary"].vertices.Max(Y).name = "special_vertex"
u.Set(1, definedon=mesh.BBoundaries("special_vertex"))