Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Periodic Boundary Conditions for an STL Geometry

More
1 year 10 months ago - 1 year 10 months ago #4435 by agupta87
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:

Code:
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.

Code:
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')


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..

Thanks,

Adyota

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 ! :-) 
Last edit: 1 year 10 months ago by agupta87.
Time to create page: 0.112 seconds