MPI-SCATCI  2.0
An MPI version of SCATCI
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 
29 
30  use precisn, only: wp
31  use const_gbl, only: stdout
33  use basematrix_module, only: basematrix
34 
35  implicit none
36 
37  public matrixelementvector
38 
39  private
40 
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 
61 contains
62 
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 
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 
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 
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 
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 
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 
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 
183  subroutine sort_matelem (this)
184  class(matrixelementvector) :: this
185 
186  call this % matrix_cache % sort
187 
188  end subroutine sort_matelem
189 
190 
195  subroutine destroy_standard (this)
196  class(matrixelementvector) :: this
197 
198  call this % matrix_cache % destroy
199 
200  end subroutine destroy_standard
201 
202 end module matrixelement_module
matrixelement_module
Matrix element module.
Definition: MatrixElement_module.f90:28
matrixelement_module::clear_standard
subroutine clear_standard(this)
Clear elements.
Definition: MatrixElement_module.f90:164
matrixelement_module::check_constructed
subroutine check_constructed(this)
Check that type is constructed.
Definition: MatrixElement_module.f90:70
matrixelement_module::matrixelementvector
This handles the matrix elements and also expands the vector size if we have reached max capacity.
Definition: MatrixElement_module.f90:45
basematrix_module
Base matrix module.
Definition: BaseMatrix_module.f90:28
matrixelement_module::construct_mat_standard
subroutine construct_mat_standard(this)
Construct the type.
Definition: MatrixElement_module.f90:85
matrixelement_module::sort_matelem
subroutine sort_matelem(this)
Sort elements.
Definition: MatrixElement_module.f90:184
matrixelement_module::expand_standard
subroutine expand_standard(this, capacity)
Retrieve element.
Definition: MatrixElement_module.f90:149
basematrix_module::basematrix
Base matrix type.
Definition: BaseMatrix_module.f90:47
matrixelement_module::get_matelem_standard
subroutine get_matelem_standard(this, idx, i, j, coeff)
Retrieve element.
Definition: MatrixElement_module.f90:134
matrixelement_module::initialize_struct_standard
subroutine initialize_struct_standard(this, matrix_size, matrix_type, block_size)
Initialize the type.
Definition: MatrixElement_module.f90:100
matrixcache_module
Matrix cache module.
Definition: MatrixCache_module.f90:28
matrixelement_module::destroy_standard
subroutine destroy_standard(this)
Destroy elements.
Definition: MatrixElement_module.f90:196
matrixelement_module::insert_matelem_standard
subroutine insert_matelem_standard(this, i, j, coefficient, class, thresh)
Insert a new element.
Definition: MatrixElement_module.f90:115
matrixcache_module::matrixcache
This handles the matrix elements and also expands the vector size if we have reached max capacity.
Definition: MatrixCache_module.f90:60