]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Guido's suggestions. Grid Creation within a program added.
authorschrage <schrage@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Apr 1999 14:43:53 +0000 (14:43 +0000)
committerschrage <schrage@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Apr 1999 14:43:53 +0000 (14:43 +0000)
git-svn-id: https://svn.dealii.org/trunk@1122 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/tutorial/chapter-1.elements/grid_creation.html

index 5565514063ec54833b732db6319efe7b59be21f3..68d0b2e44235ac2d0695e020190cd938c558e3bf 100644 (file)
 
 <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>
@@ -34,20 +35,19 @@ A hypercube can be created using the function<br>
 <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 &lt;grid/tria.h&gt;
 
-int dim=2;  // For example
+int dim=2;  // Two dimensions; to create a cube set to three
 Triangulation&lt;dim&gt; tr;
 
 tr.create_hypercube(-1,1);
@@ -127,8 +127,6 @@ this is possible. <acronym>deal.II</acronym> offers the possibility of
 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>
@@ -142,10 +140,76 @@ encountered in two dimensions can be found in the
 <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&lt;2&rt; vertices[8] = { Point&lt;2&rt; (0,0),               
+                                 Point&lt;2&rt; (1,0),               
+                                 Point&lt;2&rt; (1,1),
+                                 Point&lt;2&rt; (0,1),            
+                                 Point&lt;2&rt; (2,0),        
+                                 Point&lt;2&rt; (2,1),         
+                                 Point&lt;2&rt; (3,0),      
+                                 Point&lt;2&rt; (3,1)  };
+const int cell_vertices[3][4] = {{0, 1, 2, 3},      
+                                 {1, 4, 5, 2},
+                                 {4, 6, 7, 5}};
+                                                                            
+vector&lt;CellData&lt;2&rt; &rt; cells (3, CellData&lt;2&rt;());                
+                                                                                
+for (unsigned int i=0; i&lt;3; ++i)                                        
+  {                                                         
+    for (unsigned int j=0; j&lt;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&lt;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&lt;Point&lt;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>
@@ -162,3 +226,4 @@ Last modified: $Date$
 </p>
 </body>
 </html>
+

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.