<h1>Creation of a Grid</h1>
-<h2>Grid Types</h2>
+<h2>Different kinds of grids</h2>
<p>
-Choosing the right type of grid can be essential for solving your problem.
+All numerics are done on a grid.
+Choosing the right kind of grid can be essential for solving your problem.
A grid should be chosen to fit your problem space in the best way possible.
-Otherwise you waste memory and computing time.
+This chapter describes coarse grids for the triangulation of your domain.
</p>
<p>
<code>void Triangulation::create_hypercube(const double left=0.,const double right=1.)</code><br>
The cube created is the tensor product of the left and right edges which
default to 0 and 1, creating the unit hypercube. The hypercube will consist of
-exactly one cell.
+exactly one cell. In two dimensions, this amounts to a unit square, in three, to a unit cube.
</p>
<p class="Example">
-<span class="example">Example:</span> Below we show the includes,
+<span class="example">Example - create the square [-1,1]x[-1,x]:</span> Below we show the includes,
definitions and
function calls needed. Be sure to use them in their appropriate places.
-This example will create the hypercube [-1,1]<sup>dim</sup>.
</p>
<pre class="example">
<code>
#include <grid/tria.h>
-int dim=2; // For example
+int dim=2; // Two dimensions; to create a cube set to three
Triangulation<dim> tr;
tr.create_hypercube(-1,1);
reading a complete triangulation from a file in the <tt>ucd</tt>-format
used by avs. A <tt>ucd</tt>-file can be read with the function<br>
<code>void DataIn::read_ucd(istream&)</code><br>
-At present only lines in one dimension and lines and quads in two dimensions
-are accepted. All other data is rejected.
</p>
<p><span class="parhead">Vertex numbering in input files:</span>
<a href="http://gaia.iwr.uni-heidelberg.de/~deal/doc/auto/kdoc/basic/DataIn.html" target="_top"> <code>DataIn</code> class description</a>.
</p>
+
+<h3><a name="program">Custom grid creation from within a program</a></h3>
+
+<p>
+Another way to build cutom grids is to use <acronym>deal.II</acronym> methods
+for creating grid cells and their properties. This is done in the order
+<ol>
+<li>vertices</li>
+<li>cells</li>
+<li>boundaries</li>
+<li>create a triangulation from this information</li>
+</ol>
+You first create the vertices, then create cells by assigning vertices
+to them, then you set the boundary conditions. Last you use this information
+to create a triangulation. This is probably best illustrated by an example.
+<p class="example">
+<span class="example">Example:</span> Below we show the includes,
+definitions and
+function calls needed. Be sure to use them in their appropriate places.
+This example will create a triangulation as shown in this figure. It will
+work only in two dimensions.
+</p>
+<pre class="example">
+<code>
+const Point<2&rt; vertices[8] = { Point<2&rt; (0,0),
+ Point<2&rt; (1,0),
+ Point<2&rt; (1,1),
+ Point<2&rt; (0,1),
+ Point<2&rt; (2,0),
+ Point<2&rt; (2,1),
+ Point<2&rt; (3,0),
+ Point<2&rt; (3,1) };
+const int cell_vertices[3][4] = {{0, 1, 2, 3},
+ {1, 4, 5, 2},
+ {4, 6, 7, 5}};
+
+vector<CellData<2&rt; &rt; cells (3, CellData<2&rt;());
+
+for (unsigned int i=0; i<3; ++i)
+ {
+ for (unsigned int j=0; j<4; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
+
+SubCellData boundary_info;
+if (boundary_conditions == wave_from_left_bottom)
+ {
+ // use Neumann bc at left
+ // (mirror condition)
+ boundary_info.boundary_lines.push_back (CellData<1&rt;());
+ boundary_info.boundary_lines.back().material_id = 1;
+ boundary_info.boundary_lines[0].vertices[0] = 0;
+ boundary_info.boundary_lines[0].vertices[1] = 3;
+ };
+
+coarse_grid-&rt;create_triangulation (vector<Point<2&rt; &rt;(&vertices[0],
+ &vertices[8]),
+ cells, boundary_info);
+</code>
+</pre>
+
+
<hr>
<table class="navbar" >
<tr>
+ <td>
+ <a href="dofs.html">Next chapter: Degrees of Freedom</a>
+ </td>
<td>
<a href="toc.html">Back to this chapter's index</a>
</td>
</p>
</body>
</html>
+