/usr/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h is in libdeal.ii-dev 6.3.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | //---------------------------------------------------------------------------
// $Id: petsc_parallel_block_sparse_matrix.h 20934 2010-04-02 13:09:20Z bangerth $
// Version: $Name$
//
// Copyright (C) 2004, 2005, 2006, 2007, 2010 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__petsc_parallel_block_sparse_matrix_h
#define __deal2__petsc_parallel_block_sparse_matrix_h
#include <base/config.h>
#ifdef DEAL_II_USE_PETSC
# include <base/table.h>
# include <lac/block_matrix_base.h>
# include <lac/petsc_parallel_sparse_matrix.h>
# include <lac/petsc_parallel_block_vector.h>
# include <lac/exceptions.h>
# include <cmath>
DEAL_II_NAMESPACE_OPEN
namespace PETScWrappers
{
namespace MPI
{
/*! @addtogroup PETScWrappers
*@{
*/
/**
* Blocked sparse matrix based on the PETScWrappers::SparseMatrix class. This
* class implements the functions that are specific to the PETSc SparseMatrix
* base objects for a blocked sparse matrix, and leaves the actual work
* relaying most of the calls to the individual blocks to the functions
* implemented in the base class. See there also for a description of when
* this class is useful.
*
* In contrast to the deal.II-type SparseMatrix class, the PETSc matrices do
* not have external objects for the sparsity patterns. Thus, one does not
* determine the size of the individual blocks of a block matrix of this type
* by attaching a block sparsity pattern, but by calling reinit() to set the
* number of blocks and then by setting the size of each block separately. In
* order to fix the data structures of the block matrix, it is then necessary
* to let it know that we have changed the sizes of the underlying
* matrices. For this, one has to call the collect_sizes() function, for much
* the same reason as is documented with the BlockSparsityPattern class.
*
* @ingroup Matrix1
* @see @ref GlossBlockLA "Block (linear algebra)"
* @author Wolfgang Bangerth, 2004
*/
class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix>
{
public:
/**
* Typedef the base class for simpler
* access to its own typedefs.
*/
typedef BlockMatrixBase<SparseMatrix> BaseClass;
/**
* Typedef the type of the underlying
* matrix.
*/
typedef BaseClass::BlockType BlockType;
/**
* Import the typedefs from the base
* class.
*/
typedef BaseClass::value_type value_type;
typedef BaseClass::pointer pointer;
typedef BaseClass::const_pointer const_pointer;
typedef BaseClass::reference reference;
typedef BaseClass::const_reference const_reference;
typedef BaseClass::size_type size_type;
typedef BaseClass::iterator iterator;
typedef BaseClass::const_iterator const_iterator;
/**
* Constructor; initializes the
* matrix to be empty, without
* any structure, i.e. the
* matrix is not usable at
* all. This constructor is
* therefore only useful for
* matrices which are members of
* a class. All other matrices
* should be created at a point
* in the data flow where all
* necessary information is
* available.
*
* You have to initialize the
* matrix before usage with
* reinit(BlockSparsityPattern). The
* number of blocks per row and
* column are then determined by
* that function.
*/
BlockSparseMatrix ();
/**
* Destructor.
*/
~BlockSparseMatrix ();
/**
* Pseudo copy operator only copying
* empty objects. The sizes of the
* block matrices need to be the
* same.
*/
BlockSparseMatrix &
operator = (const BlockSparseMatrix &);
/**
* This operator assigns a scalar to
* a matrix. Since this does usually
* not make much sense (should we set
* all matrix entries to this value?
* Only the nonzero entries of the
* sparsity pattern?), this operation
* is only allowed if the actual
* value to be assigned is zero. This
* operator only exists to allow for
* the obvious notation
* <tt>matrix=0</tt>, which sets all
* elements of the matrix to zero,
* but keep the sparsity pattern
* previously used.
*/
BlockSparseMatrix &
operator = (const double d);
/**
* Resize the matrix, by setting
* the number of block rows and
* columns. This deletes all
* blocks and replaces them by
* unitialized ones, i.e. ones
* for which also the sizes are
* not yet set. You have to do
* that by calling the @p reinit
* functions of the blocks
* themselves. Do not forget to
* call collect_sizes() after
* that on this object.
*
* The reason that you have to
* set sizes of the blocks
* yourself is that the sizes may
* be varying, the maximum number
* of elements per row may be
* varying, etc. It is simpler
* not to reproduce the interface
* of the SparsityPattern
* class here but rather let the
* user call whatever function
* she desires.
*/
void reinit (const unsigned int n_block_rows,
const unsigned int n_block_columns);
/**
* Matrix-vector multiplication:
* let $dst = M*src$ with $M$
* being this matrix.
*/
void vmult (BlockVector &dst,
const BlockVector &src) const;
/**
* Matrix-vector
* multiplication. Just like the
* previous function, but only
* applicable if the matrix has
* only one block column.
*/
void vmult (BlockVector &dst,
const Vector &src) const;
/**
* Matrix-vector
* multiplication. Just like the
* previous function, but only
* applicable if the matrix has
* only one block row.
*/
void vmult (Vector &dst,
const BlockVector &src) const;
/**
* Matrix-vector
* multiplication. Just like the
* previous function, but only
* applicable if the matrix has
* only one block.
*/
void vmult (Vector &dst,
const Vector &src) const;
/**
* Matrix-vector multiplication:
* let $dst = M^T*src$ with $M$
* being this matrix. This
* function does the same as
* vmult() but takes the
* transposed matrix.
*/
void Tvmult (BlockVector &dst,
const BlockVector &src) const;
/**
* Matrix-vector
* multiplication. Just like the
* previous function, but only
* applicable if the matrix has
* only one block row.
*/
void Tvmult (BlockVector &dst,
const Vector &src) const;
/**
* Matrix-vector
* multiplication. Just like the
* previous function, but only
* applicable if the matrix has
* only one block column.
*/
void Tvmult (Vector &dst,
const BlockVector &src) const;
/**
* Matrix-vector
* multiplication. Just like the
* previous function, but only
* applicable if the matrix has
* only one block.
*/
void Tvmult (Vector &dst,
const Vector &src) const;
/**
* This function collects the
* sizes of the sub-objects and
* stores them in internal
* arrays, in order to be able to
* relay global indices into the
* matrix to indices into the
* subobjects. You *must* call
* this function each time after
* you have changed the size of
* the sub-objects.
*/
void collect_sizes ();
/**
* Return a reference to the MPI
* communicator object in use with
* this matrix.
*/
const MPI_Comm & get_mpi_communicator () const;
/**
* Make the clear() function in the
* base class visible, though it is
* protected.
*/
using BlockMatrixBase<SparseMatrix>::clear;
};
/*@}*/
// ------------- inline and template functions -----------------
inline
BlockSparseMatrix &
BlockSparseMatrix::operator = (const double d)
{
Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
for (unsigned int r=0; r<this->n_block_rows(); ++r)
for (unsigned int c=0; c<this->n_block_cols(); ++c)
this->block(r,c) = d;
return *this;
}
inline
void
BlockSparseMatrix::vmult (BlockVector &dst,
const BlockVector &src) const
{
BaseClass::vmult_block_block (dst, src);
}
inline
void
BlockSparseMatrix::vmult (BlockVector &dst,
const Vector &src) const
{
BaseClass::vmult_block_nonblock (dst, src);
}
inline
void
BlockSparseMatrix::vmult (Vector &dst,
const BlockVector &src) const
{
BaseClass::vmult_nonblock_block (dst, src);
}
inline
void
BlockSparseMatrix::vmult (Vector &dst,
const Vector &src) const
{
BaseClass::vmult_nonblock_nonblock (dst, src);
}
inline
void
BlockSparseMatrix::Tvmult (BlockVector &dst,
const BlockVector &src) const
{
BaseClass::Tvmult_block_block (dst, src);
}
inline
void
BlockSparseMatrix::Tvmult (BlockVector &dst,
const Vector &src) const
{
BaseClass::Tvmult_block_nonblock (dst, src);
}
inline
void
BlockSparseMatrix::Tvmult (Vector &dst,
const BlockVector &src) const
{
BaseClass::Tvmult_nonblock_block (dst, src);
}
inline
void
BlockSparseMatrix::Tvmult (Vector &dst,
const Vector &src) const
{
BaseClass::Tvmult_nonblock_nonblock (dst, src);
}
}
}
DEAL_II_NAMESPACE_CLOSE
#endif // DEAL_II_USE_PETSC
#endif // __deal2__petsc_parallel_block_sparse_matrix_h
|