From: schrage Date: Thu, 8 Apr 1999 15:19:35 +0000 (+0000) Subject: First checkin X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d494abdb5839a55b14f66b27cdc23ea3cdf47267;p=dealii-svn.git First checkin git-svn-id: https://svn.dealii.org/trunk@1097 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/tutorial/chapter-1.elements/matrix_structure.html b/deal.II/doc/tutorial/chapter-1.elements/matrix_structure.html new file mode 100644 index 0000000000..1c2872fd32 --- /dev/null +++ b/deal.II/doc/tutorial/chapter-1.elements/matrix_structure.html @@ -0,0 +1,111 @@ + + + + + +Matrix Structure + + + + + + + + +

Matrix Structure

+ +

Why thinking about matrix structures is important

+

+Many of the matrices encountered when trying to solve systems of differential +equations consist mostly of zeroes. At the same time those matrices are +very large, and therefore storage is expensive in terms of memory. +deal.II attempts to resolve this problem by +providing means of generating memory efficient structures for sparse +matrices where only non-zero elements are stored. +

+ +

Ways of dealing with matrix structures provided by deal.II

+

+Before you can build the appropriate matrices for your problem you +need to ascertain where the components of your matrix are non-zero +and generate a structure for storing the matrix accordingly. +This structure +is then used to actually initialize the matrix. +

+ +

The Standard Sparse Matrix

+

+The deal.II function initializing a standard sparse matrix +structure is void SparseMatrixStruct::reinit(const unsigned int m, const unsigned int n, const unsigned int max_per_row). It takes as its arguments +the size of the matrix in question and the maximum number of non-zero elements. +This number can be calculated with +int DoFHandler::max_couplings_between_dofs(). +This matrix structure can then be used to generate a matrix using +void SparseMatrix::reinit(const SparseMatrixStruct &sparsity). +In most cases you will also need to take care of the constraints to your +matrix given by the hanging nodes. +

+ +

+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 sparse square matrix structure. +

+
+
+#include <grid/dof.h>
+#include <lac/sparsematrix.h>
+
+
+int dim=2; // For example
+SparseMatrixStruct<double> smstruct;
+DoFHandler<dim> dof;
+
+// Your degrees of freedom must already be distributed
+
+smstruct.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
+
+
+ +

Compression of Matrix Structures

+ +

+Sparse matrix structure can (and indeed must) be compressed. They can be +compressed because it saves memory and they must be compressed because +the classes dealing with sparse matrices require it. +The appropriate function is void SparseMatrixStruct::compress(). + +

+Example: Starting from the example above, we +compress our matrix structure smstruct. +

+
+
+smstruct.compress();
+
+
+ + + +
+ + + + + + +
+
+Jan Schrage
+

+Last modified: $Date$ +

+ +