-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sparse_Mod.f90
65 lines (58 loc) · 3.29 KB
/
Sparse_Mod.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
#include "Assert.h90"
!==============================================================================!
module Sparse_Mod
!------------------------------------------------------------------------------!
!----------------------------------[Modules]-----------------------------------!
use Sort_Mod
use Matrix_Mod
use Grid_Mod
!------------------------------------------------------------------------------!
implicit none
!------------------------------------------------------------------------------!
! Sparse matrix type !
! !
! Sparse matrix is stored in compressed row format. !
! (See: http://netlib.org/linalg/html_templates/node91.html) !
! !
! Example: !
! !
! c c . c !
! o o . o !
! l l l !
! !
! 1 2 n !
! !
! [ 10 0 4 5 ] --> row 1 !
! [ 2 12 -1 0 ] --> rows store discretized control volumes !
! [ 0 1 99 7 ] ... !
! [ -3 11 0 53 ] --> row n !
! !
! Compressed row storage of the above matrix reads: !
! !
! A % val = [ 10 4 5 2 12 -1 1 99 7 -3 11 53 ] !
! A % col = [ 1 3 4 1 2 3 2 3 4 1 2 4 ] !
! A % row = [ 1 4 7 10 ] !
! !
! A % dia = [ 1 5 9 12 ] !
!==============================================================================!
!-----------------!
! !
! Sparse Type !
! !
!-----------------!
type, extends(Matrix_Type) :: Sparse_Type
real, allocatable :: val(:) ! value
integer, allocatable :: col(:) ! beginning of each row
integer, allocatable :: row(:) ! column positions
integer, allocatable :: dia(:) ! diagonal positions
integer, allocatable :: mir(:) ! position of the mirror entry
contains
procedure :: Sparse_Create
procedure :: Sparse_Create_Preconditioning
procedure :: Sparse_Deallocate
end type
contains
# include "Sparse_Mod/Create.f90"
# include "Sparse_Mod/Create_Preconditioning.f90"
# include "Sparse_Mod/Deallocate.f90"
end module