/*
 $Id: problemstat.cc,v 1.2 1996/10/04 15:07:32 roitzsch Exp $
 (C)opyright 1996 by Konrad-Zuse-Center, Berlin
 All rights reserved.
 Part of the Kaskade distribution
*/

#include "problemstat.h"

#include "physics.h"

#include "triang.h"
#include "elements.h"
#include "dirichletA.h"
#include "materialsA.h"

#include "cmdpars.h"
extern CmdPars Cmd;

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


StaticHeatConduction:: StaticHeatConduction() { }

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

DirichletBCs* StaticHeatConduction:: newDirichletBCs()
{
    if (Cmd.isSet("DirichletBCs","ConstDirichlet"))
         return new ConstDirichletBCs(fileName);
    else if (Cmd.isSet("DirichletBCs","LinDirichlet"))
       return new LinDirichletBCs();
    else if (Cmd.isSet("DirichletBCs","userDirichlet"))
       return new UserDirichletBCs();
    else if (Cmd.isSet("DirichletBCs","cylDirichlet"))
       return new CylDirichletBCs();
    else if (Cmd.isSet("DirichletBCs","QuadDirichlet"))
         return new QuadDirichletBCs();
    else if (Cmd.isSet("DirichletBCs","RootOfRBCs"))
         return new RootOfRBCs();
    else if (Cmd.isSet("DirichletBCs","Layer"))
         return  new LayerBCs();
    else if (Cmd.isSet("DirichletBCs","Slit"))
         return  new SlitBCs();
    else if (Cmd.isSet("DirichletBCs","ConstMCDirichlet"))
         return new ConstMCDirichletBCs(fileName);
    else MissingParameter("DirichletBCs");
    return 0;
}
//-------------------------------------------------------------------------

void StaticHeatConduction:: newMaterial()
{
    delete material;

    if (Cmd.isSet("Material","DefaultMaterial"))
    	 material = new DefaultMaterial(fileName, spaceDim);
    else if (Cmd.isSet("Material","VarElliptic"))
    	 material = new VarEllipticMaterial(fileName, spaceDim);
    else if (Cmd.isSet("Material","VarPoisson"))
    	 material = new VarPoissonMaterial(fileName, spaceDim);
    else if (Cmd.isSet("Material","PeakPoisson"))
    	 material = new PeakPoisson(fileName, spaceDim);
    else if (Cmd.isSet("Material","PeakSource"))
    	 material = new PeakSource(fileName, spaceDim);
    else if (Cmd.isSet("Material","MultiPeakSource"))
    	 material = new MultiPeakSource(fileName, spaceDim);
    else if (Cmd.isSet("Material","CylindricCoord"))
    	 material = new CylindricCoord(fileName, spaceDim);
    else if (Cmd.isSet("Material","UserStatic"))
    	 material = new UserStaticMaterial(fileName, spaceDim);
    else if (Cmd.isSet("Material","LinMaterial"))
    	 material = new LinMaterial(fileName, spaceDim);
    else if (Cmd.isSet("Material","UserVarSource"))
    	 material = new UserVarSource(fileName, spaceDim);

    else MissingParameter("Material");
}
//-------------------------------------------------------------------------


void StaticHeatConduction:: assemble(const Element& elem, 
				     const PATCH& t, const Jacobian& Jac,
				     Matrix<Num>& A, Vector<Num>& b,
				     const Matrix<Bool>* pattern,
				     Bool /*errorEstimatorCall*/)
{
    if (!elem.assembleEllip(t,A,Jac,pattern))
      missingMaterialTerm("elliptic", t.Class());

    elem.assembleMass(t,A,Jac,pattern);
    elem.assembleSource(t,b,Jac,pattern);

    if (t.onBoundary())
    {
	elem.assembleCauchyBCs(t,A,b,pattern);
	elem.assembleNeumannBCs(t,b,pattern);
    }

    //if (Cmd.isTrue("innerBoundary")) elem.assembleInnerBCs(t,b,pattern);
    if (Mesh()->innerBoundary) elem.assembleInnerBCs(t,b,pattern);
}
//-------------------------------------------------------------------------

