/* $Id: precondsg.h,v 1.1.1.1 1996/10/02 10:35:52 roitzsch Exp $ */

#ifndef PRECONDSG_H
#define PRECONDSG_H

#include "precond.h"

class SparseMatrix;


// --                  Single-Grid preconditioners


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


class DummyPreconditioner : public Preconditioner
{
  public:

    virtual precondMode mode() { return singleGrid; }

    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
};
//-------------------------------------------------------------------------


class Jacobi : public Preconditioner 
{
  public: 

    virtual precondMode mode() { return singleGrid; }
    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
};

class SGS : public Preconditioner 
{
  public: 

    virtual precondMode mode() { return singleGrid; }
    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
};

class SSOR : public Preconditioner 
{
  protected:
    Real omega;

  public: 
    virtual precondMode mode() { return singleGrid; }
    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
    virtual void initParameters();
};

class TrSSOR : public Preconditioner 
{
  protected:
    Real omega;
    Vector<Num> aux;

  public: 
    TrSSOR();

    virtual precondMode mode() { return singleGrid; }
    virtual void initParameters();

    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void close     (SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
    virtual void AMult (Vector<Num>& s,  SystemMatrix* A, Vector<Num>& r);
    virtual void ATMult(Vector<Num>& s,  SystemMatrix* A, Vector<Num>& r);
};
//-------------------------------------------------------------------------


// --		the Hierarchical Basis Preconditioner:

class HB : public Preconditioner 
{
    int 		maxLevel;
    SystemMatrix*	A0;		// Level 0 matrix
    SystemMatrix*	AM1;		// Matrix of previous level
    Vector<Num>*  	AHBDiag;	// diagonal of hierarchical basis matrix
    FamilyTree* 	familyTree;

  public: 

    HB();
    ~HB();

    virtual precondMode mode() { return multiGrid; }
    virtual void update (SystemMatrix* A, FamilyTree* familyTree,
			 DirichletBCs* dirichletBCs);
    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
};
//-------------------------------------------------------------------------

/*
   class ILU : public Preconditioner 
   {
   protected:
   
   SparseMatrix*  AILU;			// the factorized preconditioner
   Real 	   weight;
   
   public: 
   
   ILU();
   ~ILU();
   
   virtual precondMode mode() { return singleGrid; }
   virtual void update (SystemMatrix* A, FamilyTree* familyTree,
   DirichletBCs* dirichletBCs);
   virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
   virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
};
*/
//-------------------------------------------------------------------------


class ILU : public Preconditioner 
{
  protected:
    Real 	   dropTol;

  public: 

    ILU();
    ~ILU();

    virtual precondMode mode() { return singleGrid; }
    virtual void initialize(SystemMatrix* A, Vector<Num>& x, Vector<Num>& b);
    virtual void invert(Vector<Num>& lhs, SystemMatrix* A, Vector<Num>& rhs);
};

#endif
