Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_poisson_2d_fem_sps_dense_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 
23  class(sll_t_poisson_2d_fem_sps_weak_form), pointer :: weak_form
24 
25  contains
26 
30 
32 
33 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34 contains
35 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
36 
37  ! Initializer
38  subroutine s_poisson_2d_fem_sps_dense_assembler__init(self, n1, n2, weak_form)
39  class(sll_t_poisson_2d_fem_sps_dense_assembler), intent(inout) :: self
40  integer, intent(in) :: n1
41  integer, intent(in) :: n2
42  class(sll_t_poisson_2d_fem_sps_weak_form), target, intent(in) :: weak_form
43 
44  self%n1 = n1
45  self%n2 = n2
46 
47  self%weak_form => weak_form
48 
49  end subroutine
50 
51  ! Add element in stiffness and mass matrices
53  self, &
54  k1, &
55  k2, &
56  data_1d_eta1, &
57  data_1d_eta2, &
58  int_volume, &
59  inv_metric, &
60  A, &
61  M)
62  class(sll_t_poisson_2d_fem_sps_dense_assembler), intent(in) :: self
63  integer, intent(in) :: k1
64  integer, intent(in) :: k2
65  real(wp), intent(in) :: data_1d_eta1(:, :, :, :)
66  real(wp), intent(in) :: data_1d_eta2(:, :, :, :)
67  real(wp), intent(in) :: int_volume(:, :, :, :)
68  real(wp), intent(in) :: inv_metric(:, :, :, :, :, :)
69  real(wp), intent(inout) :: A(:, :)
70  real(wp), intent(inout) :: M(:, :)
71 
72  integer :: i, j, i1, i2, j1, j2, p1, p2
73  real(wp) :: Aij, Mij
74  integer :: il1, il2, jl1, jl2
75 
76  ! Extract degree of B-splines
77  p1 = size(data_1d_eta1, 3) - 1
78  p2 = size(data_1d_eta2, 3) - 1
79 
80  associate(n1 => self%n1, n2 => self%n2)
81 
82  ! Cycle over basis functions in 2D trial space (same as test space)
83  do jl2 = 1, p2 + 1
84 
85  j2 = modulo(k2 + jl2 - 2, n2)
86 
87  do jl1 = 1, p1 + 1
88 
89  j1 = k1 + jl1 - 2
90 
91  ! Second matrix global index
92  j = j1*n2 + j2 + 1
93 
94  ! Cycle over basis functions in 2D test space
95  do il2 = 1, p2 + 1
96 
97  i2 = modulo(k2 + il2 - 2, n2)
98 
99  do il1 = 1, p1 + 1
100 
101  i1 = k1 + il1 - 2
102 
103  ! First matrix global index
104  i = i1*n2 + i2 + 1
105 
106  call self%weak_form%element_mat( &
107  test_values_and_derivs_eta1=data_1d_eta1(:, :, il1, k1), &
108  test_values_and_derivs_eta2=data_1d_eta2(:, :, il2, k2), &
109  trial_values_and_derivs_eta1=data_1d_eta1(:, :, jl1, k1), &
110  trial_values_and_derivs_eta2=data_1d_eta2(:, :, jl2, k2), &
111  int_volume=int_volume(:, :, k1, k2), &
112  inv_metric=inv_metric(:, :, k1, k2, :, :), &
113  aij=aij, &
114  mij=mij)
115 
116  a(i, j) = a(i, j) + aij
117  m(i, j) = m(i, j) + mij
118 
119  end do
120  end do ! End cycle over basis functions in 2D test space
121 
122  end do
123  end do ! End cycle over basis functions in 2D trial space
124 
125  end associate
126 
128 
129  ! Add element in stiffness and mass matrices
131  self, &
132  k1, &
133  k2, &
134  data_1d_eta1, &
135  data_1d_eta2, &
136  data_2d_rhs, &
137  int_volume, &
138  b)
139  class(sll_t_poisson_2d_fem_sps_dense_assembler), intent(in) :: self
140  integer, intent(in) :: k1
141  integer, intent(in) :: k2
142  real(wp), intent(in) :: data_1d_eta1(:, :, :, :)
143  real(wp), intent(in) :: data_1d_eta2(:, :, :, :)
144  real(wp), intent(in) :: data_2d_rhs(:, :, :, :)
145  real(wp), intent(in) :: int_volume(:, :, :, :)
146  real(wp), intent(inout) :: b(:)
147 
148  integer :: i, i1, i2, p1, p2
149  real(wp) :: bi
150  integer :: il1, il2
151 
152  ! Extract degree of B-splines
153  p1 = size(data_1d_eta1, 3) - 1
154  p2 = size(data_1d_eta2, 3) - 1
155 
156  associate(n1 => self%n1, n2 => self%n2)
157 
158  ! Cycle over basis functions in 2D test space
159  do il2 = 1, p2 + 1
160 
161  i2 = modulo(k2 + il2 - 2, n2)
162 
163  do il1 = 1, p1 + 1
164 
165  i1 = k1 + il1 - 2
166 
167  ! Vector global index
168  i = i1*n2 + i2 + 1
169 
170  call self%weak_form%element_rhs( &
171  test_values_and_derivs_eta1=data_1d_eta1(:, :, il1, k1), &
172  test_values_and_derivs_eta2=data_1d_eta2(:, :, il2, k2), &
173  data_2d_rhs=data_2d_rhs(:, :, k1, k2), &
174  int_volume=int_volume(:, :, k1, k2), &
175  bi=bi)
176 
177  b(i) = b(i) + bi
178 
179  end do
180  end do ! End cycle over basis functions in 2D test space
181 
182  end associate
183 
185 
subroutine s_poisson_2d_fem_sps_dense_assembler__add_element_mat(self, k1, k2, data_1d_eta1, data_1d_eta2, int_volume, inv_metric, A, M)
subroutine s_poisson_2d_fem_sps_dense_assembler__init(self, n1, n2, weak_form)
subroutine s_poisson_2d_fem_sps_dense_assembler__add_element_rhs(self, k1, k2, data_1d_eta1, data_1d_eta2, data_2d_rhs, int_volume, b)
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