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

#ifndef ELEMENTS_H
#define ELEMENTS_H

#include "general.h"

#include "kvector.h"
#include "matrix.h"

class PATCH;
class Jacobian;

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

class Element
{
  public:

    Matrix<Bool>  *symPattern, *asymPattern, *DLYPattern;

    Element();
    virtual ~Element();

    virtual int SpaceDim()     const = 0;

    virtual int NoOfPoints()   const = 0;
    virtual int NoOfNodes()    const = 0;
    virtual int NodesOnPoint() const = 0; 
    virtual int NodesOnEdge()  const = 0; 
    virtual int InnerNodes ()  const = 0; 

    virtual int NoOfEdges() const = 0;
    virtual int NoOfFaces() const = 0;

    virtual Real SF (int node, const Vector<Real>& unitCoord) const = 0;
    virtual Real dSF(int node, int component, const Vector<Real>& unitCoord) 
    								     const = 0;
    void initAb(Matrix<Real>& A, Vector<Real>& b) const;
    void initAb(Matrix<Real>& A) const;
    void initAb(Matrix<Complex>& A, Vector<Complex>& b) const;
    void initAb(Matrix<Complex>& A) const;


    virtual Num valueAt(const Vector<Real>& unitCoord, 
			const Vector<Num>& solution)  const;

    virtual void valueAt(const Vector<Real>& unitCoord, const Vector<Num>& sol,
			 Vector<Num>& uInt, int baseNode, int nComp) const;

    virtual void gradientAt(int ip, const Jacobian& Jac, const Vector<Num>& u, 
			    Vector<Num>& grad) const;

    virtual Bool assembleEllip 	(const PATCH& patch, Matrix<Real>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleMass  	(const PATCH& patch, Matrix<Real>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleLumpedMass(const PATCH& patch, Matrix<Real>& A, 
				    const Jacobian& Jac, 
				    const Matrix<Bool>* pattern) const;
    virtual Bool assembleP  	(const PATCH& patch, Matrix<Real>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleLumpedP(const PATCH& patch, Matrix<Real>& A, 
				    const Jacobian& Jac, 
				    const Matrix<Bool>* pattern) const;

    virtual Bool assembleConvec (const PATCH& patch, Matrix<Real>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleSource	(const PATCH& patch, Vector<Real>& b, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern,
				 Real time=0.0) const;

    virtual Bool assembleNeumannBCs(const PATCH& patch, Vector<Real>& b, 
				    const Matrix<Bool>* pattern, 
				    Real time=0.0) const;
    virtual Bool assembleInnerBCs(const PATCH& patch, Vector<Real>& b, 
				    const Matrix<Bool>* pattern, 
				    Real time=0.0) const;
    virtual Bool assembleCauchyBCs (const PATCH& patch, Matrix<Real>& A, 
				    Vector<Real>& b, 
				    const Matrix<Bool>* pattern, 
				    Real time=0.0) const;

    virtual void assembleL2Norm(const PATCH& patch, Matrix<Real>& A, 
				const Jacobian& Jac, 
				const Matrix<Bool>* pattern) const;
    virtual void assembleLNorm (const PATCH& patch, Vector<Real>& b, 
				const Jacobian& Jac, 
				const Matrix<Bool>* pattern) const;

  protected:

    virtual Bool assNeumannBCOnBoundary(const PATCH& ed, Vector<int>& nodes, 
					Vector<Real>& b, 
					const Matrix<Bool>* pattern, 
					Real time=0.0) const;
    virtual Bool assBConInnerBoundary(const PATCH& ed, Vector<int>& nodes, 
					Vector<Real>& b, 
					const Matrix<Bool>* pattern, 
					Real time=0.0) const;
    virtual void assCauchyBCOnBoundary(const PATCH& ed, Vector<int>& nodes, 
				       Matrix<Real>& A, Vector<Real>& b, 
				       const Matrix<Bool>* pattern, 
				       Real time=0.0) const;
  public:

			// Complex dummies:

    virtual Bool assembleEllip 	(const PATCH& patch, Matrix<Complex>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleMass  	(const PATCH& patch, Matrix<Complex>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleLumpedMass(const PATCH& patch, Matrix<Complex>& A, 
				    const Jacobian& Jac, 
				    const Matrix<Bool>* pattern) const;

    virtual Bool assembleP  	(const PATCH& patch, Matrix<Complex>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleLumpedP(const PATCH& patch, Matrix<Complex>& A, 
				    const Jacobian& Jac, 
				    const Matrix<Bool>* pattern) const;

    virtual Bool assembleConvec (const PATCH& patch, Matrix<Complex>& A, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern) const;
    virtual Bool assembleSource	(const PATCH& patch, Vector<Complex>& b, 
				 const Jacobian& Jac, 
				 const Matrix<Bool>* pattern,
				 Real time=0.0) const;

    virtual Bool assembleNeumannBCs(const PATCH& patch, Vector<Complex>& b, 
				    const Matrix<Bool>* pattern,
				    Real time=0.0) const;
    virtual Bool assembleInnerBCs(const PATCH& patch, Vector<Complex>& b, 
				    const Matrix<Bool>* pattern,
				    Real time=0.0) const;
    virtual Bool assembleCauchyBCs (const PATCH& patch, Matrix<Complex>& A, 
				    Vector<Complex>& b, 
				    const Matrix<Bool>* pattern,
				    Real time=0.0) const;

    virtual void assembleL2Norm(const PATCH& patch, Matrix<Complex>& A, 
				const Jacobian& Jac, 
				const Matrix<Bool>* pattern) const;
    virtual void assembleLNorm (const PATCH& patch, Vector<Complex>& b, 
				const Jacobian& Jac, 
				const Matrix<Bool>* pattern) const;
    
  protected:

    void notImplemented(const char* fct) const;
    virtual void setPatterns();
};
//-------------------------------------------------------------------------

#endif


