Error: Invalid geometry detected. Edges overlap or intersect at non-end points. for expanding circular subdomains inside larger circle
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposte (1)
Jatin Waghela
il 3 Ott 2017
You may refer to the similar issue discussed at the below link:
Use geometry functions to define the geometry as stated in the documentation:
Additional suggestions are found in the following post:
0 Commenti
Vedere anche
Categorie
Scopri di più su Geometry and Mesh in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!