-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_flux.f90
58 lines (43 loc) · 2.6 KB
/
compute_flux.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
subroutine compute_flux(ne,u,N,Al,Ar,flux,SEM,SET)
!$ use omp_lib
implicit none
INCLUDE "sem.h"
INCLUDE "set.h"
TYPE(semProblem), INTENT(INOUT) :: SEM
TYPE(SETup), INTENT(INOUT) :: SET
integer, intent(in) :: ne, N
real(kind=8), intent(in) :: u(ne,N+1,2), Al(ne,2,2), Ar(ne,2,2)
real(kind=8), intent(out) :: flux(ne,N+1,2)
integer :: i
real(kind=8) :: zeros(2),boundaryflux(2)
flux(:,:,:) = 0.
zeros(:) = 0.
!##########################################
!#### Inside the computational domain ####
!##########################################
!$OMP PARALLEL DO PRIVATE(i) SHARED(flux,Ar,AL,u) SCHEDULE(static)
do i=2,ne-2
flux(i,1,:) = MATMUL(RESHAPE(Ar(i,:,:),(/2,2/)), RESHAPE((-u(i-1,N+1,:)),(/2/))) + &
MATMUL(RESHAPE(Al(i,:,:),(/2,2/)), RESHAPE((-u(i ,1,:)),(/2/)))
flux(i,N+1,:) = MATMUL(RESHAPE(Ar(i,:,:),(/2,2/)), RESHAPE( u(i,N+1,:),(/2/))) + &
MATMUL(RESHAPE(Al(i,:,:),(/2,2/)), RESHAPE(u(i+1,1,:),(/2/)))
end do
!$OMP END PARALLEL DO
!##########################################
!##### At the domain's boundaries ######
!##### And coupling term ######
!##########################################
boundaryflux(1) = SEM%sigma(SET%Cij(N+1,SEM%ne))
boundaryflux(2) = SEM%udot(SET%Cij(N+1,SEM%ne))
!SEM%T(SET%Cij(N+1,SEM%ne)) = u(1,1,1)
!SEM%udot(SET%Cij(N+1,SEM%ne)) = u(1,1,2)
!SEM%udotnew(SET%Cij(N+1,SEM%ne)) = u(1,1,2)
flux(1,1,:) = MATMUL(RESHAPE(Ar(1,:,:),(/2,2/)), RESHAPE(-boundaryflux,(/2/))) + &
MATMUL(RESHAPE(Al(1,:,:),(/2,2/)), RESHAPE(-u(1 ,1,:),(/2/)))
flux(1,N+1,:) = MATMUL(RESHAPE(Ar(1,:,:),(/2,2/)), RESHAPE( u(1,N+1,:),(/2/))) + &
MATMUL(RESHAPE(Al(1,:,:),(/2,2/)), RESHAPE( u(2,1,:),(/2/)))
flux(ne,1, :) = MATMUL(RESHAPE(Ar(ne,:,:), (/2,2/)),RESHAPE((-u(ne-1,N+1,:)),(/2/))) + &
MATMUL(RESHAPE(Al(ne,:,:), (/2,2/)),RESHAPE((-u(ne,1,:)),(/2/)))
flux(ne,N+1,:) = MATMUL(RESHAPE(Ar(ne,:,:), (/2,2/)) ,RESHAPE(u(ne, N+1,:),(/2/))) + &
MATMUL(RESHAPE(Al(ne,:,:), (/2,2/)), zeros)
end subroutine compute_flux