From e4bde0c90b0962db210d1ca0716deef2786e0574 Mon Sep 17 00:00:00 2001 From: schrage Date: Fri, 23 Apr 1999 13:12:06 +0000 Subject: [PATCH] Finished page. git-svn-id: https://svn.dealii.org/trunk@1202 0785d39b-7218-0410-832d-ea1e28bc413d --- .../chapter-1.elements/matrix_generation.html | 103 +++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/deal.II/doc/tutorial/chapter-1.elements/matrix_generation.html b/deal.II/doc/tutorial/chapter-1.elements/matrix_generation.html index e0de64eba1..09ad3d2352 100644 --- a/deal.II/doc/tutorial/chapter-1.elements/matrix_generation.html +++ b/deal.II/doc/tutorial/chapter-1.elements/matrix_generation.html @@ -17,6 +17,65 @@

Matrix and Vector Generation

+

Different kinds of matrices

+

+There are several kinds of matrices we will deal with: +

+ + +

The full matrix

+ +

+The full matrix is assumed to have mostly cells of non-zero value. +Therefore it consumes a lot of memory, much more than the other matrix types. +It is initialized using FullMatrix::reinit(const unsigned +int rows, const unsigned int cols). +

+ +

+Example: We show the include files you need, +the definitions and the function calls. Make sure to use them in their +appropriate places. This example initializes a full matrix of doubles +with 100 rows and 50 columns. +

+
+
+#include <grid/dof.h>
+#include <lac/fullmatrix.h>
+
+FullMatrix<double> A;
+
+A.reinit(100,50);
+
+
+ + +

The sparse matrix

+ +

+A sparse matrix is a matrix with mostly zero elements. In other words, +it is possible to store this matrix efficiently, which can be important +for large systems of equations. Before generating a sparse matrix you +will have to generate a +sparse matrix structure +to initialize the sparse matrix with. This is simply due to the fact that +before you can generate a memory-efficient matrix for your special +problem you need information about the matrix structure, i.e. where +the matrix has non-zero entries. +

@@ -39,7 +98,7 @@ DoFHandler<dim> dof; smstruct.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs()); -// If you grid is locally refined, condense the hanging nodes into the +// If your grid is locally refined, condense the hanging nodes into the // structure. smstruct.compress(); @@ -48,6 +107,48 @@ sm.reinit(smstruct); +

The block sparse matrix

+ +

+A block matrix is assumed to consist of blocks on the diagonal with all +the blocks having the same size. +It is initialized using +BlockSparseMatrix::reinit(const SparseMatrixStruct &sparsity) +Since this is a sparse matrix, i.e. a matrix that can be +stored efficiently, we need to generate a matrix structure first, like for the +sparse matrix. In fact, the block sparse matrix is just a specialization of +the sparse matrix. +

+ +

+Example: We show the include files you need, +the definitions and the function calls. Make sure to use them in their +appropriate places. +

+
+
+#include <grid/dof.h>
+#include <lac/blocksparsematrix.h>
+
+int dim=2; // 2 Dimensions, could also be three
+SparseMatrixStruct<double> smstruct;
+DoFHandler<dim> dof;
+BlockSparseMatrix<double> A;
+
+
+// Your degrees of freedom must already be distributed
+
+smstruct.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
+
+// If your grid is locally refined, condense the hanging nodes into the
+// structure.
+
+smstruct.compress();
+
+A.reinit(smstruct);
+
+
+
-- 2.39.5