Periodic Boundary Conditions for an STL Geometry

Hey Everyone,

I am a newbie at Netgen/NGSolve. I’m currently wanting to mesh (and eventually solve!) a PDE on a geometry defined by an STL file. Because I have a large number of STL files, I intend to use the Python libraries for Netgen and NGSolve (no GUI). Currently, I create an STL file through OpenSCAD and import it using:

import netgen.libngpy as libngpy geom = libngpy._stl.STLGeometry(STL_PATH)

This enables me to import the STL geometry. I then generate a mesh using the GenerateMesh() function.

mesh = geom.GenerateMesh() 

By generating the mesh through Netgen, I’m able to select the different surfaces in my STL file. I was able to select 8 of my 10 surfaces and identified them to be Dirichlet boundary conditions. the remaining two surfaces need to be made Periodic. I can’t find a way to do this given a Mesh. The only way I can make two surfaces periodic is by identifying those surfaces in the geometry itself. But the only way to identify those surfaces is to create a Mesh and extract the points out.

[code]# creates list of length N of empty lists for N surfaces
allpoints = np.zeros(mesh.GetNFaceDescriptors(), dtype=object)
for z in range(len(allpoints)):
allpoints[z] =

for elem in mesh.Elements2D(): # adds points to the Nth list that correspond to the Nth surface
allpoints[elem.index-1].append( list(mesh[elem.vertices[0]]) )

for z, zz in enumerate(allpoints):
ptz = np.asarray(zz)
means, stds = np.mean(ptz, axis=0), np.std(ptz, axis=0)

attempts to capture the boundaries representing the hole [DIRICHLET, 4]

if np.all(abs(means)<HOLEY/2.) and abs(means[2])<THICKNESS/4.:
mesh.SetBCName(z, ‘hole’)

# attempts to capture the side edges of the plate [DIRICHLET, 4]
elif np.any(abs(means) == PLATE/2. ):
    mesh.SetBCName(z, 'faredge')

# attempts to capture the boundaries that need to be periodic [PERIODIC, 2]
elif abs(means[2]) == THICKNESS/2.:
    mesh.SetBCName(z, 'periodic')[/code]

I was wondering if someone could help me set boundary conditions accordingly for the two opposing faces in my STL file. I’ve attached my STL file for your viewing. There’s a really really small hole in the center ! The sides I want to make periodic are two sides that are normal to the z-axis…



EDIT: I’m unsure why I can’t upload my STL file, though I have no problem sending it by email or uploading it elsewhere for your viewing. I’m not sure where to upload it though without having to create an account ! :slight_smile:

I’m unsure why I can’t upload my STL file. I can send by email if need be…