#ifndef BIOSOLVER_H
#define BIOSOLVER_H

#include <dolfin.h>

#include "BioProblem.h"
#include "Bioheat.h"
#include "FormArray.h"
#include "SigmaBoard.h"

using namespace dolfin;

class BioSolver
{
public:
    BioSolver(BioProblem* problem);
    virtual ~BioSolver ();

    void solveSystem();
    real step();
    void run();
    void save();

    real getDt() const {return dt;}
    void setDt(const real dt) {this->dt = dt; dt_f->init(problem->getMesh(),dt);}
    real getInitialTime() const {return tInitial;}
    void setInitialTime(const real t) {tInitial = t; this->t = t;}
    uint getNoSamples() const {return no_samples;}
    void setNoSamples(const uint n) {no_samples = n;}
    real getTFinal() const {return tFinal;}
    void setTFinal(const real t) {tFinal = t;}
    Function* getT() const {return T;}
    real getSigmaBoard() const {return sigmaBoard->getSigma();}
    void setSigmaBoard(const real s) {sigmaBoard->setSigma(s);}

private:
    BioProblem* problem;

    Function* T;
    Function* TOld;
    BioheatBilinearForm* a;
    BioheatLinearForm* L;
    FormArray forms;
    LinearPDE* pde;
    File* file_T;
    MeshFunction<uint>* domains;

    MeshSize* h;

    Array<BoundaryCondition*> bcs;

    SigmaBoard* sigmaBoard;
    real tInitial;
    real tFinal;
    real t;
    real dt;
    Function* dt_f;

    uint no_samples;
    uint sample;
};

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