📄 bisection.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 bisection</title> <meta name="keywords" content="bisection"> <meta name="description" content="BISECTION refines the triangulation using newest vertex bisection"> <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>bisection</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2><div class="box"><strong>BISECTION refines the triangulation using newest vertex bisection</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,eta] = bisection(mesh,eta,theta) </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"> BISECTION refines the triangulation using newest vertex bisection USAGE [mesh,eta] = bisection(mesh,eta,theta) INPUT mesh: current mesh eta: error indicator for each triangle theta: parameter in (0,1). We mark minimal number of triangles M such that \sum_{T \in M} \eta_T > \theta*\sum\eta_T OUTPUT mesh: new mesh after refinement eta: new error indicator for each triangle REFERENCE Long Chen, Short bisection implementation in MATLAB Research Notes, 2006</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)"></ul>This function is called by:<ul style="list-style-image:url(../../matlabicon.gif)"><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/circle.html" class="code" title="function circle">circle</a> CIRCLE simulates adaptive grids for a problem with moving circlular</li><li><a href="../../AFEM@matlab/1_Example/crack.html" class="code" title="function crack">crack</a> CRACK solves Poisson equation in a crack domain with AFEM.</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 [mesh,eta] = divide(mesh,eta,t,p)</a></li><li><a href="#_sub2" 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,eta] = bisection(mesh,eta,theta)</a><span class="comment">% BISECTION refines the triangulation using newest vertex bisection</span><span class="comment">%</span><span class="comment">% USAGE</span><span class="comment">% [mesh,eta] = bisection(mesh,eta,theta)</span><span class="comment">%</span><span class="comment">% INPUT</span><span class="comment">% mesh: current mesh</span><span class="comment">% eta: error indicator for each triangle</span><span class="comment">% theta: parameter in (0,1).</span><span class="comment">% We mark minimal number of triangles M such that</span><span class="comment">% \sum_{T \in M} \eta_T > \theta*\sum\eta_T</span><span class="comment">%</span><span class="comment">% OUTPUT</span><span class="comment">% mesh: new mesh after refinement</span><span class="comment">% eta: new error indicator for each triangle</span><span class="comment">%</span><span class="comment">% REFERENCE</span><span class="comment">% Long Chen,</span><span class="comment">% Short bisection implementation in MATLAB</span><span class="comment">% Research Notes, 2006</span><span class="comment">%</span><span class="comment">% L. Chen & C. Zhang 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);dualEdge = sparse(mesh.elem(:,[1,2,3]),mesh.elem(:,[2,3,1]),[1:NT,1:NT,1:NT]);d2p = sparse(edge(:,[1,2]),edge(:,[2,1]),[1:NE,1:NE]);<span class="comment">% Detailed explanation can be founded at</span><span class="comment">% Manual --> Data Structure --> Auxlliary data structure</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Meomery management for node arrary</span><span class="comment">%--------------------------------------------------------------------------</span>recycle = find(mesh.type==0); last = length(recycle);<span class="comment">% Coarsening can create empty spaces in the node array. We collect those</span><span class="comment">% scattered spaces in recycle arrary and 'last' will point out the last</span><span class="comment">% empty node index.</span><span class="comment">% mesh.type array is used to distinguish the type of nodes:</span><span class="comment">% 0: empty nodes (deleted by coarsening);</span><span class="comment">% 1: nodes in the initial triangulation or nodes from regular refinement;</span><span class="comment">% 2: new added nodes due to refinement.</span><span class="comment">%--------------------------------------------------------------------------</span><span class="comment">% Mark triangles according to the error indicator</span><span class="comment">%--------------------------------------------------------------------------</span>total = sum(eta); [temp,ix] = sort(-eta); <span class="comment">% sort in descent order</span>current = 0; marker = zeros(NE,1); <span class="keyword">for</span> t = 1:NT <span class="keyword">if</span> (current > theta*total), <span class="keyword">break</span>; <span class="keyword">end</span> <span class="comment">% err on marked elem big enough</span> index = 1; ct = ix(t); <span class="keyword">while</span> (index==1) base = d2p(mesh.elem(ct,2),mesh.elem(ct,3)); <span class="keyword">if</span> (marker(base)>0), index = 0; <span class="comment">% base is already marked</span> <span class="keyword">else</span> current = current + eta(ct); <span class="keyword">if</span> (last==0), newNode = size(mesh.node,1) + 1; <span class="keyword">end</span> <span class="keyword">if</span> (last>0), newNode = recycle(last); last = last-1; <span class="keyword">end</span> marker( d2p(mesh.elem(ct,2),mesh.elem(ct,3)) ) = newNode;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -