Error: Invalid geometry detected. Edges overlap or intersect at non-end points. for expanding circular subdomains inside larger circle

조회 수: 26 (최근 30일)
I have a code that creates a circle with radius 1 and a center at (0,0) at the first iteration. At the 2nd iteration, 10 small circles with radius 0.01 form at random coordinates inside the circle and expand by 0.01 with each following iteration.
Here's my code:
for jj = 1:100
% take nodes from step 1 and apply to step 2 to find coordinates
if jj == 2
NN = model_temp.Mesh.Nodes; XX=NN(1,:)'; YY=NN(2,:)';
end
% Create the PDE Model with a single dependent variable
numberOfPDE = 1;
model_temp = createpde(numberOfPDE);
%%%%%%%%%%%%%%%%%%%%%%%%%Geometry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if jj == 1
gdm = [1 0 0 1]';
ns = ('C1');
sf = 'C1';
[g,bt] = decsg(gdm,sf,ns');
elseif jj > 1
if jj == 2
r = 1;
c_coords = [0 0]';
ncirc = 10; % number of smaller circles
innerRs = ones(1,ncirc)*0.01; % starting radii of inner circles
r = [r innerRs]; % radii of circles
NewC = [];
while size(NewC,2) < ncirc
C = randsample(length(NN),1); loc = NN(:,C); % finds random nodes from first mesh to act as center
% coordinates for inner circles
NewC = [NewC loc];
end
c_coords = [c_coords NewC];
else
r(2:end) = r(2:end) + 0.01; % at all other iterations, increase inner radii
end
gdm = [ones(1,length(r));c_coords;r];
ns = [repmat('C',length(r),1),num2str((1:length(r))', '%-d')];
sf = [ns,repmat('+',length(r),1)]';
sf = sf(:); sf(end) = [];sf = sf';
srt = find(sf == 'C'); sf2 = sf(srt(2):end);
sf = ['(',sf,') - ((',sf2,')-C1)'];
[g,bt] = decsg(gdm,sf,ns');
end
geometryFromEdges(model_temp,g);
Hmax = 0.035;
msh = generateMesh(model_temp,'Hmax',Hmax);
pdeplot(model_temp);
end
Since I want to keep the coordinates random, each time I run the code I get different figures. Sometimes when I run it I get the error: "Invalid geometry detected. Edges overlap or intersect at non-end points." I don't know if it's a problem with my code because sometimes when I run it, I don't get any errors.
I read online that this could be caused by a bug in the PDE toolbox. What can I do to avoid this problem?

답변 (1개)

Jatin Waghela
Jatin Waghela 2017년 10월 3일

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by