NEURON
cvodestb.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 // solver CVode stub to allow cvode as dll for mswindows version.
3 
4 #include <InterViews/resource.h>
5 #include "classreg.h"
6 #include "nrnoc2iv.h"
7 #include "datapath.h"
8 #if USECVODE
9 #include "cvodeobj.h"
10 #include "netcvode.h"
11 #else
12 class Cvode;
13 #endif
14 
15 extern "C" void cvode_fadvance(double);
16 void cvode_finitialize(double t0);
17 void nrncvode_set_t(double);
18 extern "C" bool at_time(NrnThread*, double);
19 
20 extern double dt, t;
21 #define nt_t nrn_threads->_t
22 #define nt_dt nrn_threads->_dt
23 extern "C" void nrn_random_play();
24 extern int cvode_active_;
25 extern int nrn_use_daspk_;
26 
30 extern "C" void clear_event_queue();
31 void init_net_events();
32 void nrn_record_init();
33 void nrn_play_init();
36 void nrn_solver_prepare();
37 static void check_thresh(NrnThread*);
38 
39 // for fixed step thread
41  int i;
42  if (net_cvode_instance) {
45  }
46 }
47 
48 // handle events during finitialize()
50  double tsav = nt->_t;
51  if (net_cvode_instance) {
53  }
54  nt->_t = tsav;
55 }
56 
57 extern "C" void clear_event_queue() {
58  if (net_cvode_instance) {
60  }
61 }
62 
64  if (net_cvode_instance) {
66  }
67 }
68 
70  if (net_cvode_instance) {
72  }
73 }
74 
75 void nrn_play_init() {
76  if (net_cvode_instance) {
78  }
79 }
80 
82  if (net_cvode_instance) {
84  }
85 }
86 
88  if (net_cvode_instance) {
90  }
91 }
92 
94  if (net_cvode_instance) {
96  }
97 }
98 
99 extern "C" int v_structure_change;
100 
101 extern "C" void cvode_fadvance(double tstop) { // tstop = -1 means single step
102 #if USECVODE
103  int err;
104  extern int tree_changed;
105  extern int diam_changed;
106  if (net_cvode_instance) {
109  }
110  nrn_random_play();
111  err = net_cvode_instance->solve(tstop);
112  if (err != 0) {
113  printf("err=%d\n", err);
114  hoc_execerror("variable step integrator error", 0);
115  }
116  t = nt_t;
117  dt = nt_dt;
118  }
119 #endif
120 }
121 
122 void cvode_finitialize(double t0) {
123 #if USECVODE
124  if (net_cvode_instance) {
126  }
127 #endif
128 }
129 
130 extern "C" bool at_time(NrnThread* nt, double te) {
131 #if USECVODE
132  if (cvode_active_ && nt->_vcv) {
133  return ((Cvode*) nt->_vcv)->at_time(te, nt);
134  }
135 #endif
136  double x = te - 1e-11;
137  if (x <= nt->_t && x > (nt->_t - nt->_dt)) {
138  return 1;
139  }
140  return 0;
141 }
142 
143 void nrncvode_set_t(double tt) {
145  if (nc->gcv_) {
146  Cvode& cv = *nc->gcv_;
147  cv.tn_ = cv.t_ = cv.t0_ = tt;
148  } else {
149  for (int i = 0; i < nc->pcnt_; ++i) {
150  NetCvodeThreadData& p = nc->p[i];
151  for (int j = 0; j < p.nlcv_; ++j) {
152  Cvode& cv = p.lcv_[j];
153  cv.tn_ = cv.t_ = cv.t0_ = tt;
154  }
155  }
156  }
157 }
Definition: cvodeobj.h:76
double t_
Definition: cvodeobj.h:105
double t0_
Definition: cvodeobj.h:105
double tn_
Definition: cvodeobj.h:105
virtual double t0()
Definition: cvodeobj.h:89
void deliver_events(double til, NrnThread *)
Definition: netcvode.cpp:3061
NetCvodeThreadData * p
Definition: netcvode.h:252
void play_init()
Definition: netcvode.cpp:4276
Cvode * gcv_
Definition: netcvode.h:246
void check_thresh(NrnThread *)
Definition: netcvode.cpp:6130
void init_events()
Definition: netcvode.cpp:2950
void deliver_net_events(NrnThread *)
Definition: netcvode.cpp:6174
void clear_events()
Definition: netcvode.cpp:2868
int pcnt_
Definition: netcvode.h:251
void solver_prepare()
Definition: netcvode.cpp:4056
void re_init(double t0=0.)
Definition: netcvode.cpp:4089
int solve(double t)
Definition: netcvode.cpp:2095
void fixed_record_continuous(NrnThread *)
Definition: netcvode.cpp:5714
void fixed_play_continuous(NrnThread *)
Definition: netcvode.cpp:5726
void record_init()
Definition: netcvode.cpp:4259
int diam_changed
Definition: cabcode.cpp:23
double dt
Definition: netcvode.cpp:76
#define nt_dt
Definition: cvodestb.cpp:22
bool at_time(NrnThread *, double)
Definition: cvodestb.cpp:130
int cvode_active_
Definition: fadvance.cpp:163
void nrn_record_init()
Definition: cvodestb.cpp:69
void fixed_record_continuous(NrnThread *nt)
Definition: cvodestb.cpp:87
void nrn_play_init()
Definition: cvodestb.cpp:75
double t
Definition: cvodestb.cpp:20
void init_net_events()
Definition: cvodestb.cpp:63
void deliver_net_events(NrnThread *)
Definition: cvodestb.cpp:40
void nrn_random_play()
Definition: extdef.h:10
static void check_thresh(NrnThread *)
void fixed_play_continuous(NrnThread *nt)
Definition: cvodestb.cpp:81
void nrncvode_set_t(double)
Definition: cvodestb.cpp:143
int nrn_use_daspk_
Definition: treeset.cpp:72
void nrn_solver_prepare()
Definition: cvodestb.cpp:93
NetCvode * net_cvode_instance
Definition: cvodestb.cpp:27
void nrn_deliver_events(NrnThread *)
Definition: cvodestb.cpp:49
#define nt_t
Definition: cvodestb.cpp:21
void clear_event_queue()
Definition: cvodestb.cpp:57
int v_structure_change
Definition: cvodestb.cpp:99
void cvode_fadvance(double)
Definition: cvodestb.cpp:101
void cvode_finitialize(double t0)
Definition: cvodestb.cpp:122
int tree_changed
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:754
#define i
Definition: md1redef.h:12
#define printf
Definition: mwprefix.h:26
size_t p
size_t j
#define e
Definition: passive0.cpp:22
Represent main neuron object computed by single thread.
Definition: multicore.h:58
double _dt
Definition: multicore.h:60
void * _vcv
Definition: multicore.h:83
double _t
Definition: multicore.h:59