*
* @author Guido Kanschat, 1999
*/
-template<class VECTOR>
class PreconditionIdentity
{
public:
/**
* Execute preconditioning.
*/
+ template<class VECTOR>
void operator() (VECTOR&, const VECTOR&) const;
};
double omega;
};
+/**
+ * Preconditioner using an iterative solver. This preconditioner uses
+ * a fully initialized LAC iterative solver for the approximate
+ * inverse of the matrix. Naturally, this solver needs another
+ * preconditionig method.
+ *
+ * Usually, the use of #ReductionControl# is preferred over the use of
+ * the basic #SolverControl in defining this solver.
+ *
+ * @author Guido Kanschat, 1999
+ */
+template<class SOLVER, class MATRIX, class PRECONDITION>
+class PreconditionLACSolver
+{
+ public:
+ /**
+ * Constructor. Provide a solver
+ * object, a matrix, and another
+ * preconditioner for this.
+ */
+ PreconditionLACSolver(SOLVER&,
+ const MATRIX&,
+ const PRECONDITION&);
+ /**
+ * Execute preconditioning.
+ */
+ template<class VECTOR>
+ void operator() (VECTOR&, const VECTOR&) const;
+
+ private:
+ /**
+ * The solver class to use.
+ */
+ SOLVER& solver;
+ /**
+ * The matrix in use.
+ */
+ const MATRIX& matrix;
+ /**
+ * The preconditioner to use.
+ */
+ const PRECONDITION& precondition;
+};
template<class VECTOR>
void
-PreconditionIdentity<VECTOR>::operator() (VECTOR& dst, const VECTOR& src) const
+PreconditionIdentity::operator() (VECTOR& dst, const VECTOR& src) const
{
dst = src;
}
(matrix.*precondition)(dst, src, omega);
}
+//////////////////////////////////////////////////////////////////////
+
+template<class SOLVER, class MATRIX, class PRECONDITION>
+PreconditionLACSolver<SOLVER, MATRIX, PRECONDITION>
+::PreconditionLACSolver(SOLVER& solver,
+ const MATRIX& matrix,
+ const PRECONDITION& precondition)
+ :
+ solver(solver), matrix(matrix), precondition(precondition)
+{}
+
+template<class SOLVER, class MATRIX, class PRECONDITION>
+template<class VECTOR>
+void
+PreconditionLACSolver<SOLVER, MATRIX, PRECONDITION>::operator() (VECTOR& dst,
+ const VECTOR& src) const
+{
+ solver.solve(matrix, dst, src, precondition);
+}
+
+
+
#endif
cd base ; make
cd lac ; make
cd deal.II ; make
+
+clean:
+ cd base ; make clean
+ cd lac ; make clean
+ cd deal.II ; make clean
SolverControl control(100, 1.e-12);
SolverCG<SparseMatrix<double>, Vector<double> >solver(control, mem);
- PreconditionIdentity<Vector<double> > precondition;
+ PreconditionIdentity precondition;
solver.solve(A,u,f,precondition);
u = 0.;
SolverControl cgcontrol(10,0., false, false);
PrimitiveVectorMemory<Vector<double> > cgmem;
SolverCG<SparseMatrix<double>, Vector<double> > cgsolver(cgcontrol, cgmem);
- PreconditionIdentity<Vector<double> > cgprec;
+ PreconditionIdentity cgprec;
MGCoarseGridLACIteration<SolverCG<SparseMatrix<double>, Vector<double> >,
- SparseMatrix<double>, PreconditionIdentity<Vector<double> > >
+ SparseMatrix<double>, PreconditionIdentity>
coarse(cgsolver, mgA[0], cgprec);
MGSmootherLAC smoother(mgA);
SolverControl cgcontrol(20,0., false, false);
PrimitiveVectorMemory<Vector<double> > cgmem;
SolverCG<SparseMatrix<double>, Vector<double> > cgsolver(cgcontrol, cgmem);
- PreconditionIdentity<Vector<double> > cgprec;
+ PreconditionIdentity cgprec;
MGCoarseGridLACIteration<SolverCG<SparseMatrix<double>, Vector<double> >,
- SparseMatrix<double>, PreconditionIdentity<Vector<double> > >
+ SparseMatrix<double>, PreconditionIdentity>
coarse(cgsolver, mgA[tr.n_levels()-2], cgprec);
MGSmootherRelaxation<double>
typedef MGCoarseGridLACIteration<SolverCG<SparseMatrix<double> , Vector<double> >,
SparseMatrix<double>, /*PreconditionRelaxation<SparseMatrix<double> ,*/
- PreconditionIdentity<Vector<double> > >
+ PreconditionIdentity >
Coarse;
FDMG multigrid(level, A, transfer);
// PreconditionRelaxation<SparseMatrix<double> , Vector<double> >
- PreconditionIdentity<Vector<double> >
+ PreconditionIdentity
cgprec;//(A[minlevel], &SparseMatrix<double> ::template precondition_SSOR<double>, 1.2);
Coarse coarsegrid(cgcg, A[minlevel], cgprec);
solver.solve(A,u,f,P);
}
-main()
+int main()
{
ofstream logfile("solver.output");
deallog.attach(logfile);
deallog.depth_console(0);
- PrimitiveVectorMemory<Vector<double> > mem;
- SolverControl control(50, 1.e-5);
+ GrowingVectorMemory<Vector<double> > mem;
+ SolverControl control(100, 1.e-5);
+ SolverControl verbose_control(100, 1.e-5, true);
SolverCG<SparseMatrix<float> , Vector<double> > cg(control, mem);
SolverGMRES<SparseMatrix<float> , Vector<double> > gmres(control, mem,20);
SolverBicgstab<SparseMatrix<float> , Vector<double> > bicgstab(control, mem);
for (unsigned int size=4; size <= 40; size *= 3)
{
- deallog << "Size " << size << endl;
-
unsigned int dim = (size-1)*(size-1);
+ deallog << "Size " << size << " Unknowns " << dim << endl;
+
// Make matrix
FDMatrix testproblem(size, size);
SparseMatrixStruct structure(dim, dim, 5);
SparseMatrix<float> A(structure);
testproblem.laplacian(A);
- PreconditionIdentity<Vector<double> >
+ PreconditionIdentity
prec_no;
PreconditionRelaxation<SparseMatrix<float> , Vector<double> >
prec_sor(A, &SparseMatrix<float> ::template precondition_SOR<double>, 1.2);
-DEAL::Size 4
+DEAL::Size 4 Unknowns 9
DEAL::SOR-diff:0
DEAL:no:cg::Starting
DEAL:no:cg::Starting
DEAL:no:cg::Convergence step 2
-DEAL:no:Bicgstab::Go!
DEAL:no:Bicgstab::Starting
DEAL:no:Bicgstab::Convergence step 3
DEAL:no:GMRES::Starting
DEAL:ssor:cg::Starting
DEAL:ssor:cg::Starting
DEAL:ssor:cg::Convergence step 4
-DEAL:ssor:Bicgstab::Go!
DEAL:ssor:Bicgstab::Starting
DEAL:ssor:Bicgstab::Convergence step 3
DEAL:ssor:GMRES::Starting
DEAL:ssor:GMRES::Starting
DEAL:ssor:GMRES::Convergence step 3
DEAL:ssor:QMRS::Starting
-DEAL:ssor:QMRS::Convergence step 11
+DEAL:ssor:QMRS::Convergence step 5
DEAL:sor:Richardson::Starting
DEAL:sor:Richardson::Convergence step 10
DEAL:sor:cg::Starting
DEAL:sor:cg::Starting
-DEAL:sor:cg::Failure step 50
-DEAL:sor:Bicgstab::Go!
+DEAL:sor:cg::Failure step 100
DEAL:sor:Bicgstab::Starting
DEAL:sor:Bicgstab::Convergence step 5
DEAL:sor:GMRES::Starting
DEAL:sor:GMRES::Starting
DEAL:sor:GMRES::Convergence step 4
DEAL:sor:QMRS::Starting
-DEAL:sor:QMRS::Convergence step 12
-DEAL::Size 12
+DEAL:sor:QMRS::Failure step 100
+DEAL::Size 12 Unknowns 121
DEAL::SOR-diff:0
DEAL:no:cg::Starting
DEAL:no:cg::Starting
DEAL:no:cg::Convergence step 16
-DEAL:no:Bicgstab::Go!
DEAL:no:Bicgstab::Starting
DEAL:no:Bicgstab::Convergence step 13
DEAL:no:GMRES::Starting
DEAL:no:QMRS::Starting
DEAL:no:QMRS::Convergence step 18
DEAL:ssor:Richardson::Starting
-DEAL:ssor:Richardson::Failure step 50
+DEAL:ssor:Richardson::Convergence step 88
DEAL:ssor:cg::Starting
DEAL:ssor:cg::Starting
DEAL:ssor:cg::Convergence step 10
-DEAL:ssor:Bicgstab::Go!
DEAL:ssor:Bicgstab::Starting
DEAL:ssor:Bicgstab::Convergence step 6
DEAL:ssor:GMRES::Starting
DEAL:ssor:GMRES::Starting
DEAL:ssor:GMRES::Convergence step 9
DEAL:ssor:QMRS::Starting
-DEAL:ssor:QMRS::Convergence step 44
+DEAL:ssor:QMRS::Convergence step 12
DEAL:sor:Richardson::Starting
-DEAL:sor:Richardson::Failure step 50
+DEAL:sor:Richardson::Failure step 100
DEAL:sor:cg::Starting
DEAL:sor:cg::Starting
-DEAL:sor:cg::Failure step 50
-DEAL:sor:Bicgstab::Go!
+DEAL:sor:cg::Failure step 100
DEAL:sor:Bicgstab::Starting
DEAL:sor:Bicgstab::Convergence step 19
DEAL:sor:GMRES::Starting
DEAL:sor:GMRES::Starting
DEAL:sor:GMRES::Convergence step 24
DEAL:sor:QMRS::Starting
-DEAL:sor:QMRS::Convergence step 43
-DEAL::Size 36
+DEAL:sor:QMRS::Failure step 100
+DEAL::Size 36 Unknowns 1225
DEAL::SOR-diff:2.21867e-30
DEAL:no:cg::Starting
DEAL:no:cg::Starting
-DEAL:no:cg::Failure step 50
-DEAL:no:Bicgstab::Go!
+DEAL:no:cg::Convergence step 58
DEAL:no:Bicgstab::Starting
DEAL:no:Bicgstab::Convergence step 45
DEAL:no:GMRES::Starting
DEAL:no:GMRES::Starting
-DEAL:no:GMRES::Failure step 50
+DEAL:no:GMRES::Failure step 100
DEAL:no:QMRS::Starting
-DEAL:no:QMRS::Failure step 50
+DEAL:no:QMRS::Convergence step 63
DEAL:ssor:Richardson::Starting
-DEAL:ssor:Richardson::Failure step 50
+DEAL:ssor:Richardson::Failure step 100
DEAL:ssor:cg::Starting
DEAL:ssor:cg::Starting
DEAL:ssor:cg::Convergence step 26
-DEAL:ssor:Bicgstab::Go!
DEAL:ssor:Bicgstab::Starting
DEAL:ssor:Bicgstab::Convergence step 18
DEAL:ssor:GMRES::Starting
DEAL:ssor:GMRES::Starting
DEAL:ssor:GMRES::Convergence step 25
DEAL:ssor:QMRS::Starting
-DEAL:ssor:QMRS::Failure step 50
+DEAL:ssor:QMRS::Convergence step 28
DEAL:sor:Richardson::Starting
-DEAL:sor:Richardson::Failure step 50
+DEAL:sor:Richardson::Failure step 100
DEAL:sor:cg::Starting
DEAL:sor:cg::Starting
-DEAL:sor:cg::Failure step 50
-DEAL:sor:Bicgstab::Go!
+DEAL:sor:cg::Failure step 100
DEAL:sor:Bicgstab::Starting
-DEAL:sor:Bicgstab::Failure step 50
+DEAL:sor:Bicgstab::Convergence step 59
DEAL:sor:GMRES::Starting
DEAL:sor:GMRES::Starting
-DEAL:sor:GMRES::Failure step 50
+DEAL:sor:GMRES::Failure step 100
DEAL:sor:QMRS::Starting
-DEAL:sor:QMRS::Failure step 50
+DEAL:sor:QMRS::Failure step 100
+DEAL::GrowingVectorMemory:Overall allocated vectors: 345
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 20