I'm searching for a way to generate a mesh that consists mostly of the same elements and i mean not only the same type, but the exact same size to ease the FEM-calculation.
Is there a particular algorithm or software package i should look into?
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It only takes a minute to sign up.
Sign up to join this communityI'm searching for a way to generate a mesh that consists mostly of the same elements and i mean not only the same type, but the exact same size to ease the FEM-calculation.
Is there a particular algorithm or software package i should look into?
Generating exactly the same elements is not entirely straightforward, and algorithms marching cubes-like algorithms might be needed to make the mesh-generation process completely automatic. However, as mentioned in the comments, you will not be able to capture arbitrary boundaries with that.
Depending on your goals, you might decide to help the mesher software to generate the conformal mesh that satisfies both requirements: as little sizes/orientations of the elements as possible, and conformal to the boundary. I will use GMSH as a software of choice.
Consider, the following 2-D example that you want to mesh:
Here, we have a challenge of capturing the boundary at the bottom, but a lot of the potential to have a "structured mesh" in the top half (which is a square).
Attempt 1: just use the characteristic length at the points of the geometry and rely on the mesher's best effort:
cl=0.1; z=0.;
Point(1) = {0.5,0.5,z,cl};
Point(2) = {-0.5,0.5,z,cl};
Point(3) = {-0.5,-0.5,z,cl};
Point(4) = {0.5,-0.5,z,cl};
Point(6) = {0.0, -0.5, z, cl};
Line(1)={1,2};
Line(2)={2,3};
Line(4)={4,1};
Circle(5) = {3,6,4};
Line Loop(1) = {1,2,5,4};
Plane Surface(1) = {1};
Unfortunately, the mesher created a mesh that certainly does not satisfy the requirement of "same-size" triangles.
Attempt 2: specify structured mesh in an obvious region:
cl=0.1; z=0.;
Point(1) = {0.5,0.5,z,cl};
Point(2) = {-0.5,0.5,z,cl};
Point(3) = {-0.5,-0.5,z,cl};
Point(4) = {0.5,-0.5,z,cl};
Line(1)={1,2}; Transfinite Line{1} = 10;
Line(2)={2,3}; Transfinite Line{2} = 10;
Line(3)={3,4}; Transfinite Line{3} = 10;
Line(4)={4,1}; Transfinite Line{4} = 10;
Line Loop(1) = {1,2,3,4};
Plane Surface(1) = {1}; Transfinite Surface{1};
Point(6) = {0.0, -0.5, z, cl};
Circle(5) = {3,6,4};
Line Loop(2) = {5,-3};
Plane Surface(2) = {2};
Now, in one region, the mesh consists of exactly the same triangles and is conformal to the mesh in the other region.
Can we do better?
Attempt 3: manually add another region with a specified mesh:
cl=0.1; z=0.;
Point(1) = {0.5,0.5,z,cl};
Point(2) = {-0.5,0.5,z,cl};
Point(3) = {-0.5,-0.5,z,cl};
Point(4) = {0.5,-0.5,z,cl};
Line(1)={1,2}; Transfinite Line{1} = 11;
Line(2)={2,3}; Transfinite Line{2} = 11;
Line(3)={3,4}; Transfinite Line{3} = 11;
Line(4)={4,1}; Transfinite Line{4} = 11;
Line Loop(1) = {1,2,3,4};
Plane Surface(1) = {1}; Transfinite Surface{1};
Point(10) = {-0.4,-0.5,z,cl};
Point(11) = {0.4,-0.5,z,cl};
Point(12) = {0.4,-0.7,z,cl};
Point(13) = {-0.4,-0.7,z,cl};
Line(10) = {10,13}; Transfinite Line{10} = 3;
Line(11) = {13,12}; Transfinite Line{11} = 9;
Line(12) = {12,11}; Transfinite Line{12} = 3;
Line(13) = {11,10}; Transfinite Line{13} = 9;
Line Loop(3) = {10,11,12,13};
Plane Surface(3) = {3}; Transfinite Surface{3};
Point(6) = {0.0, -0.5, z, cl};
Circle(5) = {3,6,4};
Line(21) = {4,11};
Line(22) = {10,3};
Line Loop(2) = {5,21,-12,-11,-10,22};
Plane Surface(2) = {2};
Effectively, what I have done -> is applied marching cubes manually. I am not aware if GMSH contains something built-in to perform this kind of meshing. However, one would certainly be able to write a script that performs a marching cube-type algorithm to generate a GMSH-compliant geometry file.
It is also possible to have structured mesh regions with different triangle sizes to connect with the help of a relatively small number of triangles (unstructured mesh regions).
NB: I used a very primitive way to instruct GMSH on the mesh, there are better ways to do it.