NEURON
nonvintblock.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 /*
5 Interface for adding blocks of equations setup and solved in python
6 analogous to the LONGITUDINAL_DIFFUSION at nonvint time for fixed and
7 variable step methods. Of course, limited to single thread.
8 
9 The substantive idea is embodied in the last 7 definitions below that look
10 like functions with distinct prototypes. The obscurity is due to having
11 a single function pointer in nrniv/nrnoc library space which gets dynamically
12 filled in when the Python nonvint_block_supervisor module is imported.
13 When that function is called, the supervisor interprets the remaining arguments
14 according to the first "method" argument. The tid (thread id) argument
15 should always be 0. Only one of the methods has a meaningful int return value.
16 The other uses can merely return 0.
17 */
18 
19 #if defined(nrnoc_fadvance_c)
20 /* define only in fadvance.cpp */
21 #define nonvintblock_extern /**/
22 #else
23 /* declare everywhere else */
24 #define nonvintblock_extern extern
25 #endif
26 
27 extern int nrn_nonvint_block_helper(int method, int length, double* pd1, double* pd2, int tid);
28 
30  *nrn_nonvint_block)(int method, int length, double* pd1, double* pd2, int tid);
31 
32 #define nonvint_block(method, size, pd1, pd2, tid) \
33  nrn_nonvint_block ? nrn_nonvint_block_helper(method, size, pd1, pd2, tid) : 0
34 
35 /* called near end of nrnoc/treeset.cpp:v_setup_vectors after structure_change_cnt is incremented.
36  */
37 #define nrn_nonvint_block_setup() nonvint_block(0, 0, 0, 0, 0)
38 
39 /* called in nrnoc/fadvance.cpp:nrn_finitialize before mod file INITIAL blocks */
40 #define nrn_nonvint_block_init(tid) nonvint_block(1, 0, 0, 0, tid)
41 
42 /* called at end of nrnoc/treeset.cpp:rhs and nrncvode/cvtrset.cpp:rhs */
43 #define nrn_nonvint_block_current(size, rhs, tid) nonvint_block(2, size, rhs, 0, tid)
44 /*if any ionic membrane currents are generated, they subtract from
45  NrnThread.node_rhs_storage()*/
46 
47 /* called at end of nrnoc/treeset.cpp:lhs and nrncvode/cvtrset.cpp:lhs */
48 #define nrn_nonvint_block_conductance(size, d, tid) nonvint_block(3, size, d, 0, tid)
49 /*if any ionic membrane currents are generated, di/dv adds to the vector of diagonal values */
50 
51 /* called at end of nrnoc/fadvance.cpp:nonvint */
52 #define nrn_nonvint_block_fixed_step_solve(tid) nonvint_block(4, 0, 0, 0, tid)
53 
54 /* returns the number of extra equations solved by cvode or ida */
55 #define nrn_nonvint_block_ode_count(offset, tid) nonvint_block(5, offset, 0, 0, tid)
56 
57 /* fill in the double* y with the initial values */
58 #define nrn_nonvint_block_ode_reinit(size, y, tid) nonvint_block(6, size, y, 0, tid)
59 
60 /* using the values in double* y, fill in double* ydot so that ydot = f(y) */
61 #define nrn_nonvint_block_ode_fun(size, y, ydot, tid) nonvint_block(7, size, y, ydot, tid)
62 
63 /* Solve (1 + dt*jacobian)*x = b replacing b values with the x values.
64  Note that y (state values) are available for constructing the jacobian
65  (if the problem is non-linear) */
66 #define nrn_nonvint_block_ode_solve(size, b, y, tid) nonvint_block(8, size, b, y, tid)
67 
68 /* Do any desired preprocessing of Jacobian in preparation for ode_solve.
69  This will be called at least every time dt changes */
70 #define nrn_nonvint_block_jacobian(size, ypred, ydot, tid) nonvint_block(9, size, ypred, ydot, tid)
71 
72 /* multiply the existing values in y (cvode.atol()) with appropriate scale factors */
73 #define nrn_nonvint_block_ode_abstol(size, y, tid) nonvint_block(10, size, y, 0, tid)
int nrn_nonvint_block_helper(int method, int length, double *pd1, double *pd2, int tid)
Definition: fadvance.cpp:1051
nonvintblock_extern int(* nrn_nonvint_block)(int method, int length, double *pd1, double *pd2, int tid)
Definition: nonvintblock.h:30
#define nonvintblock_extern
Definition: nonvintblock.h:24