Defining a subdomain consisting of a single vertex

Is it possible to create a mesh that contains a named subdomain consisting of one vertex? I would like to set a “dirichlet” condition at a single vertex.

I already know how to take the BitArray of Freedofs and clear one bit to do this. That works fine. However, it would be nice to create a (surface) mesh that has a specific point as a vertex in it. And to “name” that vertex so that I could impose it as a dirichlet condition, possibly using bbnd_dirichlet=“name”, or maybe it should be bbbnd_dirichlet=“name”, within the definition of the finite element space. Is this possible?

p.s. This is not for a 2nd order elliptic problem. I know that setting point conditions can be problematic there.

-Shawn

Yes, it is possible !

You name vertices in the OCC - geometry, and then you can ask for mesh.GetBBBoundaries(), and mesh.BBBoundaries(“V1”), and the bbbnd_dirichlet works as well.

Joachim

That’s great. But how do you name vertices in the OCC geometry? I couldn’t find that.

-Shawn

it’s the same way as you name edges and faces, here is a complete example:

from ngsolve import *
from netgen.occ import *

shape = Box((0,0,0), (1,1,1))
shape.vertices.Max(X+Y+Z).name="V1"
shape.vertices.Nearest( (0,0,0) ).name="V2"
mesh = Mesh(OCCGeometry(shape).GenerateMesh(maxh=0.5))

print (mesh.GetBBBoundaries())
r = mesh.BBBoundaries("V1")
print (r.Mask())

fes = H1(mesh, order=1, dirichlet_bbbnd="V2")
print (fes.FreeDofs())

Ok, but suppose I want a sphere surface mesh (radius=1, centered at origin), and I want (0,0,1) to be a vertex in the mesh that gets generated. Can I still do that? The example above seems to imply that the only available vertices are the corners of the box.

You create a vertex - shape, and glue it to the sphere

sp = Sphere( (0,0,0), 1)
x = 0.3
y = 0.5
z = sqrt(1-x**2-y**2)
v = Vertex( (x,y,z) )
v.name = "V"
shape = Glue([sp, v])
mesh = Mesh(OCCGeometry(shape).GenerateMesh(maxh=0.5))

Ok, thank you. That was not obvious.

-Shawn

I tried this (I’m making a surface mesh):

sp = Sphere( (0,0,0), 1).faces[0]
sp.name = “sphere”
x0 = 0.3
y0 = 0.5
z0 = sqrt(1 - x0^2 - y0^2)
p0 = Vertex( (x0,y0,z0) )
p0.name = “P0”
surf0 = Glue([sp, p0])
surf0.name = “sphere”

and then I mesh it:

mesh = Mesh(OCCGeometry(surf0, dim=3).GenerateMesh(maxh=maxh))

and it does create a vertex labeled “P0”. But when I look at the coordinates of that point, it is NOT (0.3, 0.5, z0). Not even close. Is it possible to force that point to be a vertex in the mesh?

Just to recap, I have tried creating a 3-D box mesh with a diagonal line segment “glued” to it. When I draw the shape, I can see that line segment. But the generated mesh does not conform to it.

So this feature is not implemented, right? You can’t force netgen to create a mesh that conforms to a given vertex or line segment (in 3-D for instance). I just want to be sure I’m not missing something.

p.s. I know you can have embedded subdomains (of the same dimension) with a conforming mesh. I have seen that example.

hi,
the point in the surface is working now, this was a bug in mesh compressing when first meshing attempt failed:

yes, you are right, floating edges are not supported (yet).

Thanks a lot!

-Shawn