| MESH toolbox 0.1 Matlab/Octave mesh utils

- Main Page
- Related Pages
- Modules
- Files

- File List
- File Members

All Files Functions Groups Pages
RefineMesh.m
Go to the documentation of this file.
1 function [RefTh,MatProj]=RefineMesh(varargin)
2 % function [RefTh,MatProj]=RefineThOptV1(varargin)
3 % refines the mesh Th by a factor of 4
4 %
5 % parameters:
6 % Th : mesh structure
7 % sort : set to true if sort boundaries
8 %
9 % Example:
10 % - Original mesh (Th)
11 % \image html images/RefineMesh1.png "figure : Mesh before refinement"
12 % \image latex images/RefineMesh1.eps "My application" width=10cm
13 % - Refine mesh (Thr1)
14 % @verbatim
15 % Thr1=RefineMesh(Th); @endverbatim
16 % \image html images/RefineMesh2.png "figure : Mesh after refinement : sort=false"
17 % - Refine mesh with sort boundaries (Thr2)
18 % @verbatim
19 % Thr2=RefineMesh(Th,'sort',true); @endverbatim
20 % \image html images/RefineMesh3.png "figure : Mesh after refinement : sort=true"
21 %
22 p = inputParser;
23 p.addRequired('Th', @isstruct);
24 %
25 p.addParamValue('sort', false, @islogical );
26
27 p.parse(varargin{:});
28 Th=p.Results.Th;
29
30 [e2q,e2t,e2n,e2do,e2be]=BuildEdges(Th);
31 [qf,mef]=BuildMeshP2(Th,e2q,e2t,e2n);
32
33 [beref,belref]=BuildBE(e2q,e2be,Th.nq);
34 beref=beref';
35 belref=belref';
36 Tr=[mef([1 2 4],:),mef([2 3 5],:),mef([2 5 4],:),mef([4 5 6],:)];
37 mel=[Th.mel,Th.mel,Th.mel,Th.mel];
38 qfl=zeros(1,size(qf,2));
39 qfl=zeros(1,size(qf,2));
40 qfl(1:Th.nq)=Th.ql;
41 titi=zeros(1,size(e2q,1));
42 titi(e2be(:,1))=e2be(:,3);
43 qfl(Th.nq+1:end)=titi;
44
45 if nargout==2
46 MatProj=GetMatPrTh2RefTh(Th.nq,e2q);
47 end
48 if p.Results.sort
49 [beref,belref]=SortBoundary(beref,belref);
50 end
51 RefTh=struct('q',qf,'me',Tr,'ql',qfl,'mel',mel,'be',beref,'bel',belref, ...
52 'nq',size(qf,2), ...
53 'nme',size(Tr,2), ...
54 'nbe',size(beref,2), ...
55 'areas',ComputeAreaOpt(qf,Tr),...
56 'lbe',EdgeLengthOpt(beref,qf));
57 end