17 #ifndef _FCST_LINEAR_SOLVERS_H_
18 #define _FCST_LINEAR_SOLVERS_H_
21 #include <deal.II/lac/vector.h>
22 #include <deal.II/lac/block_vector.h>
23 #include <deal.II/lac/sparse_matrix.h>
24 #include <deal.II/lac/block_sparse_matrix.h>
25 #include <deal.II/lac/block_matrix_array.h>
26 #include <deal.II/lac/vector_memory.h>
27 #include <deal.II/lac/sparse_direct.h>
28 #include <deal.II/lac/solver_gmres.h>
29 #include <deal.II/lac/precondition.h>
30 #include <deal.II/lac/sparse_ilu.h>
32 using namespace dealii;
53 namespace LinearSolvers
102 template<
typename MATRIX,
typename VECTOR>
105 const VECTOR& right_hand_side)
const
108 tmp = right_hand_side;
110 SparseDirectUMFPACK solver;
111 solver.initialize(matrix);
162 template<
typename MATRIX,
typename VECTOR,
typename PRECONDITIONER>
165 const VECTOR& right_hand_side,
166 const unsigned int& n_iter,
167 const double& tolerance,
168 const PRECONDITIONER& preconditioner)
const
170 SolverControl solver_control(n_iter, tolerance);
172 typename SolverGMRES< VECTOR >::AdditionalData additional_data(100,
false,
true);
174 SolverGMRES< VECTOR > solver(solver_control, additional_data);
194 template<
typename MATRIX,
typename VECTOR,
typename PRECONDITIONER>
195 void solve(SolverControl& solver_control,
196 const MATRIX& matrix,
198 const VECTOR& right_hand_side,
199 const PRECONDITIONER& preconditioner)
const
201 SolverGMRES< VECTOR > solver(solver_control);
233 preconditioner_matrix(matrix.n_block_rows()),
234 preconditioner_pointer(matrix.n_block_rows()),
235 preconditioner(matrix.n_block_rows())
239 for(
unsigned int i = 0; i < matrix.n_block_rows(); ++i)
241 preconditioner_matrix[i].initialize(matrix.block(i,i),
242 SparseILU<double>::AdditionalData());
243 preconditioner_pointer[i].set_memory(&
vector_pool);
244 preconditioner_pointer[i] = &preconditioner_matrix[i];
247 for(
unsigned int i = 0; i < matrix.n_block_rows(); ++i)
248 for(
unsigned int j = 0; j < matrix.n_block_cols(); ++j)
251 preconditioner.enter(preconditioner_pointer[i], i, i);
253 preconditioner.enter(matrix.block(i,j), i, j);
This class implements ILU preconditioner.
Definition: linear_solvers.h:221
SparseDirectUMFPACKSolver()
Constructor.
Definition: linear_solvers.h:81
~GMRESSolver()
Destructor.
Definition: linear_solvers.h:144
void solve(const MATRIX &matrix, VECTOR &solution, const VECTOR &right_hand_side) const
This function solves the linear system Ax = b where.
Definition: linear_solvers.h:103
This class implements GMRES solver.
Definition: linear_solvers.h:129
std::vector< PointerMatrixAux< SparseILU< double >, Vector< double > > > preconditioner_pointer
Preconditioner pointer.
Definition: linear_solvers.h:281
static GrowingVectorMemory< BlockVector< double > > block_vector_pool
Definition: linear_solvers.h:60
void solve(SolverControl &solver_control, const MATRIX &matrix, VECTOR &solution, const VECTOR &right_hand_side, const PRECONDITIONER &preconditioner) const
This routine is used when solver_control is an object already initialized.
Definition: linear_solvers.h:195
FCSTLogStream log
Object used to output data to file and, if file attached recorded to a file as well.
BlockTrianglePrecondition< double > preconditioner
Preconditioner.
Definition: linear_solvers.h:270
This class implements an interface to the sparse direct solver UMFPACK, see the link below http://www...
Definition: linear_solvers.h:71
~ILUPreconditioner()
Destructor.
Definition: linear_solvers.h:260
void solve(const MATRIX &matrix, VECTOR &solution, const VECTOR &right_hand_side, const unsigned int &n_iter, const double &tolerance, const PRECONDITIONER &preconditioner) const
This function solves the linear system Ax = b where.
Definition: linear_solvers.h:163
ILUPreconditioner(const BlockSparseMatrix< double > &matrix)
Constructor.
Definition: linear_solvers.h:231
static GrowingVectorMemory< Vector< double > > vector_pool
Memory management objects.
Definition: linear_solvers.h:59
std::vector< SparseILU< double > > preconditioner_matrix
Preconditioner matrix.
Definition: linear_solvers.h:276
GMRESSolver()
Constructor.
Definition: linear_solvers.h:139
~SparseDirectUMFPACKSolver()
Destructor.
Definition: linear_solvers.h:86