libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_newton_bridge.h
Go to the documentation of this file.
1
8#ifndef ODE_NEWTON_BRIDGE_H_
9#define ODE_NEWTON_BRIDGE_H_
10
11#include "ode_newton.h"
12
13namespace ode {
14
16template <class Integrator>
17class OdeNewtonBridge : public OdeNewton {
18
19 public:
21
26 OdeNewtonBridge (unsigned long neq, unsigned long nnew, Integrator *integrator)
27 : OdeNewton (nnew) {
28
29 //make the default Newton iteration limit quite high
30 set_iter_Newton(10000);
31
32 //store pointers to the ODE solver object and its members
33 integrator_ = integrator;
34 sol_ = integrator_->sol_;
35 Jac_ = integrator_->Jac_;
36 dt_ = &(integrator_->dt_);
37 //store ODE system size
38 neq_ = integrator_->neq_;
39 //store Newton system size;
40 nnew_ = nnew;
41
42 //temporary values for evaluation of ODE fun within Newton fun
43 ftemp_ = new double[neq];
44 //temporary solution values
45 soltemp_ = new double[neq];
46 }
49 delete [] ftemp_;
50 delete [] soltemp_;
51 }
52
53 protected:
54
56 unsigned long neq_;
58 unsigned long nnew_;
60 Integrator *integrator_;
62 double *sol_;
64 double **Jac_;
66 double *dt_;
67
69 double *ftemp_;
71 double *soltemp_;
72
74
78 void fun(double *solin, double *fout) { integrator_->ode_fun_(solin, fout); }
80
84 void jac(double *solin, double **Jout) { integrator_->ode_jac_(solin, Jout); }
85};
86
88
92template <class Integrator>
93class OdeNewtonIRK : public OdeNewtonBridge<Integrator> {
94
95 public:
97
102 OdeNewtonIRK (unsigned long neq, int nk, Integrator *integrator) :
103 OdeNewtonBridge<Integrator> (neq, neq*nk, integrator) {
104
105 //number of stages or k vectors
106 nk_ = nk;
107 //pointer to stage k values
108 k_ = integrator->k_;
109 //pointers to tableau coefficients
110 a = integrator->a;
111 b = integrator->b;
112 }
113
114 protected:
115
117 int nk_;
119 double **k_;
121 double **a;
123 double *b;
124};
125
127
133template <class Integrator>
134class OdeNewtonSDIRK : public OdeNewtonBridge<Integrator> {
135
136 public:
138
142 OdeNewtonSDIRK (unsigned long neq, Integrator *integrator) :
143 OdeNewtonBridge<Integrator> (neq, neq, integrator) {
144
145 //pointer to stage k values
146 k_ = integrator->k_;
147 //pointers to tableau coefficients
148 gam = integrator->gam;
149 a = integrator->a;
150 b = integrator->b;
151 //index of k vector being solved for
152 ik_ = 0;
153 }
154
156 void set_ik (int ik) { ik_ = ik; }
157
158 protected:
159
161 double **k_;
163 double gam;
165 double **a;
167 double *b;
169 int ik_;
170};
171
172} // namespace ode
173
174#endif
Templated base class connecting solver objects and OdeNewton objects.
double ** Jac_
pointer to the solver's Jacobian matrix
void fun(double *solin, double *fout)
wrapper around system evaluation function
unsigned long neq_
ODE system size.
double * dt_
pointer to time step member
void jac(double *solin, double **Jout)
wrapper around Jacobian evaluation function
Integrator * integrator_
storage of a pointer to the solver class
double * ftemp_
temporary values for evaluation of Newton function
OdeNewtonBridge(unsigned long neq, unsigned long nnew, Integrator *integrator)
constructs
double * sol_
pointer to the solver's solution vector
double * soltemp_
temporary solution values
unsigned long nnew_
Newton system size.
Newton's method for nonlinear systems of equations.
Definition ode_newton.h:18
void set_iter_Newton(unsigned long iter_Newton)
sets the iteration counter
Definition ode_newton.h:52
Extension of OdeNewtonBridge class for fully implicit methods.
int nk_
number of stages or k vectors
OdeNewtonIRK(unsigned long neq, int nk, Integrator *integrator)
constructs
double ** a
pointer to tableau coefficients
double ** k_
pointer to the stage slopes of RK methods
double * b
pointer to tableau coefficients
Extension of OdeNewtonBridge class for fully SDIRK methods.
void set_ik(int ik)
sets the index of the k vector being solved for
double ** k_
pointer to the stage slopes of RK methods
double ** a
pointer to tableau coefficients
OdeNewtonSDIRK(unsigned long neq, Integrator *integrator)
constructs
double gam
diagonal tableau coefficient
double * b
pointer to tableau coefficients
int ik_
the index of the k vector being solved for