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

#ifndef ADAPTNL_H
#define ADAPTNL_H

#include "adapt.h"

class MLSparseMatrix;
class LinSystem;
class Generation;

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


class RK1 : public DLY
{
  public:

    RK1(Element* elementDLY, Element* elementLagrange,Interface* interfaceDLY);
    virtual ~RK1();
    virtual Bool estimateError(Problem& problem);

  protected:

    Element* lagrangeElementDLY;
    Vector<SBool> doRefine;


    Bool DoRefine(int node) { return doRefine[node]; }

    virtual void distributeError(Problem& problem);

    void solveQuadDefectProblem(Problem& problem, Vector<Num>& error, 
				Vector<Num>& uQ, Vector<Num>& ADiag); 

    virtual void nonLinCorrection(Vector<Num>& error, const Vector<Num>& uQ, 
				  const Vector<Num>& ADiag, 
				  const Vector<Real>& lagrangeAreaWeights,
				  Problem& problem);

    void enforcedPMediaRefinement(Problem& problem);
};
//-------------------------------------------------------------------------


class RKA : public RK1
{
  public:

    RKA(Element* elementDLY, Element* elementLagrange,Interface* interfaceDLY);
    virtual Bool estimateError(Problem& problem);
    
  protected:
    
    virtual void distributeError(Problem& problem);

    void solveQuadProblem(Problem& problem, Vector<Num>& error, 
			  Vector<Num>& uQ, MLSparseMatrix& AQ); 

    virtual void nonLinCorrection(Vector<Num>& error, const Vector<Num>& uQ, 
				  MLSparseMatrix& AQ, 
				  const Vector<Real>& lagrangeAreaWeights,
				  Problem& problem);
};
//-------------------------------------------------------------------------


class RK2 : public RKA
{
  public:

    RK2(Element* elementDLY, Element* elementLagrange,Interface* interfaceDLY);
    virtual Bool estimateError(Problem& problem);

  protected:

    virtual void nonLinCorrection(Vector<Num>& error, const Vector<Num>& uQ, 
				  MLSparseMatrix& AQ, 
				  const Vector<Real>& lagrangeAreaWeights,
				  Problem& problem);
};

#endif
