21extern "C" void set_arms_pars(io_t* io,
int Dscale,
int *ipar,
double *tolcoef,
int *lfil);
23#include <boost/timer/timer.hpp>
24#include "dune/istl/preconditioners.hh"
40 typedef typename Op::Range Range;
42 typedef typename Op::field_type field_type;
47 static char main[] =
"main";
49 boost::timer::cpu_timer iluTimer;
50 std::cout <<
"ilut constructor: ";
52 int n = A.
nrows(), nnz = A.
nnz(), ierr;
55 csmat = (csptr)Malloc(
sizeof(SparMat), main );
56 ierr = COOcs(n, nnz, &A.
data[0], &A.
cidx[0], &A.
ridx[0], csmat);
59 printf(
" *** ILU error - COOcs code %d csmat=%p\n", ierr, csmat);
63 lu = (iluptr)Malloc(
sizeof(ILUSpar), main);
64 ierr = ilut(csmat, lu, lfil, tol, flog);
67 printf(
" *** PrecondType::ILUT error - ilut code %d lu=%p\n", ierr, lu);
71 xx = (
double *)Malloc(n*
sizeof(
double), main);
72 yy = (
double *)Malloc(n*
sizeof(
double), main);
75 std::cout <<
"PrecondType::ILUT: n=" << n <<
", nnz=" << nnz <<
" dropTol=" << tol <<
", fillfac="
76 << 1.0*nnz_ilu(lu)/(nnz+1.0) <<
", lfil=" << lfil <<
", time="
77 << (
double)(iluTimer.elapsed().user)/1e9 <<
"s\n";
88 virtual void pre (Domain&, Range&) {}
89 virtual void post (Domain&) {}
91 virtual void apply (Domain& x, Range
const& y)
103 virtual Dune::SolverCategory::Category
category()
const override
105 return Dune::SolverCategory::sequential;
125 typedef typename Op::Range Range;
126 typedef Range Domain;
127 typedef typename Op::field_type field_type;
133 static char main[] =
"main";
135 boost::timer::cpu_timer iluTimer;
137 int n = A.
nrows(), nnz = A.
nnz(), ierr;
140 csmat = (csptr)Malloc(
sizeof(SparMat), main );
141 ierr = COOcs(n, nnz, &A.
data[0], &A.
cidx[0], &A.
ridx[0], csmat);
144 printf(
" *** ILU error - COOcs code %d csmat=%p\n", ierr, csmat);
148 lu = (iluptr)Malloc(
sizeof(ILUSpar), main);
149 ierr = ilukC(fill_lev, csmat, lu, flog);
152 printf(
" *** PrecondType::ILUK error - ilut code %d lu=%p\n", ierr, lu);
156 xx = (
double *)Malloc(n*
sizeof(
double), main);
157 yy = (
double *)Malloc(n*
sizeof(
double), main);
161 std::cout <<
"PrecondType::ILUK: n=" << n <<
", nnz=" << nnz <<
", fillfac="
162 << 1.0*nnz_ilu(lu)/(nnz+1.0) <<
", fill_lev="
163 << fill_lev <<
", time=" << (
double)(iluTimer.elapsed().user)/1e9 <<
"s\n";
175 virtual void pre (Domain&, Range&) {}
178 virtual void apply (Domain& x, Range
const& y)
190 virtual Dune::SolverCategory::Category
category()
const override
192 return Dune::SolverCategory::sequential;
210 typedef typename Op::Range Range;
211 typedef Range Domain;
212 typedef typename Op::field_type field_type;
215 ARMSPreconditioner(Op& op,
int lfil=4,
double tol=1.0e-2,
int lev_reord=1,
double tolind = 0.2,
int verbosity=2)
217 static char main[] =
"main";
218 static char main2[] =
"main:ArmsSt";
220 boost::timer::cpu_timer iluTimer;
222 int n = A.
nrows(), nnz = A.
nnz(), ierr, diagscal = 1;
225 double droptol[7], dropcoef[7];
230 csmat = (csptr)Malloc(
sizeof(SparMat), main );
231 ierr = COOcs(n, nnz, &A.
data[0], &A.
cidx[0], &A.
ridx[0], csmat);
234 printf(
" *** PrecondType::ARMS error - COOcs code %d csmat=%p\n", ierr, csmat);
238 memset(&io,0,
sizeof(io));
242 for (
int j=0; j<7; j++)
244 lfil_arr[j] = lfil*((int) nnz/n);
245 droptol[j] = tol*dropcoef[j];
248 ArmsSt = (arms) Malloc(
sizeof(armsMat),main2);
251 ierr = arms2(csmat, ipar, droptol, lfil_arr, tolind, ArmsSt, flog);
254 printf(
" *** PrecondType::ARMS error - arms2 code %d ArmsSt=%p\n", ierr, ArmsSt);
258 yy = (
double *)Malloc(n*
sizeof(
double), main);
261 std::cout <<
"PrecondType::ARMS: n=" << n <<
", nnz=" << nnz <<
", dropTol=" << tol
262 <<
", lev_reord=" << lev_reord
263 <<
", lfil=" << lfil <<
", time=" << (double)(iluTimer.elapsed().user)/1e9 <<
"s\n";
273 virtual void pre (Domain&, Range&) {}
276 virtual void apply (Domain& x, Range
const& y)
288 virtual Dune::SolverCategory::Category
category()
const override
290 return Dune::SolverCategory::sequential;
virtual void apply(Domain &x, Range const &y)
virtual Dune::SolverCategory::Category category() const override
returns the category of the operator
virtual void post(Domain &)
ARMSPreconditioner(Op &op, int lfil=4, double tol=1.0e-2, int lev_reord=1, double tolind=0.2, int verbosity=2)
virtual void pre(Domain &, Range &)
virtual void post(Domain &)
ILUKPreconditioner(Op &op, int fill_lev=3, int verbosity=2)
virtual void pre(Domain &, Range &)
virtual Dune::SolverCategory::Category category() const override
returns the category of the operator
virtual void apply(Domain &x, Range const &y)
virtual void apply(Domain &x, Range const &y)
virtual void pre(Domain &, Range &)
virtual void post(Domain &)
virtual Dune::SolverCategory::Category category() const override
returns the category of the operator
ILUTPreconditioner(Op &op, int lfil=240, double tol=1.0e-2, int verbosity=2)
SparseIndexInt nrows() const
Returns number of rows (computes them, if not known)
std::vector< SparseIndexInt > ridx
row indices
std::vector< SparseIndexInt > cidx
column indices
std::vector< Scalar > data
data
void set_arms_pars(io_t *io, int Dscale, int *ipar, double *tolcoef, int *lfil)