EikMesh

During my Ph.D. I created EikMesh (Zönnchen & Köster, 2019), a Java library for generating 2D meshes. It is part of Vadere and was developed to generate high-quality meshes for spatial discretization in the domain of pedestrian dynamics.

The execution of the following code example generates a mesh for a ring.

VRectangle bound = new VRectangle(-0.1, -0.1, 2.2, 2.2);
IDistanceFunction d_r = IDistanceFunction.createRing(1, 1, 0.2, 1.0);
double h_min = 0.1;
PEikMesh meshImprover = new PEikMesh(d_r,h_min,bound);
meshImprover.generate();

You can build complex geometries by combining multiple distance functions.

VRectangle bound = ...
VRectangle rect = new VRectangle(0.5, 0.5, 1, 1);
IDistanceFunction d_c = IDistanceFunction.createDisc(0.5, 0.5, 0.5);
IDistanceFunction d_r = IDistanceFunction.create(rect);
IDistanceFunction d = IDistanceFunction.substract(d_c, d_r);
double h_min = 0.03;
var meshImprover = new PEikMesh(
				d,
				p -> h_min + 0.5 * Math.abs(d.apply(p)),
				h_min,
				bound,
				Arrays.asList(rect));

VRectangle rect = new VRectangle(-0.5, -0.5, 1, 1);
VRectangle boundary = new VRectangle(-2,-0.7,4,1.4);

IDistanceFunction d1_c = IDistanceFunction.createDisc(-0.5, 0, 0.5);
IDistanceFunction d2_c = IDistanceFunction.createDisc(0.5, 0, 0.5);
IDistanceFunction d_r = IDistanceFunction.create(rect);
IDistanceFunction d_b = IDistanceFunction.create(boundary);
IDistanceFunction d_unionTmp = IDistanceFunction.union(d1_c, d_r)
IDistanceFunction d_union = IDistanceFunction.union(d_unionTmp, d2_c);
IDistanceFunction d = IDistanceFunction.substract(d_b,d_union);

double h_min = 0.03;
var meshImprover = new PEikMesh(
				d,
				p -> h_min + 0.5 * Math.abs(d.apply(p)),
				edgeLength,
GeometryUtils.boundRelative(boundary.getPath()),
				Arrays.asList(rect));

var triangulation = meshImprover.generate();

References

  1. Zönnchen, B., & Köster, G. (2019). A parallel generator for sparse unstructured meshes to solve the eikonal equation. Journal of Computational Science, 32, 141–147. https://doi.org/10.1016/j.jocs.2018.09.009