Line |
Branch |
Exec |
Source |
1 |
|
|
// ______ ______ _ _ _____ ______ |
2 |
|
|
// | ____| ____| | (_)/ ____| | ____| |
3 |
|
|
// | |__ | |__ | | _| (___ ___| |__ |
4 |
|
|
// | __| | __| | | | |\___ \ / __| __| |
5 |
|
|
// | | | |____| |____| |____) | (__| |____ |
6 |
|
|
// |_| |______|______|_|_____/ \___|______| |
7 |
|
|
// Finite Elements for Life Sciences and Engineering |
8 |
|
|
// |
9 |
|
|
// License: LGL2.1 License |
10 |
|
|
// FELiScE default license: LICENSE in root folder |
11 |
|
|
// |
12 |
|
|
// Main authors: F. Raphel |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef _BCLSOLVER_HPP |
16 |
|
|
#define _BCLSOLVER_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
|
20 |
|
|
// External includes |
21 |
|
|
#ifdef FELISCE_WITH_SUNDIALS |
22 |
|
|
#include "cvode/cvode.h" /* prototypes for CVODE fcts. and consts. */ |
23 |
|
|
#include "nvector/nvector_serial.h" /* serial N_Vector types, fcts., and macros */ |
24 |
|
|
#include "cvode/cvode_dense.h" /* prototype for CVDense */ |
25 |
|
|
#include "sundials/sundials_dense.h" /* definitions DenseMat DENSE_ELEM */ |
26 |
|
|
#include "sundials/sundials_types.h" /* definition of type realtype */ |
27 |
|
|
#include "cvode/cvode_spgmr.h"//tests /* prototypes & constants for CVSPGMR */ |
28 |
|
|
#include "cvode/cvode_band.h" /* prototype for CVBand */ |
29 |
|
|
#include "sundials/sundials_band.h" /* definitions of type DlsMat and macros */ |
30 |
|
|
#include "cvode/cvode_bandpre.h" /* prototypes & constants for CVBANDPRE module */ |
31 |
|
|
#include "sundials/sundials_math.h" /* definition of ABS */ |
32 |
|
|
#endif |
33 |
|
|
|
34 |
|
|
// Project includes |
35 |
|
|
#include <Solver/ionicSolver.hpp> |
36 |
|
|
#include <Solver/cardiacFunction.hpp> |
37 |
|
|
|
38 |
|
|
namespace felisce { |
39 |
|
|
|
40 |
|
|
class BCLUserData { |
41 |
|
|
public: |
42 |
|
|
double u; |
43 |
|
|
int pos; |
44 |
|
|
int iType; |
45 |
|
|
}; |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
class BCLSolver: |
50 |
|
|
public IonicSolver { |
51 |
|
|
public: |
52 |
|
|
//!Constructor. |
53 |
|
|
BCLSolver(FelisceTransient::Pointer fstransient); |
54 |
|
|
//!Destructor. |
55 |
|
|
~BCLSolver() override; |
56 |
|
|
|
57 |
|
|
void initialize(std::vector<PetscVector>& sol_0) override; |
58 |
|
|
|
59 |
|
|
//!Solve the EDO. |
60 |
|
|
void solveEDO() override; |
61 |
|
|
//!Computation of ionic current from EDO solution. |
62 |
|
|
void computeIon() override; |
63 |
|
|
|
64 |
|
|
// functor and acces to variable properties fhn |
65 |
|
|
|
66 |
|
|
inline const std::vector<int>& cellType() const { |
67 |
|
|
return m_cellType; |
68 |
|
|
} |
69 |
|
✗ |
inline std::vector<int>& cellType() { |
70 |
|
✗ |
return m_cellType; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
inline const HeteroMVCoeff& MVCoeff() const { |
74 |
|
|
return m_heteroCoeff; |
75 |
|
|
} |
76 |
|
✗ |
inline HeteroMVCoeff& MVCoeff() { |
77 |
|
✗ |
return m_heteroCoeff; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
|
81 |
|
|
#ifdef FELISCE_WITH_SUNDIALS |
82 |
|
|
static int M_f(realtype t, N_Vector y, N_Vector ydot, void *f_data); |
83 |
|
|
#endif |
84 |
|
|
|
85 |
|
|
static void hgate(double&, double&, double, int); |
86 |
|
|
static void fgate(double&, double&, double, int); |
87 |
|
|
static void rgate(double&, double&, double, int); |
88 |
|
|
static void sgate(double&, double&, double, int); |
89 |
|
|
static double Heaviside(double,double); |
90 |
|
|
|
91 |
|
|
//Variables for CVODE |
92 |
|
|
std::vector<BCLUserData> m_userData; |
93 |
|
|
void * m_data; |
94 |
|
|
std::vector<void *> m_cvode_mem; |
95 |
|
|
#ifdef FELISCE_WITH_SUNDIALS |
96 |
|
|
std::vector<N_Vector> m_initvalue; |
97 |
|
|
std::vector<N_Vector> m_abstol; |
98 |
|
|
#endif |
99 |
|
|
|
100 |
|
|
protected: |
101 |
|
|
HeteroMVCoeff m_heteroCoeff; |
102 |
|
|
std::vector<int> m_cellType; |
103 |
|
|
private: |
104 |
|
|
}; |
105 |
|
|
static std::vector<double> tauhp; //tau_h+ |
106 |
|
|
static std::vector<double> tauhm; //tau_h- |
107 |
|
|
static std::vector<double> taufp; //tau_f+ |
108 |
|
|
static std::vector<double> taufm; //tau_f- |
109 |
|
|
static std::vector<double> taurp; //tau_r+ |
110 |
|
|
static std::vector<double> taurm; //tau_r- |
111 |
|
|
static std::vector<double> tausp; //tau_s+ |
112 |
|
|
static std::vector<double> tausm; //tau_s- |
113 |
|
|
static std::vector<double> gfi; //g_fi |
114 |
|
|
static std::vector<double> Vfi; //V_fi |
115 |
|
|
static std::vector<double> gso; //g_so |
116 |
|
|
static std::vector<double> gsi; //g_si |
117 |
|
|
static std::vector<double> beta1; //beta_1 |
118 |
|
|
static std::vector<double> beta2; //beta_2 |
119 |
|
|
static std::vector<double> V1; //V_1 |
120 |
|
|
static std::vector<double> V2; //V_2 |
121 |
|
|
static std::vector<double> gto; //g_to |
122 |
|
|
static std::vector<double> Vc; //V_c |
123 |
|
|
static std::vector<double> Vs; //V_s |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
|
127 |
|
|
#endif |
128 |
|
|
|