ESTER
Evolution STEllaire en Rotation
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
solver.h
Go to the documentation of this file.
1 #ifndef _SOLVER_H
2 #define _SOLVER_H
3 
4 #include "ester-config.h"
5 #include "matrix.h"
6 #include "matrix.h"
7 
13 
15 public:
16  int verbose;
17  virtual ~solver_operator() {};
18  virtual void left_precond(matrix &)=0;
19  virtual void right_precond(matrix &)=0;
20  virtual matrix solve(const matrix &)=0;
21 };
22 
24  matrix *m,*msup,*minf,*c,*r;
26  int nb,lu_flag,*N,oc;
27  char tempdir[50];
28  int **ipiv;
29  void lu_calc();
30  void lu_block(int i);
31  void solve_block(int i,char trans,matrix &x);
32  void read_block(int i);
33  void write_block(int i,const matrix &);
34  void flush_block(int i);
35  void read_blocksup(int i);
36  void write_blocksup(int i,const matrix &);
37  void flush_blocksup(int i);
38  void read_blockinf(int i);
39  void write_blockinf(int i,const matrix &);
40  void flush_blockinf(int i);
41  void fwd_subs(matrix &);
42  void back_subs(matrix &);
43 public:
44  explicit solver_full(int nblocks,int offcore=0);
45  ~solver_full();
46  void set_block(int iblock,matrix &);
47  void set_blocksup(int iblock,matrix &);
48  void set_blockinf(int iblock,matrix &);
49  void left_precond(matrix &x) {fwd_subs(x);}
51  matrix solve(const matrix &);
52 };
53 
55 
56 public:
59  void left_precond(matrix &) {};
60  void right_precond(matrix &) {};
61  matrix solve(const matrix &a) {return 0*a;};
62 };
63 
69 // nv is the number of variables (equations) of the problem.
70 // eq_set(i) (i<nv) is 1 if the i-th equation is defined in ths block.
71 // nr[i],nth[i] is the size of the i-th equation (It is automatically taken from
72 // the size of D).
73 class solver {
74 
75  /* A solver_elem object stores one term of a equation in the form D*(L,I*x,R).
76  The type indicate which of the matrices D,L,I,R are different from unity:
77 
78  'd': D
79  'l': D,L
80  'r': D,R
81  'f': D,L,R
82  'm': D,L,I
83  's': D,R,I
84  'g': D,L,R,I
85 
86  The set of terms in one given eq. referred to one given variable is represented
87  as a linked list of solver_elem objects. */
88 
94  class solver_elem {
104  char type;
108  friend class solver_block;
109  friend class solver;
110  };
111 
112  /* A solver_block object contains all the equations for a given block. A block
113  refers to one domain or to one set of boundary conditions.
114 
115  The equations are represented as an array of linked lists of solver_elem objects
116  such that eq[i][j] is a pointer to the first solver_elem object of the list
117  representing the terms in the i-th equation associated with the j-th variable.
118 
119  nv is the number of variables (equations) of the problem.
120  eq_set(i) (i<nv) is 1 if the i-th equation is defined in ths block.
121  nr[i],nth[i] is the size of the i-th equation (It is automatically taken from
122  the size of D).
123 
124  Methods:
125 
126  init(nvar) is called first to initialize the object for nvar variables
127  destroy() should be called when the object is no longer needed. After calling
128  destroy(), the object can be re-initialized with a different number
129  of variables
130  reset() to clean out all the equations
131  reset(i) to clean out only the i-th equation
132  add_*(...) to add a term in the equation
133  */
134 
140  class solver_block {
141  int nv;
142  int *nr;
144  int *nth;
146  solver_elem ***eq;
155  friend class solver;
156  public:
160  void init(int nvar);
162  void destroy();
164  void reset();
166  void reset(int ieq);
177  void add(int ieq,int ivar,char type, const matrix *d, const matrix *l, const matrix *r, const matrix *i);
178 
181  inline void add_d(int ieq,int ivar,const matrix &d) {
182  add(ieq,ivar,'d',&d,NULL,NULL,NULL);
183  }
185  inline void add_l(int ieq,int ivar,const matrix &d,const matrix &l) {
186  add(ieq,ivar,'l',&d,&l,NULL,NULL);
187  }
189  inline void add_r(int ieq,int ivar,const matrix &d,const matrix &r) {
190  add(ieq,ivar,'r',&d,NULL,&r,NULL);
191  }
193  inline void add_lr(int ieq,int ivar,const matrix &d,const matrix &l,const matrix &r) {
194  add(ieq,ivar,'f',&d,&l,&r,NULL);
195  }
197  inline void add_li(int ieq,int ivar,const matrix &d,const matrix &l,const matrix &i) {
198  add(ieq,ivar,'m',&d,&l,NULL,&i);
199  }
201  inline void add_ri(int ieq,int ivar,const matrix &d,const matrix &r,const matrix &i) {
202  add(ieq,ivar,'s',&d,NULL,&r,&i);
203  }
205  inline void add_lri(int ieq,int ivar,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
206  add(ieq,ivar,'g',&d,&l,&r,&i);
207  }
208 
209  };
210 
211  int nb;
212  int nv;
213  int **var_nr;
214  int **var_nth;
215  int **var_ntop;
216  int **var_nbot;
217  int solver_N;
218  int *def_nr;
219  char type[21],**var;
220  int initd,sync;
231  void mult_op(matrix *);
232  int cgs(const matrix &rhs,matrix &x,int maxit);
233  void create();
234  void create_full();
235  void wrap(const matrix *,matrix *);
236  void unwrap(const matrix *,matrix *);
237  void fill_void_blocks();
238  int check_struct();
239  void check_struct_error(const char *err_msg,int n,int i,int j,solver_elem *p);
240  int check_struct_block(int n,int i,int j);
241  int check_struct_bc_th(int n,int i,int j,const char *bctype);
242  int check_struct_bc(int n,int i,int j,const char *bctype);
243  void check_full(int n, const matrix &opi,int pos);
244  void subst_dep();
245  void subst_dep_eq(const char *block_type,solver_block *,int n,int i,int j);
246  void subst_dep_elem(int i,int k,solver_block *bb,solver_elem *p,const matrix &d,int n2,int m2);
247  void solve_dep();
248 public:
250  int debug;
251  double rel_tol,abs_tol;
252  void (*mult_fcn)(matrix *,void *context);
254  solver();
255  void destroy();
256  ~solver() {if(initd) destroy();};
257  void init(int nblock,int nvar,const char *solver_type);
258  void set_nr(int *nr);
259  void reset();
260  void reset(int iblock);
261  void reset(int iblock,int ieq);
262  void reset(int iblock,const char *eq_name);
263  void reset(const char *eq_name);
264  void regvar(const char *var_name,int dependent=0);
265  inline void regvar_dep(const char *var_name) {regvar(var_name,1);}
266  int get_nvar();
267  int get_nblocks();
268  int get_id(const char *varn);
269  void set_rhs(const char *eqn,const matrix &b);
270  matrix get_rhs(const char *eqn);
271  matrix get_var(const char *varn);
272  matrix get_rhs(int ieq);
273  matrix get_var(int ivar);
275  void solve(int *info=NULL);
276  // info[0]: LU factorization
277  // info[1]: Iterative refinement
278  // info[2]: CGS iteration
279  // info[3]: Number of iterative refinement iterations (-1 if no convergence, -2 if error)
280  // info[4]: Number of CGS iterations (-1 if no convergence, -2 if error)
281  void mult(matrix *);
282 
283  void add(int iblock,const char *eqn, const char *varn,const char *block_type,char type,const matrix *d,const matrix *l,const matrix *r,const matrix *i);
284  void add(const char *eqn, const char *varn,const char *block_type,char type,const matrix *d,const matrix_block_diag *l,const matrix *r,const matrix *i);
285 
286  inline void add_d(const char *eqn, const char *varn,const matrix &d) {
287  add(eqn,varn,"block",'d',&d,NULL,NULL,NULL);
288  }
289  inline void add_l(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l) {
290  add(eqn,varn,"block",'l',&d,&l,NULL,NULL);
291  }
292  inline void add_r(const char *eqn, const char *varn,const matrix &d,const matrix &r) {
293  add(eqn,varn,"block",'r',&d,NULL,&r,NULL);
294  }
295  inline void add_lr(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &r) {
296  add(eqn,varn,"block",'f',&d,&l,&r,NULL);
297  }
298  inline void add_li(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &i) {
299  add(eqn,varn,"block",'m',&d,&l,NULL,&i);
300  }
301  inline void add_ri(const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
302  add(eqn,varn,"block",'s',&d,NULL,&r,&i);
303  }
304  inline void add_lri(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &r,const matrix &i) {
305  add(eqn,varn,"block",'g',&d,&l,&r,&i);
306  }
307 
308  inline void bc_pol_add_d(const char *eqn, const char *varn,const matrix &d) {
309  add(eqn,varn,"bc_pol",'d',&d,NULL,NULL,NULL);
310  }
311  inline void bc_pol_add_l(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l) {
312  add(eqn,varn,"bc_pol",'l',&d,&l,NULL,NULL);
313  }
314  inline void bc_pol_add_r(const char *eqn, const char *varn,const matrix &d,const matrix &r) {
315  add(eqn,varn,"bc_pol",'r',&d,NULL,&r,NULL);
316  }
317  inline void bc_pol_add_lr(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &r) {
318  add(eqn,varn,"bc_pol",'f',&d,&l,&r,NULL);
319  }
320  inline void bc_pol_add_li(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &i) {
321  add(eqn,varn,"bc_pol",'m',&d,&l,NULL,&i);
322  }
323  inline void bc_pol_add_ri(const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
324  add(eqn,varn,"bc_pol",'s',&d,NULL,&r,&i);
325  }
326  inline void bc_pol_add_lri(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &r,const matrix &i) {
327  add(eqn,varn,"bc_pol",'g',&d,&l,&r,&i);
328  }
329 
330  inline void bc_eq_add_d(const char *eqn, const char *varn,const matrix &d) {
331  add(eqn,varn,"bc_eq",'d',&d,NULL,NULL,NULL);
332  }
333  inline void bc_eq_add_l(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l) {
334  add(eqn,varn,"bc_eq",'l',&d,&l,NULL,NULL);
335  }
336  inline void bc_eq_add_r(const char *eqn, const char *varn,const matrix &d,const matrix &r) {
337  add(eqn,varn,"bc_eq",'r',&d,NULL,&r,NULL);
338  }
339  inline void bc_eq_add_lr(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &r) {
340  add(eqn,varn,"bc_eq",'f',&d,&l,&r,NULL);
341  }
342  inline void bc_eq_add_li(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &i) {
343  add(eqn,varn,"bc_eq",'m',&d,&l,NULL,&i);
344  }
345  inline void bc_eq_add_ri(const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
346  add(eqn,varn,"bc_eq",'s',&d,NULL,&r,&i);
347  }
348  inline void bc_eq_add_lri(const char *eqn, const char *varn,const matrix &d,const matrix_block_diag &l,const matrix &r,const matrix &i) {
349  add(eqn,varn,"bc_eq",'g',&d,&l,&r,&i);
350  }
351 
352  inline void add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
353  add(iblock,eqn,varn,"block",'d',&d,NULL,NULL,NULL);
354  }
355  inline void add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
356  add(iblock,eqn,varn,"block",'l',&d,&l,NULL,NULL);
357  }
358  inline void add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
359  add(iblock,eqn,varn,"block",'r',&d,NULL,&r,NULL);
360  }
361  inline void add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
362  add(iblock,eqn,varn,"block",'f',&d,&l,&r,NULL);
363  }
364  inline void add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
365  add(iblock,eqn,varn,"block",'m',&d,&l,NULL,&i);
366  }
367  inline void add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
368  add(iblock,eqn,varn,"block",'s',&d,NULL,&r,&i);
369  }
370  inline void add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
371  add(iblock,eqn,varn,"block",'g',&d,&l,&r,&i);
372  }
373 
374  inline void bc_pol_add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
375  add(iblock,eqn,varn,"bc_pol",'d',&d,NULL,NULL,NULL);
376  }
377  inline void bc_pol_add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
378  add(iblock,eqn,varn,"bc_pol",'l',&d,&l,NULL,NULL);
379  }
380  inline void bc_pol_add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
381  add(iblock,eqn,varn,"bc_pol",'r',&d,NULL,&r,NULL);
382  }
383  inline void bc_pol_add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
384  add(iblock,eqn,varn,"bc_pol",'f',&d,&l,&r,NULL);
385  }
386  inline void bc_pol_add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
387  add(iblock,eqn,varn,"bc_pol",'m',&d,&l,NULL,&i);
388  }
389  inline void bc_pol_add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
390  add(iblock,eqn,varn,"bc_pol",'s',&d,NULL,&r,&i);
391  }
392  inline void bc_pol_add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
393  add(iblock,eqn,varn,"bc_pol",'g',&d,&l,&r,&i);
394  }
395 
396  inline void bc_eq_add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
397  add(iblock,eqn,varn,"bc_eq",'d',&d,NULL,NULL,NULL);
398  }
399  inline void bc_eq_add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
400  add(iblock,eqn,varn,"bc_eq",'l',&d,&l,NULL,NULL);
401  }
402  inline void bc_eq_add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
403  add(iblock,eqn,varn,"bc_eq",'r',&d,NULL,&r,NULL);
404  }
405  inline void bc_eq_add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
406  add(iblock,eqn,varn,"bc_eq",'f',&d,&l,&r,NULL);
407  }
408  inline void bc_eq_add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
409  add(iblock,eqn,varn,"bc_eq",'m',&d,&l,NULL,&i);
410  }
411  inline void bc_eq_add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
412  add(iblock,eqn,varn,"bc_eq",'s',&d,NULL,&r,&i);
413  }
414  inline void bc_eq_add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
415  add(iblock,eqn,varn,"bc_eq",'g',&d,&l,&r,&i);
416  }
417 
418  inline void bc_bot1_add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
419  add(iblock,eqn,varn,"bc_bot1",'d',&d,NULL,NULL,NULL);
420  }
421  inline void bc_bot1_add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
422  add(iblock,eqn,varn,"bc_bot1",'l',&d,&l,NULL,NULL);
423  }
424  inline void bc_bot1_add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
425  add(iblock,eqn,varn,"bc_bot1",'r',&d,NULL,&r,NULL);
426  }
427  inline void bc_bot1_add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
428  add(iblock,eqn,varn,"bc_bot1",'f',&d,&l,&r,NULL);
429  }
430  inline void bc_bot1_add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
431  add(iblock,eqn,varn,"bc_bot1",'m',&d,&l,NULL,&i);
432  }
433  inline void bc_bot1_add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
434  add(iblock,eqn,varn,"bc_bot1",'s',&d,NULL,&r,&i);
435  }
436  inline void bc_bot1_add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
437  add(iblock,eqn,varn,"bc_bot1",'g',&d,&l,&r,&i);
438  }
439 
440  inline void bc_bot2_add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
441  add(iblock,eqn,varn,"bc_bot2",'d',&d,NULL,NULL,NULL);
442  }
443  inline void bc_bot2_add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
444  add(iblock,eqn,varn,"bc_bot2",'l',&d,&l,NULL,NULL);
445  }
446  inline void bc_bot2_add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
447  add(iblock,eqn,varn,"bc_bot2",'r',&d,NULL,&r,NULL);
448  }
449  inline void bc_bot2_add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
450  add(iblock,eqn,varn,"bc_bot2",'f',&d,&l,&r,NULL);
451  }
452  inline void bc_bot2_add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
453  add(iblock,eqn,varn,"bc_bot2",'m',&d,&l,NULL,&i);
454  }
455  inline void bc_bot2_add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
456  add(iblock,eqn,varn,"bc_bot2",'s',&d,NULL,&r,&i);
457  }
458  inline void bc_bot2_add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
459  add(iblock,eqn,varn,"bc_bot2",'g',&d,&l,&r,&i);
460  }
461 
462  inline void bc_top1_add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
463  add(iblock,eqn,varn,"bc_top1",'d',&d,NULL,NULL,NULL);
464  }
465  inline void bc_top1_add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
466  add(iblock,eqn,varn,"bc_top1",'l',&d,&l,NULL,NULL);
467  }
468  inline void bc_top1_add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
469  add(iblock,eqn,varn,"bc_top1",'r',&d,NULL,&r,NULL);
470  }
471  inline void bc_top1_add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
472  add(iblock,eqn,varn,"bc_top1",'f',&d,&l,&r,NULL);
473  }
474  inline void bc_top1_add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
475  add(iblock,eqn,varn,"bc_top1",'m',&d,&l,NULL,&i);
476  }
477  inline void bc_top1_add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
478  add(iblock,eqn,varn,"bc_top1",'s',&d,NULL,&r,&i);
479  }
480  inline void bc_top1_add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
481  add(iblock,eqn,varn,"bc_top1",'g',&d,&l,&r,&i);
482  }
483 
484  inline void bc_top2_add_d(int iblock,const char *eqn, const char *varn,const matrix &d) {
485  add(iblock,eqn,varn,"bc_top2",'d',&d,NULL,NULL,NULL);
486  }
487  inline void bc_top2_add_l(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l) {
488  add(iblock,eqn,varn,"bc_top2",'l',&d,&l,NULL,NULL);
489  }
490  inline void bc_top2_add_r(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r) {
491  add(iblock,eqn,varn,"bc_top2",'r',&d,NULL,&r,NULL);
492  }
493  inline void bc_top2_add_lr(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r) {
494  add(iblock,eqn,varn,"bc_top2",'f',&d,&l,&r,NULL);
495  }
496  inline void bc_top2_add_li(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &i) {
497  add(iblock,eqn,varn,"bc_top2",'m',&d,&l,NULL,&i);
498  }
499  inline void bc_top2_add_ri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &r,const matrix &i) {
500  add(iblock,eqn,varn,"bc_top2",'s',&d,NULL,&r,&i);
501  }
502  inline void bc_top2_add_lri(int iblock,const char *eqn, const char *varn,const matrix &d,const matrix &l,const matrix &r,const matrix &i) {
503  add(iblock,eqn,varn,"bc_top2",'g',&d,&l,&r,&i);
504  }
505 
506 };
507 
508 
509 #define RK_END 0
510 #define RK_STEP 1
511 #define RK_INTERMEDIATE 2
512 
513 class RKF_solver {
514  int nv;
515  char **var;
516  int *nr,*nc;
517  bool *reg;
519  double t,t_eval;
520  bool initd;
521  double step;
522  int stage;
523  void wrap(const matrix *,matrix *);
524  void unwrap(const matrix *,matrix *);
525  int get_id(const char *varn);
526  void check_init();
527 public:
528  double abs_tol,rel_tol;
529  RKF_solver();
530  void init(int nvar);
531  void destroy();
532  ~RKF_solver() {if(!initd) destroy();};
533  void regvar(const char *var_name,const matrix &initial_value);
534  void regvars(const matrix_map &vars);
535  void set_step(double);
536  matrix get_var(const char *var_name);
538  double get_t();
539  void set_deriv(const char *var_name,const matrix &value);
540  void set_derivs(const matrix_map &values);
541 
542  int solve(double t0,double t1);
543 
544 };
545 
546 /*
547 Runge-Kutta solver for SDIRK (Singly diagonally implicit Runge-Kutta)
548 or ESDIRK (Explicit singly diagonally implicit Runge-Kutta).
549 
550 Butcher tableau for SDIRK methods is:
551 
552  c0 | a 0 0 0 ... 0
553  c1 | a10 a 0 0 ... 0
554  c2 | a20 a21 a 0 ... 0
555  : | ...
556  1 | b0 b1 b2 b3 ... a
557  |-------------------------
558  | b0 b1 b2 b3 ... a
559 
560 and for ESDIRK methods:
561 
562  0 | 0 0 0 0 ... 0
563  c1 | a10 a 0 0 ... 0
564  c2 | a20 a21 a 0 ... 0
565  : | ...
566  1 | b0 b1 b2 b3 ... a
567  |-------------------------
568  | b0 b1 b2 b3 ... a
569 
570 We want to solve the equation:
571 
572  F(t,u,v,...,du/dt,dv/dt,...)=0
573 
574 First, define a new object:
575 
576  --> SDIRK_solver rk;
577 
578 Initialize solver:
579 
580  --> rk.init(nvar,method);
581 
582 Where nvar is the number of variables an method can be:
583 
584  - "be" Backward Euler (SDIRK) A-stable, L-stable
585  - "cn" Crank-Nicolson (ESDIRK) A-stable, not L-stable
586  - "sdirk2" SDIRK method of order 2 (Alexander,1977) A-stable, L-stable
587  - "sdirk3" SDIRK method of order 3 (Alexander,1977) A-stable, L-stable
588  - "sdirk4" SDIRK method of order 4 (Skvortsov,2006) A-stable, L-stable
589  - "esdirk3" ESDIRK method of order 3 (Segawa) A-stable, L-stable
590  - "esdirk4" ESDIRK method of order 4 (Segawa) A-stable, L-stable
591 
592 Register variables:
593 
594  --> rk.regvar("u",u0);
595  --> rk.regvar("v",v0);
596  --> ...
597 
598 For ESDIRK methods, the initial value of the temporal derivative is also needed:
599 
600  --> if(rk.needs_initial_derivative()) { // true for ESDIRK method
601  --> rk.set_initial_derivative("u",du0);
602  --> rk.set_initial_derivative("v",dv0);
603  --> ...}
604 
605 Set the time step:
606 
607  --> rk.set_step(h);
608 
609 Start main loop:
610  --> int state;
611  --> while((state=rk.solve(t0,t1))!=RK_END) {
612  --> double delta,t;
613  --> matrix u0,v0,...;
614  --> delta=rk.get_delta();
615  --> t=rk.get_t();
616  --> u0=rk.get_var("u");
617  --> v0=rk.get_var("v");
618  --> ...
619 Solve:
620  F(t,u,v,...,du/dt,dv/dt,...)=0
621 for u,v,... using:
622  du/dt=(u-u0)/delta
623  dv/dt=(v-v0)/delta
624  ...
625 and write the solution:
626 
627  --> rk.set_var("u",u);
628  --> rk.set_var("v",v);
629  --> ...
630 Check if the RK step is complete:
631  --> if(state==RK_STEP) {
632  ... save variables at this step t,u,v,...
633  --> }
634 End main loop
635  --> }
636 
637 Finalize the solver:
638  --> rk.destroy();
639 
640 The functions regvar,get_var ans set_var have their equivalents using matrix_map objects
641 reg_vars, set_vars and get_vars.
642 
643 */
644 
647  double alpha;
648  char **var;
649  int *nr,*nc;
650  bool *reg;
652  double step;
653  int stage;
655  matrix *y,x,*k,*dy,x0;
656  double t,t_eval,delta;
657  void wrap(const matrix *,matrix *);
658  void unwrap(const matrix *,matrix *);
659  int get_id(const char *varn);
660  void check_init();
661  void check_method();
662  void init_be();
663  void init_cn();
664  void init_sdirk2();
665  void init_sdirk3();
666  void init_sdirk4();
667  void init_esdirk3();
668  void init_esdirk4();
669 public:
670  //double abs_tol,rel_tol;
671  SDIRK_solver();
672  void init(int nvar,const char *type);
673  void destroy();
675  void regvar(const char *var_name,const matrix &initial_value);
676  void regvars(const matrix_map &vars);
677  void set_initial_derivative(const char *var_name,const matrix &initial_value);
678  void set_initial_derivatives(const matrix_map &vars);
679  void set_var(const char *var_name,const matrix &value);
680  void set_vars(const matrix_map &values);
681  void set_step(double);
682  double get_step();
683  double get_delta();
684  matrix get_var(const char *var_name);
686  int number_of_stages();
688  int get_order();
690  double get_t();
691 
692  int solve(double t0,double t1);
693 
694 };
695 
696 
697 #endif
void bc_top2_add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:502
Stores one term of an equation.
Definition: solver.h:94
void add_d(const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:286
int check_struct_block(int n, int i, int j)
Definition: solver.cpp:1624
void bc_pol_add_r(const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:314
int ** var_nbot
var_nbot[i][j] is the resolution of the i-th bottom boundary condition on the j-th variable ...
Definition: solver.h:216
void bc_eq_add_ri(const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:345
Definition: matrix.h:287
void bc_top2_add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:499
void init_sdirk2()
Definition: SDIRK_solver.cpp:378
matrix solve(const matrix &a)
Definition: solver.h:61
solver()
Definition: solver.cpp:97
matrix b
Definition: solver.h:654
matrix x0
Definition: solver.h:655
void bc_bot2_add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:446
void bc_top2_add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:496
void set_block(int iblock, matrix &)
Definition: solver_full.cpp:73
void init(int nvar, const char *type)
Definition: SDIRK_solver.cpp:18
int check_struct_bc_th(int n, int i, int j, const char *bctype)
Definition: solver.cpp:1711
virtual ~solver_operator()
Definition: solver.h:17
void set_nr(int *nr)
Definition: solver.cpp:268
matrix dep
Definition: solver.h:221
int check_struct_bc(int n, int i, int j, const char *bctype)
Definition: solver.cpp:1783
void add_l(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l)
Definition: solver.h:289
int nb
Number of blocks defined in the problem.
Definition: solver.h:211
matrix R
Definition: solver.h:105
void bc_top1_add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:471
void bc_top2_add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:493
void bc_eq_add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:396
double get_t()
Definition: RKF_solver.cpp:136
void bc_top1_add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:480
void bc_pol_add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:383
void * mult_context
Definition: solver.h:253
~SDIRK_solver()
Definition: solver.h:674
void bc_top2_add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:490
void bc_eq_add_lri(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &r, const matrix &i)
Definition: solver.h:348
solver_full(int nblocks, int offcore=0)
Definition: solver_full.cpp:19
A solver object stores a system of equation to solve.
Definition: solver.h:73
int debug
Definition: solver.h:250
int oc
Definition: solver.h:26
void solve_block(int i, char trans, matrix &x)
Definition: solver_full.cpp:200
matrix * c
Definition: solver.h:24
int nv
Definition: solver.h:514
int check_struct()
Definition: solver.cpp:1521
void set_initial_derivative(const char *var_name, const matrix &initial_value)
Definition: SDIRK_solver.cpp:206
~RKF_solver()
Definition: solver.h:532
matrix * sol
Definition: solver.h:230
int verbose
Definition: solver.h:249
The matrix class is used to facilitate the work with regular dense matrices.
Definition: matrix.h:9
double get_t()
Definition: SDIRK_solver.cpp:251
matrix b5
Definition: solver.h:518
void bc_top2_add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:487
void(* mult_fcn)(matrix *, void *context)
Definition: solver.h:252
solver_block * block
Definition: solver.h:223
void add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:352
solver_block * bc_top1
Definition: solver.h:226
matrix * y
Definition: solver.h:518
void add_lri(int ieq, int ivar, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Introduces a term of type 'g'.
Definition: solver.h:205
char tempdir[50]
Definition: solver.h:27
void unwrap(const matrix *, matrix *)
Definition: RKF_solver.cpp:170
double t_eval
Definition: solver.h:519
void unwrap(const matrix *, matrix *)
Performs the inverse operation of the wrap function: restore the single vector x into the blocked vec...
Definition: solver.cpp:1303
int * N
Definition: solver.h:26
void bc_bot1_add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:427
void add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:367
void add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:364
int get_id(const char *varn)
Definition: SDIRK_solver.cpp:236
double abs_tol
Definition: solver.h:251
void set_blocksup(int iblock, matrix &)
Definition: solver_full.cpp:85
void regvars(const matrix_map &vars)
Definition: SDIRK_solver.cpp:198
void bc_eq_add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:411
void add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:358
solver_block * bc_bot1
Definition: solver.h:224
The matrix_block_diag class is used to store block diagonal matrices.
Definition: matrix.h:202
solver_operator* op
Definition: solver.h:222
int get_id(const char *varn)
Definition: solver.cpp:311
void check_method()
Definition: SDIRK_solver.cpp:87
int solve(double t0, double t1)
Definition: SDIRK_solver.cpp:306
void read_blockinf(int i)
Definition: solver_full.cpp:311
matrix get_var(const char *varn)
Definition: solver.cpp:365
matrix_map get_vars()
Definition: solver.cpp:372
void add(int ieq, int ivar, char type, const matrix *d, const matrix *l, const matrix *r, const matrix *i)
Introduces a term in an equation of the block.
Definition: solver.cpp:68
void regvar(const char *var_name, const matrix &initial_value)
Definition: RKF_solver.cpp:71
matrix * y
Definition: solver.h:655
void bc_top2_add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:484
void bc_pol_add_d(const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:308
void check_struct_error(const char *err_msg, int n, int i, int j, solver_elem *p)
Definition: solver.cpp:1866
void bc_pol_add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:386
void add_r(const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:292
int ** ipiv
Definition: solver.h:28
matrix x_eval
Definition: solver.h:518
matrix deriv
Definition: solver.h:518
void flush_block(int i)
Definition: solver_full.cpp:305
void regvar_dep(const char *var_name)
Definition: solver.h:265
double rel_tol
Definition: solver.h:528
matrix * dy
Definition: solver.h:518
int nb
Definition: solver.h:26
void set_blockinf(int iblock, matrix &)
Definition: solver_full.cpp:93
void reset()
Definition: solver.cpp:222
int initd
Definition: solver.h:220
matrix ipiv_flag
Definition: solver.h:25
void init(int nvar)
Definition: RKF_solver.cpp:18
double rel_tol
Definition: solver.h:251
matrix k[6]
Definition: solver.h:518
int ** var_nth
var_nr[i][j] is the azimuthal resolution of the j-th variable in the i-th equation ...
Definition: solver.h:214
void subst_dep()
Substitutes dependent variables defined in the solver.
Definition: solver.cpp:1899
void wrap(const matrix *, matrix *)
Stores distributed (ie. split into several blocks) matrix y into the single vector x...
Definition: solver.cpp:1249
solver_block * bc_eq
Definition: solver.h:229
void mult(matrix *)
Definition: solver.cpp:505
void bc_bot2_add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:449
void left_precond(matrix &x)
Definition: solver.h:49
void init(int nblock, int nvar, const char *solver_type)
Initialize the solver object for nblock blocks, nvar variables, using a solver operator of type solve...
Definition: solver.cpp:115
void read_blocksup(int i)
Definition: solver_full.cpp:352
double get_step()
Definition: SDIRK_solver.cpp:167
void fwd_subs(matrix &)
Definition: solver_full.cpp:218
void flush_blockinf(int i)
Definition: solver_full.cpp:346
void bc_eq_add_l(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l)
Definition: solver.h:333
void write_blocksup(int i, const matrix &)
Definition: solver_full.cpp:369
void check_init()
Definition: SDIRK_solver.cpp:80
matrix x
Definition: solver.h:655
void set_var(const char *var_name, const matrix &value)
Definition: SDIRK_solver.cpp:222
void destroy()
Definition: solver.cpp:178
void set_derivs(const matrix_map &values)
Definition: RKF_solver.cpp:144
void add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:361
void regvar(const char *var_name, int dependent=0)
Definition: solver.cpp:276
void bc_pol_add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:389
int * nr
nr[i] is the radial resolution of the i-th variable
Definition: solver.h:143
matrix I
Definition: solver.h:105
void lu_block(int i)
Definition: solver_full.cpp:162
void bc_eq_add_r(const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:336
void write_block(int i, const matrix &)
Definition: solver_full.cpp:285
void add_li(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &i)
Definition: solver.h:298
~solver_block()
Definition: solver.h:158
void add_ri(int ieq, int ivar, const matrix &d, const matrix &r, const matrix &i)
Introduces a term of type 's'.
Definition: solver.h:201
double t_eval
Definition: solver.h:656
int order
Definition: solver.h:646
int stage
Definition: solver.h:522
void bc_pol_add_lr(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &r)
Definition: solver.h:317
void bc_top1_add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:474
void add_li(int ieq, int ivar, const matrix &d, const matrix &l, const matrix &i)
Introduces a term of type 'm'.
Definition: solver.h:197
void init(int nvar)
Initializes the object with nvar variables.
Definition: solver.cpp:10
void init_sdirk4()
Definition: SDIRK_solver.cpp:409
void right_precond(matrix &)
Definition: solver.h:60
void bc_bot2_add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:455
void subst_dep_elem(int i, int k, solver_block *bb, solver_elem *p, const matrix &d, int n2, int m2)
Definition: solver.cpp:2014
double t
Definition: solver.h:519
int ** var_ntop
var_ntop[i][j] is the resolution of the i-th top boundary condition on the j-th variable ...
Definition: solver.h:215
matrix * r
Definition: solver.h:24
matrix * dy
Definition: solver.h:655
matrix * msup
Definition: solver.h:24
matrix b4
Definition: solver.h:518
void add_ri(const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:301
virtual void right_precond(matrix &)=0
Definition: solver.h:645
void init_esdirk4()
Definition: SDIRK_solver.cpp:439
void destroy()
Destroys the object and frees memory.
Definition: solver.cpp:27
void init_sdirk3()
Definition: SDIRK_solver.cpp:391
void regvars(const matrix_map &vars)
Definition: RKF_solver.cpp:96
matrix eq_set
eq_set(i) is 1 if the i-th equation is defined in this block.
Definition: solver.h:154
void fill_void_blocks()
Definition: solver.cpp:326
int maxit_cgs
Definition: solver.h:249
int nv
The number of variables (and equation) of the problem.
Definition: solver.h:141
matrix L
Definition: solver.h:105
void bc_bot1_add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:430
matrix blk_index
Definition: solver.h:25
char ** var
Definition: solver.h:515
int maxit_ref
Definition: solver.h:249
int number_of_implicit_stages()
Definition: SDIRK_solver.cpp:169
void add_r(int ieq, int ivar, const matrix &d, const matrix &r)
Introduces a term of type 'r'.
Definition: solver.h:189
virtual void left_precond(matrix &)=0
void destroy()
Definition: SDIRK_solver.cpp:63
void bc_eq_add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:402
void bc_bot1_add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:424
void set_deriv(const char *var_name, const matrix &value)
Definition: RKF_solver.cpp:140
int get_nblocks()
Definition: solver.cpp:305
void bc_bot2_add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:440
void add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:370
void set_vars(const matrix_map &values)
Definition: SDIRK_solver.cpp:226
int number_of_stages()
Definition: SDIRK_solver.cpp:168
void add_lr(int ieq, int ivar, const matrix &d, const matrix &l, const matrix &r)
Introduces a term of type 'f'.
Definition: solver.h:193
void set_step(double)
Definition: SDIRK_solver.cpp:232
RKF_solver()
Definition: RKF_solver.cpp:10
void bc_pol_add_l(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l)
Definition: solver.h:311
matrix get_rhs(const char *eqn)
Definition: solver.cpp:358
void back_subs(matrix &)
Definition: solver_full.cpp:239
matrix get_var(const char *var_name)
Definition: SDIRK_solver.cpp:259
int * nc
Definition: solver.h:516
void bc_eq_add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:414
void bc_eq_add_lr(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &r)
Definition: solver.h:339
void bc_eq_add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:408
void solve_dep()
Solves dependent variables: compute in the sol field the values of dependent variables (have to be ca...
Definition: solver.cpp:2110
matrix a
Definition: solver.h:518
matrix_map get_vars()
Definition: SDIRK_solver.cpp:263
void check_init()
Definition: RKF_solver.cpp:64
matrix * minf
Definition: solver.h:24
matrix * rhs
Definition: solver.h:230
char type[21]
Definition: solver.h:219
matrix get_var(const char *var_name)
Definition: RKF_solver.cpp:123
double get_delta()
Definition: SDIRK_solver.cpp:255
void add_l(int ieq, int ivar, const matrix &d, const matrix &l)
Introduces a term of type 'l'.
Definition: solver.h:185
matrix c
Definition: solver.h:654
void bc_top1_add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:462
matrix * m
Definition: solver.h:24
int sync
Definition: solver.h:220
SDIRK_solver()
Definition: SDIRK_solver.cpp:10
void unwrap(const matrix *, matrix *)
Definition: SDIRK_solver.cpp:293
void bc_pol_add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:392
void add_lr(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &r)
Definition: solver.h:295
int * nc
Definition: solver.h:649
bool needs_initial_derivative()
Definition: SDIRK_solver.cpp:171
int * nr
Definition: solver.h:649
double t
Definition: solver.h:656
double abs_tol
Definition: solver.h:528
void flush_blocksup(int i)
Definition: solver_full.cpp:387
void bc_bot1_add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:421
solver_block * bc_pol
Definition: solver.h:228
matrix reg
Definition: solver.h:221
void bc_bot2_add_li(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &i)
Definition: solver.h:452
int nv
Definition: solver.h:646
int nv
Number of variables of the problem.
Definition: solver.h:212
void bc_pol_add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:380
int cgs(const matrix &rhs, matrix &x, int maxit)
Definition: solver.cpp:772
void set_rhs(const char *eqn, const matrix &b)
Definition: solver.cpp:345
void set_initial_derivatives(const matrix_map &vars)
Definition: SDIRK_solver.cpp:213
void bc_eq_add_lr(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r)
Definition: solver.h:405
bool initd
Definition: solver.h:520
Definition: solver.h:14
matrix x
Definition: solver.h:518
char type
Definition: solver.h:104
void mult_op(matrix *)
Definition: solver.cpp:512
void reset()
Resets all equations of the block.
Definition: solver.cpp:40
int get_id(const char *varn)
Definition: RKF_solver.cpp:108
void bc_bot1_add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:433
void add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:355
matrix D
Definition: solver.h:105
int solver_N
Definition: solver.h:217
Definition: solver.h:54
void bc_pol_add_li(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &i)
Definition: solver.h:320
int stage
Definition: solver.h:653
void init_cn()
Definition: SDIRK_solver.cpp:367
void regvar(const char *var_name, const matrix &initial_value)
Definition: SDIRK_solver.cpp:173
void solve(int *info=NULL)
Solves the set of equations stored in the operator object.
Definition: solver.cpp:392
int * def_nr
def_nr[i] is the number of radial points in the i-th block
Definition: solver.h:218
void check_full(int n, const matrix &opi, int pos)
Definition: solver.cpp:1206
double step
Definition: solver.h:652
Stores all the equations for a given block (a block can either be a domain or a set of boundary condi...
Definition: solver.h:140
void bc_pol_add_lri(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &r, const matrix &i)
Definition: solver.h:326
void add_d(int ieq, int ivar, const matrix &d)
Introduces a term of type 'd' for the ivar-th variable in the ieq-th equation.
Definition: solver.h:181
void right_precond(matrix &x)
Definition: solver.h:50
void set_step(double)
Definition: RKF_solver.cpp:104
void bc_eq_add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:399
void add_lri(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &r, const matrix &i)
Definition: solver.h:304
bool * reg
Definition: solver.h:517
int nstages
Definition: solver.h:646
int * nr
Definition: solver.h:516
Definition: solver.h:513
int verbose
Definition: solver.h:16
void lu_calc()
Definition: solver_full.cpp:120
bool initd
Definition: solver.h:651
void bc_eq_add_li(const char *eqn, const char *varn, const matrix &d, const matrix_block_diag &l, const matrix &i)
Definition: solver.h:342
int lu_flag
Definition: solver.h:26
bool first_explicit
Definition: solver.h:651
matrix a
Definition: solver.h:654
void bc_top1_add_ri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:477
~solver_full()
Definition: solver_full.cpp:49
void bc_pol_add_ri(const char *eqn, const char *varn, const matrix &d, const matrix &r, const matrix &i)
Definition: solver.h:323
virtual matrix solve(const matrix &)=0
void wrap(const matrix *, matrix *)
Definition: SDIRK_solver.cpp:273
bool * reg
Definition: solver.h:650
void bc_eq_add_d(const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:330
void bc_pol_add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:377
void create_full()
Creates a solver operator of type "full".
Definition: solver.cpp:868
solver_elem *** eq
Pointers to all the terms of all the equations of the block.
Definition: solver.h:152
solver_elem * next
Pointer to the next term in the equation.
Definition: solver.h:107
Definition: solver.h:23
void bc_bot2_add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:443
matrix solve(const matrix &)
Solves the set of equation stored in the object given the right hand side rhs.
Definition: solver_full.cpp:106
void init_be()
Definition: SDIRK_solver.cpp:360
void destroy()
Definition: RKF_solver.cpp:48
int ** var_nr
var_nr[i][j] is the radial resolution of the j-th variable in the i-th equation
Definition: solver.h:213
void bc_bot1_add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:418
solver_iter()
Definition: solver.h:57
void write_blockinf(int i, const matrix &)
Definition: solver_full.cpp:328
void bc_top1_add_r(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &r)
Definition: solver.h:468
int solve(double t0, double t1)
Definition: RKF_solver.cpp:183
double step
Definition: solver.h:521
void bc_top1_add_l(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l)
Definition: solver.h:465
double alpha
Definition: solver.h:647
char ** var
Definition: solver.h:219
void subst_dep_eq(const char *block_type, solver_block *, int n, int i, int j)
Definition: solver.cpp:1964
~solver_iter()
Definition: solver.h:58
void bc_bot1_add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:436
void bc_pol_add_d(int iblock, const char *eqn, const char *varn, const matrix &d)
Definition: solver.h:374
int use_cgs
Definition: solver.h:249
~solver()
Definition: solver.h:256
solver_block()
Definition: solver.h:157
void create()
Creates the solver solver operator depending on the type of solver configured (defined when calling s...
Definition: solver.cpp:840
solver_block * bc_bot2
Definition: solver.h:225
void bc_bot2_add_lri(int iblock, const char *eqn, const char *varn, const matrix &d, const matrix &l, const matrix &r, const matrix &i)
Definition: solver.h:458
int * nth
nth[i] is the azimuthal resolution of the i-th variable.
Definition: solver.h:145
matrix c
Definition: solver.h:518
void add(int iblock, const char *eqn, const char *varn, const char *block_type, char type, const matrix *d, const matrix *l, const matrix *r, const matrix *i)
Definition: solver.cpp:1452
matrix_map get_vars()
Definition: RKF_solver.cpp:127
int get_nvar()
Definition: solver.cpp:299
int get_order()
Definition: SDIRK_solver.cpp:170
void read_block(int i)
Definition: solver_full.cpp:268
double delta
Definition: solver.h:656
solver_block * bc_top2
Definition: solver.h:227
char ** var
Definition: solver.h:648
void left_precond(matrix &)
Definition: solver.h:59
void init_esdirk3()
Definition: SDIRK_solver.cpp:424
void wrap(const matrix *, matrix *)
Definition: RKF_solver.cpp:150
matrix * k
Definition: solver.h:655