/* $Id: elements2.h,v 1.2 1997/07/11 09:46:08 bzferdma Exp $ */

#ifndef ELEMENTS2_H
#define ELEMENTS2_H

#include "elementsA.h"

typedef Real (shapeFct2)(Real x, Real y);

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


			//  Linear Triangle


class Triangle : public StdElement
{

  public:

    Triangle(Material* material);
    virtual ~Triangle() { }

    virtual int SpaceDim()     const { return 2; }

    virtual int NoOfPoints()   const { return 3; }
    virtual int NoOfNodes()    const { return 3; }

    virtual int NodesOnPoint() const { return 1; }
    virtual int NodesOnEdge()  const { return 0; }
    virtual int InnerNodes ()  const { return 0; }

    virtual int NoOfEdges() const { return 3; }
    virtual int NoOfFaces() const { return 3; }

    virtual Real SF(int node, const Vector<Real>& unitCoord) const 
		      { return (*sf[node])(unitCoord[1], unitCoord[2]); }
    virtual Real dSF(int node, int deriv, const Vector<Real>& unitCoord) const 
    		      { return (*dsf[node][deriv])(unitCoord[1], unitCoord[2]); }


    virtual void assembleConstEllip (const PATCH& patch, Matrix<Real>& A, 
				     const Jacobian& Jac, 
				     const Matrix<Bool>* pattern) const
	    { assembleConstEllip2(patch, A, Jac, pattern); } 

    virtual void assembleConstConvec(const PATCH& patch, Matrix<Real>& A, 
				     const Jacobian& Jac, 
				     const Matrix<Bool>* pattern) const
	    { assembleConstConvec2(patch, A, Jac, pattern); }


  protected:

    Triangle() : StdElement() { }

    
    virtual void basicInit();
    virtual void compConstantMatrices();

    virtual void getLocalFaceNodes(int edNo, Vector<int>& nodes) const;


  protected:

    shapeFct2*  sf[1+3],
    	      *dsf[1+3][1+2]; 	// (*dsf[i][k])(...): dsf(node i)/dx(k)
};
//-------------------------------------------------------------------------


class HQuadTriangle : public Triangle
{

  public:

    HQuadTriangle(Material* material);

    virtual int NoOfNodes()    const { return 6; }
    virtual int NodesOnEdge()  const { return 1; }

    virtual Real SF(int node, const Vector<Real>& unitCoord) const 
		    { return (*HQsf[node])(unitCoord[1], unitCoord[2]); }
    virtual Real dSF(int node, int deriv, const Vector<Real>& unitCoord) const 
    		    { return (*dHQsf[node][deriv])(unitCoord[1], unitCoord[2]); }

  protected:

    HQuadTriangle() : Triangle() { }

    virtual void basicInit();
    virtual void setPatterns();
    virtual void getLocalFaceNodes(int edNo, Vector<int>& nodes) const;

    shapeFct2*  HQsf[1+6],
    	      *dHQsf[1+6][1+2]; // (*dsf[i][k])(...): dsf(node i)/dx(k)
};
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------


class HQuadTriangleFast : public HQuadTriangle
{

  public:

    HQuadTriangleFast(Material* material);

    virtual Bool assembleEllip (const PATCH& patch, Matrix<Real>& A, 
				const Jacobian& Jac, 
				const Matrix<Bool>* pattern) const;
  protected:

    virtual void basicInit();
};
//-------------------------------------------------------------------------

	
// --		   Quadratic Lagrangian Triangle:


class LQuadTriangle : public HQuadTriangle
{

  public:

    LQuadTriangle(Material* material);

    virtual Real SF(int node, const Vector<Real>& unitCoord) const 
		      { return (*LQsf[node])(unitCoord[1], unitCoord[2]); }
    virtual Real dSF(int node, int deriv, const Vector<Real>& unitCoord) const 
    		    { return (*dLQsf[node][deriv])(unitCoord[1], unitCoord[2]); }

  protected:

    virtual void basicInit();

    shapeFct2*  LQsf[1+6],
    	      *dLQsf[1+6][1+2]; // (*dsf[i][k])(...): dsf(node i)/dx(k);

};


#endif
