Hi, I am trying to use this function with no success. here is my code so far. It builds a helical coil and bounding box and then I try to make the top and bottom faces of the box periodic. I would like both entire faces to be periodic. what I mean is that part of each has an interior face of the intersection of the coil with the box face.
I’ve determined, with the netgen webgui, which face numbers these are so 4 and 2 are bigger parts of the box faces I need to correspond. 7 and 8 are the respective smaller faces representing the ends of the coil.
from ngsolve import *
from netgen.occ import *
import math
from netgen.meshing import IdentificationType
from ngsolve.webgui import Draw
from netgen.webgui import Draw as DrawGeo
r = 0.01
h = 0.06
extra = h / 2
# cyl = (base pt, axis dir, radius, height)
cyl = Cylinder((0, 0, 0), Z, r, h).faces[0]
extracyl = Cylinder((0, 0, -extra), Z, r, h + 2 * extra).faces[0]
seg = Segment((0, 0), (2 * math.pi, h))
seg2 = Segment((0, 0), (4 * math.pi, 2 * h))
tseg = seg.Edge()
heli = Edge(seg, cyl)
heli2 = Edge(seg2, extracyl)
spiral = Wire([heli])
spiral2 = Wire([heli2])
piperadius = 0.003
circ = Face(Wire([Circle(heli.start, heli.start_tangent, piperadius)]))
coil = Pipe(spiral, circ)
circ2 = Face(Wire([Circle(heli2.start, heli2.start_tangent, piperadius)]))
coil2 = Pipe(spiral2, circ2)
box = Box((r * 3, r * 3, 0), (-r * 3, -r * 3, h))
coilfinal = coil2 - (coil2 - box)
air = box - coilfinal
geo = Glue([air, coilfinal])
# trans = Translation(h*Z)
geo.faces[8].Identify(geo.faces[7], "periodic", IdentificationType.PERIODIC)
geo.faces[4].Identify(geo.faces[2], "periodic", IdentificationType.PERIODIC)
# %%
# geo = OCCGeometry(boxandcoilmain)
geo = OCCGeometry(geo)
mesh = Mesh(geo.GenerateMesh(meshsize.coarse, maxh=0.3)).Curve(3)
Draw(mesh, clipping={"y": 1, "z": 0, "dist": 1.14})
If a python notebook version of this is preferred, I can post that too…
I have tried adding a transformation arg into the call. the one I use is seen commented out above the first Identify call. I don’t see any identified points when I turn that option on in the mesh settings.
also, i have shown that the identification/periodicity works if the pipe is straight but only on outer faces 2 and 4. the inner faces 7 and 8 do not work even in that base case even when those are the only two I try to match. here is the extra code for that which depends on the code above up to including the definition of coilfinal.
# the following is a way to confirm that the box cuts the coil at
# exactly one turn so that the end cap faces end up aligned. I extrude from
# one to the other linearly in z dir
p = coilfinal.faces[1].Extrude(h * Z)
pview = OCCGeometry(p)
straightcoil = p - (p - box)
air2 = box - straightcoil
straightexample = Glue([air2, straightcoil])
straightexample.faces[7].Identify(straightexample.faces[8], "periodic",
IdentificationType.PERIODIC)
straightexample.faces[2].Identify(straightexample.faces[4], "periodic",
IdentificationType.PERIODIC)
geoOCC = OCCGeometry(straightexample)
mesh = Mesh(geoOCC.GenerateMesh(meshsize.coarse, maxh=0.3)).Curve(3)
Draw(mesh, clipping={"y": 1, "z": 0, "dist": 1.14})
Thanks for your help.
Micron Jenkins