Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_linear_operator_penalized.F90
Go to the documentation of this file.
1 
10 
12  !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 #include "sll_working_precision.h"
14 
17 
18  implicit none
19 
20  public :: &
22 
23  private
24  ! ..................................................
28  sll_int32 :: n_dim_nullspace = 1
29 
30  sll_real64, dimension(:,:), allocatable :: vecs
31 
32  class(sll_t_linear_operator_abstract), pointer :: ptr_linear_operator => null()
33  contains
34  procedure :: create => create_linear_operator_penalized
35  procedure :: free => free_linear_operator_penalized
36  procedure :: dot => dot_linear_operator_penalized
37  procedure :: print_info => print_info_linear_operator_penalized
39  ! ..................................................
40 
41 contains
42 
43  ! ............................................
51  & linear_operator, &
52  & vecs, n_dim_nullspace)
53  implicit none
54  class(sll_t_linear_operator_penalized) , intent(inout) :: self
55  class(sll_t_linear_operator_abstract), target, optional, intent(in) :: linear_operator
56  sll_real64,dimension(:,:) , optional, intent(in) :: vecs
57  sll_int32 , optional, intent(in) :: n_dim_nullspace
58  ! local
59 
60  if (present(linear_operator)) then
61  self % ptr_linear_operator => linear_operator
62  end if
63  ! ...
64 
65  ! ...
66  call self % initialize_abstract (other=linear_operator)
67  ! ...
68 
69  ! ...
70  self % n_dim_nullspace = 1
71  if (present(n_dim_nullspace)) then
72  self % n_dim_nullspace = n_dim_nullspace
73  end if
74  ! ...
75 
76  ! ...
77  allocate(self % vecs(self % n_dim_nullspace, self % n_global_cols))
78  self % vecs = 0.0_f64
79  ! ...
80 
81  ! ... \todo add assertions
82  if (present(vecs)) then
83  self % vecs = vecs
84  else
85  if (self % n_dim_nullspace == 1) then
86  self % vecs = 1.0_f64
87  else
88  stop "create_linear_operator_penalized: wrong arguments for the vecs attribut"
89  end if
90  end if
91  ! ...
92 
94  ! ............................................
95 
96  ! ............................................
101  implicit none
102  class(sll_t_linear_operator_penalized), intent(inout) :: self
103  ! local
104 
105  ! ...
106  deallocate(self % vecs)
107  ! ...
108 
109  end subroutine free_linear_operator_penalized
110  ! ............................................
111 
112  ! ...................................................
118  subroutine dot_linear_operator_penalized(self, x, y)
119  implicit none
120  class(sll_t_linear_operator_penalized), intent(in) :: self
121  sll_real64,dimension(:), intent(in ) :: x
122  sll_real64,dimension(:), intent( out) :: y
123  ! local
124  sll_int32 :: i
125 
126  ! ...
127  if ( associated(self % ptr_linear_operator) .eqv. .true.) then
128  call self % ptr_linear_operator % dot(x, y)
129  else
130  stop "dot_real_linear_operator_penalized: linear operator must be initialized"
131  end if
132  ! ...
133 
134  ! ... add penalization term
135  do i = 1, self % n_dim_nullspace
136  y(:) = y(:) + dot_product(self % vecs(i, :), x(:)) / real(self % n_global_cols, f64)
137  end do
138  ! ...
139 
140  end subroutine dot_linear_operator_penalized
141  ! ...................................................
142 
143  ! ...................................................
148  implicit none
149  class(sll_t_linear_operator_penalized), intent(in) :: self
150  ! local
151 
152  print *, ">>>> linear_operator_penalized"
153  call self % print_info_abstract()
154 
155  print *, "* n_dim_nullspace : ", self % n_dim_nullspace
156  print *, "<<<< "
157 
159  ! ...................................................
160 
module for abstract linear operator
module for a penalized linear operator
subroutine free_linear_operator_penalized(self)
destroys the current object
subroutine dot_linear_operator_penalized(self, x, y)
apply the dot operation
subroutine create_linear_operator_penalized(self, linear_operator, vecs, n_dim_nullspace)
creates a linear operator_penalized
subroutine print_info_linear_operator_penalized(self)
prints a linear operator
    Report Typos and Errors