Hey guys!
I am currently trying to generate a mesh, that consists of two geometries previously imported from two STEP-files. Both of these files are attached.
After importing, I cut out a hole of both geometries seperately and I name their surfaces.
The question now is, wether it is possible to generate a mesh, containig both geometries(they should fit together perfectly) with individual mesh sizes?
Gleitlager_D48mm_w17mm_gap.step (13.6 KB)
Gleitlager_D48mm_w17mm_top.step (18.6 KB)
Here is my code:
from netgen.occ import *
from ngsolve import *
import pyngcore as ngcore
D = 48 * 10**-3
R = D / 2
d = 46 * 10**-3
r = d / 2
w = 17.5 * 10**-3
epsilon = 0.5
e = epsilon * (R - r)
max_mesh_gap = 500 * 10**-6
max_mesh_top = 1000 * 10**-6
scale = 10**3
# Import geometry
step_geo_top = OCCGeometry(str(file_step_top))
step_geo_gap = OCCGeometry(str(file_step_gap))
# Get geometry as shape
# The imported STEP-file is in meters, therefore some downscaling needs to be done.
shape_top = step_geo_top.shape
shape_top = shape_top.Scale(Pnt(0, 0, 0), 10**-3 / scale)
shape_gap = step_geo_gap.shape
shape_gap = shape_gap.Scale(Pnt(0, 0, 0), 10**-3 / scale)
# Fuse the geometries
# shape = shape_top + shape_gap
# Define position and direction of shaft
start_point_shaft = Pnt(0, -e, w/2)
direction_shaft = Vec(0, 0, -1)
# Create shaft
shaft = Cylinder(gp_Ax2(start_point_shaft, direction_shaft), r, w)
shaft.faces[0].name = 'inside'
# Create bearing geometry
# bearing = shape - shaft
lub_top = shape_top - shaft
lub_gap = shape_gap - shaft
# Create final geometry
geo_top = OCCGeometry(lub_top)
geo_gap = OCCGeometry(lub_gap)
# Give names to surfaces
geo_top.shape.faces.Max(Z).name = 'front'
geo_top.shape.faces.Min(Z).name = 'back'
geo_gap.shape.faces.Max(Z).name = 'front'
geo_gap.shape.faces.Min(Z).name = 'back'
for face in geo_top.shape.faces:
if face.name == 'front' or face.name == 'back':
face.col = (1, 0, 0)
elif face.name == 'inside':
face.col = (0, 0, 1)
else:
face.name = 'outside'
face.col = (0, 1, 1)
# print(face.name)
for face in geo_gap.shape.faces:
if face.name == 'front' or face.name == 'back':
face.col = (1, 0, 0)
elif face.name == 'inside':
face.col = (0, 0, 1)
else:
face.name = 'outside'
face.col = (0, 1, 1)
# print(face.name)
# Visaulize geometry
Draw(geo_top)
print('\nGeometry finished\n')
# Generate meshes
ngcore.SetNumThreads(numProc)
with ngcore.TaskManager():
mesh_top = Mesh(geo_top.GenerateMesh(maxh=max_mesh_top))
ngcore.SetNumThreads(numProc)
with ngcore.TaskManager():
mesh_gap = Mesh(geo_gap.GenerateMesh(maxh=max_mesh_gap))
# Visualize mesh
Draw(mesh_gap)
print('\nMesh finished\n')
print('\nSuccess! Finished Executing!\n')
Thank you very much for your help!
Best Boindil