Home > vbmeg > external > iso2mesh > sample > demo_refine_spherebox_mesh.m

demo_refine_spherebox_mesh

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Create meshes for a sphere inside a cubic domain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %  Create meshes for a sphere inside a cubic domain
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 
0005 % preparation
0006 
0007 % you have to add the path to iso2mesh toolbox
0008 % addpath('/path/to/iso2mesh/toolbox/');
0009 
0010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0011 %  Part 0.  Create a Spherical Mesh
0012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0013 
0014 [no,el]=meshasphere([30 30 30],20,2.5);
0015 
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 %  Part I.  A Coarse Mesh for a Sphere Inside a Box with Refinement
0018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0019 
0020 % generate a coarse volumetric mesh from the sphere with an additional bounding box
0021 % the maximum element volume is 8
0022 
0023 ISO2MESH_SESSION='demo_sph3_';
0024 
0025 srcpos=[30. 30. 0.];                     % set the center of the ROI
0026 fixednodes=[30.,30.,0.1; 30 30 30];     % add control points so we can refine mesh densities there
0027 nodesize=[ones(size(no,1),1) ; 0.2; 4];  % set target edge size of 1 for all nodes on the sphere
0028                                          % target edge size 0.3 near (30,30,0.05)
0029                                          % and target edge size 4 near (30,30,30)
0030 nfull=[no;fixednodes];                   % append additional control points
0031 [node3,elem3,face3]=surf2mesh([nfull,nodesize],el,[0 0 0],[61 61 61],1,8,[30 30 30],[],[2 2 2 2 6 6 6 6]);
0032                              % ^- add node size as the last            ^ max volume     ^- edge sizes at the 8
0033                              %    column to node                                           corners of the bounding box
0034 [node3,elem3,face3]=sortmesh(srcpos,node3,elem3,1:4,face3,1:3);  % reorder the nodes/elements
0035                                                  % so that the nodes near earch order
0036                                                  % are more clustered in the memory
0037 elem3(:,1:4)=meshreorient(node3,elem3(:,1:4));   % reorient elements to ensure the volumns are positive
0038 
0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0040 %  Part II.  A Dense Mesh for a Sphere Inside a Box with Refinement
0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0042 % generate a dense volumetric mesh from the sphere with an additional bounding box
0043 % the maximum element volume is 2
0044 
0045 ISO2MESH_SESSION='demo_sph2_';
0046 
0047 nodesize=[0.7*ones(size(no,1),1) ; 0.2; 2];  % set target edge size to 0.7 near the sphere
0048                                              % 0.2 near (30,30,0.5) and 2 near (30,30,30)
0049 [node2,elem2,face2]=surf2mesh([nfull,nodesize],el,[0 0 0],[61 61 61],1,2,[30 30 30],[],[1 1 1 1 5 5 5 5]);
0050 
0051 figure; plotmesh(node2,face2(:,1:3),'y>30');axis equal;
0052 
0053 [node2,elem2,face2]=sortmesh(srcpos,node2,elem2,1:4,face2,1:3);
0054 elem2(:,1:4)=meshreorient(node2,elem2(:,1:4));
0055 
0056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0057 %  Part III.  A Coarse Mesh for a Sphere Inside a Box without Refinement
0058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0059 
0060 ISO2MESH_SESSION='demo_sph1_';
0061 
0062 % reduce the surface node numbers to 20%
0063 [no2,el2]=meshresample(no,el,0.2);  % down sample the sphere mesh
0064 
0065 % using the coarse spherical surface, we generate a coarse volumetric
0066 % mesh with maximum volume of 10
0067 
0068 [node1,elem1,face1]=surf2mesh(no2,el2,[0 0 0],[61 61 61],1,10,[30 30 30],[],1);
0069 [node1,elem1,face1]=sortmesh(srcpos,node1,elem1,1:4,face1,1:3);
0070 elem1(:,1:4)=meshreorient(node1,elem1(:,1:4));
0071 
0072 clear ISO2MESH_SESSION

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005