Previous Up Next
Previous: 3.3.1 Triangulations
Up: 3.3 Building a mesh
Next: 3.3.3 Geometric variables, inner and region bdy, normal

3.3.2 Border(), buildmesh(), polygon()

Use it to triangulate domain defined by its boundary. The syntax is
 
border(ib,t_min,t_max,nb_t)
 begin  
  ...x:=f(t);
  ...y:=g(t)...
 end;
buildmesh(nb_max);
where each line with border could be replaced by a line with polygon
polygon(ib,'file_name'[,nb_t]); 
where f,g are generic functions and the [...] denotes an optional addition. The boundary is given in parametric form. The name of the parameter must be t and the two coordinates must be x and y . When the parameter goes from t_min to t_max the boundary must be scanned so as to have Omega on its left, meaning counter clockwise if it is the outer boundary and clockwise if it is the boundary of a hole. Boundaries must be closed but they may be entered by parts, each part with one instruction border , and have inner dividing curves; nb_t points are put on the boundary with values t = tmin + i * (tmax - tmin) / (nbt-1) where i takes integer values from 0 to nb_t-1 .

The triangulation is created by a Delaunay-Voronoi method with nb_max vertices at most. The size of the triangles is monitored by the size of the nearest boundary edge. Therefore local refinement can be achieved by adding inner artificial boundaries.

Triangulation may have boundaries with several connected components. Each connected component is numbered by the integer ib .

Inner boundaries (i.e. boundaries having the domain on both sides) can be useful either to separate regions or to monitor the triangulation by forcing vertices and edges in it. They must be oriented so that they leave Omega on their right if they are closed. If they do not carry any boundary conditions they should be given identification number ib=0 .

The usual if... then ... else statement can be used with the compound statement: begin...end . This allows piecewise parametric definitions of complicated or polygonal boundaries.

The boundary identification number ib can be overwritten.For example:

border(2,0,4,41) begin
   if(t<=1)then  {  x:=t; y:=0 };
   if((t>1)and(t<2))then {  x:=1; y:=t-1; ib=1 };
   if((t>=2)and(t<=3))then  { x:=3-t; y:=1 };
   if(t>3)then { x:=0; y:=4-t }
end;
buildmesh(400);

Recall that begin and { is the same and so is end and }. Here one side of the unit square has ib=1. The 3 other sides have ib=2.

The keyword polygon causes a sequence of boundary points to be read from the file file_name which must be in the same directory as the program. All points must be in sequential order and describing part of the boundary counter clockwise; the last one should be equal to the first one for a closed curve.

The format is

x[0]    y[0]
x[1]    y[1]
....
each being separated by a tab or a carriage return. The last parameter nb_t is optional; it means that each segment will be divided into nb_t1+ equal segments (i.e. nb_t points are added on each segments).

For example

polygon(1,'mypoints.dta',2);
buildmesh(100);
with the file mypoints.dta containing
0.      0.
1.      0.
1.      1.
0.      1.
0.      0.
triangulates the unit square with 4 points on each side and gives ib=1 to its boundary. Note that polygon(1,'mypoints.dta') is like polygon(1,'mypoints.dta',0).

3.3.2.1 buildmesh and domain decomposition

There is a problem with buildmesh when doing domain decomposition: by default Gfem swap the diagonals at the corners of the domain if the triangle has two boundary edges. This will lead to bad domain decomposition at the sub-domain interfaces.

To solve this, there is a new flag for buildmesh which is optional:

buildmesh(<max_number_of_vertices>, <flag>)
where <flag> =


Christophe Prud'homme

Previous Up Next