/*
 $Id: elements.cc,v 1.3 1996/10/11 15:15:15 bzferdma Exp $
 (C)opyright 1996 by Konrad-Zuse-Center, Berlin
 All rights reserved.
 Part of the Kaskade distribution
*/

#include "elements.h"

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

Element:: Element()
{ 
    symPattern  = 0;
    asymPattern = 0;
    DLYPattern  = 0;
}
//-------------------------------------------------------------------------

Element:: ~Element() 
{ 
    delete symPattern;
    delete asymPattern;
    delete DLYPattern;
}
//-------------------------------------------------------------------------


// -- 	         set the default assembling patterns:


void Element:: setPatterns()
{
    int i, k;
    const int nnodes =NoOfNodes();

    symPattern  = new Matrix<int>(NoOfNodes(),NoOfNodes());
    asymPattern = new Matrix<int>(NoOfNodes(),NoOfNodes()); 
    DLYPattern  = 0;

    FORALL_ROWS(*symPattern,i)
      FORALL_COLUMNS(*symPattern,k)
	(*symPattern)(i,k) = (*asymPattern)(i,k) = False;

    for (i=1; i<=nnodes; ++i)
      for (k=1; k<=i; ++k) (*symPattern)(i,k) = True;

    for (i=1; i<=nnodes; ++i)
      for (k=1; k<=nnodes; ++k) (*asymPattern)(i,k) = True;
}
//-------------------------------------------------------------------------


void Element:: initAb(Matrix<Real>& A, Vector<Real>& b) const
{
    int i, j;
    const int dim = NoOfNodes();

    for (i=1; i<=dim; ++i) 
    {
	b[i] = 0.0;
   	for (j=1; j<=dim; ++j) A(i,j) = 0.0;
    }
}
//-------------------------------------------------------------------------

void Element:: initAb(Matrix<Real>& A) const
{
    int i, j;
    const int dim = NoOfNodes();

    for (i=1; i<=dim; ++i) 
   	for (j=1; j<=dim; ++j) A(i,j) = 0.0;
}
//-------------------------------------------------------------------------

void Element:: initAb(Matrix<Complex>& A, Vector<Complex>& b) const
{
    int i, j;
    const int dim = NoOfNodes();

    for (i=1; i<=dim; ++i) 
    {
	b[i] = 0.0;
   	for (j=1; j<=dim; ++j) A(i,j) = 0.0;
    }
}
//-------------------------------------------------------------------------

void Element:: initAb(Matrix<Complex>& A) const
{
    int i, j;
    const int dim = NoOfNodes();

    for (i=1; i<=dim; ++i) 
   	for (j=1; j<=dim; ++j) A(i,j) = 0.0;
}
//-------------------------------------------------------------------------

void Element:: notImplemented(const char* s) const
{
    cout << "\n*** class Element: function " << s << " not implemented\n"; 
    cout.flush(); abort();
}
//-------------------------------------------------------------------------

Num Element:: valueAt(const Vector<Real>& /*unitCoord*/, 
		      const Vector<Num>& /*solution*/)  const
{ notImplemented("valueAt"); return 0; }


void Element:: valueAt(const Vector<Real>& /*unitCoord*/, const Vector<Num>& /*sol*/,
		       Vector<Num>& /*uInt*/, int /*baseNode*/, int /*nComp*/) const
{ notImplemented("valueAt(...)"); }


void Element:: gradientAt(int /*ip*/, const Jacobian& /*Jac*/, const Vector<Num>& /*u*/, 
			  Vector<Num>& /*grad*/) const
{ notImplemented("gradientAt"); }

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

Bool Element:: assembleEllip(const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleEllip"); return 0; }

Bool Element:: assembleMass (const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleMass"); return 0; }

Bool Element:: assembleP (const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleP"); return 0; }

Bool Element:: assembleSource (const PATCH& /*patch*/, Vector<Real>& /*b*/, 
			       const Jacobian& /*Jac*/,
			       const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assembleSource"); return 0; }

Bool Element:: assembleLumpedMass (const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
				   const Jacobian& /*Jac*/,
				   const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLumpedMass"); return 0; }

Bool Element:: assembleLumpedP (const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
				   const Jacobian& /*Jac*/,
				   const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLumpedP"); return 0; }

Bool Element:: assembleConvec(const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
			      const Jacobian& /*Jac*/,
			      const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleConvec"); return 0; }

Bool Element:: assembleNeumannBCs(const PATCH& /*patch*/, Vector<Real>& /*b*/, 
				    const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assembleNeumannBCs"); return 0; }

Bool Element:: assembleInnerBCs(const PATCH& /*patch*/, Vector<Real>& /*b*/, 
				    const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assembleInnerBCs"); return 0; }

Bool Element:: assembleCauchyBCs (const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
				  Vector<Real>& /*b*/, const Matrix<Bool>* /*pattern*/,
				  Real /*time*/)  const
{ notImplemented("assembleCauchyBCs"); return 0; }

Bool Element:: assNeumannBCOnBoundary(const PATCH& /*ed*/, Vector<int>& /*nodes*/, 
				      Vector<Real>& /*b*/, 
				      const Matrix<Bool>* /*pattern*/, 
				      Real /*time*/) const
{ notImplemented("assNeumannBCOnBoundary"); return 0; }

Bool Element:: assBConInnerBoundary(const PATCH& /*ed*/, Vector<int>& /*nodes*/, 
				      Vector<Real>& /*b*/, 
				      const Matrix<Bool>* /*pattern*/, 
				      Real /*time*/) const
{ notImplemented("assBConInnerBoundary"); return 0; }

void Element:: assCauchyBCOnBoundary(const PATCH& /*ed*/, Vector<int>& /*nodes*/, 
				    Matrix<Real>& /*A*/, Vector<Real>& /*b*/, 
				    const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assCauchyBCOnBoundary"); }


void Element:: assembleL2Norm(const PATCH& /*patch*/, Matrix<Real>& /*A*/, 
			      const Jacobian& /*Jac*/,
			      const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleL2Norm"); }

void Element:: assembleLNorm(const PATCH& /*patch*/, Vector<Real>& /*b*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLNorm"); }


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

			// Complex dummies:


Bool Element:: assembleEllip(const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleEllip"); return 0; }

Bool Element:: assembleMass (const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleMass"); return 0; }

Bool Element:: assembleSource (const PATCH& /*patch*/, Vector<Complex>& /*b*/, 
			       const Jacobian& /*Jac*/,
			       const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assembleSource"); return 0; }

Bool Element:: assembleLumpedMass (const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
				   const Jacobian& /*Jac*/,
				   const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLumpedMass"); return 0; }

Bool Element:: assembleP (const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
				   const Jacobian& /*Jac*/,
				   const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLumpedMass"); return 0; }

Bool Element:: assembleLumpedP (const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
				   const Jacobian& /*Jac*/,
				   const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLumpedMass"); return 0; }

Bool Element:: assembleConvec(const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
			      const Jacobian& /*Jac*/,
			      const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleConvec"); return 0; }

Bool Element:: assembleNeumannBCs(const PATCH& /*patch*/, Vector<Complex>& /*b*/, 
				  const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assembleNeumannBCs"); return 0; }

Bool Element:: assembleInnerBCs(const PATCH& /*patch*/, Vector<Complex>& /*b*/, 
				  const Matrix<Bool>* /*pattern*/, Real /*time*/) const
{ notImplemented("assembleInnerBCs"); return 0; }

Bool Element:: assembleCauchyBCs (const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
				  Vector<Complex>& /*b*/,
				  const Matrix<Bool>* /*pattern*/, Real /*time*/)  const
{ notImplemented("assembleCauchyBCs"); return 0; }

void Element:: assembleL2Norm(const PATCH& /*patch*/, Matrix<Complex>& /*A*/, 
			      const Jacobian& /*Jac*/,
			      const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleL2Norm"); }

void Element:: assembleLNorm(const PATCH& /*patch*/, Vector<Complex>& /*b*/, 
			     const Jacobian& /*Jac*/,
			     const Matrix<Bool>* /*pattern*/) const
{ notImplemented("assembleLNorm"); }

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