-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatOp_OPENMP.f90
65 lines (56 loc) · 2.35 KB
/
MatOp_OPENMP.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
58
59
60
61
62
63
64
65
Subroutine MatOp_OPENMP(a,b,dt,g,Theta,PCRI,H,P,IndexWaterLevel,DZiADZ,nElem,Edge,Neighbor,EdgeLength,CirDistance,nEdge)
! Compute the Semi-Implicit Method Coefficient Matrix
! Casulli, V. A high-resolution wetting and drying algorithm for free-surfacehydrodynamics.
! INTERNATIONAL JOURNAL FOR NUMERICAL METHODS IN FLUIDS, v. 60, n. 4 (2009), p. 391-408
! Input:
! a -> Free-Surface Elevation Vector
! Output:
! b -> Solution
! List of Modifications:
! -> 10.03.2014: Routine Implementation (Rafael Cavalcanti)
! Programmer: Rafael Cavalcanti
!$ use omp_lib
Use MeshVars
Use Hydrodynamic
Implicit None
Integer:: iElem, iEdge, Pij, Face
Double Precision:: Sum, Coef
Double Precision:: NearZero = 1e-10
Double Precision:: dt
!type(MeshGridParam) :: MeshParam
!type(HydrodynamicParam) :: HydroParam
Double Precision, intent(in) :: a(nElem)
Double Precision, intent(out) :: b(nElem)
Integer:: nElem,nEdge
Double Precision:: g,Theta,PCRI
Double Precision:: H(nEdge)
Double Precision:: P(nElem)
Double Precision:: IndexWaterLevel(nElem)
Double Precision:: DZiADZ(nEdge)
Integer:: Edge(4,nElem)
Integer:: Neighbor(4,nElem)
Double Precision:: EdgeLength(nEdge)
Double Precision:: CirDistance(nEdge)
Coef = g*(Theta*dt)**2
!call omp_set_num_threads(2)
! 1. Compute T Matrix (Casulli, 2009)
!$OMP parallel do default(none) shared(a,b,P,Edge,Neighbor,EdgeLength,CirDistance,IndexWaterLevel,DZiADZ,nElem,H,Pcri,NearZero,Coef) private(iElem,iEdge,Face,Pij, Sum)
Do iElem = 1, nElem
b(iElem) = P(iElem)*a(iElem) ! Initializing b
Sum = 0.
Do iEdge = 1, 4
Face = Edge(iEdge,iElem)
Pij = Neighbor(iEdge,iElem)
If (Pij == 0.or.H(Face) <= PCRI+NearZero) Then
If (IndexWaterLevel(iElem)>0) Then
Sum = Sum + Coef*( EdgeLength(Face)/CirDistance(Face) )*( ( - a(iElem) ) )*DZiADZ(Face) !( EdgeLength(Face)/CirDistance(Face) )*
EndIf
Else
Sum = Sum + Coef*( EdgeLength(Face)/CirDistance(Face) )*( ( a(Pij) - a(iElem) ) )*DZiADZ(Face)
EndIf
EndDo
b(iElem) = b(iElem) - Sum
EndDo
!$OMP end parallel do
Return
End Subroutine MatOp_OPENMP