#ifndef POTENTIALPROBLEM_H
#define POTENTIALPROBLEM_H

#include <dolfin.h>
#include "TissueParameters.h"

using namespace dolfin;

#warning "put in common defs"
typedef std::vector<std::pair<SubDomain*,Function*> > DirichletBCList;

class PotentialProblem
{
public:
    PotentialProblem(
            Mesh& mesh,
            std::vector<SubDomain*> subdomains,
            Function* source,
            SubDomain* electrode,
            DirichletBCList dirichletBCs,
            TissueParameters& tissueParameters
            ) :
        mesh(mesh),
        subdomains(subdomains),
        source(source),
        electrode(electrode),
        dirichletBCs(dirichletBCs),
        targetPower(20),
        initialResistance(118)
    {
        sigma0_t = new Function(mesh,tissueParameters.getSigma0());
        sigma1_t = new Function(mesh,tissueParameters.getSigma1());
    };

    virtual ~PotentialProblem ()
    {
        delete sigma0_t;
        delete sigma1_t;
    };

    Mesh& getMesh() const {return mesh;}
    std::vector<SubDomain*> getSubdomains() const {return subdomains;}
    Function* getSource() const {return source;}
    SubDomain* getElectrode() const {return electrode;}
    DirichletBCList getDirichletBCs() const {return dirichletBCs;}
    real getTargetPower() const {return targetPower;}
    void setTargetPower(const real p) {targetPower = p;}
    real getTissuePowerFraction() const {return tissuePowerFraction;}
    void setTissuePowerFraction(const real f) {tissuePowerFraction = f;}
    real getInitialResistance() const {return initialResistance;}
    void setInitialResistance(const real r) {initialResistance = r;}
    Function* getTissueSigma0() const {return sigma0_t;}
    Function* getTissueSigma1() const {return sigma1_t;}

private:
    Mesh& mesh;
    std::vector<SubDomain*> subdomains;
    Function* source;
    Function* sigma0_t;
    Function* sigma1_t;
    SubDomain* electrode;
    DirichletBCList dirichletBCs;
    real targetPower;
    real tissuePowerFraction;
    real initialResistance;
};

#endif /* end of include guard: POTENTIALPROBLEM_H */
