From b168638dda7812c35e037d9d2d2f4ca3ae7c5d22 Mon Sep 17 00:00:00 2001 From: schrage Date: Wed, 28 Apr 1999 14:02:27 +0000 Subject: [PATCH] First check-in. git-svn-id: https://svn.dealii.org/trunk@1219 0785d39b-7218-0410-832d-ea1e28bc413d --- .../doc/tutorial/chapter-1.elements/rhs.html | 184 ++++++++++++++++++ deal.II/doc/tutorial/figures/zoom_in.eps | 0 2 files changed, 184 insertions(+) create mode 100644 deal.II/doc/tutorial/chapter-1.elements/rhs.html create mode 100644 deal.II/doc/tutorial/figures/zoom_in.eps diff --git a/deal.II/doc/tutorial/chapter-1.elements/rhs.html b/deal.II/doc/tutorial/chapter-1.elements/rhs.html new file mode 100644 index 0000000000..8d15cdc412 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-1.elements/rhs.html @@ -0,0 +1,184 @@ + + + + + +The Problem Matrix and the Right Hand Side + + + + + + + + +

The Problem Matrix and the Right Hand Side

+ +

+Having talked a lot about the initialization of matrices and vectors +we shall now discuss how to fill them. You have to: +

+
    +
  1. Define a quadrature used for approximations.
  2. +
  3. Calculate the trial functions for the + finite elements and their faces. +
  4. +
  5. Integrate the problem locally.
  6. +
  7. Insert your local matrix into the global one.
  8. +
+ +

Calculating finite element trial functions

+ +

+

+ +

+Example: +The two lines below calculate trial functions for the two-dimensional finite element fe and +for its faces using Gaussian quadrature. The first line calculates the trial +function for the finite element associated with the degree of freedom dof, +updating the values of the gradients and of the Jacobi determinant multiplied by a +weight function given by the quadrature qc. The second line +does the same for the faces of the finite element, updating the JxW +values and the quadrature points. +

+
+
+// Calculate the trial functions on the cell faces.
+FEValues<2> fevalues(fe, qc, UpdateFlags(update_gradients |
+					   update_JxW_values));
+FEFaceValues<2> ffvalues(fe, qf,
+	UpdateFlags(update_JxW_values | update_q_points));
+
+
+ +

Integrating the problem

+ +

+Integration of a problem is performed locally, i.e. you have to traverse all +the cells and integrate the problem on the cell. This implies that you need a local +matrix to store your results. This local matrix must then be inserted +into the global problem matrix. +

+ +

+Example: Integration of the two-dimensional Laplace-problem: +Integration is done locally. Therefore we need appropriate definitions for +

+ + +
+
+  vector<int> indices(fe.total_dofs);
+  Vector<double> elvec(fe.total_dofs);
+  
+  FullMatrix<double> elmat(fe.total_dofs);
+
+
+ +

+Next we traverse all the cells and integrate the Laplace problem using the +discretized Laplace operator. qc is a Gaussian +Quadrature<dim>. +

+ +

+The outer loop traverses all the points of the quadrature qc. +The inner two loops traverse the degrees of freedom of the finite element +fe where du and dv are the gradients +with respect to the quadrature points. fevalues.JxW(k) gives +the Jacobi determinant multiplied by the weight of the quadrature point +k. Taken together the line
+ +elmat(i,j) += fevalues.JxW(k) * du * dv; + +
+gives the discretized Laplace operator. +

+ +
+
+// Integrate the problem locally...
+vector<int> indices(fe.total_dofs);
+Vector<double> elvec(fe.total_dofs);
+  
+FullMatrix<double> elmat(fe.total_dofs);
+  
+for (DoFHandler<2>::active_cell_iterator c = dof.begin_active()
+               				; c != dof.end() ; ++c)
+{
+  fevalues.reinit(c, stb);
+  elmat.clear();
+  elvec.clear();
+  c->get_dof_indices(indices);
+    
+  for (unsigned k=0;k
+
+ + + + +
+ + + + + + + +
+
+Jan Schrage
+

+Last modified: $Date$ +

+ + + + diff --git a/deal.II/doc/tutorial/figures/zoom_in.eps b/deal.II/doc/tutorial/figures/zoom_in.eps new file mode 100644 index 0000000000..e69de29bb2 -- 2.39.5