661
edits
Carandraug (talk | contribs) (using templates and octave guidelines for code formatting) |
Carandraug (talk | contribs) (using the Forge and Codeline templates) |
||
Line 13: | Line 13: | ||
This tutorial shows the workflow to generate a triangular mesh inside an arbitrary region. | This tutorial shows the workflow to generate a triangular mesh inside an arbitrary region. | ||
This tutorial requires that you install the package | This tutorial requires that you install the package {{Forge|fpl}} and {{Forge|msh}} (which requires [http://geuz.org/gmsh/ Gmsh] installed in your system). Alternatively, the core function {{Codeline|delaunay}} could be used (the tutorial explains how) but the result aren't so pretty. | ||
The first part of the tutorial requires an interesting shape. If you have Inkscape you can use the previous tutorial to load it into octave. Here I will be using [http://ubuntuone.com/5pNS12ZChUXeGNBniWNa3J this SVG]. | The first part of the tutorial requires an interesting shape. If you have Inkscape you can use the previous tutorial to load it into octave. Here I will be using [http://ubuntuone.com/5pNS12ZChUXeGNBniWNa3J this SVG]. | ||
Line 25: | Line 25: | ||
P = bsxfun (@minus, P, centroid (P)); | P = bsxfun (@minus, P, centroid (P)); | ||
</pre>}} | </pre>}} | ||
Now we have our SVG as a polygon compatible with the Geometry package format. You can plot the polygon using the function | Now we have our SVG as a polygon compatible with the Geometry package format. You can plot the polygon using the function {{Codeline|drawPolygon}}. the next step is to mesh the interior of the polygon. To do this we could just call {{Codeline|delaunay}} on the polygon and be done with it, but in general such mesh wont be so nice (you will need to add interior points). A very effective way of generating a good mesh is to use the package {{Forge|msh}}, which requires [http://geuz.org/gmsh/ Gmsh] installed in your system. The function {{Codeline|data2geo}} in the Geometry package makes our work very easy: | ||
{{Code|Generating mesh for plot with msh package|<pre> | {{Code|Generating mesh for plot with msh package|<pre> | ||
Line 36: | Line 36: | ||
<!-- </syntaxhighlight> --> | <!-- </syntaxhighlight> --> | ||
To plot the generated mesh we use the function | To plot the generated mesh we use the function {{Codeline|pdemesh}} from the {{Forge|fpl}} package. | ||
{{Code|Plotting mesh with fpl package|<pre> | {{Code|Plotting mesh with fpl package|<pre> |