NEURON
cvodeobj.h
Go to the documentation of this file.
1 #ifndef cvodeobj_h
2 #define cvodeobj_h
3 
4 #include "nrnmpi.h"
5 #include "nrnneosm.h"
6 //#include "shared/nvector_serial.h"
7 #include "shared/nvector.h"
8 #include "membfunc.h"
9 #include "netcon.h"
10 
11 class NetCvode;
12 class Daspk;
13 class TQItem;
14 class TQueue;
15 typedef std::vector<PreSyn*> PreSynList;
16 struct BAMech;
17 struct NrnThread;
18 class PlayRecList;
19 class PlayRecord;
20 class STEList;
21 class HTList;
22 
23 class CvMembList {
24  public:
25  CvMembList();
26  virtual ~CvMembList();
29  int index;
30 };
31 
32 class BAMechList {
33  public:
38  static void destruct(BAMechList** first);
39 };
40 
41 #define CTD(i) ctd_[((nctd_ > 1) ? (i) : 0)]
43  public:
45  virtual ~CvodeThreadData();
47 
48  int no_cap_count_; // number of nodes with no capacitance
51  Node** no_cap_child_; // connected to nodes that have no capacitance
54  CvMembList* cmlext_; // used only by daspk
55  CvMembList* no_cap_memb_; // used only by cvode, point processes in the no cap nodes
63  PreSynList* psl_th_; // with a threshold
65  double** pv_;
66  double** pvdot_;
67  int nvoffset_; // beginning of this threads states
68  int nvsize_; // total number of states for this thread
69  int neq_v_; // for daspk, number of voltage states for this thread
70  int nonvint_offset_; // synonym for neq_v_. Beginning of this threads nonvint variables.
71  int nonvint_extra_offset_; // extra states (probably Python). Not scattered or gathered.
72  PlayRecList* record_;
73  PlayRecList* play_;
74 };
75 
76 class Cvode {
77  public:
78  Cvode(NetCvode*);
79  Cvode();
80  virtual ~Cvode();
81 
82  virtual int handle_step(NetCvode*, double);
83  virtual int init(double t);
84  virtual int advance_tn();
85  virtual int interpolate(double t);
86  virtual double tn() {
87  return tn_;
88  } // furthest time of advance
89  virtual double t0() {
90  return t0_;
91  } // beginning of last real step
92  void init_prepare();
93 
94  int solve(); // checks event_flag and init or advance_tn
95  void statistics();
96  double gam();
97  double time() const {
98  return t_;
99  }
100  void free_cvodemem();
101  int order();
102  void maxorder(int), minstep(double), maxstep(double);
103 
104  public:
105  double tn_, t0_, t_;
107  bool can_retreat_; // only true after an integration step
108  // statistics
109  void stat_init();
112 
113  private:
114  void alloc_cvode();
115  void alloc_daspk();
116  int cvode_init(double);
117  int cvode_advance_tn();
118  int cvode_interpolate(double);
119  int daspk_init(double);
120  int daspk_advance_tn();
121  int daspk_interpolate(double);
122 
123  public:
124  N_Vector nvnew(long);
125  int setup(N_Vector ypred, N_Vector fpred);
126  int solvex_thread(double* b, double* y, NrnThread* nt);
127  int solvex_thread_part1(double* b, NrnThread* nt);
129  int solvex_thread_part3(double* b, NrnThread* nt);
130  void fun_thread(double t, double* y, double* ydot, NrnThread* nt);
131  void fun_thread_transfer_part1(double t, double* y, NrnThread* nt);
132  void fun_thread_transfer_part2(double* ydot, NrnThread* nt);
133  void fun_thread_ms_part1(double t, double* y, NrnThread* nt);
134  void fun_thread_ms_part2(NrnThread* nt);
135  void fun_thread_ms_part3(NrnThread* nt);
136  void fun_thread_ms_part4(double* ydot, NrnThread* nt);
137  void fun_thread_ms_part34(double* ydot, NrnThread* nt);
138  bool at_time(double, NrnThread*);
139  void set_init_flag();
140  void check_deliver(NrnThread* nt = 0);
141  void evaluate_conditions(NrnThread* nt = 0);
142  void ste_check();
143  void states(double*);
144  void dstates(double*);
145  void error_weights(double*);
146  void acor(double*);
147  void fill(Cvode* standard);
148  // following 7 crucial for local time step recording, also used by global
149  void delete_prl();
150  void record_add(PlayRecord*);
151  void record_continuous();
153  void play_add(PlayRecord*);
154  void play_continuous(double t);
155  void play_continuous_thread(double t, NrnThread*);
156  void do_ode(NrnThread*);
157  void do_nonode(NrnThread* nt = 0);
158  double* n_vector_data(N_Vector, int);
159 
160  private:
161  void cvode_constructor();
162  bool init_global();
163  void init_eqn();
164  void daspk_init_eqn();
165  void matmeth();
166  void nocap_v(NrnThread*);
167  void nocap_v_part1(NrnThread*);
168  void nocap_v_part2(NrnThread*);
169  void nocap_v_part3(NrnThread*);
170  void solvemem(NrnThread*);
171  void atolvec_alloc(int);
172  double h();
173  N_Vector ewtvec();
174  N_Vector acorvec();
177 
178  public:
179  // daspk
182  int res(double, double*, double*, double*, NrnThread*);
183  int psol(double, double*, double*, double, NrnThread*);
184  void daspk_scatter_y(N_Vector); // daspk solves vi,vx instead of vm,vx
185  void daspk_gather_y(N_Vector);
186  void daspk_scatter_y(double*, int);
187  void daspk_gather_y(double*, int);
188  void scatter_y(double*, int);
189  void gather_y(N_Vector);
190  void gather_y(double*, int);
191  void scatter_ydot(double*, int);
192  void gather_ydot(N_Vector);
193  void gather_ydot(double*, int);
194 
195  public:
196  void activate_maxstate(bool);
197  void maxstate(double*);
198  void maxstate(bool, NrnThread* nt = 0);
199  void maxacor(double*);
200 
201  public:
202  void* mem_;
203  N_Vector y_;
204  N_Vector atolnvec_;
205  N_Vector maxstate_;
206  N_Vector maxacor_;
207 
208  public:
210 #if USENEOSIM
211  TQueue* neosim_self_events_;
212 #endif
213  public:
215  NrnThread* nth_; // for lvardt
216  int nctd_;
217  long int* nthsizes_; // N_Vector_NrnThread uses this copy of ctd_[i].nvsize_
219  int neq_;
222  double tstop_;
224 
225  private:
226  void rhs(NrnThread*);
227  void rhs_memb(CvMembList*, NrnThread*);
228  void lhs(NrnThread*);
229  void lhs_memb(CvMembList*, NrnThread*);
230  void triang(NrnThread*);
231  void bksub(NrnThread*);
232 
233  private:
234  // segregation of old vectorized information to per cell info
235  friend class NetCvode;
236  bool is_owner(double*); // for play and record in local step context.
237  bool local_;
238  void daspk_setup1_tree_matrix(); // unused
239  void daspk_setup2_tree_matrix(); // unused
241 
242  private:
244 #if PARANEURON
245  public:
246  bool use_partrans_;
247  int global_neq_;
248  int opmode_; // 1 advance, 2 interpolate, 3 init; for testing
249 #endif // PARANEURON
250 };
251 
252 #endif
Memb_list * ml
Definition: cvodeobj.h:37
BAMechList * next
Definition: cvodeobj.h:35
BAMech * bam
Definition: cvodeobj.h:36
static void destruct(BAMechList **first)
Definition: netcvode.cpp:1358
BAMechList(BAMechList **first)
Definition: netcvode.cpp:1346
Memb_list * ml
Definition: cvodeobj.h:28
int index
Definition: cvodeobj.h:29
CvMembList * next
Definition: cvodeobj.h:27
virtual ~CvMembList()
Definition: netcvode.cpp:1496
Definition: cvodeobj.h:76
void rhs_memb(CvMembList *, NrnThread *)
Definition: cvtrset.cpp:62
int init_calls_
Definition: cvodeobj.h:110
void fun_thread_ms_part2(NrnThread *nt)
Definition: occvode.cpp:746
int neq_
Definition: cvodeobj.h:219
void ste_check()
void free_cvodemem()
Definition: cvodeobj.cpp:1063
bool is_owner(double *)
Definition: netcvode.cpp:6614
double next_at_time_
Definition: cvodeobj.h:221
double t_
Definition: cvodeobj.h:105
int mxb_calls_
Definition: cvodeobj.h:111
long int * nthsizes_
Definition: cvodeobj.h:217
void daspk_setup2_tree_matrix()
void maxstep(double)
Definition: cvodeobj.cpp:1051
double tstop_begin_
Definition: cvodeobj.h:223
void do_nonode(NrnThread *nt=0)
Definition: occvode.cpp:927
void alloc_daspk()
Definition: cvodeobj.cpp:1134
void cvode_constructor()
Definition: cvodeobj.cpp:721
int solvex_thread_part2(NrnThread *nt)
Definition: occvode.cpp:622
void rhs(NrnThread *)
Definition: cvtrset.cpp:16
int advance_calls_
Definition: cvodeobj.h:110
void lhs_memb(CvMembList *, NrnThread *)
Definition: cvtrset.cpp:109
void play_continuous_thread(double t, NrnThread *)
Definition: occvode.cpp:1082
void init_prepare()
Definition: cvodeobj.cpp:893
bool at_time(double, NrnThread *)
Definition: cvodeobj.cpp:768
void nocap_v(NrnThread *)
Definition: occvode.cpp:807
int nctd_
Definition: cvodeobj.h:216
void states(double *)
Definition: occvode.cpp:961
N_Vector atolnvec_
Definition: cvodeobj.h:204
void * mem_
Definition: cvodeobj.h:202
int cvode_init(double)
Definition: cvodeobj.cpp:1084
int jac_calls_
Definition: cvodeobj.h:111
void dstates(double *)
Definition: occvode.cpp:972
int psol(double, double *, double *, double, NrnThread *)
Definition: nrndaspk.cpp:605
bool init_global()
Definition: occvode.cpp:83
void triang(NrnThread *)
Definition: cvtrset.cpp:130
void fun_thread_transfer_part1(double t, double *y, NrnThread *nt)
Definition: occvode.cpp:669
double tstop_end_
Definition: cvodeobj.h:223
TQItem * tqitem_
Definition: cvodeobj.h:240
void record_add(PlayRecord *)
Definition: occvode.cpp:1021
CvodeThreadData * ctd_
Definition: cvodeobj.h:214
void play_add(PlayRecord *)
Definition: occvode.cpp:1060
int prior2init_
Definition: cvodeobj.h:243
void daspk_scatter_y(N_Vector)
Definition: nrndaspk.cpp:393
virtual double tn()
Definition: cvodeobj.h:86
void stat_init()
Definition: cvodeobj.cpp:887
virtual ~Cvode()
Definition: cvodeobj.cpp:858
void gather_y(N_Vector)
Definition: occvode.cpp:490
void daspk_init_eqn()
Definition: occvode.cpp:342
int ts_inits_
Definition: cvodeobj.h:111
int setup(N_Vector ypred, N_Vector fpred)
Definition: occvode.cpp:541
void play_continuous(double t)
Definition: occvode.cpp:1068
void record_continuous()
Definition: occvode.cpp:1029
void statistics()
Definition: cvodeobj.cpp:1433
void lhs(NrnThread *)
Definition: cvtrset.cpp:83
void fun_thread_ms_part4(double *ydot, NrnThread *nt)
Definition: occvode.cpp:757
N_Vector y_
Definition: cvodeobj.h:203
N_Vector maxstate_
Definition: cvodeobj.h:205
Daspk * daspk_
Definition: cvodeobj.h:181
void nocap_v_part2(NrnThread *)
Definition: occvode.cpp:886
void fun_thread_transfer_part2(double *ydot, NrnThread *nt)
Definition: occvode.cpp:693
void daspk_setup1_tree_matrix()
void new_no_cap_memb(CvodeThreadData &, NrnThread *)
Definition: occvode.cpp:277
void fun_thread_ms_part34(double *ydot, NrnThread *nt)
Definition: occvode.cpp:749
void fun_thread_ms_part1(double t, double *y, NrnThread *nt)
Definition: occvode.cpp:726
void record_continuous_thread(NrnThread *)
Definition: occvode.cpp:1048
int solvex_thread_part3(double *b, NrnThread *nt)
Definition: occvode.cpp:626
void check_deliver(NrnThread *nt=0)
Definition: netcvode.cpp:5689
int daspk_interpolate(double)
bool structure_change_
Definition: cvodeobj.h:209
void nocap_v_part3(NrnThread *)
Definition: occvode.cpp:889
void evaluate_conditions(NrnThread *nt=0)
Definition: netcvode.cpp:5660
void fill(Cvode *standard)
bool can_retreat_
Definition: cvodeobj.h:107
NetCvode * ncv_
Definition: cvodeobj.h:218
virtual int advance_tn()
Definition: cvodeobj.cpp:1144
void fun_thread(double t, double *y, double *ydot, NrnThread *nt)
Definition: occvode.cpp:662
void before_after(BAMechList *, NrnThread *)
Definition: occvode.cpp:778
int interpolate_calls_
Definition: cvodeobj.h:110
void fun_thread_ms_part3(NrnThread *nt)
Definition: occvode.cpp:753
void matmeth()
Definition: cvodeobj.cpp:1467
Cvode()
Definition: cvodeobj.cpp:718
void maxstate(double *)
Definition: cvodeobj.cpp:984
double time() const
Definition: cvodeobj.h:97
int order()
Definition: cvodeobj.cpp:1016
N_Vector acorvec()
Definition: cvodeobj.cpp:1425
void maxorder(int)
Definition: cvodeobj.cpp:1029
int res(double, double *, double *, double *, NrnThread *)
Definition: nrndaspk.cpp:450
double tstop_
Definition: cvodeobj.h:222
void scatter_y(double *, int)
Definition: occvode.cpp:464
NrnThread * nth_
Definition: cvodeobj.h:215
virtual int init(double t)
Definition: cvodeobj.cpp:1216
void acor(double *)
Definition: occvode.cpp:994
double * n_vector_data(N_Vector, int)
Definition: occvode.cpp:451
virtual int interpolate(double t)
Definition: cvodeobj.cpp:1249
void bksub(NrnThread *)
Definition: cvtrset.cpp:146
bool local_
Definition: cvodeobj.h:237
void init_eqn()
Definition: occvode.cpp:108
int daspk_advance_tn()
Definition: cvodeobj.cpp:1403
N_Vector ewtvec()
Definition: cvodeobj.cpp:1417
double h()
Definition: cvodeobj.cpp:760
void nocap_v_part1(NrnThread *)
Definition: occvode.cpp:853
void activate_maxstate(bool)
Definition: cvodeobj.cpp:927
void delete_prl()
Definition: occvode.cpp:1006
void set_init_flag()
Definition: cvodeobj.cpp:803
void solvemem(NrnThread *)
Definition: occvode.cpp:642
double gam()
Definition: cvodeobj.cpp:752
int cvode_advance_tn()
Definition: cvodeobj.cpp:1327
bool use_daspk_
Definition: cvodeobj.h:180
void daspk_gather_y(N_Vector)
Definition: nrndaspk.cpp:421
void atolvec_alloc(int)
Definition: cvodeobj.cpp:849
int solvex_thread_part1(double *b, NrnThread *nt)
Definition: occvode.cpp:599
void maxacor(double *)
Definition: cvodeobj.cpp:999
double t0_
Definition: cvodeobj.h:105
double tn_
Definition: cvodeobj.h:105
virtual double t0()
Definition: cvodeobj.h:89
void scatter_ydot(double *, int)
Definition: occvode.cpp:508
N_Vector nvnew(long)
Definition: cvodeobj.cpp:811
void gather_ydot(N_Vector)
Definition: occvode.cpp:521
void alloc_cvode()
Definition: cvodeobj.cpp:1014
virtual int handle_step(NetCvode *, double)
Definition: netcvode.cpp:2280
int solve()
Definition: cvodeobj.cpp:1195
int cvode_interpolate(double)
Definition: cvodeobj.cpp:1371
int daspk_init(double)
Definition: cvodeobj.cpp:1130
int f_calls_
Definition: cvodeobj.h:111
N_Vector maxacor_
Definition: cvodeobj.h:206
int event_flag_
Definition: cvodeobj.h:220
void do_ode(NrnThread *)
Definition: occvode.cpp:901
int solvex_thread(double *b, double *y, NrnThread *nt)
Definition: occvode.cpp:555
bool initialize_
Definition: cvodeobj.h:106
void error_weights(double *)
Definition: occvode.cpp:983
void minstep(double)
Definition: cvodeobj.cpp:1040
virtual ~CvodeThreadData()
Definition: netcvode.cpp:1394
int nonvint_extra_offset_
Definition: cvodeobj.h:71
int nonvint_offset_
Definition: cvodeobj.h:70
PreSynList * psl_th_
Definition: cvodeobj.h:63
PlayRecList * play_
Definition: cvodeobj.h:73
double ** pvdot_
Definition: cvodeobj.h:66
CvMembList * cv_memb_list_
Definition: cvodeobj.h:52
void delete_memb_list(CvMembList *)
Definition: netcvode.cpp:1500
int rootnodecount_
Definition: cvodeobj.h:59
CvMembList * no_cap_memb_
Definition: cvodeobj.h:55
double ** pv_
Definition: cvodeobj.h:65
BAMechList * before_breakpoint_
Definition: cvodeobj.h:56
CvMembList * cmlext_
Definition: cvodeobj.h:54
int v_node_count_
Definition: cvodeobj.h:60
BAMechList * after_solve_
Definition: cvodeobj.h:57
Node ** no_cap_node_
Definition: cvodeobj.h:50
CvMembList * cmlcap_
Definition: cvodeobj.h:53
Node ** v_parent_
Definition: cvodeobj.h:62
int no_cap_count_
Definition: cvodeobj.h:48
PlayRecList * record_
Definition: cvodeobj.h:72
Node ** v_node_
Definition: cvodeobj.h:61
HTList * watch_list_
Definition: cvodeobj.h:64
Node ** no_cap_child_
Definition: cvodeobj.h:51
BAMechList * before_step_
Definition: cvodeobj.h:58
int no_cap_child_count_
Definition: cvodeobj.h:49
Definition: nrndaspk.h:11
Definition: htlist.h:35
Definition: bbtqueue.h:6
double t
Definition: cvodeobj.cpp:59
std::vector< PreSyn * > PreSynList
Definition: cvodeobj.h:14
static int first
Definition: fmenu.cpp:190
Definition: section.h:133
Represent main neuron object computed by single thread.
Definition: multicore.h:58