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(:, :)
55 real(real64), allocatable :: sphere_weights(:)
56 end type projector_matrix_t
57
58contains
59
60 ! -------------------------------------------------
61 subroutine projector_matrix_allocate(this, nprojs, sphere, has_mix_matrix, is_cmplx)
62 type(projector_matrix_t), intent(out) :: this
63 integer, intent(in) :: nprojs
64 type(submesh_t), intent(in) :: sphere
65 logical, intent(in) :: has_mix_matrix
66 logical, optional, intent(in) :: is_cmplx
67
69
70 this%npoints = sphere%np
71 this%nprojs = nprojs
72 this%nregions = sphere%num_regions
73 nullify(this%map)
74 nullify(this%position)
75
76 this%is_cmplx = optional_default(is_cmplx, .false.)
77
78 safe_allocate(this%regions(1:this%nregions+1))
79 if (this%is_cmplx) then
80 safe_allocate(this%zprojectors(1:this%npoints, 1:nprojs))
81 else
82 safe_allocate(this%dprojectors(1:this%npoints, 1:nprojs))
83 end if
84 safe_allocate(this%scal(1:nprojs))
85
86 if (has_mix_matrix) then
87 if (this%is_cmplx) then
88 safe_allocate(this%zmix(1:nprojs, 1:nprojs, 1:4))
89 else
90 safe_allocate(this%dmix(1:nprojs, 1:nprojs))
91 end if
92 end if
93
95 end subroutine projector_matrix_allocate
96
97 ! -------------------------------------------------
98
99 subroutine projector_matrix_deallocate(this)
100 type(projector_matrix_t), intent(inout) :: this
101
103
104 safe_deallocate_a(this%regions)
105 safe_deallocate_a(this%dprojectors)
106 safe_deallocate_a(this%zprojectors)
107 safe_deallocate_a(this%scal)
108 safe_deallocate_a(this%sphere_weights)
109 safe_deallocate_a(this%dmix)
110 safe_deallocate_a(this%zmix)
111
112 nullify(this%position)
113 nullify(this%map)
114 this%npoints = 0
115 this%nprojs = 0
116 this%nregions = 0
117 this%is_cmplx = .false.
118
120 end subroutine projector_matrix_deallocate
121
122 ! -------------------------------------------------
123
124end module projector_matrix_oct_m
125
126!! Local Variables:
127!! mode: f90
128!! coding: utf-8
129!! 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.