]> https://gitweb.dealii.org/ - dealii.git/commitdiff
introduce a new class that contains a matrix and its position in the block system
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Sat, 19 Sep 2009 16:02:21 +0000 (16:02 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Sat, 19 Sep 2009 16:02:21 +0000 (16:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@19479 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/matrix_block.h [new file with mode: 0644]

diff --git a/deal.II/lac/include/lac/matrix_block.h b/deal.II/lac/include/lac/matrix_block.h
new file mode 100644 (file)
index 0000000..325849c
--- /dev/null
@@ -0,0 +1,119 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2007, 2008, 2009 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+#ifndef __deal2__matrix_block_h
+#define __deal2__matrix_block_h
+
+#include <base/config.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+/**
+ * A wrapper around a matrix object, storing the coordinates in a
+ * block matrix as well.
+ *
+ * @note They are the position in the global matrix, where we don't use
+ * BlockSparseMatrix. Matrices may have the same coordinates for the
+ * following reason: A preconditioner for the Oseen system can be
+ * built as a block system, where the pressure block is of the form
+ * M^-1 F A^-1 with m the mass matrix (u,v), A the Laplacian and F the
+ * advection diffusion operator. So, I need to build three matrices
+ * for a single block in my system + in some cases a pressure
+ * stabilization.
+ *
+ * MatrixBlock comes handy when using BlockMatrixArray. Once the
+ * MatrixBlock has been properly initalized and filled, it can be used
+ * as:
+ * @begin{code}
+ * std::vector<MatrixBlock<SparseMatrix<double> > > blocks;
+ *
+ * ...
+ *
+ * BlockMatrixArray matrix (n_blocks, n_blocks);
+ *
+ * for (unsigned int i=0;i<blocks.size;++i)
+ *   matrix.enter(blocks[i].row, blocks[i].column, blocks[i].matrix);
+ * @end{code}
+ *
+ *
+ * @author Guido Kanschat, 2006
+ */
+template <class MATRIX>
+struct MatrixBlock
+{
+                                    /**
+                                     * Constructor rendering an
+                                     * uninitialized object.
+                                     */
+    MatrixBlock();
+    
+                                    /**
+                                     * Copy constructor.
+                                     */
+    MatrixBlock(const MatrixBlock<MATRIX>& M);
+    
+                                    /**
+                                     * Constructor setting block
+                                     * coordinates, but not
+                                     * initializing the matrix.
+                                     */
+    
+    MatrixBlock(unsigned int i, unsigned int j);
+    
+                                    /**
+                                     * Row coordinate.  This is the
+                                     * position of the data member
+                                     * matrix on the global matrix.
+                                     */
+    unsigned int row;
+                                    /**
+                                     * Column coordinate.  This is
+                                     * the position of the data
+                                     * member matrix on the global
+                                     * matrix.
+                                     */
+    unsigned int column;
+    
+                                    /**
+                                     * The matrix itself
+                                     */
+    MATRIX matrix;
+};
+
+
+template <class MATRIX>
+MatrixBlock<MATRIX>::MatrixBlock()
+               :
+               row(deal_II_numbers::invalid_unsigned_int),
+               column(deal_II_numbers::invalid_unsigned_int)
+{}
+
+
+template <class MATRIX>
+MatrixBlock<MATRIX>::MatrixBlock(const MatrixBlock<MATRIX>& M)
+               :
+               row(M.row),
+               column(M.column),
+               matrix(M.matrix)
+{}
+
+
+template <class MATRIX>
+MatrixBlock<MATRIX>::MatrixBlock(unsigned int i, unsigned int j)
+               :
+               row(i), column(j)
+{}
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif

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.