Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_characteristics_2d_explicit_euler.F90
Go to the documentation of this file.
1 !**************************************************************
2 ! Copyright INRIA
3 ! Authors :
4 ! CALVI project team
5 !
6 ! This code SeLaLib (for Semi-Lagrangian-Library)
7 ! is a parallel library for simulating the plasma turbulence
8 ! in a tokamak.
9 !
10 ! This software is governed by the CeCILL-B license
11 ! under French law and abiding by the rules of distribution
12 ! of free software. You can use, modify and redistribute
13 ! the software under the terms of the CeCILL-B license as
14 ! circulated by CEA, CNRS and INRIA at the following URL
15 ! "http://www.cecill.info".
16 !**************************************************************
17 
21 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "sll_assert.h"
23 #include "sll_memory.h"
24 #include "sll_working_precision.h"
25 
27  sll_p_periodic, &
28  sll_p_set_to_limit
29 
35 
36  implicit none
37 
38  public :: &
41 
42  private
43 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
44 
46  sll_int32 :: npts1
47  sll_int32 :: npts2
48  sll_real64 :: eta1_min
49  sll_real64 :: eta1_max
50  sll_real64 :: eta2_min
51  sll_real64 :: eta2_max
52  procedure(sll_i_signature_process_outside_point), pointer, nopass :: &
53  process_outside_point1
54  procedure(sll_i_signature_process_outside_point), pointer, nopass :: &
55  process_outside_point2
56 
57  contains
58  procedure, pass(charac) :: init => initialize_explicit_euler_2d_charac
59  procedure, pass(charac) :: compute_characteristics => &
62 
63 contains
65  Npts1, &
66  Npts2, &
67  bc_type_1, &
68  bc_type_2, &
69  eta1_min, &
70  eta1_max, &
71  eta2_min, &
72  eta2_max, &
73  process_outside_point1, &
74  process_outside_point2) &
75  result(charac)
76 
77  type(sll_t_charac_2d_explicit_euler), pointer :: charac
78  sll_int32, intent(in) :: npts1
79  sll_int32, intent(in) :: npts2
80  sll_int32, intent(in), optional :: bc_type_1
81  sll_int32, intent(in), optional :: bc_type_2
82  sll_real64, intent(in), optional :: eta1_min
83  sll_real64, intent(in), optional :: eta1_max
84  sll_real64, intent(in), optional :: eta2_min
85  sll_real64, intent(in), optional :: eta2_max
86  procedure(sll_i_signature_process_outside_point), optional :: &
87  process_outside_point1
88  procedure(sll_i_signature_process_outside_point), optional :: &
89  process_outside_point2
90  sll_int32 :: ierr
91 
92  sll_allocate(charac, ierr)
94  charac, &
95  npts1, &
96  npts2, &
97  bc_type_1, &
98  bc_type_2, &
99  eta1_min, &
100  eta1_max, &
101  eta2_min, &
102  eta2_max, &
103  process_outside_point1, &
104  process_outside_point2)
105 
107 
109  charac, &
110  Npts1, &
111  Npts2, &
112  bc_type_1, &
113  bc_type_2, &
114  eta1_min, &
115  eta1_max, &
116  eta2_min, &
117  eta2_max, &
118  process_outside_point1, &
119  process_outside_point2)
120 
121  class(sll_t_charac_2d_explicit_euler) :: charac
122  sll_int32, intent(in) :: npts1
123  sll_int32, intent(in) :: npts2
124  sll_int32, intent(in), optional :: bc_type_1
125  sll_int32, intent(in), optional :: bc_type_2
126  sll_real64, intent(in), optional :: eta1_min
127  sll_real64, intent(in), optional :: eta1_max
128  sll_real64, intent(in), optional :: eta2_min
129  sll_real64, intent(in), optional :: eta2_max
130  procedure(sll_i_signature_process_outside_point), optional :: &
131  process_outside_point1
132  procedure(sll_i_signature_process_outside_point), optional :: &
133  process_outside_point2
134 
135  charac%Npts1 = npts1
136  charac%Npts2 = npts2
137 
138  if (present(eta1_min)) then
139  charac%eta1_min = eta1_min
140  else
141  charac%eta1_min = 0._f64
142  end if
143  if (present(eta1_max)) then
144  charac%eta1_max = eta1_max
145  else
146  charac%eta1_max = 1._f64
147  end if
148  if (present(eta2_min)) then
149  charac%eta2_min = eta2_min
150  else
151  charac%eta2_min = 0._f64
152  end if
153 
154  if (present(eta2_max)) then
155  charac%eta2_max = eta2_max
156  else
157  charac%eta2_max = 1._f64
158  end if
159 
160  !charac%process_outside_point1 => process_outside_point1
161  !charac%process_outside_point2 => process_outside_point2
162 
163  if (present(process_outside_point1)) then
164  charac%process_outside_point1 => process_outside_point1
165  else if (.not. (present(bc_type_1))) then
166  print *, '#provide boundary condition'
167  print *, '#bc_type_1 or process_outside_point1 function'
168  print *, '#in initialize_explicit_euler_2d_charac'
169  stop
170  else
171  select case (bc_type_1)
172  case (sll_p_periodic)
173  charac%process_outside_point1 => sll_f_process_outside_point_periodic
174  case (sll_p_set_to_limit)
175  charac%process_outside_point1 => sll_f_process_outside_point_set_to_limit
176  case default
177  print *, '#bad value of boundary condition'
178  print *, '#in initialize_sll_t_characteristics_2d_explicit_euler_2d'
179  stop
180  end select
181  end if
182 
183  if ((present(process_outside_point1)) .and. (present(bc_type_1))) then
184  print *, '#provide either process_outside_point1 or bc_type_1'
185  print *, '#and not both'
186  print *, '#in initialize_sll_t_characteristics_2d_explicit_euler_2d'
187  stop
188  end if
189 
190  if (present(process_outside_point2)) then
191  charac%process_outside_point2 => process_outside_point2
192  else if (.not. (present(bc_type_2))) then
193  print *, '#provide boundary condition'
194  print *, '#bc_type_2 or process_outside_point1 function'
195  stop
196  else
197  select case (bc_type_2)
198  case (sll_p_periodic)
199  charac%process_outside_point2 => sll_f_process_outside_point_periodic
200  case (sll_p_set_to_limit)
201  charac%process_outside_point2 => sll_f_process_outside_point_set_to_limit
202  case default
203  print *, '#bad value of boundary condition'
204  print *, '#in initialize_sll_t_characteristics_2d_explicit_euler_2d'
205  stop
206  end select
207  end if
208 
209  if ((present(process_outside_point2)) .and. (present(bc_type_2))) then
210  print *, '#provide either process_outside_point2 or bc_type_2'
211  print *, '#and not both'
212  print *, '#in initialize_sll_t_characteristics_2d_explicit_euler_2d'
213  stop
214  end if
215 
217 
219  charac, &
220  A1, &
221  A2, &
222  dt, &
223  input1, &
224  input2, &
225  output1, &
226  output2)
227 
228  class(sll_t_charac_2d_explicit_euler) :: charac
229  sll_real64, dimension(:, :), intent(in) :: a1
230  sll_real64, dimension(:, :), intent(in) :: a2
231  sll_real64, intent(in) :: dt
232  sll_real64, dimension(:), intent(in) :: input1
233  sll_real64, dimension(:), intent(in) :: input2
234  sll_real64, dimension(:, :), intent(out) :: output1
235  sll_real64, dimension(:, :), intent(out) :: output2
236  sll_int32 :: i
237  sll_int32 :: j
238  sll_int32 :: npts1
239  sll_int32 :: npts2
240  sll_real64 :: eta1_min
241  sll_real64 :: eta1_max
242  sll_real64 :: eta2_min
243  sll_real64 :: eta2_max
244 
245  npts1 = charac%Npts1
246  npts2 = charac%Npts2
247  eta1_min = charac%eta1_min
248  eta1_max = charac%eta1_max
249  eta2_min = charac%eta2_min
250  eta2_max = charac%eta2_max
251 
252  sll_assert(size(a1, 1) >= charac%Npts1)
253  sll_assert(size(a1, 2) >= charac%Npts2)
254  sll_assert(size(a2, 1) >= charac%Npts1)
255  sll_assert(size(a2, 2) >= charac%Npts2)
256  sll_assert(size(input1) >= charac%Npts1)
257  sll_assert(size(input2) >= charac%Npts2)
258  sll_assert(size(output1, 1) >= charac%Npts1)
259  sll_assert(size(output1, 2) >= charac%Npts2)
260  sll_assert(size(output2, 1) >= charac%Npts1)
261  sll_assert(size(output2, 2) >= charac%Npts2)
262 
263  do j = 1, npts2
264  do i = 1, npts1
265  output1(i, j) = input1(i) - dt*a1(i, j)
266  if ((output1(i, j) <= eta1_min) .or. (output1(i, j) >= eta1_max)) then
267  output1(i, j) = charac%process_outside_point1(output1(i, j), eta1_min, eta1_max)
268  end if
269  output2(i, j) = input2(j) - dt*a2(i, j)
270  if ((output2(i, j) <= eta2_min) .or. (output2(i, j) >= eta2_max)) then
271  output2(i, j) = charac%process_outside_point2(output2(i, j), eta2_min, eta2_max)
272  end if
273  end do
274  end do
275 
276  end subroutine compute_explicit_euler_2d_charac
277 
Abstract class to compute the characteristic in two dimensions.
real(kind=f64) function, public sll_f_process_outside_point_periodic(eta, eta_min, eta_max)
real(kind=f64) function, public sll_f_process_outside_point_set_to_limit(eta, eta_min, eta_max)
computes the characteristic with explicit euler scheme
type(sll_t_charac_2d_explicit_euler) function, pointer, public sll_f_new_explicit_euler_2d_charac(Npts1, Npts2, bc_type_1, bc_type_2, eta1_min, eta1_max, eta2_min, eta2_max, process_outside_point1, process_outside_point2)
subroutine initialize_explicit_euler_2d_charac(charac, Npts1, Npts2, bc_type_1, bc_type_2, eta1_min, eta1_max, eta2_min, eta2_max, process_outside_point1, process_outside_point2)
subroutine compute_explicit_euler_2d_charac(charac, A1, A2, dt, input1, input2, output1, output2)
    Report Typos and Errors