gmsh 中的组合平移和旋转网格划分

计算科学 网格生成 gmsh
2021-12-26 23:55:22

对于流动模拟,我试图重现啮合同向旋转双螺杆挤出机的特定螺杆元件设计。我正在使用 gmsh (v2.16),其中元素是由具有组合平移和旋转extrude命令的 2D 表面制成的。2D 表面是一个简单的形状,如下图左侧所示:

在此处输入图像描述

该形状被平移 1 个单位并旋转 360 度模拟挤出,得到右侧的形状,从而形成螺纹。

不幸的是,生成的网格包含“扭曲”,这些扭曲显示为沿着贯穿螺钉长度的挤压线的孔。

我尝试细化网格,但孔并没有消失。我如何使用这种挤压工艺获得光滑的表面?

在此处输入图像描述

几何文件:

// inputs
length = 1;
pitch = 1;
alpha_i = Pi/3; // intermesh angle [0,Pi/2]
alpha_f = alpha_i; // flight angle
alpha_t = Pi/2 - alpha_f; // tip angle
alpha_r = alpha_t; // root angle

// based on unit screw diameter
Cd = Cos(alpha_i/2);  // centerline distance
Dr = 2*Cd-1; // root diameter
Hc = 1-Cd; // channel depth
Ih = Sin(alpha_i/2)/2; // intermesh height

lc = 0.1;
offset_x = Cd/2; // from x=0
offset_y = 0; // from y=0

// first screw

c1p0 = newp; // center point 
Point(c1p0) = {-offset_x+0, offset_y+0, 0, lc};

angle = alpha_t/2;
xt1 = 1/2*Cos(angle);
yt1 = 1/2*Sin(angle);

angle = angle + alpha_f;
xr1 = Dr/2*Cos(angle);
yr1 = Dr/2*Sin(angle);

angle = angle + alpha_r;
xr2 = Dr/2*Cos(angle);
yr2 = Dr/2*Sin(angle);

angle = angle + alpha_f;
xt2 = 1/2*Cos(angle);
yt2 = 1/2*Sin(angle);

angle = angle + alpha_t;
xt3 = 1/2*Cos(angle);
yt3 = 1/2*Sin(angle);

angle = angle + alpha_f;
xr3 = Dr/2*Cos(angle);
yr3 = Dr/2*Sin(angle);

angle = angle + alpha_r;
xr4 = Dr/2*Cos(angle);
yr4 = Dr/2*Sin(angle);

angle = angle + alpha_f;
xt4 = 1/2*Cos(angle);
yt4 = 1/2*Sin(angle);

c1p1 = newp; Point(c1p1) = {-offset_x+xt1, offset_y+yt1, 0, lc};
c1p2 = newp; Point(c1p2) = {-offset_x+xr1, offset_y+yr1, 0, lc};
c1p3 = newp; Point(c1p3) = {-offset_x+xr2, offset_y+yr2, 0, lc};
c1p4 = newp; Point(c1p4) = {-offset_x+xt2, offset_y+yt2, 0, lc};
c1p5 = newp; Point(c1p5) = {-offset_x+xt3, offset_y+yt3, 0, lc};
c1p6 = newp; Point(c1p6) = {-offset_x+xr3, offset_y+yr3, 0, lc};
c1p7 = newp; Point(c1p7) = {-offset_x+xr4, offset_y+yr4, 0, lc};
c1p8 = newp; Point(c1p8) = {-offset_x+xt4, offset_y+yt4, 0, lc};

c1a = newc; Circle(c1a) = {c1p2,c1p0,c1p3};
c1b = newc; Circle(c1b) = {c1p4,c1p0,c1p5};
c1c = newc; Circle(c1c) = {c1p6,c1p0,c1p7};
c1d = newc; Circle(c1d) = {c1p8,c1p0,c1p1};

// flank areas
alpha = -1/2*((xt1-xr1)*(xt1-xr1)+(yt1-yr1)*(yt1-yr1))/(yt1-yr1);
beta = -(xt1-xr1)/(yt1-yr1);
x0 = xr1 + alpha*beta/(1+beta*beta)*(1-Sqrt(1-(1+1/(beta*beta))*(1-Cd*Cd/(alpha*alpha))));
y0 = yr1 - alpha - beta*(xr1-x0);

p = newp; Point(p) = {-offset_x+x0, offset_y+y0, 0, lc};
c1e = newc; Circle(c1e) = {c1p1,p,c1p2};

p = newp; Point(p) = {-offset_x-x0, offset_y+y0, 0, lc};
c1f = newc; Circle(c1f) = {c1p3,p,c1p4};

p = newp; Point(p) = {-offset_x-x0, offset_y-y0, 0, lc};
c1g = newc; Circle(c1g) = {c1p5,p,c1p6};

p = newp; Point(p) = {-offset_x+x0, offset_y-y0, 0, lc};
c1h = newc; Circle(c1h) = {c1p7,p,c1p8};

ll = newl; Line Loop(ll) = {c1f, c1b, c1g, c1c, c1h, c1d, c1e, c1a};
s = newl; Plane Surface(s) = {ll};

Extrude {{0,0,length}, {0,0,1}, {-offset_x, -offset_y, 0}, 2*Pi*pitch*length} {
  Surface{s};
}

更新:使用@nicoguaro 的答案,我能够在 FREECAD 中生成以下几何图形:

在此处输入图像描述

然而,如图所示,椭圆由曲线连接,这些曲线实际上应该是直线。通过添加更多切片进行细化可以改善这一点,但也会显着增加计算成本。这只是包含大约 30 个这些元件的螺杆中的一个螺杆元件。这很快变得太多而无法渲染。无论如何用直线而不是曲线连接?

2个回答

我无法使用 Gmsh 正确可视化您的几何图形,或将其导出。我使用 FreeCAD 生成了类似的东西。也许您可以根据自己的目的修改此脚本。

from __future__ import division, print_function
import FreeCAD as FC
import Draft
from numpy import sin, cos, pi

nturns = 1
nslices = 20
length = 10
width = 20
height = 60
dz = height/nslices
place = FC.Placement()
dang = 2*pi*nturns/(nslices - 1)
slices = []
for k in range(nslices):
    ang = k*dang
    place.Rotation = (0, 0, sin(ang/2), cos(ang/2))
    place.Base = FC.Vector(-length/2, -width/2, k*dz)
    slices.append(Draft.makeEllipse(10, 20, place))

doc = FC.ActiveDocument
loft = doc.addObject('Part::Loft','Loft')
loft.Sections = slices
loft.Solid = True
loft.Ruled = True

我真的会为您复杂的几何图形使用商业工具。我建议 Comsol。

我知道这并不能直接回答您的问题,但是我最近一直在考虑您的问题(我需要为非平凡的几何体创建 3D 网格),并且我浪费了很多时间来编写适当的 .geo 文件。最后,Gmsh 甚至无法将 3D 网格重新组合成四面体。

另一方面,我几乎可以立即使用 Comsol 生成所需的网格。