/* $Id: materialsA.h,v 1.3 1996/11/19 10:01:56 bzferdma Exp $ */

#ifndef MATERIALSA_H
#define MATERIALSA_H

#include "materials.h"

class Parser;

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


class DefaultMaterial : public Material
{
  public:
 
    DefaultMaterial(int spaceDim0);
    DefaultMaterial(const char* fileName, int spaceDim0);
    virtual ~DefaultMaterial();

    virtual Bool EllipticTerm  (int type) { return eTerm[type]; }
    virtual Bool MassTerm      (int type) { return mTerm[type]; }
    virtual Bool PTerm         (int type) { return pTerm[type]; }
    virtual Bool ConvectionTerm(int type) { return cTerm[type]; }
    virtual Bool SourceTerm    (int type) { return sTerm[type]; }


    // Derived class: Redefine setMaterialType() due to overloaded E
    virtual void setMaterialType();
    virtual Real E(int type, Vector<Real>* /*x*/=0, int i=1, int j=1) 
    						{ return (*eVal[type])(i,j); }
    virtual Real M(int type, Vector<Real>* /*x*/=0, int i=1, int j=1) 
						{ return (*mVal[type])(i,j); }
    virtual Real P(int type, Vector<Real>* /*x*/=0, int i=1, int j=1) 
						{ return (*pVal[type])(i,j); }
    virtual Real C(int type, int i, Vector<Real>* /*x*/=0) 		
						{ return (*cVal[type])[i]; }
    virtual Real S(int type, Vector<Real>* /*x*/=0, Real /*time*/=0.0) 	
						{ return   sVal[type]; }
    virtual Real Neumann(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Inner(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Cauchy (int type, Vector<Real>* x=0, Real time=0.0);


  protected:

    Vector<Matrix<Real>*> eVal, mVal, pVal;  	       
    Vector<Vector<Real>*> cVal;
    Vector<Real>	  sVal, neumannVal, cauchyVal;

    Vector<Bool> eTerm, mTerm, pTerm, cTerm, sTerm, neumannTerm, cauchyTerm;


    void readMaterials(Parser& parser);
    void readBCValues (Parser& parser);
    void readFactors  (Parser& parser, Real* eFact, Real* mFact,  Real* pFact,
		       Real* cFact, Real* sFact, Real* neumannFact,
		       Real* cauchyFact);
};
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------


class VarSourceMaterial : public DefaultMaterial
{
  public:
 
    VarSourceMaterial(const char* fileName, int spaceDim0);
    virtual ~VarSourceMaterial() { }

    virtual Bool SourceTerm     (int /*type*/) { return True;  }
    virtual Bool constSourceTerm(int /*type*/) { return False; }    
    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0) = 0; 
};
//-------------------------------------------------------------------------

 
class VarEllipticMaterial : public DefaultMaterial   
{
  public:
 
    VarEllipticMaterial(const char* fileName, int spaceDim0);
    virtual ~VarEllipticMaterial() { }

    virtual Bool EllipticTerm     (int /*type*/) { return True;  }
    virtual Bool constEllipticTerm(int /*type*/) { return False; }    

    // Derived class: Redefine setMaterialType() due to overloaded E
    virtual void setMaterialType() { matType = isotropic; }
    virtual Real E(int /*type*/, Vector<Real>* /*x*/=0, int /*i*/=1, int /*j*/=1) { return 1.0; }
};
//-------------------------------------------------------------------------

class LinMaterial : public DefaultMaterial
{
  public:
 
    LinMaterial(const char* fileName, int spaceDim0);
    virtual ~LinMaterial() { }

    virtual Bool SourceTerm     (int /*type*/) { return True;  }
    virtual Bool constSourceTerm(int /*type*/) { return False; }    
    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);

    virtual Bool MassTerm     (int /*type*/) { return True;  }
    virtual Bool constMassTerm(int /*type*/) { return False; }    
    virtual Real M(int type, Vector<Real>* x=0, int i=1, int j=1);

    virtual Bool constNeumannTerm(int /*type*/) { return False; }    
    virtual Bool constCauchyTerm(int /*type*/)  { return False; }    

    virtual Real Neumann(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Cauchy(int type, Vector<Real>* x=0, Real time=0.0);

    virtual Num trueSolInPoint(const Vector<Real>& x, const Real time);
    virtual Bool trueSolKnown() { return True; }

};
//-------------------------------------------------------------------------

class VarPoissonMaterial : public DefaultMaterial
{
  public:
 
    VarPoissonMaterial(const char* fileName, int spaceDim0);
    virtual ~VarPoissonMaterial() { }

    virtual Bool EllipticTerm     (int /*type*/) { return True;  }
    virtual Bool constEllipticTerm(int /*type*/) { return False; }    

    virtual Bool SourceTerm     (int /*type*/) { return True;  }
    virtual Bool constSourceTerm(int /*type*/) { return False; }    

    // Derived class: Redefine setMaterialType() due to overloaded E
    virtual void setMaterialType() { matType = isotropic; }
    virtual Real E(int /*type*/, Vector<Real>* /*x*/=0, int /*i*/=1, int /*j*/=1) { return 1.0; }
    virtual Real S(int /*type*/, Vector<Real>* /*x*/=0, Real /*time*/=0.0)    { return 0.0; }

    //virtual Real E(int type, Vector<Real>* x=0, int i=1, int j=1) = 0;
    //virtual Real S(int type, Vector<Real>* x=0, Real time=0.0) = 0;
};
//-------------------------------------------------------------------------


class UserStaticMaterial : public DefaultMaterial
{
  public:
 
    UserStaticMaterial(const char* fileName, int spaceDim0);
    virtual ~UserStaticMaterial() { }

    virtual Bool EllipticTerm     (int /*type*/) { return True;  }
    virtual Bool constEllipticTerm(int /*type*/) { return False; }    

    virtual Bool MassTerm     (int /*type*/) { return True;  }
    virtual Bool constMassTerm(int /*type*/) { return False; }    

    virtual Bool SourceTerm     (int /*type*/) { return True;  }
    virtual Bool constSourceTerm(int /*type*/) { return False; }    

    virtual Bool constNeumannTerm(int /*type*/) { return False; }    
    virtual Bool constCauchyTerm(int /*type*/)  { return False; }    

    // Derived class: Redefine setMaterialType() due to overloaded E
    virtual void setMaterialType();
    virtual Real E(int type, Vector<Real>* x=0, int i=1, int j=1);
    virtual Real M(int type, Vector<Real>* x=0, int i=1, int j=1);
    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Neumann(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Cauchy(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Inner(int type, Vector<Real>* x=0, Real time=0.0);

    virtual Num trueSolInPoint(const Vector<Real>& x, const Real time);
    virtual Bool trueSolKnown();

  protected:
    virtual Real E1d(Real x);
    virtual Real E2d(Real x, Real y);
    virtual Real E3d(Real x, Real y, Real z);

    virtual Real M1d(Real x);
    virtual Real M2d(Real x, Real y);
    virtual Real M3d(Real x, Real y, Real z);

    virtual Real S1d(Real x);
    virtual Real S2d(Real x, Real y);
    virtual Real S3d(Real x, Real y, Real z);

};
//-------------------------------------------------------------------------

class CylindricCoord : public UserStaticMaterial
{
  public:
 
    CylindricCoord(const char* fileName, int spaceDim0);
    virtual ~CylindricCoord() { }

    // Derived class: Redefine setMaterialType() due to overloaded E
    virtual void setMaterialType();
    virtual Real E(int type, Vector<Real>* x=0, int i=1, int j=1);
    virtual Real M(int type, Vector<Real>* x=0, int i=1, int j=1);
    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Neumann(int type, Vector<Real>* x=0, Real time=0.0);
    virtual Real Cauchy(int type, Vector<Real>* x=0, Real time=0.0);

    virtual Num  trueSolInPoint(const Vector<Real>& x, const Real time);
    virtual Bool trueSolKnown(); 

  protected:
    virtual Real E1d(Real x);
    virtual Real E2d(Real x, Real y);
    virtual Real E3d(Real x, Real y, Real z);

    virtual Real M1d(Real x);
    virtual Real M2d(Real x, Real y);
    virtual Real M3d(Real x, Real y, Real z);

    virtual Real S1d(Real x);
    virtual Real S2d(Real x, Real y);
    virtual Real S3d(Real x, Real y, Real z);

};
//-------------------------------------------------------------------------

class UserVarSource : public VarSourceMaterial
{
  public:
 
    UserVarSource(const char* fileName, int spaceDim0);
    virtual ~UserVarSource() { }

    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);
};
//-------------------------------------------------------------------------


class PeakPoisson : public VarPoissonMaterial
{
  public:
 
    PeakPoisson(const char* fileName, int spaceDim0);
    virtual ~PeakPoisson() { }

    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);

  protected:
    virtual Real S1d(Real x);
    virtual Real S2d(Real x, Real y);
    virtual Real S3d(Real x, Real y, Real z);
};
//-------------------------------------------------------------------------


// -- 	im folgenden die Waermequellen mit Gauss-Kontur,


class PeakSource : public VarSourceMaterial
{
  public:
 
    PeakSource(const char* fileName, int spaceDim0);
    virtual ~PeakSource() { }

    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);

    virtual Num trueSolInPoint(const Vector<Real>& x, const Real time);
    virtual Bool trueSolKnown()   { return True; }

  protected:
    virtual Real S1d(Real x);
    virtual Real S2d(Real x, Real y);
    virtual Real S3d(Real x, Real y, Real z);
};
//-------------------------------------------------------------------------

class MultiPeakSource : public VarSourceMaterial
{
  public:
 
    MultiPeakSource(const char* fileName, int spaceDim0);
    virtual ~MultiPeakSource() { }

    virtual Real S(int type, Vector<Real>* x=0, Real time=0.0);

  protected:
    virtual Real S1d(Real x);
    virtual Real S2d(Real x, Real y);
    virtual Real S3d(Real x, Real y, Real z);
};


#endif
