Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_advection_2d_integer_oblic.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 
24 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 #include "sll_assert.h"
26 #include "sll_memory.h"
27 #include "sll_working_precision.h"
28 
29  use sll_m_advection_1d_base, only: &
31 
34 
35  use sll_m_interpolators_2d_base, only: &
37 
38  implicit none
39 
40  public :: &
44 
45  private
46 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 
49 
50  class(sll_c_advector_1d), pointer :: adv_x1
51  class(sll_c_advector_1d), pointer :: adv_aligned
52  class(sll_c_interpolator_2d), pointer :: interp
53  class(sll_c_characteristics_2d_base), pointer :: charac
54  sll_real64, dimension(:), pointer :: eta1_coords
55  sll_real64, dimension(:), pointer :: eta2_coords
56  sll_real64, dimension(:, :), pointer :: charac_feet1
57  sll_real64, dimension(:, :), pointer :: charac_feet2
58  sll_real64, dimension(:, :), pointer :: phi_at_aligned
59  sll_int32, dimension(:), pointer :: spaghetti_index
60  sll_real64, dimension(:), pointer :: phi_at_aligned_1d
61  sll_real64, dimension(:), pointer :: charac_feet_aligned_1d
62  sll_int32 :: spaghetti_size
63  sll_int32 :: npts1
64  sll_int32 :: npts2
65  sll_int32 :: shift
66 ! contains
67  ! procedure, pass(adv) :: initialize => &
68  ! initialize_integer_oblic_2d_advector
69  ! procedure, pass(adv) :: advect_2d => &
70  ! sll_s_integer_oblic_advect_2d
71 
73 
74 contains
76  adv_x1, &
77  adv_aligned, &
78  interp, &
79  charac, &
80  Npts1, &
81  Npts2, &
82  eta1_min, &
83  eta1_max, &
84  eta2_min, &
85  eta2_max, &
86  eta1_coords, &
87  eta2_coords) &
88  result(adv)
89  type(sll_t_integer_oblic_2d_advector), pointer :: adv
90  class(sll_c_advector_1d), pointer :: adv_x1
91  class(sll_c_advector_1d), pointer :: adv_aligned
92  class(sll_c_interpolator_2d), pointer :: interp
93  class(sll_c_characteristics_2d_base), pointer :: charac
94  sll_int32, intent(in) :: npts1
95  sll_int32, intent(in) :: npts2
96  sll_real64, intent(in), optional :: eta1_min
97  sll_real64, intent(in), optional :: eta1_max
98  sll_real64, intent(in), optional :: eta2_min
99  sll_real64, intent(in), optional :: eta2_max
100  sll_real64, dimension(:), pointer, optional :: eta1_coords
101  sll_real64, dimension(:), pointer, optional :: eta2_coords
102  sll_int32 :: ierr
103 
104  sll_allocate(adv, ierr)
105 
107  adv, &
108  adv_x1, &
109  adv_aligned, &
110  interp, &
111  charac, &
112  npts1, &
113  npts2, &
114  eta1_min, &
115  eta1_max, &
116  eta2_min, &
117  eta2_max, &
118  eta1_coords, &
119  eta2_coords)
120 
122 
124  adv, &
125  adv_x1, &
126  adv_aligned, &
127  interp, &
128  charac, &
129  Npts1, &
130  Npts2, &
131  eta1_min, &
132  eta1_max, &
133  eta2_min, &
134  eta2_max, &
135  eta1_coords, &
136  eta2_coords)
137  type(sll_t_integer_oblic_2d_advector), intent(inout) :: adv
138  class(sll_c_advector_1d), pointer :: adv_x1
139  class(sll_c_advector_1d), pointer :: adv_aligned
140  class(sll_c_interpolator_2d), pointer :: interp
141  class(sll_c_characteristics_2d_base), pointer :: charac
142  sll_int32, intent(in) :: npts1
143  sll_int32, intent(in) :: npts2
144  sll_real64, intent(in), optional :: eta1_min
145  sll_real64, intent(in), optional :: eta1_max
146  sll_real64, intent(in), optional :: eta2_min
147  sll_real64, intent(in), optional :: eta2_max
148  sll_real64, dimension(:), pointer, optional :: eta1_coords
149  sll_real64, dimension(:), pointer, optional :: eta2_coords
150  sll_int32 :: ierr
151  sll_int32 :: i
152  sll_real64 :: delta_eta1
153  sll_real64 :: delta_eta2
154 
155  adv%shift = 0
156  adv%Npts1 = npts1
157  adv%Npts2 = npts2
158  adv%adv_x1 => adv_x1
159  adv%adv_aligned => adv_aligned
160  adv%interp => interp
161  adv%charac => charac
162  !SLL_ALLOCATE(adv%x1_mesh(Npts1),ierr)
163  !SLL_ALLOCATE(adv%x2_mesh(Npts2),ierr)
164  sll_allocate(adv%eta1_coords(npts1), ierr)
165  sll_allocate(adv%eta2_coords(npts2), ierr)
166 
167  sll_allocate(adv%charac_feet1(npts1, npts2), ierr)
168  sll_allocate(adv%charac_feet2(npts1, npts2), ierr)
169 
170  sll_allocate(adv%phi_at_aligned(npts1, npts2), ierr)
171  sll_allocate(adv%spaghetti_index(npts1), ierr)
172  sll_allocate(adv%phi_at_aligned_1d(npts1*npts2), ierr)
173  sll_allocate(adv%charac_feet_aligned_1d(npts1*npts2), ierr)
174 
175  if (present(eta1_min) .and. present(eta1_max)) then
176  if (present(eta1_coords)) then
177  print *, '#provide either eta1_coords or eta1_min and eta1_max'
178  print *, '#and not both in subroutine initialize_BSL_2d_advector'
179  stop
180  else
181  delta_eta1 = (eta1_max - eta1_min)/real(npts1 - 1, f64)
182  do i = 1, npts1
183  adv%eta1_coords(i) = eta1_min + real(i - 1, f64)*delta_eta1
184  end do
185  end if
186  else if (present(eta1_coords)) then
187  if (size(eta1_coords, 1) < npts1) then
188  print *, '#bad size for eta1_coords in initialize_BSL_2d_advector'
189  stop
190  else
191  adv%eta1_coords(1:npts1) = eta1_coords(1:npts1)
192  end if
193  else
194  print *, '#Warning, we assume eta1_min = 0._f64 eta1_max = 1._f64'
195  delta_eta1 = 1._f64/real(npts1 - 1, f64)
196  do i = 1, npts1
197  adv%eta1_coords(i) = real(i - 1, f64)*delta_eta1
198  end do
199  end if
200 
201  if (present(eta2_min) .and. present(eta2_max)) then
202  if (present(eta2_coords)) then
203  print *, '#provide either eta2_coords or eta2_min and eta2_max'
204  print *, '#and not both in subroutine initialize_BSL_2d_advector'
205  stop
206  else
207  delta_eta2 = (eta2_max - eta2_min)/real(npts2 - 1, f64)
208  do i = 1, npts2
209  adv%eta2_coords(i) = eta2_min + real(i - 1, f64)*delta_eta2
210  end do
211  end if
212  else if (present(eta2_coords)) then
213  if (size(eta2_coords, 1) < npts2) then
214  print *, '#bad size for eta2_coords in initialize_BSL_2d_advector'
215  stop
216  else
217  adv%eta2_coords(1:npts2) = eta2_coords(1:npts2)
218  end if
219  else
220  print *, '#Warning, we assume eta2_min = 0._f64 eta2_max = 1._f64'
221  delta_eta2 = 1._f64/real(npts2 - 1, f64)
222  do i = 1, npts2
223  adv%eta2_coords(i) = real(i - 1, f64)*delta_eta2
224  end do
225  end if
226 
228 
229 ! subroutine set_shift(adv, shift)
230 ! type(sll_t_integer_oblic_2d_advector) :: adv
231 ! sll_int32, intent(in) :: shift
232 ! adv%shift = shift
233 ! end subroutine set_shift
234 !
235 !
236 ! function get_shift(adv) result(shift)
237 ! type(sll_t_integer_oblic_2d_advector) :: adv
238 ! sll_int32 :: shift
239 ! shift = adv%shift
240 ! end function get_shift
241 
243  adv, &
244  phi, &
245  shift, &
246  dt, &
247  input, &
248  output)
250  sll_real64, dimension(:, :), intent(in) :: phi
251  sll_int32, intent(in) :: shift
252  sll_real64, intent(in) :: dt
253  sll_real64, dimension(:, :), intent(in) :: input
254  sll_real64, dimension(:, :), intent(out) :: output
255  sll_int32 :: npts1
256  sll_int32 :: npts2
257  sll_real64 :: a
258  sll_int32 :: i
259  sll_real64 :: delta_x1
260  print *, '#not implemented for the moment'
261 
262  sll_assert(size(input, 1) > 0)
263  sll_assert(size(input, 2) > 0)
264  output = 0.0_f64 + dt - dt
265 
266  npts1 = adv%Npts1
267  npts2 = adv%Npts2
268  a = real(shift, f64)/real(npts2 - 1, f64)
269  delta_x1 = (adv%eta1_coords(npts1) - adv%eta1_coords(1))/real(npts1 - 1, f64)
270 
271  !first compute phi at aligned points
272  do i = 1, npts2
273  call adv%adv_x1%advect_1d_constant( &
274  a, &
275  real(i - 1, f64)*delta_x1, &
276  phi(1:npts1, i), &
277  adv%phi_at_aligned(1:npts1, i))
278  end do
279 
280 ! call compute_spaghetti( &
281 ! Npts1-1, &
282 ! Npts2-1, &
283 ! shift, &
284 ! adv%spaghetti_index, &
285 ! adv%spaghetti_size)
286 !
287 ! call load_spaghetti( &
288 ! adv%phi_at_aligned, &
289 ! adv%phi_at_aligned_1d, &
290 ! adv%spaghetti_index, &
291 ! Npts1, &
292 ! Npts2)
293 
294 ! do i=1,num_spaghetti
295 ! call adv%advect_1d_constant( &
296 ! tau, &
297 ! dt, &
298 ! buf1d_spaghetti(s:s+spaghetti_size), &
299 ! buf1d_spaghetto(1:spaghetti_size))
300 !
301 ! buf1d_spaghetti(s:s+spaghetti_size)=buf1d_spaghetto(1:spaghetti_size)
302 !
303 ! s = s+spaghetti_size
304 ! enddo
305 
306 ! call adv%charac%compute_characteristics( &
307 ! A1, &
308 ! A2, &
309 ! dt, &
310 ! adv%eta1_coords, &
311 ! adv%eta2_coords, &
312 ! adv%charac_feet1, &
313 ! adv%charac_feet2)
314 
315 ! call adv%interp%compute_interpolants( &
316 ! input, &
317 ! adv%eta1_coords, &
318 ! adv%Npts1, &
319 ! adv%eta2_coords, &
320 ! adv%Npts2 )
321 
322 ! output = adv%interp%interpolate_array( &
323 ! adv%Npts1, &
324 ! adv%Npts2, &
325 ! input, &
326 ! adv%charac_feet1, &
327 ! adv%charac_feet2)
328 
329  end subroutine sll_s_integer_oblic_advect_2d
330 
Abstract class for advection.
subroutine, public sll_s_integer_oblic_advect_2d(adv, phi, shift, dt, input, output)
type(sll_t_integer_oblic_2d_advector) function, pointer, public sll_f_new_integer_oblic_2d_advector(adv_x1, adv_aligned, interp, charac, Npts1, Npts2, eta1_min, eta1_max, eta2_min, eta2_max, eta1_coords, eta2_coords)
subroutine initialize_integer_oblic_2d_advector(adv, adv_x1, adv_aligned, interp, charac, Npts1, Npts2, eta1_min, eta1_max, eta2_min, eta2_max, eta1_coords, eta2_coords)
Abstract class to compute the characteristic in two dimensions.
abstract data type for 2d interpolation
Base class/basic interface for 2D interpolators.
    Report Typos and Errors