| MESH toolbox 0.1 Matlab/Octave mesh utils

- Main Page
- Related Pages
- Modules
- Files

- File List
- File Members

All Files Functions Groups Pages
refine_demo1.m
Go to the documentation of this file.
1 function refine_demo1(varargin)
2 % function refine_demo1(varargin)
3 % demo function using refine mesh tools and mesh plot command.
4 %
5 % Parameters:
6 % save : set to true to save figures in image directory.
7 % savename : set save file base name.
8 % percent : set color mesh lines
9 % meshfile : set mesh file name
10 % randlabel : if true, boundaries label set to random values
11 %
12 % Examples:
13 % - Original mesh (Th)
14 % \image html images/RefineMesh1.png "figure : Mesh before refinement"
15 % \image latex images/RefineMesh1.eps "My application" width=10cm
16 % - Refine mesh (Thr1)
17 % @verbatim
18 % Thr1=RefineMesh(Th); @endverbatim
19 % \image html images/RefineMesh2.png "figure : Mesh after refinement : sort=false"
20 % - Refine mesh with sort boundaries (Thr2)
21 % @verbatim
22 % Thr2=RefineMesh(Th,'sort',true); @endverbatim
23 % \image html images/RefineMesh3.png "figure : Mesh after refinement : sort=true"
24 %
25 % See also:
26 % #RefineMesh
27 p = inputParser;
28 %
29 p.addParamValue('save', false, @islogical );
30 p.addParamValue('savename', 'RefineMesh', @isstr );
31 p.addParamValue('percent', 50 , @(t) ((t>0)&&(t<=100)) );
32 p.addParamValue('meshfile',['mesh',filesep,'disque4-1-3.msh'], @isstr );
33 p.addParamValue('randlabel',false,@islogical);
34 p.parse(varargin{:});
35 close all
36
37 addpath('base');
38 addpath('graphic');
39 addpath('refine');
40
41 Th=GetMeshOpt(p.Results.meshfile);
42 %%%%%%%
43 % give random boundaries label
44 if p.Results.randlabel
45 LB=unique(Th.bel);
46 nB=length(LB);
47 belT=Th.bel*0;
48 for i=1:nB
49 I=find(Th.bel == LB(i));
50 belT(I)=randi(1000);
51 end
52 Th.bel=belT;
53 end
54 %%%%%%%
55
56 figure(1)
57 PlotMesh(Th,'color',[0 0 0])
58 RGBcolors=PlotBounds(Th,'LineWidth',2);
59 PlotBoundsEdgeNumber(Th,'RGBEdgeColors',RGBcolors,'Color',[0 0 0],'LineStyle','-','LineWidth',0.5);
60 SaveImage(p.Results.save,[p.Results.savename,'1'],p.Results.percent)
61 title('Mesh before refinement')
62
63 Thref=RefineMesh(Th);
64 figure(2)
65 PlotMesh(Thref,'color',[0 0 0])
66 PlotBounds(Thref,'LineWidth',2,'RGBcolors',RGBcolors);
67 PlotBoundsEdgeNumber(Thref,'RGBEdgeColors',RGBcolors,'Color',[0 0 0],'LineStyle','-','LineWidth',0.5);
68 SaveImage(p.Results.save,[p.Results.savename,'2'],p.Results.percent)
69 title('Mesh after refinement : sort=false')
70
71 Threfs=RefineMesh(Th,'sort',true);
72 figure(3)
73 PlotMesh(Threfs,'color',[0 0 0])
74 PlotBounds(Threfs,'LineWidth',2,'RGBcolors',RGBcolors);
75 PlotBoundsEdgeNumber(Threfs,'RGBEdgeColors',RGBcolors,'Color',[0 0 0],'LineStyle','-','LineWidth',0.5);
76 SaveImage(p.Results.save,[p.Results.savename,'3'],p.Results.percent)
77 title('Mesh after refinement : sort=true')