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
71 this%is_cmplx = optional_default(is_cmplx, .false.)
72
73 safe_allocate(this%regions(1:this%nregions+1))
74 if (this%is_cmplx) then
75 safe_allocate(this%zprojectors(1:this%npoints, 1:nprojs))
76 else
77 safe_allocate(this%dprojectors(1:this%npoints, 1:nprojs))
78 end if
79 safe_allocate(this%scal(1:nprojs))
80
81 if (has_mix_matrix) then
82 if (this%is_cmplx) then
83 safe_allocate(this%zmix(1:nprojs, 1:nprojs, 1:4))
84 else
85 safe_allocate(this%dmix(1:nprojs, 1:nprojs))
86 end if
87 end if
88
90 end subroutine projector_matrix_allocate
91
92 ! -------------------------------------------------
93
94 subroutine projector_matrix_deallocate(this)
95 type(projector_matrix_t), intent(inout) :: this
96
98
99 safe_deallocate_a(this%regions)
100 safe_deallocate_a(this%dprojectors)
101 safe_deallocate_a(this%zprojectors)
102 safe_deallocate_a(this%scal)
103 safe_deallocate_a(this%dmix)
104 safe_deallocate_a(this%zmix)
105
106 nullify(this%position)
107 nullify(this%map)
108
110 end subroutine projector_matrix_deallocate
111
112 ! -------------------------------------------------
113
115
116!! Local Variables:
117!! mode: f90
118!! coding: utf-8
119!! 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.