Gmsh: Petal Interface花瓣界面

给出一个生成花瓣界面网格的GMSH示例。花瓣界面的网格可用于验证求解二阶椭圆界面问题的算法的有效性,利用Gmsh内置的脚本文件可以轻易生成具有复杂形状的界面,这使得Gmsh成为生成各种网格的一个非常实用工具。

下面给出具体示例。目的是在区域上生成一个五叶花瓣界面,其表达式如下:

.

容易知道其外法向量为, 这里. 其图形如下图所示.
gmsh-petal1gmsh-petal2
生成图2的脚本文件如下所示, 这里要注意两个地方:1.生成五叶花瓣的循环;2. Coherence去掉重复的点.

/*
	To generate petal interface in square [-1,1]^2, and the interface is parametrized with the polar angle 'theta' [1]: 
	r = 1/2 + Sin( 5* theta ) / 7, [0, 2*pi].
	
	Remark 1. To make use of data conviencely, we label one Physical entities usually outer part) as '1' and another one (usually interior part)as '2';
										--Numanal 2016/07/10
Reference:
	[1] Lin Mu,Junping Wang, etc, Weak Galerkin methods for second order elliptic interface problems, J. comp. phy. 250(2013) 106-125.
*/
ls = .2/2^0;
nPoints = 9;	// Number of points in one petal
start = Pi/2-2*Pi/10;  end = Pi/2+2*Pi/10;
step = (end-start)/(nPoints-1);

Point(1) = {-1,-1,0,ls}; Point(2) = {1,-1,0,ls};
Point(3) = {1,1,0,ls};	Point(4) = {-1,1,0,ls};

Line(1) = {1,2}; Line(2)={2,3}; Line(3)={3,4}; Line(4)={4,1};

For k In {0:4}   // Five petal
    start = Pi/2-Pi/5 + k*2*Pi/5;    // the Position of each petal
    For i In {0:nPoints-1}    
	    theta = start + step*i;
        pList[i] = newp;
        Point(pList[i]) = {(0.5+Sin(5*theta)/7)*Cos(theta), 
                            (0.5+Sin(5*theta)/7)*Sin(theta),0,ls};
    EndFor
    Spline(newl) = pList[];  //Creates spline curve, i.e., a petal.
EndFor
Coherence; //Delete all duplicate elementary geometrical entities(Points here).

Line Loop(11) = {5,6,7,8,9}; Plane Surface(12) = {11};
Line Loop(13) = {1,2,3,4};   Plane Surface(14) = {13,11};
Physical Surface(1)={14};   //outer part '1'
Physical Surface(2)={12};   //interior part '2'