~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to dolfin/la/SparsityPattern.h

  • Committer: Anders Logg
  • Date: 2008-05-15 16:02:44 UTC
  • Revision ID: logg@simula.no-20080515160244-e2a4wkfxfzmts16s
Add new class SingularSolver:

This class provides a linear solver for singular linear systems
Ax = b where A has a one-dimensional null-space (kernel). This
may happen for example when solving Poisson's equation with
pure Neumann boundary conditions.

The solver attempts to create an extended non-singular system
by adding the constraint [1, 1, 1, ...]^T x = 0.

If an optional mass matrix M is supplied, the solver attempts
to create an extended non-singular system by adding the
constraint m^T x = 0 where m is the lumped mass matrix. This
corresponds to setting the average (integral) of the finite
element function with coefficients x to zero.

The solver makes not attempt to check that the null-space is
indeed one-dimensional. It is also assumed that the system
Ax = b retains its sparsity pattern between calls to solve().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Copyright (C) 2007 Garth N. Wells
2
2
// Licensed under the GNU LGPL Version 2.1.
3
3
//
4
 
// Modified by Anders Logg 2007.
 
4
// Modified by Anders Logg, 2007-2008.
5
5
//
6
6
// First added:  2007-03-13
7
 
// Last changed: 2007-04-03
 
7
// Last changed: 2008-05-15
8
8
 
9
9
#ifndef __SPARSITY_PATTERN_H
10
10
#define __SPARSITY_PATTERN_H
27
27
  {
28
28
  public:
29
29
 
30
 
    /// Constructor
 
30
    /// Create empty sparsity pattern
31
31
    SparsityPattern();
32
 
    
 
32
  
 
33
    /// Create sparsity pattern for matrix of given dimensions
 
34
    SparsityPattern(uint M, uint N);
 
35
 
 
36
    /// Create sparsity pattern for vector of given dimension
 
37
    SparsityPattern(uint M);
 
38
 
33
39
    /// Destructor
34
40
    ~SparsityPattern();
35
41
 
39
45
    /// Initialise sparsity pattern for a parallel matrix with total number of rows and columns
40
46
    void pinit(uint rank, const uint* dims);
41
47
 
42
 
    /// Insert non-zero entry
43
 
    void insert(const uint* num_rows, const uint * const * rows);
 
48
    /// Insert non-zero entries
 
49
    void insert(uint m, const uint* rows, uint n, const uint* cols);
 
50
 
 
51
    /// Insert non-zero entries
 
52
    void insert(const uint* num_rows, const uint * const * rows)
 
53
    { insert(num_rows[0], rows[0], num_rows[1], rows[1]); }
44
54
 
45
55
    /// Insert non-zero entry for parallel matrices
46
56
    void pinsert(const uint* num_rows, const uint * const * rows);