]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Finish this example.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 20 Dec 1999 15:36:40 +0000 (15:36 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 20 Dec 1999 15:36:40 +0000 (15:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@2092 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/Attic/examples/step-by-step/step-3/step-3.cc
deal.II/examples/step-3/step-3.cc

index 93e06010aa72da175ac3239ce054a4dd235fac5e..25178f6044f4bb578b0132a0ed25f9c70c96e96f 100644 (file)
@@ -1,3 +1,5 @@
+/* $Id$ */
+
                                 // These include files are already
                                 // known to you. They declare the
                                 // classes which handle
 #include <fstream>
 
 
+                                // Instead of the procedural
+                                // programming of previous examples,
+                                // we encapsulate everything into a
+                                // class for this program. The class
+                                // consists of functions which do
+                                // certain aspects of a finite
+                                // element program, a `main' function
+                                // which controls what is done first
+                                // and what is done next, and a list
+                                // of member variables.
 class LaplaceProblem 
 {
   public:
+                                    // This is the constructor:
     LaplaceProblem ();
+
+                                    // And the top-level function,
+                                    // which is called from the
+                                    // outside to start the whole
+                                    // program (see the `main'
+                                    // function at the bottom of this
+                                    // file):
+    void run ();
     
+  private:
+                                    // Then there are some member
+                                    // functions that mostly do what
+                                    // their names suggest. Since
+                                    // they do not need to be called
+                                    // from outside, they are made
+                                    // private to this class.
+  private:
     void make_grid_and_dofs ();
     void assemble_system ();
     void solve ();
     void output_results ();
 
-    void run ();
-    
-  private:
-    Triangulation<2> triangulation;
-    FEQ1<2>          fe;
-    DoFHandler<2>    dof_handler;
-    
+                                    // And then we have the member
+                                    // variables. There are variables
+                                    // describing the triangulation
+                                    // and the numbering of the
+                                    // degrees of freedom...
+    Triangulation<2>     triangulation;
+    DoFHandler<2>        dof_handler;
+    FEQ1<2>              fe;
+
+                                    // ...variables for the sparsity
+                                    // pattern and values of the
+                                    // system matrix resulting from
+                                    // the discretization of the
+                                    // Laplace equation...
     SparseMatrixStruct   sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
-    Vector<double>       system_rhs;
-
+                                    // ...and variables which will
+                                    // hold the right hand side and
+                                    // solution vectors.
     Vector<double>       solution;
+    Vector<double>       system_rhs;
 };
 
 
@@ -153,8 +191,8 @@ void LaplaceProblem::make_grid_and_dofs ()
                                   // the one cell which made up the
                                   // initial grid. Of course, on the
                                   // next coarser level, the number
-                                  // of cells is one quarter of the
-                                  // cells on the finest level,
+                                  // of cells is one quarter that of
+                                  // the cells on the finest level,
                                   // i.e. 256, then 64, 16, 4, and
                                   // 1. We can get the total number
                                   // of cells like this:
index 93e06010aa72da175ac3239ce054a4dd235fac5e..25178f6044f4bb578b0132a0ed25f9c70c96e96f 100644 (file)
@@ -1,3 +1,5 @@
+/* $Id$ */
+
                                 // These include files are already
                                 // known to you. They declare the
                                 // classes which handle
 #include <fstream>
 
 
+                                // Instead of the procedural
+                                // programming of previous examples,
+                                // we encapsulate everything into a
+                                // class for this program. The class
+                                // consists of functions which do
+                                // certain aspects of a finite
+                                // element program, a `main' function
+                                // which controls what is done first
+                                // and what is done next, and a list
+                                // of member variables.
 class LaplaceProblem 
 {
   public:
+                                    // This is the constructor:
     LaplaceProblem ();
+
+                                    // And the top-level function,
+                                    // which is called from the
+                                    // outside to start the whole
+                                    // program (see the `main'
+                                    // function at the bottom of this
+                                    // file):
+    void run ();
     
+  private:
+                                    // Then there are some member
+                                    // functions that mostly do what
+                                    // their names suggest. Since
+                                    // they do not need to be called
+                                    // from outside, they are made
+                                    // private to this class.
+  private:
     void make_grid_and_dofs ();
     void assemble_system ();
     void solve ();
     void output_results ();
 
-    void run ();
-    
-  private:
-    Triangulation<2> triangulation;
-    FEQ1<2>          fe;
-    DoFHandler<2>    dof_handler;
-    
+                                    // And then we have the member
+                                    // variables. There are variables
+                                    // describing the triangulation
+                                    // and the numbering of the
+                                    // degrees of freedom...
+    Triangulation<2>     triangulation;
+    DoFHandler<2>        dof_handler;
+    FEQ1<2>              fe;
+
+                                    // ...variables for the sparsity
+                                    // pattern and values of the
+                                    // system matrix resulting from
+                                    // the discretization of the
+                                    // Laplace equation...
     SparseMatrixStruct   sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
-    Vector<double>       system_rhs;
-
+                                    // ...and variables which will
+                                    // hold the right hand side and
+                                    // solution vectors.
     Vector<double>       solution;
+    Vector<double>       system_rhs;
 };
 
 
@@ -153,8 +191,8 @@ void LaplaceProblem::make_grid_and_dofs ()
                                   // the one cell which made up the
                                   // initial grid. Of course, on the
                                   // next coarser level, the number
-                                  // of cells is one quarter of the
-                                  // cells on the finest level,
+                                  // of cells is one quarter that of
+                                  // the cells on the finest level,
                                   // i.e. 256, then 64, 16, 4, and
                                   // 1. We can get the total number
                                   // of cells like this:

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.