From 3a488bd99960440a33cc4f9da5934b3d6b6fe47d Mon Sep 17 00:00:00 2001
From: schrage
In order to assemble the matrices we basically need to:
+
First we generate an n times n square matrix where n is the number
@@ -78,16 +79,16 @@ The problem is of the form Au=f:
-
The two lines below calculate trial functions for the finite elements and
for their faces using Gaussian quadrature.
Integration is done locally. Therefore we need appropriate definitions for
+Assembling the problem
What's to be done
+
-
-
void
-Laplace::assemble_primal(const Function<2>& exact, const Function<2>&)
+Laplace::assemble_primal(const Function<2>&exact, const Function<2>&)
{
Generating the matrix structures
+Generating the matrix structures
Calculatinginite element trial functions
+Calculatinginite element trial functions
@@ -95,6 +96,7 @@ for their faces using Gaussian quadrature.
- FEValues<2> fevalues(fe_primal, qc_primal, UpdateFlags(update_gradients |
+ FEValues<2> fevalues(fe_primal, qc_primal, UpdateFlags(update_gradients |
update_JxW_values));
- FEFaceValues<2> ffvalues(fe_primal, qf_primal,
+ FEFaceValues<2> ffvalues(fe_primal, qf_primal,
UpdateFlags(update_JxW_values | update_q_points));
Integrating the problem
-
- vector indices(fe_primal.total_dofs);
+ vector<int> indices(fe_primal.total_dofs);
dVector elvec(fe_primal.total_dofs);
dFMatrix elmat(fe_primal.total_dofs);
@@ -117,7 +119,7 @@ discretized Laplace operator. qc_primal is a Gaussian quadrature.
- for (DoFHandler<2>::active_cell_iterator c = dof_primal.begin_active()
+ for (DoFHandler<2>::active_cell_iterator c = dof_primal.begin_active()
; c != dof_primal.end() ; ++c)
{
fevalues.reinit(c, stb);
@@ -125,15 +127,15 @@ discretized Laplace operator. qc_primal is a Gaussian quadrature.
elvec.clear();
c->get_dof_indices(indices);
- for (unsigned k=0;k dv = fevalues.shape_grad(i,k);
+ const Point<2> dv = fevalues.shape_grad(i,k);
- for (unsigned j=0;j du = fevalues.shape_grad(j,k);
+ const Point<2> du = fevalues.shape_grad(j,k);
elmat(i,j) += fevalues.JxW(k)
* du * dv
@@ -149,45 +151,53 @@ discretized Laplace operator. qc_primal is a Gaussian quadrature.
There are two DEAL functions relevant for us at the moment:
+
static_void interpolate_boundary_values(...)
+
which does exactly what it says. This function returns a list of pairs
of boundary indicators and the according functions denoting the respective
Dirichlet boundary values.
This output is used by
+
static void apply_boundary_values(...)
+
that inserts the proper boundary conditions into the equation system:
- map boundary_values;
- DoFHandler<2>::FunctionMap dirichlet_bc;
+ map<int,double> boundary_values;
+ DoFHandler<2>::FunctionMap dirichlet_bc;
BoundaryFct bfkt;
- dirichlet_bc[0]=&bfkt;
- VectorTools<2>::interpolate_boundary_values(dof_primal,dirichlet_bc,fe_primal,boundary,boundary_values);
+ dirichlet_bc[0]=&bfkt;
+ VectorTools<2>::interpolate_boundary_values(dof_primal,dirichlet_bc,fe_primal,boundary,boundary_values);
u.reinit(f);
- MatrixTools<2>::apply_boundary_values(boundary_values,A,u,f);
+ MatrixTools<2>::apply_boundary_values(boundary_values,A,u,f);
+
First, we need a few definitions:
+
-
boundary_values
maps boundary values computed by interpolate_boundary_values
to boundary indicators,i.e. to boundaries.
dirichlet_bc
maps boundary functions, supplied by us, to boundary indicators. The boundary functions compute the boundary values.
-bfkt is a function returning sin(x)*sin(y)
+bfkt
is a function returning sin(x)*sin(y)
, thereby supplying boundary values.
+
This may seem a bit confusing. What actually happens is the following:
+
interpolate_boundary_values
takes the boundary functions
bfkt
, its relation to boundaries dirichlet_bc
and
@@ -197,11 +207,11 @@ to our boundaries. The function looks at all the boundaries. All we
ever need to do is specify the initial triangulation.
apply_boundary_values
subsequently takes that mapping and
-our equation system Au=f
and inserts the boundary values into
+our equation system Au=f and inserts the boundary values into
the equation system which can then be solved.
-
+
diff --git a/deal.II/doc/tutorial/chapter-3.laplace/index.html b/deal.II/doc/tutorial/chapter-3.laplace/index.html
index f977f4cff8..da40543860 100644
--- a/deal.II/doc/tutorial/chapter-3.laplace/index.html
+++ b/deal.II/doc/tutorial/chapter-3.laplace/index.html
@@ -73,8 +73,7 @@ and the boundary conditions are set
Solving the problem
-
-where the problem is solved
+where the problem is solved
@@ -85,9 +84,13 @@ where the problem is solved
Jan Schrage
-
Last modified: Mon 15 Feb 1999