Manually add points to 3D OCCGeometry

Hi,

I want to manually add points to mesh vertices to a cube domain generated with OCCGeometry, like the cell[6] of this documentation for a 2D domain. Is this possible?

Thanks in advance!

yes, create an occ vertex, and glue it to the cube.

1 Like

Hi,

Thanks for your earlier help! I tried

cube =  Box(Pnt(0,0,0), Pnt(sidelength,sidelength,sidelength))

cube.faces.Min(X).name="back"
cube.faces.Max(X).name="front"

cube.faces.Min(Y).name="left"
cube.faces.Max(Y).name="right"

cube.faces.Min(Z).name="bot"
cube.faces.Max(Z).name="top"

if hrzperiodic:
   # by periodic condition, we identify the back as the front face
   # as well as the left as the right face
   cube.faces["back"][0].Identify(cube.faces["front"][0], "bf")
   cube.faces["left"][0].Identify(cube.faces["right"][0], "lr")

# mesh generation
geo = OCCGeometry(Glue([cube,Vertex(Pnt(sidelength/2,sidelength/2,sidelength/2))]))

However, I got the error when trying to generate the mesh. If I run the above code and then try to generate mesh in NGSolve, I got netgen.libngpy._meshing.NgException: Ask for unused hash-value. And if I try to use it with Firedrake, I got ValueError: Provided mesh has some entities not reachable by traversing cells (maybe rogue vertices?).

Am I using it in some wrong way?

Thanks in advance!

from firedrake import 
from netgen.occ import *
import netgen.gui
from netgen.meshing import MeshingParameters

# Define a 3D cube domain
cube = Box(Pnt(0,0,0), Pnt(1,1/2,1))
cube2 = Box(Pnt(0,1/2,0), Pnt(1,1,1))
vertex = Vertex(Pnt(1/2,1/2,1/2))

# Attempt to glue the point into the cube geometry
geo = OCCGeometry(Glue([cube,cube2,vertex]))

# Generate the mesh
mp = MeshingParameters()
ngmsh = geo.GenerateMesh(maxh=0.5, mp=mp)
msh = Mesh(ngmsh)
1 Like

the first line seems wrong :slight_smile:

1 Like