MPI-SCATCI 2.0
An MPI version of SCATCI
Loading...
Searching...
No Matches
MatrixElement_module.f90
Go to the documentation of this file.
1! Copyright 2019
2!
3! For a comprehensive list of the developers that contributed to these codes
4! see the UK-AMOR website.
5!
6! This file is part of UKRmol-in (UKRmol+ suite).
7!
8! UKRmol-in is free software: you can redistribute it and/or modify
9! it under the terms of the GNU General Public License as published by
10! the Free Software Foundation, either version 3 of the License, or
11! (at your option) any later version.
12!
13! UKRmol-in is distributed in the hope that it will be useful,
14! but WITHOUT ANY WARRANTY; without even the implied warranty of
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16! GNU General Public License for more details.
17!
18! You should have received a copy of the GNU General Public License
19! along with UKRmol-in (in source/COPYING). Alternatively, you can also visit
20! <https://www.gnu.org/licenses/>.
21
22!> \brief Matrix element module
23!> \authors A Al-Refaie
24!> \date 2017
25!>
26!> \note 16/01/2019 - Jakub Benda: Unifom coding style and expanded documentation.
27!>
28module matrixelement_module
29
30 use precisn, only: wp
31 use const_gbl, only: stdout
32 use matrixcache_module, only: matrixcache
33 use basematrix_module, only: basematrix
34
35 implicit none
36
37 public matrixelementvector
38
39 private
40
41 !> \brief This handles the matrix elements and also expands the vector size if we have reached max capacity
42 !> \authors A Al-Refaie
43 !> \date 2017
44 !>
45 type, extends(basematrix) :: matrixelementvector
46 type(matrixcache) :: matrix_cache
47 contains
48 procedure, public :: sort => sort_matelem
49 !procedure, public :: prune_threshold
50 procedure, public :: initialize_struct_self => initialize_struct_standard
51 procedure, public :: construct_self => construct_mat_standard
52 procedure, public :: insert_matelem_self => insert_matelem_standard
53 procedure, public :: get_matelem_self => get_matelem_standard
54 procedure, public :: clear_self => clear_standard
55 procedure, public :: expand_capacity => expand_standard
56 procedure, public :: destroy_self => destroy_standard
57 !procedure, public :: count_occurance
58 !procedure, public :: construct
59 end type matrixelementvector
60
61contains
62
63 !> \brief Check that type is constructed
64 !> \authors A Al-Refaie
65 !> \date 2017
66 !>
67 !> Checks if the type is constructed and hard aborts when not.
68 !>
69 subroutine check_constructed (this)
70 class(matrixelementvector) :: this
71
72 if (.not. this % constructed) then
73 write (stdout, "('Vector::constructed - Vector is not constructed')")
74 stop "Vector::constructed - Vector is not constructed"
75 end if
76
77 end subroutine check_constructed
78
79
80 !> \brief Construct the type
81 !> \authors A Al-Refaie
82 !> \date 2017
83 !>
84 subroutine construct_mat_standard (this)
85 class(matrixelementvector) :: this
86
87 print *, 'MatrixElement::construct_mat_standard'
88
89 call this % matrix_cache % construct
90 call this % matrix_cache % clear
91
92 end subroutine construct_mat_standard
93
94
95 !> \brief Initialize the type
96 !> \authors A Al-Refaie
97 !> \date 2017
98 !>
99 subroutine initialize_struct_standard (this, matrix_size, matrix_type, block_size)
100 class(matrixelementvector) :: this
101 integer, intent(in) :: matrix_size, matrix_type, block_size
102 integer :: ido
103
104 this % initialized = .true.
105 !this % matrix_dimension = matrix_size
106
107 end subroutine initialize_struct_standard
108
109
110 !> \brief Insert a new element
111 !> \authors A Al-Refaie
112 !> \date 2017
113 !>
114 subroutine insert_matelem_standard (this, i, j, coefficient, class, thresh)
115 class(matrixelementvector) :: this
116 integer, intent(in) :: i, j, class
117 real(wp), intent(in) :: coefficient, thresh
118
119 !this%matrix_size = max(this%matrix_size,i,j)
120 if (abs(coefficient) < thresh) return
121
122 call this % matrix_cache % insert_into_cache(i, j, coefficient)
123
124 this % n = this % matrix_cache % n
125
126 end subroutine insert_matelem_standard
127
128
129 !> \brief Retrieve element
130 !> \authors A Al-Refaie
131 !> \date 2017
132 !>
133 subroutine get_matelem_standard (this, idx, i, j, coeff)
134 class(matrixelementvector) :: this
135 integer, intent(in) :: idx
136 integer, intent(out) :: i, j
137 real(wp), intent(out) :: coeff
138
139 call this % matrix_cache % get_from_cache(idx, i, j, coeff)
140
141 end subroutine get_matelem_standard
142
143
144 !> \brief Retrieve element
145 !> \authors A Al-Refaie
146 !> \date 2017
147 !>
148 subroutine expand_standard (this, capacity)
149 class(matrixelementvector) :: this
150 integer, intent(in) :: capacity
151
152 call this % matrix_cache % expand_capacity(capacity)
153
154 write (stdout, "('Current Matrix array size is ',i4)") this % matrix_cache % max_capacity
155
156 end subroutine expand_standard
157
158
159 !> \brief Clear elements
160 !> \authors A Al-Refaie
161 !> \date 2017
162 !>
163 subroutine clear_standard (this)
164 class(matrixelementvector) :: this
165 integer :: ido
166
167 !do ido=1,this%max_capacity
168 ! this%matrix_elements(ido)%i = -1
169 ! this%matrix_elements(ido)%j = -1
170 ! this%matrix_elements(ido)%coefficient = 0.0_wp
171 !enddo
172 !this%matrix_size = 0
173
174 call this % matrix_cache % clear
175
176 end subroutine clear_standard
177
178
179 !> \brief Sort elements
180 !> \authors A Al-Refaie
181 !> \date 2017
182 !>
183 subroutine sort_matelem (this)
184 class(matrixelementvector) :: this
185
186 call this % matrix_cache % sort
187
188 end subroutine sort_matelem
189
190
191 !> \brief Destroy elements
192 !> \authors A Al-Refaie
193 !> \date 2017
194 !>
195 subroutine destroy_standard (this)
196 class(matrixelementvector) :: this
197
198 call this % matrix_cache % destroy
199
200 end subroutine destroy_standard
201
202end module matrixelement_module