how to create a mesh with internal boundary
spvfly opened this issue · comments
Yuanlang Su commented
I read the Mesh Generation for Implicit Geometries, but I still do not know how to create a mesh with internal boundary. please show me a example for the mesh with internal boundary
popersson commented
A simple trick is to put fix points along the internal boundaries. It's not guaranteed to work unless you use a constrained Delaunay triangulation (which Matlab has now), but in practice it usually works fine if the point distributions are fine enough. I only have an example in Matlab, see below, but it should be easy to do in Python if you prefer that.
% distmesh_internal_boundary.m
fd = @(p) drectangle(p,0,1,0,1);
pv_line = [0.3,0.7; 0.7,0.5];
h_line = 0.03;
hmax = 0.15;
fh = @(p) min(h_line + 0.3*abs(dpoly(p, pv_line)), hmax);
hmin = h_line;
box = [0,0; 1,1];
fix_box = [0,0; 1,0; 0,1; 1,1];
n_line = ceil(norm(diff(pv_line, [], 1)) / h_line);
s_line = linspace(0, 1, n_line + 1)';
fix_line = pv_line(ones(size(s_line)),:) + s_line * diff(pv_line, [], 1);
[p,t] = distmesh2d(fd, fh, hmin, box, [fix_box; fix_line]);
simpplot(p,t)
line(pv_line(:,1), pv_line(:,2), 'linewidth', 3, 'color','k');