Skip to content

Instantly share code, notes, and snippets.

@mhochsteger
Created April 4, 2022 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhochsteger/dd2ffb5e04cefa39ba7a13f010094dea to your computer and use it in GitHub Desktop.
Save mhochsteger/dd2ffb5e04cefa39ba7a13f010094dea to your computer and use it in GitHub Desktop.
Netgen closesurface identification with Netgen
from netgen.occ import *
from netgen.meshing import IdentificationType
box = Box((0,0,0),(1,1,1))
plate = Box((0,0,0.48),(1,1,0.52)).mat("plate")
air = (box-plate).mat("air")
plate.faces.Min(Z).Identify(plate.faces.Max(Z), name="plate_identification", type=IdentificationType.CLOSESURFACES)
shape = Glue([plate,air])
geo = OCCGeometry(shape)
nmesh = geo.GenerateMesh(maxh=0.3)
slices = [2**(-i) for i in reversed(range(1,6))]
nmesh.ZRefine("plate_identification", slices)
from ngsolve import *
mesh = Mesh(nmesh)
Draw(mesh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment