Octopus
projector_matrix.F90
Go to the documentation of this file.
1!! Copyright (C) 2010 X. Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use debug_oct_m
23 use global_oct_m
27
28 implicit none
29
30 private
31
32 public :: &
36
39 ! Components are public by default
40 real(real64), allocatable :: dprojectors(:, :)
41 complex(real64), allocatable :: zprojectors(:, :)
42 real(real64), allocatable :: scal(:)
43 integer :: npoints
44 integer :: nprojs
45 integer :: nregions
46 integer, allocatable :: regions(:)
47 real(real64), allocatable :: dmix(:, :)
48 complex(real64), allocatable :: zmix(:, :, :)
49 logical :: is_cmplx = .false.
50
51 integer, pointer, contiguous :: map(:)
52 real(real64), pointer, contiguous :: position(:, :)
53 end type projector_matrix_t
54
55contains
56
57 ! -------------------------------------------------
58 subroutine projector_matrix_allocate(this, nprojs, sphere, has_mix_matrix, is_cmplx)
59 type(projector_matrix_t), intent(out) :: this
60 integer, intent(in) :: nprojs
61 type(submesh_t), intent(in) :: sphere
62 logical, intent(in) :: has_mix_matrix
63 logical, optional, intent(in) :: is_cmplx
64
66
67 this%npoints = sphere%np
68 this%nprojs = nprojs
69 this%nregions = sphere%num_regions
70 nullify(this%map)
71 nullify(this%position)
72
73 this%is_cmplx = optional_default(is_cmplx, .false.)
74
75 safe_allocate(this%regions(1:this%nregions+1))
76 if (this%is_cmplx) then
77 safe_allocate(this%zprojectors(1:this%npoints, 1:nprojs))
78 else
79 safe_allocate(this%dprojectors(1:this%npoints, 1:nprojs))
80 end if
81 safe_allocate(this%scal(1:nprojs))
82
83 if (has_mix_matrix) then
84 if (this%is_cmplx) then
85 safe_allocate(this%zmix(1:nprojs, 1:nprojs, 1:4))
86 else
87 safe_allocate(this%dmix(1:nprojs, 1:nprojs))
88 end if
89 end if
90
92 end subroutine projector_matrix_allocate
93
94 ! -------------------------------------------------
95
96 subroutine projector_matrix_deallocate(this)
97 type(projector_matrix_t), intent(inout) :: this
98
100
101 safe_deallocate_a(this%regions)
102 safe_deallocate_a(this%dprojectors)
103 safe_deallocate_a(this%zprojectors)
104 safe_deallocate_a(this%scal)
105 safe_deallocate_a(this%dmix)
106 safe_deallocate_a(this%zmix)
107
108 nullify(this%position)
109 nullify(this%map)
110 this%npoints = 0
111 this%nprojs = 0
112 this%nregions = 0
113 this%is_cmplx = .false.
116 end subroutine projector_matrix_deallocate
117
118 ! -------------------------------------------------
119
120end module projector_matrix_oct_m
121
122!! Local Variables:
123!! mode: f90
124!! coding: utf-8
125!! End:
subroutine, public projector_matrix_deallocate(this)
subroutine, public projector_matrix_allocate(this, nprojs, sphere, has_mix_matrix, is_cmplx)
A set of projectors defined on a submesh.