#ifndef INCLUDE_NASTDIFFQUOT2DDONORCELL_H
#define INCLUDE_NASTDIFFQUOT2DDONORCELL_H

//-----------------------------------------------------------------------------
//  NastDiffQuot2dDonorCell.h
//-----------------------------------------------------------------------------
//
//  Copyright (C) 1998 Technische Universitaet Muenchen, Germany
//  written by Bernhard Brueck
//
//  This file is part of Nast++
//
//-----------------------------------------------------------------------------
//  CNastDiffQuot2dDonorCell berechnet die Differenzenquotienten nach dem
//  DonorCell Schema mit Upwinding.
//-----------------------------------------------------------------------------
//  Aenderungen:
//

#include "NastConfig.h"
#include "NastDebug.h"
#include "NastDiffQuot2d.h"

class CNastStaggeredGrid2d;
class CNastGeometry2d;

class CNastDiffQuot2dDonorCell : public CNastDiffQuot2d
{
public:
    //-------------------------------------------------------------------------
    //                         Konstruktor + Destruktor
    //-------------------------------------------------------------------------
    //  grid  Gitter
    //  geom  die zugehoerige Geometrie
    //  gamma Upwind-Dikretisierungsfaktor
    //
    CNastDiffQuot2dDonorCell( double gamma );
    ~CNastDiffQuot2dDonorCell();

    //-------------------------------------------------------------------------
    //                            Memberfunktionen
    //-------------------------------------------------------------------------

    double diff_duv_dx( int i, int j ) const;
    double diff_duv_dy( int i, int j ) const;

    double diff_du2_dx( int i, int j ) const;
    double diff_dv2_dy( int i, int j ) const;

    double diff_lapl_u( int i, int j ) const;
    double diff_lapl_v( int i, int j ) const;

    virtual void useGrid( CNastStaggeredGrid2d &grid );

    //-------------------------------------------------------------------------
    //                                  Debug
    //-------------------------------------------------------------------------
    //  debugInfo    gibt Information ueber den Zustand des Objekts aus
    //  assertValid  testet das Objekt auf Integritaet
    //
    virtual void debugDump( CNastDumpContext &dumpContext ) const;
    virtual void assertValid() const;

protected:
    //-------------------------------------------------------------------------
    //                            Hilfsfunktionen
    //-------------------------------------------------------------------------

    CNastStaggeredGrid2d* grid() const;

    //-------------------------------------------------------------------------
    //                            Membervariablen
    //-------------------------------------------------------------------------
    //  Konstanten fuer schnelle Berechnung
    double m_rdx;		//  1 / dx
    double m_rdy;		//  1 / dy
    double m_rdx2;	//  1 / (dx*dx)
    double m_rdy2;	//  1 / (dy*dy)
    double m_r4dx;	//  1 / (4*dx)
    double m_r4dy;	//  1 / (4*dy)
    
    const double m_gamma;	            //  Upwind-Diskretisierungsfaktor
    CNastStaggeredGrid2d *m_pGrid;     //  Gitter

private:
    //  nicht impl.
    CNastDiffQuot2dDonorCell( const CNastDiffQuot2dDonorCell &other);	            
    const CNastDiffQuot2dDonorCell& operator=( const CNastDiffQuot2dDonorCell &other );
};


//-------------------------------------------------------------------------
//                            inline
//-------------------------------------------------------------------------

inline CNastStaggeredGrid2d* 
CNastDiffQuot2dDonorCell::grid() const
{
    NAST_ASSERT( m_pGrid );
    return m_pGrid;
}

#endif // INCLUDE_NASTDIFFQUOT2DDONORCELL_H












