18 #ifndef _FCST_LINEAR_SOLVERS_H_
19 #define _FCST_LINEAR_SOLVERS_H_
21 #include <lac/vector.h>
22 #include <lac/block_vector.h>
24 #include <lac/sparse_matrix.h>
25 #include <lac/block_sparse_matrix.h>
26 #include <lac/filtered_matrix.h>
28 #include <lac/block_matrix_array.h>
29 #include <lac/vector_memory.h>
31 #include <lac/sparse_direct.h>
32 #include <lac/solver_gmres.h>
34 #include <lac/precondition.h>
35 #include <lac/sparse_ilu.h>
37 using namespace dealii;
58 namespace LinearSolvers
107 template<
typename MATRIX,
typename VECTOR>
108 void solve(
const MATRIX& matrix,
110 const VECTOR& right_hand_side)
const
113 tmp = right_hand_side;
115 SparseDirectUMFPACK solver;
116 solver.initialize(matrix);
144 GMRESSolver() { deallog <<
"Solving the linear system using GMRES" << std::endl; }
171 template<
typename MATRIX,
typename VECTOR,
typename PRECONDITIONER>
172 void solve(
const MATRIX& matrix,
174 const VECTOR& right_hand_side,
175 const unsigned int& n_iter,
176 const double& tolerance,
177 const PRECONDITIONER& preconditioner)
const
179 SolverControl solver_control(n_iter,
182 typename SolverGMRES< VECTOR >::AdditionalData additional_data(100,
186 SolverGMRES< VECTOR > solver(solver_control,
219 preconditioner_matrix(matrix.n_block_rows()),
220 preconditioner_pointer(matrix.n_block_rows())
222 deallog <<
"ILUPreconditioner is used" << std::endl;
224 preconditioner.initialize(matrix.n_block_rows(),
227 for(
unsigned int i = 0; i < matrix.n_block_rows(); ++i)
229 preconditioner_matrix[i].initialize(matrix.block(i,i),
230 SparseILU<double>::AdditionalData());
231 preconditioner_pointer[i].set_memory(&
vector_pool);
232 preconditioner_pointer[i] = &preconditioner_matrix[i];
235 for(
unsigned int i = 0; i < matrix.n_block_rows(); ++i)
236 for(
unsigned int j = 0; j < matrix.n_block_cols(); ++j)
239 preconditioner.enter(preconditioner_pointer[i], i, i);
241 preconditioner.enter(matrix.block(i,j), i, j);