`r=6;rr=0.2;a=0.8;b=0.4;%% Geometry `

scattering_model = createpde;%%

% Define a circle in a rectangle, place these in one matrix, and create a

% set formula that subtracts the circle from the rectangle.

C1 = [1,0,0,r]';C2 = [1,0,0,rr]';E2 = [4,0,0,a,b,0]';C1 = [C1;zeros(length(E2)-length(C1),1)];C2 = [C2;zeros(length(E2)-length(C2),1)];gm = [C1,E2,C2];sf = 'C1+E2+C2';%%% Create the geometry.

ns = char('C1','E2','C2');ns = ns';g = decsg(gm,sf,ns);%%% Include the geometry in the model and plot it.

geometryFromEdges(scattering_model,g);pdegplot(scattering_model,'EdgeLabels','on')axis equalgenerateMesh(scattering_model,'Hmax',0.1);pdeplot(scattering_model)%%

V=scattering_model.Mesh.Nodes';F=scattering_model.Mesh.Elements';F1=F(:,1:3);F2=F(:,4:6);F=[F1;F2];F=unique(F,'rows');

When I was using matlab 2016b, there was no problem in building the grid. The same program appeared in the 2019a version with a significant error. The 2019a has the wrong grid as follows：

The green point in the figure is the adjacent point of the red point. There should be no such arrangement in the correct grid F.

And this kind of grid is not allowed in finite elements, right? Caused a lot of trouble for subsequent programming.

## Best Answer