Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_qn_solver_2d_fem_sps_stencil_new_assembler.F90
Go to the documentation of this file.
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 
5 
7 
8  implicit none
9 
11 
12  private
13 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 
15  ! Working precision
16  integer, parameter :: wp = f64
17 
19 
20  integer :: n1
21  integer :: n2
22  integer :: p1
23  integer :: p2
24 
25  class(sll_t_qn_solver_2d_fem_sps_weak_form), pointer :: weak_form
26 
27  contains
28 
32 
34 
35 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 contains
37 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 
39  ! Initializer
40  subroutine s_qn_solver_2d_fem_sps_stencil_new_assembler__init(self, n1, n2, p1, p2, weak_form)
41  class(sll_t_qn_solver_2d_fem_sps_stencil_new_assembler), intent(inout) :: self
42  integer, intent(in) :: n1
43  integer, intent(in) :: n2
44  integer, intent(in) :: p1
45  integer, intent(in) :: p2
46  class(sll_t_qn_solver_2d_fem_sps_weak_form), target, intent(in) :: weak_form
47 
48  self%n1 = n1
49  self%n2 = n2
50  self%p1 = p1
51  self%p2 = p2
52 
53  self%weak_form => weak_form
54 
55  end subroutine
56 
57  ! Add element in stiffness and mass matrices
59  self, &
60  k1, &
61  k2, &
62  data_1d_eta1, &
63  data_1d_eta2, &
64  int_volume, &
65  inv_metric, &
66  coeffs1, &
67  coeffs2, &
68  A, &
69  M)
70  class(sll_t_qn_solver_2d_fem_sps_stencil_new_assembler), intent(in) :: self
71  integer, intent(in) :: k1
72  integer, intent(in) :: k2
73  real(wp), intent(in) :: data_1d_eta1(:, :, :, :)
74  real(wp), intent(in) :: data_1d_eta2(:, :, :, :)
75  real(wp), intent(in) :: int_volume(:, :, :, :)
76  real(wp), intent(in) :: inv_metric(:, :, :, :, :, :)
77  real(wp), intent(in) :: coeffs1(:, :, :, :)
78  real(wp), intent(in) :: coeffs2(:, :, :, :)
79  real(wp), intent(inout) :: A(-self%p1:, -self%p2:, :, :)
80  real(wp), intent(inout) :: M(-self%p1:, -self%p2:, :, :)
81 
82  integer :: i1, i2, j1, j2, s1, s2
83  real(wp) :: Ael, Mel
84  integer :: il1, il2, jl1, jl2
85 
86  associate(n1 => self%n1, &
87  n2 => self%n2, &
88  p1 => self%p1, &
89  p2 => self%p2)
90 
91  ! Cycle over basis functions in 2D trial space (same as test space)
92  do jl2 = 1, p2 + 1
93 
94  j2 = modulo(k2 + jl2 - 2, n2) + 1
95 
96  do jl1 = 1, p1 + 1
97 
98  j1 = k1 + jl1 - 1
99 
100  ! Cycle over basis functions in 2D test space
101  do il2 = 1, p2 + 1
102 
103  i2 = modulo(k2 + il2 - 2, n2) + 1
104 
105  do il1 = 1, p1 + 1
106 
107  i1 = k1 + il1 - 1
108 
109  call self%weak_form%element_mat( &
110  test_values_and_derivs_eta1=data_1d_eta1(:, :, il1, k1), &
111  test_values_and_derivs_eta2=data_1d_eta2(:, :, il2, k2), &
112  trial_values_and_derivs_eta1=data_1d_eta1(:, :, jl1, k1), &
113  trial_values_and_derivs_eta2=data_1d_eta2(:, :, jl2, k2), &
114  int_volume=int_volume(:, :, k1, k2), &
115  inv_metric=inv_metric(:, :, k1, k2, :, :), &
116  coeffs1=coeffs1(:, :, k1, k2), &
117  coeffs2=coeffs2(:, :, k1, k2), &
118  aij=ael, &
119  mij=mel)
120 
121  s1 = j1 - i1
122  s2 = modulo(j2 - i2 + p2, n2) - p2
123 
124  a(s1, s2, i1, i2) = a(s1, s2, i1, i2) + ael
125  m(s1, s2, i1, i2) = m(s1, s2, i1, i2) + mel
126 
127  end do
128  end do ! End cycle over basis functions in 2D test space
129 
130  end do
131  end do ! End cycle over basis functions in 2D trial space
132 
133  end associate
134 
136 
137  ! Add element in stiffness and mass matrices
139  self, &
140  k1, &
141  k2, &
142  data_1d_eta1, &
143  data_1d_eta2, &
144  data_2d_rhs, &
145  int_volume, &
146  bs)
147  class(sll_t_qn_solver_2d_fem_sps_stencil_new_assembler), intent(in) :: self
148  integer, intent(in) :: k1
149  integer, intent(in) :: k2
150  real(wp), intent(in) :: data_1d_eta1(:, :, :, :)
151  real(wp), intent(in) :: data_1d_eta2(:, :, :, :)
152  real(wp), intent(in) :: data_2d_rhs(:, :, :, :)
153  real(wp), intent(in) :: int_volume(:, :, :, :)
154  real(wp), intent(inout) :: bs(:, :)
155 
156  integer :: i1, i2, p1, p2
157  real(wp) :: bi
158  integer :: il1, il2
159 
160  ! Extract degree of B-splines
161  p1 = size(data_1d_eta1, 3) - 1
162  p2 = size(data_1d_eta2, 3) - 1
163 
164  associate(n1 => self%n1, n2 => self%n2)
165 
166  ! Cycle over basis functions in 2D test space
167  do il2 = 1, p2 + 1
168 
169  i2 = modulo(il2 - 2 + k2, n2) + 1
170 
171  do il1 = 1, p1 + 1
172 
173  i1 = il1 - 1 + k1
174 
175  call self%weak_form%element_rhs( &
176  test_values_and_derivs_eta1=data_1d_eta1(:, :, il1, k1), &
177  test_values_and_derivs_eta2=data_1d_eta2(:, :, il2, k2), &
178  data_2d_rhs=data_2d_rhs(:, :, k1, k2), &
179  int_volume=int_volume(:, :, k1, k2), &
180  bi=bi)
181 
182  bs(i1, i2) = bs(i1, i2) + bi
183 
184  end do
185  end do ! End cycle over basis functions in 2D test space
186 
187  end associate
188 
190 
subroutine s_qn_solver_2d_fem_sps_stencil_new_assembler__init(self, n1, n2, p1, p2, weak_form)
subroutine s_qn_solver_2d_fem_sps_stencil_new_assembler__add_element_rhs(self, k1, k2, data_1d_eta1, data_1d_eta2, data_2d_rhs, int_volume, bs)
subroutine s_qn_solver_2d_fem_sps_stencil_new_assembler__add_element_mat(self, k1, k2, data_1d_eta1, data_1d_eta2, int_volume, inv_metric, coeffs1, coeffs2, A, M)
Module to select the kind parameter.
integer, parameter, public f64
f64 is the kind type for 64-bit reals (double precision)
    Report Typos and Errors