📄 uniformrefine.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head> <title>Description of uniformrefine</title> <meta name="keywords" content="uniformrefine"> <meta name="description" content="UNIFORMREFINE refines the current triangulation by dividing"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="m2html © 2003 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../../m2html.css"></head><body><a name="_top"></a><!-- # AFEM@matlab --><!-- menu.html 4_Refine --><h1>uniformrefine</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2><div class="box"><strong>UNIFORMREFINE refines the current triangulation by dividing</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2><div class="box"><strong>function [mesh] = uniformrefine(mesh) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2><div class="fragment"><pre class="comment"> UNIFORMREFINE refines the current triangulation by dividing each triangle into four similar triangles USAGE [mesh] = uniformrefine(mesh) Input: mesh: current mesh Output: mesh: new mesh after refinement</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../../matlabicon.gif)"><li><a href="label.html" class="code" title="function elem = label(node,elem)">label</a> LABEL label the longest edge of each triangle as the base</li></ul>This function is called by:<ul style="list-style-image:url(../../matlabicon.gif)"><li><a href="../../AFEM@matlab/1_Example/Lbig.html" class="code" title="function Lbig">Lbig</a> LBIG solves Poisson equation in a L-shaped domain with FEM with</li><li><a href="../../AFEM@matlab/1_Example/Lshape.html" class="code" title="function Lshape">Lshape</a> LSHAPE solves Poisson equation in a L-shaped domain with FEM with</li><li><a href="../../AFEM@matlab/1_Example/simple.html" class="code" title="function simple">simple</a> SIMPLE solves Poisson equation with Dirichlet boundaray condition in a</li></ul><!-- crossreference --><h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2><ul style="list-style-image:url(../../matlabicon.gif)"><li><a href="#_sub1" class="code">function bdEdge = updatebd(bdEdge,marker,d2p)</a></li></ul><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2><div class="fragment"><pre><a name="_sub0" href="#_subfunctions" class="code">function [mesh] = uniformrefine(mesh)</a><span class="comment">% UNIFORMREFINE refines the current triangulation by dividing</span><span class="comment">% each triangle into four similar triangles</span><span class="comment">%</span><span class="comment">% USAGE</span><span class="comment">% [mesh] = uniformrefine(mesh)</span><span class="comment">%</span><span class="comment">% Input:</span><span class="comment">% mesh: current mesh</span><span class="comment">%</span><span class="comment">% Output:</span><span class="comment">% mesh: new mesh after refinement</span><span class="comment">%</span><span class="comment">% L. Chen 10-12-2006</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Construct data structure</span><span class="comment">%--------------------------------------------------------------------------</span>edge = [mesh.elem(:,[1,2]); mesh.elem(:,[1,3]); mesh.elem(:,[2,3])];edge = unique(sort(edge,2),<span class="string">'rows'</span>);N = size(mesh.node,1); NT = size(mesh.elem,1); NE = size(edge,1);d2p = sparse(edge(:,[1,2]),edge(:,[2,1]),[1:NE,1:NE],N,N);<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% New nodes from the mid points of each edge</span><span class="comment">%--------------------------------------------------------------------------</span>newnode = (mesh.node(edge(:,1),:)+mesh.node(edge(:,2),:))/2; newsolu = (mesh.solu(edge(:,1),:)+mesh.solu(edge(:,2),:))/2; mesh.node = [mesh.node; newnode]; mesh.solu = [mesh.solu; newsolu]; mesh.type = uint8(ones(size(mesh.node,1),1));marker = N+1:N+NE; <span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% refine each triangle into four triangles</span><span class="comment">% 3</span><span class="comment">% / \</span><span class="comment">% 6 - 5</span><span class="comment">% / \ / \</span><span class="comment">% 1 - 4 - 2</span><span class="comment">%--------------------------------------------------------------------------</span><span class="keyword">for</span> t=1:NT p(1:3) = mesh.elem(t,[1 2 3]); p(4) = marker(d2p(mesh.elem(t,1),mesh.elem(t,2))); p(5) = marker(d2p(mesh.elem(t,2),mesh.elem(t,3))); p(6) = marker(d2p(mesh.elem(t,3),mesh.elem(t,1))); mesh.elem(t,[1 2 3]) = [p(1) p(4) p(6)]; mesh.elem(size(mesh.elem,1)+1,[1 2 3]) = [p(4) p(2) p(5)]; mesh.elem(size(mesh.elem,1)+1,[1 2 3]) = [p(6) p(5) p(3)]; mesh.elem(size(mesh.elem,1)+1,[1 2 3]) = [p(4) p(5) p(6)];<span class="keyword">end</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Update boundary edges</span><span class="comment">%--------------------------------------------------------------------------</span>mesh.Dirichlet = <a href="#_sub1" class="code" title="subfunction bdEdge = updatebd(bdEdge,marker,d2p)">updatebd</a>(mesh.Dirichlet,marker,d2p);mesh.Neumann = <a href="#_sub1" class="code" title="subfunction bdEdge = updatebd(bdEdge,marker,d2p)">updatebd</a>(mesh.Neumann,marker,d2p);<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Label the mesh by the longest edge rule</span><span class="comment">%--------------------------------------------------------------------------</span>mesh.elem = <a href="label.html" class="code" title="function elem = label(node,elem)">label</a>(mesh.node,mesh.elem);<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% plot refined mesh</span><span class="comment">%--------------------------------------------------------------------------</span>subplot(1,2,2); hold off; trisurf(mesh.elem,mesh.node(:,1),mesh.node(:,2),zeros(size(mesh.node,1),1));view(2), axis equal, axis off;title(<span class="string">'Mesh after uniform refinement'</span>, <span class="string">'FontSize'</span>, 14)<span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% End of function UNIFORMREFINE</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Sub functions called by UNIFORMREFINE</span><span class="comment">%--------------------------------------------------------------------------</span><a name="_sub1" href="#_subfunctions" class="code">function bdEdge = updatebd(bdEdge,marker,d2p)</a><span class="comment">% UPDATEDBD refine the boundary edges</span><span class="comment">%</span><span class="comment">% INPUT</span><span class="comment">% bdEdge: set of boundary edges</span><span class="comment">% marker: new node index for marked edge</span><span class="comment">% d2p: index mapping from dual edge to primary edge</span><span class="comment">%</span><span class="comment">% OUTPUT</span><span class="comment">% bdEdge: set of refined boundary edges</span><span class="comment">%</span>NB = size(bdEdge,1);<span class="keyword">for</span> k = 1:NB i = bdEdge(k,1); j = bdEdge(k,2); bdEdge(k,:) = [i,marker(d2p(i,j))]; bdEdge(size(bdEdge,1)+1,:) = [marker(d2p(i,j)),j];<span class="keyword">end</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% End of function UPDATEDBD</span><span class="comment">%--------------------------------------------------------------------------</span></pre></div><hr><address>Generated on Fri 17-Nov-2006 11:02:53 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> © 2003</address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -