Mercurial > repos > public > sbplib
annotate +rv/+time/rungekuttaRV.m @ 1169:d02e5b8a0b24 feature/rv
Rename RungekuttaRV time steppers. Add RungekuttaRVMultiStage time stepper
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 28 Jun 2019 13:13:17 +0200 |
parents | 010bb2677230 |
children |
rev | line source |
---|---|
846
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
1 % Takes one time step of size dt using the rungekutta method |
1012
1e437c9e5132
Create residual viscosity package +rv and generalize the ResidualViscosity class
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
847
diff
changeset
|
2 % starting from v and where the function F(v,t,RV) gives the |
846
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
3 % time derivatives. coeffs is a struct holding the RK coefficients |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
4 % for the specific method. RV is the residual viscosity which is updated |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
5 % in between the stages and after the updated solution is computed. |
1017
2d7c1333bd6c
Add support for using the ODE to approximate the time derivative in the residual
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1012
diff
changeset
|
6 function v = rungekuttaRV(v, t , dt, F, RV, DvDt, coeffs) |
846
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
7 % Move one stage outside to avoid branching for updating the |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
8 % residual inside the loop. |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
9 k = zeros(length(v), coeffs.s); |
1152
010bb2677230
Clean up in +rv/+time. Make the time stepping more efficient by not storing unnessecary properties in the RK-RV time steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1017
diff
changeset
|
10 k(:,1) = F(v,t,RV.evaluateViscosity(v,DvDt(v))); |
846
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
11 |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
12 % Compute the intermediate stages k |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
13 for i = 2:coeffs.s |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
14 u = v; |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
15 for j = 1:i-1 |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
16 u = u + dt*coeffs.a(i,j)*k(:,j); |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
17 end |
1152
010bb2677230
Clean up in +rv/+time. Make the time stepping more efficient by not storing unnessecary properties in the RK-RV time steppers
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1017
diff
changeset
|
18 k(:,i) = F(u,t+coeffs.c(i)*dt, RV.evaluateViscosity(u,DvDt(u))); |
846
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
19 end |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
20 |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
21 % Compute the updated solution as a linear combination |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
22 % of the intermediate stages. |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
23 u = v; |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
24 for i = 1:coeffs.s |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
25 u = u + dt*coeffs.b(i)*k(:,i); |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
26 end |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
27 v = u; |
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
28 end |