From 485bd6eb10cde642297c20f6c1213e7f15ff640b Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Sat, 19 Sep 2009 16:02:21 +0000 Subject: [PATCH] introduce a new class that contains a matrix and its position in the block system git-svn-id: https://svn.dealii.org/trunk@19479 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/matrix_block.h | 119 +++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 deal.II/lac/include/lac/matrix_block.h diff --git a/deal.II/lac/include/lac/matrix_block.h b/deal.II/lac/include/lac/matrix_block.h new file mode 100644 index 0000000000..325849c744 --- /dev/null +++ b/deal.II/lac/include/lac/matrix_block.h @@ -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 + +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 > > blocks; + * + * ... + * + * BlockMatrixArray matrix (n_blocks, n_blocks); + * + * for (unsigned int i=0;i +struct MatrixBlock +{ + /** + * Constructor rendering an + * uninitialized object. + */ + MatrixBlock(); + + /** + * Copy constructor. + */ + MatrixBlock(const MatrixBlock& 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 +MatrixBlock::MatrixBlock() + : + row(deal_II_numbers::invalid_unsigned_int), + column(deal_II_numbers::invalid_unsigned_int) +{} + + +template +MatrixBlock::MatrixBlock(const MatrixBlock& M) + : + row(M.row), + column(M.column), + matrix(M.matrix) +{} + + +template +MatrixBlock::MatrixBlock(unsigned int i, unsigned int j) + : + row(i), column(j) +{} + + +DEAL_II_NAMESPACE_CLOSE + +#endif -- 2.39.5