?? example.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Overview and Examples of QMG</title></head><body BGCOLOR="#E0FFE0" TEXT="#000000" LINK = "#0080C0" VLINK = "#004060" ALINK = "#FF0000" ><center><table><tr><td><a href="qmg2_0_home.html"><img src=logo1.jpg alt="QMG logo"></a></td><td><h1>Overview and Examples of QMG</h1></td></table></center>Consider the following problem: you have some kind of mechanicalpart. One facet of the part is held at 100 degrees C, an oppositefacet is 0 degrees C. The object has a crack in the middle that acts like an insulator.All other facets are thermally insulated. Whatis the equilibrium temperature distribution on the interior of the part?Where are the largest temperature gradients? This problem is calleda <em>boundary value problem</em>.One popular way to solve boundary value problems is the<em>finite-element method.</em><p>From the point of view of software development, the three mostdifficult aspects of finite-element analysis are the geometricmodeling tools, the mesh generator, and the finite-elementsystem solver. The QMG package is intended to address mesh generation in two and three dimensions. It also has afew tools to assist in geometric modeling and anelementary finite-element solver that solves the sparse matrix equation withMatlab's backslash operator.<p>The QMG package consists of approximately 40 separate functions.The user of QMG invokes the functions through a console interface.QMG does not have its own console interface; instead it relieson the scripting capabilities of other software packages.Currently QMG runs inside two different scripting environments: Matlab andTcl/Tk. In addition, the user can invoke QMG <a href="standalone.html">directly from theshell</a> in either Windows or Unix. <p>Also provided are a suite of examplesdemonstrating the use of many of these functions, as well asa help utility (<code>help</code> in Matlab; <code>gmhelp</code> in Tcl/Tk) toobtain on-line documentation on the functions. In addition,there is a browser-based <a href=ref.html>reference manual.</a><p>Although the interface to QMG is by typing function invocations,it would be easy to extend QMG with a GUI control sinceboth Matlab and Tcl/Tk have GUI-building commands. <p>All the QMG functions, except for the examples shipped with the software, begin with the prefix <strong>gm</strong>, which is short for “geometry.” Functions that begin with <strong>gm_</strong> are lower-level internal functions.<p>The input to the mesh generator is called a <em>brep.</em>(Terms used by other mesh generation systems for the inputto the mesh generatorare <em>model</em> or <em>geometry.</em>)Its output is amesh. In Matlab, breps and meshes are represented asstructured objects (nested cell arrays) that can bedirectly manipulated by the user. In Tcl/Tk, breps andmeshes have an internal representation that can be convertedeither to a long text-string or to a list for manipulationby the user. In either Matlab or Tcl/Tk, the underlyingdata carried in breps and meshes is the same.A separate <a href="geom.html">page</a> describes thedata representations.<p>A brep in QMG is a 2D or 3D object with curved boundaries.In particular, the boundaries are described by Beziercurves (in 2D) or patches (in 3D). Two kinds of patchesare allowed: triangular Bezier patches and tensor-productquadrilateral patches.<p>Here are some distinguishing features of the QMG mesh generator compared to othermesh generators. Onthe positive side,<ul><li>The QMG mesh generator is fully automatic, meaning that nohuman intervention is necessary to guide the mesh generationor preprocess the domain once you have constructed it withthe modeler. There is no need to repair the mesh aftermesh generation is complete.<li>The QMG mesh generator handles complicated topology. The domaincan have holes and quite complexinternal boundaries, and it can be disconnected.It is OK to have many facets meet at a single vertex.<li>The QMG mesh generator has certain <a href="meshgen.html#guarantees">theoretical guarantees</a>.</ul>On the negative side,<ul><li>QMG 2.0 cannot handle other geometric representations used by somemodeling systems like NURBS patches.<li>QMG 2.0 is an in-core mesh generator, meaning that theinput brep, all intermediate data structures, and the output meshmust all be resident in memory at the same time. This meansthat QMG may run out of memory on very large breps (or very finemeshes).<li>The QMG mesh generator generates an <em>unstructured</em> mesh, meaningthat the mesh is composed of triangles (in 2D) or tetrahedra (in 3D)with no regular pattern. Structured meshes are preferable for some applications: these are mesheswith a global cartesian product structure on the meshnodes. Structured meshes are easier for computationand are preferable for problems with a strong anisotropy (such asa boundary layer in a high-speed flow). But they are much moredifficult to fit into complicated geometries. Unstructured meshesare typically used for isotropic problems that do not have boundarylayers.<li>QMG 2.0 is not compatible with file formats fromwell-known commercial geometric packages.<li>QMG 2.0 element quality, though guaranteed theoretically, in practicestill leaves something to be desired.<li>QMG is not good at producing coarse meshes.Even on its coarsest settings, QMG tends to produce many more tetrahedra than are necessary. (QMG has a theoretical guaranteethat, when set for a coarse mesh, itwill give the coarsest possible mesh, up to a constant factor. Unfortunately,the constant factor involved is fairly large.)</ul><p>For three-dimensional geometric modeling, graphics are very helpful.The Tcl/Tk version of QMG uses VRML1.0 for 3D graphics, so you need to have a web-browser(presumably either Netscape or Internet Explorer) that can view VRML files. For more information about VRML, see the <a href="http://www.web3d.org/vrml/">VRML repository</a>.This site includes a list of free and commercial VRML viewers.The Matlab version of QMG can use either VRML 1.0 or Matlab'sbuilt-in graphics capabilities.<p>Finite-element analysis is available only in the Matlab versionof QMG.For the finite-element analysis, the user must call the meshgenerator, set up the desired boundary conditions, and call the solverprogram. The boundary conditions can be arbitrary Matlab functions.They are associated with faces of the domain as property-value pairsof the faces.<hr><h2> A 2-dimensional example </h2><p> Here is an example of solving a two-dimensional boundary valueproblem using QMG. This is test file <code>test7.m</code> in the Matlab exampledirectory. The Tcl/Tk example <code>test7.tcl</code> is similar, except itdoes not invoke the finite-element solver.The domain is a circle with two elliptic holesand one slit (an internal boundary). The boundary conditions are <em>u</em>=1 on one hole, <em>u</em>=2 on the other hole,and <em>du/dn</em>=0 (insulated) on the exterior and on the slit.First, here is script file for this test.<pre><code>%% QMG 2.0 test 7: a circle with two elliptic holes and a slit.echo onglobal interactive%% Make an approximation to a circle using 6 Bezier cubic arcs.numseg = 6;[verts, scrap] = gm_circ_approx(0, 2*pi, numseg);[numvert,scrap] = size(verts);verts = verts(1:3*numseg,:);codes = kron(ones(numseg,1),[2;3;3]);codes(1) = 0;c0 = gm_cpoly(verts,codes);%% Make two elliptic holes.hole1 = gmapply([.2, 0, 0; 0,.1,-.5], c0);c = gmcavity(c0,hole1);hole2 = gmapply([.2, 0, 0; 0, .1, .5], c0);c = gmcavity(c,hole2);%% Make a slit by modifying the brep directly.%% Insert two new control points at (-.6,-.1) and (.6,.1).[scrap,numcp] = size(c{4});c{4}(:,numcp:numcp+1) = [.6,-.6;.1,-.1];%% Insert two new vertices at these points.[scrap,numv] = size(c{5});c{5}(:,numv:numv+1) = {'newv1','newv2' {}, {} {}, {} {}, {}{'vertex';[];numcp},{'vertex';[];numcp+1}};%% Insert a new edge connecting those vertices.[scrap,nume] = size(c{6});c{6}(:,nume) = {'newe1'{}{'newv1','newv2'}{}{'bezier_curve';1;[numcp,numcp+1]}};%% Insert the new edge as a repeated boundary of the region.oldbsize = length(c{7}{2,0}); c{7}{2,0}{oldbsize} = 'newe1';c{7}{2,0}{oldbsize+1} = 'newe1';c_color = gmrndcolor(c);if length(interactive) > 0 gmviz(c_color), gmshowcolor(c_color)end%% generate a mesh. Elements of size about .2.show = 0;if length(interactive) > 0 show = 1;endm = gmmeshgen(c_color,'size','(const .2)', 'show', show);%% Display the meshif length(interactive) > 0 gmviz(m)end[c_color2, m2] = gmdouble(c_color, {'*'}, m);%% Check the mesh.gmchecktri(c_color2,m2);%% Default neumann BC du/dn=0 on all faces except the two%% holes that get Dirichlet conditions.for j = 0 : nume if length(findstr('cav1',double(c_color2{6}{0,j}))) [npv,scrap] = size(c_color2{6}(1,j)); c_color2{6}{1,j}(:,npv) = {'bc'; '(d (const 1))'}; end if length(findstr('cav2',double(c_color2{6}{0,j}))) [npv,scrap] = size(c_color2{6}(1,j)); c_color2{6}{1,j}(:,npv) = {'bc'; '(d (const 2))'}; endendu = gmfem(c_color2, m2);if length(interactive) > 0 gmplot(m2, u)endglobal aspprodglobal meshsizesumif length(aspprod) > 0 aspprod = aspprod * asp; [scrap,numvtx] = size(m2{4}); meshsizesum = meshsizesum + numvtx;end</code></pre>The mesh generator on this example required less than a second on aPentium Pro. The function gmchecktri in the above script producedthe following output:<pre><code>Maximum aspect ratio = 19.1017 achieved insimplex #668 of topological entity mregion (2:0) which has vertices 52 372 388 Maximum global side length = 0.206452Minimum global altitude = 0.00212975Number of nodes = 409 number of elements = 706</code></pre><p>The brep produced by this mfile is illustrated in the followingfigure.The edges have been colored so that green corresponds to the insulatedfaces, red to the <em>u</em>=2 boundary condition, and blue to the<em>u</em>=1 boundary condition.<p><img src="test7-brep.jpg" alt="example 2D brep"><p>The mesh produced by the mesh generator is depicted in thefollowing figure.<p><img src="test7-mesh.jpg" alt="example 2D mesh"><p>As seen from the above trace, the worst aspect ratio occurring in thismesh is about 19. It is obvious from looking at this mesh that themesh generator could do better in the sense that there are nodesthat could be locally displaced to improve the overall quality ofthe mesh.We have not yet implemented any heuristic improvement techniques.<p>Finally, the color plot of the finite-element solution withmixed boundary conditions looks like this. <p><img src="test7-sol.jpg" alt="example 2D finite-element solution"><hr><h2> A 3-dimensional example </h2>This example shows a 3-dimensional brep with an internal boundary.No BVP issolved in this test case. This example is scripted inin Tcl/Tk. The object is shaped like a hex nut with a small interior crack.The object is constructing using Tcl/Tk <a href="test9_tcl.txt">script</a> piece by piece, i.e., each surface and edge is constructed step by step.<p>The mesh generator required 121 seconds on this example (Pentium Pro 166MHz).The properties of the resulting mesh are:<pre><code>Maximum aspect ratio = 72.4505 achieved insimplex #1190 of topological entity hexnutcrack (3:0) which has vertices 3 351 489 493 Maximum global side length = 0.780871Minimum global altitude = 0.00121479Number of nodes = 807 number of elements = 3403</code></pre><p>The brep used for this test was rendered in VRML by a call to <a href="ref.html#gmviz"><code>gmviz</code></a>function. You can see the object now if you have a VRML viewerinstalled in your browser. Two renderings are available:in the first rendering, the outer faces are shown, but they hidethe internal boundary.In the second rendering, one of the outer surfaces hasbeen made transparent using the statement:<pre><code>gmset hexobj2 [gm_addpropval $hexobj {s_top} {color} {{(1 0 0 0)}}]</code></pre>In this second rendering, the internal crack is visible as a smallmagenta triangle.<ol><li><a href="hexobj1.wrl">VRML rendering with all outer boundaries visible.</a><li><a href="hexobj2.wrl">VRML rendering with one outer boundary invisible and internal boundary visible.</a></ol><hr><p>This documentation is written by <a href="http://www.cs.cornell.edu/home/vavasis/vavasis.html">Stephen A. Vavasis</a> and iscopyright ©1999 by <a href="http://www.info.cornell.edu/CUHomePage.html">Cornell University</a>.Permission to reproduce this documentation is granted provided thisnotice remains attached. There is no warranty of any kind onthis software or its documentation. See the accompanying file<a href="copyright.html">'copyright'</a>for a full statement of the copyright.<p><address>Stephen A. Vavasis, Computer Science Department, Cornell University,Ithaca, NY 14853, vavasis@cs.cornell.edu</address></body></html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -