SPEED
MAKE_BUTCHERARRAY.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
19
23! where p is the order of the scheme and s is the number of stages
24! Schemes Implemented: RK(2,2), RK(3,3), RK(4,4)
32
33
34
35 subroutine make_butcherarray(order, stages, A_low, B_low, c)
36
37 implicit none
38
39 integer*4:: order, stages
40 real*8, dimension(stages,stages) :: a
41 real*8, dimension(stages) :: b, c, a_low, b_low
42
43 a = 0; b = 0; c = 0; a_low = 0; b_low = 0;
44
45 select case(order)
46
47 case(2)
48 ! RK(2,2)
49 select case(stages)
50 case(2)
51 c(2) = 1
52 b(1) = 0.5; b(2)=0.5
53 a(2,1) = 1
54
55 call make_low_storage_coefficients(stages,a,b,c,a_low,b_low)
56
57 case default
58 write(*,'(A)') 'RK scheme not implemented'
59 end select
60
61 case(3)
62 ! RK(3,3)
63 select case(stages)
64 case(3)
65 c(2) = 0.5; c(3) = 1
66 b(1) = 1.d0/6; b(2) = 2.d0/3; b(3) = 1.d0/6
67 a(2,1) = 0.5;
68 a(3,1) = -1; a(3,2) = 2
69
70 call make_low_storage_coefficients(stages,a,b,c,a_low,b_low)
71
72
73 case default
74 write(*,'(A)') 'RK scheme not implemented'
75 end select
76
77 case(4)
78
79 select case(stages)
80 ! RK(4,4)
81 case(4)
82 c(2) = 0.5; c(3) = 0.5; c(4) = 1
83 b(1) = 1.d0/6; b(2) = 1.d0/3; b(3) = 1.d0/3; b(4) = 1.d0/6
84 a(2,1) = 0.5;
85 a(3,2) = 0.5;
86 a(4,3) = 1;
87
88 call make_low_storage_coefficients(stages,a,b,c,a_low,b_low)
89
90
91 case default
92 write(*,'(A)') 'RK scheme not implemented'
93
94 end select
95
96
97
98
99
100 case default
101 write(*,'(A)') 'RK scheme not implemented'
102
103 end select
104
105
106 end subroutine make_butcherarray
107
108!**************************************************************************************************
109
110
123
124
125
126 subroutine make_low_storage_coefficients(stages,A,b,c,A_low,B_low)
127
128 implicit none
129
130 integer*4:: stages
131 real*8, dimension(stages,stages) :: a
132 real*8, dimension(stages) :: b, c, a_low, b_low
133 integer*4 :: i
134
135
136 ! Compute Low storage coefficients according to the
137 ! paper Toulorge and Desmet: "Optimal Runge-Kutta schemes for discontinuous
138 ! Galerkin space discretizations applied to wave propagation problems"
139
140 a_low(1) = 0;
141
142 do i = 1, stages -1
143 b_low(i) = a(i+1,i)
144 enddo
145 b_low(stages) = b(stages)
146
147 do i = 2, stages
148 if (b(i) .ne. 0.d0) then
149 a_low(i) = (b(i-1) - b_low(i-1))/b(i);
150 else
151 a_low(i) = (a(i+1,i-1) - c(i))/b_low(i);
152 endif
153 enddo
154
155
156 end subroutine make_low_storage_coefficients
157
158
159
subroutine make_butcherarray(order, stages, a_low, b_low, c)
Makes Butcher array for Runge-Kutta scheme.
subroutine make_low_storage_coefficients(stages, a, b, c, a_low, b_low)
Computes Low-storage memory coefficients for Runge-Kutta scheme.