7 use regrid_solvers,
only : solve_linear_system, solve_tridiagonal_system
10 implicit none ;
private
12 public edge_slopes_implicit_h3
13 public edge_slopes_implicit_h5
16 real,
parameter :: hneglect_dflt = 1.e-30
49 subroutine edge_slopes_implicit_h3( N, h, u, edge_slopes, h_neglect )
50 integer,
intent(in) :: n
51 real,
dimension(:),
intent(in) :: h
52 real,
dimension(:),
intent(in) :: u
53 real,
dimension(:,:),
intent(inout) :: edge_slopes
55 real,
optional,
intent(in) :: h_neglect
59 real :: h0_2, h1_2, h0h1
64 real,
dimension(5) :: x
65 real,
dimension(4,4) :: asys
66 real,
dimension(4) :: bsys, csys
67 real,
dimension(3) :: dsys
68 real,
dimension(N+1) :: tri_l, &
76 hneglect = hneglect_dflt ;
if (
present(h_neglect)) hneglect = h_neglect
77 hneglect3 = hneglect**3
93 d = 4.0 * h0h1 * ( h0 + h1 ) + h1_3 + h0_3
96 alpha = h1 * (h0_2 + h0h1 - h1_2) / ( d + hneglect3 )
97 beta = h0 * (h1_2 + h0h1 - h0_2) / ( d + hneglect3 )
98 a = -12.0 * h0h1 / ( d + hneglect3 )
105 tri_b(i+1) = a * u(i) + b * u(i+1)
112 x(i) = x(i-1) + h(i-1)
118 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
121 bsys(i) = u(i) * ( h(i) )
125 call solve_linear_system( asys, bsys, csys, 4 )
128 dsys(2) = 2.0 * csys(3)
129 dsys(3) = 3.0 * csys(4)
133 tri_b(1) = evaluation_polynomial( dsys, 3, x(1) )
138 x(i) = x(i-1) + h(n-5+i)
144 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
147 bsys(i) = u(n-4+i) * ( h(n-4+i) )
151 call solve_linear_system( asys, bsys, csys, 4 )
154 dsys(2) = 2.0 * csys(3)
155 dsys(3) = 3.0 * csys(4)
159 tri_b(n+1) = evaluation_polynomial( dsys, 3, x(5) )
162 call solve_tridiagonal_system( tri_l, tri_d, tri_u, tri_b, tri_x, n+1 )
165 edge_slopes(i,1) = tri_x(i)
166 edge_slopes(i-1,2) = tri_x(i)
168 edge_slopes(1,1) = tri_x(1)
169 edge_slopes(n,2) = tri_x(n+1)
171 end subroutine edge_slopes_implicit_h3
176 subroutine edge_slopes_implicit_h5( N, h, u, edge_slopes, h_neglect )
177 integer,
intent(in) :: n
178 real,
dimension(:),
intent(in) :: h
179 real,
dimension(:),
intent(in) :: u
180 real,
dimension(:,:),
intent(inout) :: edge_slopes
182 real,
optional,
intent(in) :: h_neglect
219 real :: h0, h1, h2, h3
221 real :: g_4, g_5, g_6
222 real :: d2, d3, d4, d5, d6
223 real :: n2, n3, n4, n5, n6
229 real :: h0ph1, h0ph1_2
230 real :: h0ph1_3, h0ph1_4
231 real :: h2ph3, h2ph3_2
232 real :: h2ph3_3, h2ph3_4
235 real,
dimension(7) :: x
236 real,
dimension(6,6) :: asys
237 real,
dimension(6) :: bsys, csys
238 real,
dimension(5) :: dsys
239 real,
dimension(N+1) :: tri_l, &
246 hneglect = hneglect_dflt ;
if (
present(h_neglect)) hneglect = h_neglect
277 d2 = ( h1_2 - g_2 ) / ( h0 + hneglect )
278 d3 = ( h1_3 - g_3 ) / ( h0 + hneglect )
279 d4 = ( h1_4 - g_4 ) / ( h0 + hneglect )
280 d5 = ( h1_5 - g_5 ) / ( h0 + hneglect )
281 d6 = ( h1_6 - g_6 ) / ( h0 + hneglect )
290 n2 = ( g_2 - h2_2 ) / ( h3 + hneglect )
291 n3 = ( g_3 - h2_3 ) / ( h3 + hneglect )
292 n4 = ( g_4 - h2_4 ) / ( h3 + hneglect )
293 n5 = ( g_5 - h2_5 ) / ( h3 + hneglect )
294 n6 = ( g_6 - h2_6 ) / ( h3 + hneglect )
306 asys(2,3) = -0.5 * d2
308 asys(2,5) = -0.5 * h2
309 asys(2,6) = -0.5 * n2
313 asys(3,3) = - d3 / 6.0
314 asys(3,4) = h1_2 / 6.0
315 asys(3,5) = h2_2 / 6.0
318 asys(4,1) = - h1_2 / 2.0
319 asys(4,2) = - h2_2 / 2.0
320 asys(4,3) = d4 / 24.0
321 asys(4,4) = - h1_3 / 24.0
322 asys(4,5) = h2_3 / 24.0
323 asys(4,6) = n4 / 24.0
325 asys(5,1) = h1_3 / 6.0
326 asys(5,2) = - h2_3 / 6.0
327 asys(5,3) = - d5 / 120.0
328 asys(5,4) = h1_4 / 120.0
329 asys(5,5) = h2_4 / 120.0
330 asys(5,6) = n5 / 120.0
332 asys(6,1) = - h1_4 / 24.0
333 asys(6,2) = - h2_4 / 24.0
334 asys(6,3) = d6 / 720.0
335 asys(6,4) = - h1_5 / 720.0
336 asys(6,5) = h2_5 / 720.0
337 asys(6,6) = n6 / 720.0
339 bsys(:) = (/ 0.0, -1.0, 0.0, 0.0, 0.0, 0.0 /)
341 call solve_linear_system( asys, bsys, csys, 6 )
353 tri_b(k+1) = a * u(k-1) + b * u(k) + c * u(k+1) + d * u(k+2)
386 h0ph1_2 = h0ph1 * h0ph1
387 h0ph1_3 = h0ph1_2 * h0ph1
388 h0ph1_4 = h0ph1_2 * h0ph1_2
390 d2 = ( h1_2 - g_2 ) / ( h0 + hneglect )
391 d3 = ( h1_3 - g_3 ) / ( h0 + hneglect )
392 d4 = ( h1_4 - g_4 ) / ( h0 + hneglect )
393 d5 = ( h1_5 - g_5 ) / ( h0 + hneglect )
394 d6 = ( h1_6 - g_6 ) / ( h0 + hneglect )
403 n2 = ( g_2 - h2_2 ) / ( h3 + hneglect )
404 n3 = ( g_3 - h2_3 ) / ( h3 + hneglect )
405 n4 = ( g_4 - h2_4 ) / ( h3 + hneglect )
406 n5 = ( g_5 - h2_5 ) / ( h3 + hneglect )
407 n6 = ( g_6 - h2_6 ) / ( h3 + hneglect )
419 asys(2,3) = -0.5 * d2
421 asys(2,5) = -0.5 * h2
422 asys(2,6) = -0.5 * n2
426 asys(3,3) = - d3 / 6.0
427 asys(3,4) = h1_2 / 6.0
428 asys(3,5) = h2_2 / 6.0
431 asys(4,1) = - h0ph1_2 / 2.0
433 asys(4,3) = d4 / 24.0
434 asys(4,4) = - h1_3 / 24.0
435 asys(4,5) = h2_3 / 24.0
436 asys(4,6) = n4 / 24.0
438 asys(5,1) = h0ph1_3 / 6.0
440 asys(5,3) = - d5 / 120.0
441 asys(5,4) = h1_4 / 120.0
442 asys(5,5) = h2_4 / 120.0
443 asys(5,6) = n5 / 120.0
445 asys(6,1) = - h0ph1_4 / 24.0
447 asys(6,3) = d6 / 720.0
448 asys(6,4) = - h1_5 / 720.0
449 asys(6,5) = h2_5 / 720.0
450 asys(6,6) = n6 / 720.0
452 bsys(:) = (/ 0.0, -1.0, -h1, h1_2/2.0, -h1_3/6.0, h1_4/24.0 /)
454 call solve_linear_system( asys, bsys, csys, 6 )
466 tri_b(2) = a * u(1) + b * u(2) + c * u(3) + d * u(4)
471 x(i) = x(i-1) + h(i-1)
477 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
480 bsys(i) = u(i) * h(i)
484 call solve_linear_system( asys, bsys, csys, 6 )
487 dsys(2) = 2.0 * csys(3)
488 dsys(3) = 3.0 * csys(4)
489 dsys(4) = 4.0 * csys(5)
490 dsys(5) = 5.0 * csys(6)
495 tri_b(1) = evaluation_polynomial( dsys, 5, x(1) )
526 h2ph3_2 = h2ph3 * h2ph3
527 h2ph3_3 = h2ph3_2 * h2ph3
528 h2ph3_4 = h2ph3_2 * h2ph3_2
530 d2 = ( h1_2 - g_2 ) / ( h0 + hneglect )
531 d3 = ( h1_3 - g_3 ) / ( h0 + hneglect )
532 d4 = ( h1_4 - g_4 ) / ( h0 + hneglect )
533 d5 = ( h1_5 - g_5 ) / ( h0 + hneglect )
534 d6 = ( h1_6 - g_6 ) / ( h0 + hneglect )
543 n2 = ( g_2 - h2_2 ) / ( h3 + hneglect )
544 n3 = ( g_3 - h2_3 ) / ( h3 + hneglect )
545 n4 = ( g_4 - h2_4 ) / ( h3 + hneglect )
546 n5 = ( g_5 - h2_5 ) / ( h3 + hneglect )
547 n6 = ( g_6 - h2_6 ) / ( h3 + hneglect )
559 asys(2,3) = -0.5 * d2
561 asys(2,5) = -0.5 * h2
562 asys(2,6) = -0.5 * n2
566 asys(3,3) = - d3 / 6.0
567 asys(3,4) = h1_2 / 6.0
568 asys(3,5) = h2_2 / 6.0
572 asys(4,2) = - h2ph3_2 / 2.0
573 asys(4,3) = d4 / 24.0
574 asys(4,4) = - h1_3 / 24.0
575 asys(4,5) = h2_3 / 24.0
576 asys(4,6) = n4 / 24.0
579 asys(5,2) = - h2ph3_3 / 6.0
580 asys(5,3) = - d5 / 120.0
581 asys(5,4) = h1_4 / 120.0
582 asys(5,5) = h2_4 / 120.0
583 asys(5,6) = n5 / 120.0
586 asys(6,2) = - h2ph3_4 / 24.0
587 asys(6,3) = d6 / 720.0
588 asys(6,4) = - h1_5 / 720.0
589 asys(6,5) = h2_5 / 720.0
590 asys(6,6) = n6 / 720.0
592 bsys(:) = (/ 0.0, -1.0, h2, h2_2/2.0, h2_3/6.0, h2_4/24.0 /)
594 call solve_linear_system( asys, bsys, csys, 6 )
606 tri_b(n) = a * u(n-3) + b * u(n-2) + c * u(n-1) + d * u(n)
611 x(i) = x(i-1) + h(n-7+i)
617 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
620 bsys(i) = u(n-6+i) * h(n-6+i)
624 call solve_linear_system( asys, bsys, csys, 6 )
627 dsys(2) = 2.0 * csys(3)
628 dsys(3) = 3.0 * csys(4)
629 dsys(4) = 4.0 * csys(5)
630 dsys(5) = 5.0 * csys(6)
635 tri_b(n+1) = evaluation_polynomial( dsys, 5, x(7) )
638 call solve_tridiagonal_system( tri_l, tri_d, tri_u, tri_b, tri_x, n+1 )
641 edge_slopes(i,1) = tri_x(i)
642 edge_slopes(i-1,2) = tri_x(i)
644 edge_slopes(1,1) = tri_x(1)
645 edge_slopes(n,2) = tri_x(n+1)
647 end subroutine edge_slopes_implicit_h5