/* $Id: precond.h,v 1.2 1996/10/04 15:07:17 roitzsch Exp $ */

#ifndef PRECOND_H
#define PRECOND_H

#include "general.h"
#include "kvector.h"

class SystemMatrix;
class DirichletBCs;
class FamilyTree;

//-------------------------------------------------------------------------


// -- the base class preconditioner may be used as a dummy (no preconditioning)


class Preconditioner
{
  protected:
    
    SystemMatrix*  AP;				// the actual preconditioner
    DirichletBCs*  dirichletBCs;

    int infoLinSystem, infoPrecond;
    int timeLinSystem, accTimeLinSystem;


  public:

    Preconditioner();
    virtual ~Preconditioner();

    virtual precondMode mode() = 0;
    virtual Bool diagonalOnly() { return False; }

    virtual void update(SystemMatrix* AP, FamilyTree* familyTree,
			DirichletBCs* dirichletBCs);
    virtual void initParameters() { }

    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b) = 0;
    virtual void close     (SystemMatrix* /*A*/, Vector<Num>& /*x*/, Vector<Num>& /*b*/) { }

    virtual void AMult (Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
    virtual void ATMult(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs) = 0;

    virtual int  memSpace(int /*print*/=0)  { return 0; }


  protected:

    void residual(Vector<Num>& newR, Vector<Num>& r, 
		  SystemMatrix& A, Vector<Num>& e);
};

#endif
