24extern "C" void set_arms_pars(io_t* io,
int Dscale,
int *ipar,
double *tolcoef,
int *lfil);
26#include <boost/timer/timer.hpp>
27#include "dune/istl/preconditioners.hh"
43 typedef typename Op::Range Range;
45 typedef typename Op::field_type field_type;
50 static char main[] =
"main";
52 boost::timer::cpu_timer iluTimer;
53 std::cout <<
"ilut constructor: ";
55 int n = A.
nrows(), nnz = A.
nnz(), ierr;
58 csmat = (csptr)Malloc(
sizeof(SparMat), main );
59 ierr = COOcs(n, nnz, &A.
data[0], &A.
cidx[0], &A.
ridx[0], csmat);
62 printf(
" *** ILU error - COOcs code %d csmat=%p\n", ierr, csmat);
66 lu = (iluptr)Malloc(
sizeof(ILUSpar), main);
67 ierr = ilut(csmat, lu, lfil, tol, flog);
70 printf(
" *** PrecondType::ILUT error - ilut code %d lu=%p\n", ierr, lu);
74 xx = (
double *)Malloc(n*
sizeof(
double), main);
75 yy = (
double *)Malloc(n*
sizeof(
double), main);
78 std::cout <<
"PrecondType::ILUT: n=" << n <<
", nnz=" << nnz <<
" dropTol=" << tol <<
", fillfac="
79 << 1.0*nnz_ilu(lu)/(nnz+1.0) <<
", lfil=" << lfil <<
", time="
80 << (
double)(iluTimer.elapsed().user)/1e9 <<
"s\n";
91 virtual void pre (Domain&, Range&) {}
92 virtual void post (Domain&) {}
94 virtual void apply (Domain& x, Range
const& y)
106 virtual Dune::SolverCategory::Category
category()
const override
108 return Dune::SolverCategory::sequential;
128 typedef typename Op::Range Range;
129 typedef Range Domain;
130 typedef typename Op::field_type field_type;
136 static char main[] =
"main";
138 boost::timer::cpu_timer iluTimer;
140 int n = A.
nrows(), nnz = A.
nnz(), ierr;
143 csmat = (csptr)Malloc(
sizeof(SparMat), main );
144 ierr = COOcs(n, nnz, &A.
data[0], &A.
cidx[0], &A.
ridx[0], csmat);
147 printf(
" *** ILU error - COOcs code %d csmat=%p\n", ierr, csmat);
151 lu = (iluptr)Malloc(
sizeof(ILUSpar), main);
152 ierr = ilukC(fill_lev, csmat, lu, flog);
155 printf(
" *** PrecondType::ILUK error - ilut code %d lu=%p\n", ierr, lu);
159 xx = (
double *)Malloc(n*
sizeof(
double), main);
160 yy = (
double *)Malloc(n*
sizeof(
double), main);
164 std::cout <<
"PrecondType::ILUK: n=" << n <<
", nnz=" << nnz <<
", fillfac="
165 << 1.0*nnz_ilu(lu)/(nnz+1.0) <<
", fill_lev="
166 << fill_lev <<
", time=" << (
double)(iluTimer.elapsed().user)/1e9 <<
"s\n";
178 virtual void pre (Domain&, Range&) {}
181 virtual void apply (Domain& x, Range
const& y)
193 virtual Dune::SolverCategory::Category
category()
const override
195 return Dune::SolverCategory::sequential;
213 typedef typename Op::Range Range;
214 typedef Range Domain;
215 typedef typename Op::field_type field_type;
218 ARMSPreconditioner(Op& op,
int lfil=4,
double tol=1.0e-2,
int lev_reord=1,
double tolind = 0.2,
int verbosity=2)
220 static char main[] =
"main";
221 static char main2[] =
"main:ArmsSt";
223 boost::timer::cpu_timer iluTimer;
225 int n = A.
nrows(), nnz = A.
nnz(), ierr, diagscal = 1;
228 double droptol[7], dropcoef[7];
233 csmat = (csptr)Malloc(
sizeof(SparMat), main );
234 ierr = COOcs(n, nnz, &A.
data[0], &A.
cidx[0], &A.
ridx[0], csmat);
237 printf(
" *** PrecondType::ARMS error - COOcs code %d csmat=%p\n", ierr, csmat);
241 memset(&io,0,
sizeof(io));
245 for (
int j=0; j<7; j++)
247 lfil_arr[j] = lfil*((int) nnz/n);
248 droptol[j] = tol*dropcoef[j];
251 ArmsSt = (arms) Malloc(
sizeof(armsMat),main2);
254 ierr = arms2(csmat, ipar, droptol, lfil_arr, tolind, ArmsSt, flog);
257 printf(
" *** PrecondType::ARMS error - arms2 code %d ArmsSt=%p\n", ierr, ArmsSt);
261 yy = (
double *)Malloc(n*
sizeof(
double), main);
264 std::cout <<
"PrecondType::ARMS: n=" << n <<
", nnz=" << nnz <<
", dropTol=" << tol
265 <<
", lev_reord=" << lev_reord
266 <<
", lfil=" << lfil <<
", time=" << (double)(iluTimer.elapsed().user)/1e9 <<
"s\n";
276 virtual void pre (Domain&, Range&) {}
279 virtual void apply (Domain& x, Range
const& y)
291 virtual Dune::SolverCategory::Category
category()
const override
293 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)