Simple Sphere Layers Plot

28 views
Skip to first unread message

shorty2243

unread,
Mar 7, 2018, 12:55:01 PM3/7/18
to iso2mesh-users
Hello,

I have a multilayer-sphere mesh, is there a way to plot the layers similar to the below image using plotmesh ?

Thanks

Image result for earth's crust


Qianqian Fang

unread,
Mar 7, 2018, 1:58:51 PM3/7/18
to iso2mes...@googlegroups.com, shorty2243
On 03/07/2018 12:55 PM, shorty2243 wrote:
Hello,

I have a multilayer-sphere mesh, is there a way to plot the layers similar to the below image using plotmesh ?

you can find two sample scripts below, 1st one is easier, but the cut is jagged;
the 2nd one is cleaner, but requires an extra surface boolean operation - it works
on Linux, not sure if the boolean operator has difficulty on windows.

the generated plots are attached.

% plot exploded mesh components without surface-boolean

[no1,fc1]=meshasphere([0 0 0],10,1);
[no2,fc2]=meshasphere([0 0 0],20,1);
[no3,fc3]=meshasphere([0 0 0],30,1.5);
[no,fc]=mergemesh(no1,fc1,no2,fc2,no3,fc3);

[node,elem]=s2m(no,fc,1,5,'tetgen',[0 0 0; 11 0 0; 21 0 0]);

figure;
hold on
plotmesh([node(:,1)-10 ,node(:,2:3)],elem(elem(:,end)==3,:),'x<-10')
plotmesh([node(:,1) ,node(:,2:3)],elem(elem(:,end)==2,:),'x<0')
plotmesh([node(:,1)+10 ,node(:,2:3)],elem(elem(:,end)==1,:))

camlight; lighting phong


% plot exploded mesh components with surface-boolean (cut by a bounding box)

[nbbx,fbbx]=meshabox([-40 -40 -40],[0 40 40],20);

[no,fc]=mergemesh(no1,fc1,no2,fc2(:,[1 3 2]),no3,fc3); %need to revert direction of the middle layer

[nosph,fcsph]=surfboolean(no,fc(:,[1 3 2]),'resolve',nbbx,fbbx);  % cut the 3-sphere by a box

[node,elem]=s2m(nosph,fcsph,1,5,'tetgen',[-1 0 0; -11 0 0; -21 0 0; 1 0 0; 11 0 0; 21 0 0]); % create tet mesh

figure;
hold on
plotmesh([node(:,1)-10 ,node(:,2:3)],elem(elem(:,end)==3,:))
plotmesh([node(:,1) ,node(:,2:3)],   elem(elem(:,end)==2,:))
plotmesh([node(:,1)+10 ,node(:,2:3)],elem(elem(:,end)==1,:),'facecolor','r','linestyle',':')
plotmesh([node(:,1)+10 ,node(:,2:3)],elem(elem(:,end)==4,:),'facecolor','r','linestyle',':')


camlight; lighting phong


Thanks

Image result for earth's crust


--
You received this message because you are subscribed to the Google Groups "iso2mesh-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To post to this group, send email to iso2mes...@googlegroups.com.
Visit this group at https://groups.google.com/group/iso2mesh-users.
For more options, visit https://groups.google.com/d/optout.


explode_plot_mesh.png
explode_plot_mesh_cleancut.png

shorty2243

unread,
Mar 8, 2018, 7:14:33 AM3/8/18
to iso2mesh-users
Thankyou so much!

Very helpful

T
Reply all
Reply to author
Forward
0 new messages