From 5923bdd4d50100160b31490e43549a66dfa41e54 Mon Sep 17 00:00:00 2001 From: schrage Date: Mon, 12 Apr 1999 14:43:53 +0000 Subject: [PATCH] Guido's suggestions. Grid Creation within a program added. git-svn-id: https://svn.dealii.org/trunk@1122 0785d39b-7218-0410-832d-ea1e28bc413d --- .../chapter-1.elements/grid_creation.html | 83 +++++++++++++++++-- 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/deal.II/doc/tutorial/chapter-1.elements/grid_creation.html b/deal.II/doc/tutorial/chapter-1.elements/grid_creation.html index 5565514063..68d0b2e442 100644 --- a/deal.II/doc/tutorial/chapter-1.elements/grid_creation.html +++ b/deal.II/doc/tutorial/chapter-1.elements/grid_creation.html @@ -12,12 +12,13 @@

Creation of a Grid

-

Grid Types

+

Different kinds of grids

-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.

@@ -34,20 +35,19 @@ A hypercube can be created using the function
void Triangulation::create_hypercube(const double left=0.,const double right=1.)
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.

-Example: Below we show the includes, +Example - create the square [-1,1]x[-1,x]: 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]dim.

 
 #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);
@@ -127,8 +127,6 @@ this is possible. deal.II offers the possibility of
 reading a complete triangulation from a file in the ucd-format 
 used by avs. A ucd-file can be read with the function
void DataIn::read_ucd(istream&)
-At present only lines in one dimension and lines and quads in two dimensions -are accepted. All other data is rejected.

Vertex numbering in input files: @@ -142,10 +140,76 @@ encountered in two dimensions can be found in the DataIn class description.

+ +

Custom grid creation from within a program

+ +

+Another way to build cutom grids is to use deal.II methods +for creating grid cells and their properties. This is done in the order +

    +
  1. vertices
  2. +
  3. cells
  4. +
  5. boundaries
  6. +
  7. create a triangulation from this information
  8. +
+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. +

+Example: 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. +

+
+
+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);
+
+
+ +
+ @@ -162,3 +226,4 @@ Last modified: $Date$

+ -- 2.39.5