1
// Copyright (C) 2008 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2005-09-19
5
// Last changed: 2008-05-10
7
#ifndef __SINGULAR_SOLVER_H
8
#define __SINGULAR_SOLVER_H
10
#include <dolfin/common/types.h>
11
#include <dolfin/parameter/Parametrized.h>
12
#include "LinearSolver.h"
16
/// This class provides a linear solver for singular linear systems
17
/// Ax = b where A has a one-dimensional null-space (kernel). This
18
/// may happen for example when solving Poisson's equation with
19
/// pure Neumann boundary conditions.
21
/// The solver attempts to create an extended non-singular system
22
/// by adding the constraint [1, 1, 1, ...]^T x = 0.
24
/// If an optional mass matrix M is supplied, the solver attempts
25
/// to create an extended non-singular system by adding the
26
/// constraint m^T x = 0 where m is the lumped mass matrix. This
27
/// corresponds to setting the average (integral) of the finite
28
/// element function with coefficients x to zero.
30
/// The solver makes not attempt to check that the null-space is
31
/// indeed one-dimensional. It is also assumed that the system
32
/// Ax = b retains its sparsity pattern between calls to solve().
34
class SingularSolver : public Parametrized
38
/// Create linear solver
39
SingularSolver(SolverType solver_type=lu, PreconditionerType pc_type=ilu);
44
/// Solve linear system Ax = b
45
uint solve(const GenericMatrix& A, GenericVector& x, const GenericVector& b);
47
/// Solve linear system Ax = b using mass matrix M for setting constraint
48
uint solve(const GenericMatrix& A, GenericVector& x, const GenericVector& b,
49
const GenericMatrix& M);
53
// Initialize extended system
54
void init(const GenericMatrix& A);
56
// Create extended system
57
void create(const GenericMatrix& A, const GenericVector& b, const GenericMatrix* M);
60
LinearSolver linear_solver;
65
// Solution of extended system