Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_advection_2d_bsl.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 
18 ! in development; should be at least cubic splines
19 ! attached with computation of characteristics
20 
23 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #include "sll_memory.h"
25 #include "sll_working_precision.h"
26 #include "sll_errors.h"
27 
31 
32  implicit none
33 
34  public :: sll_f_new_advector_2d_bsl, &
37 
38  private
39 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40 
42 
43  class(sll_c_interpolator_2d), pointer :: interp
44  class(sll_c_characteristics_2d_base), pointer :: charac
45  sll_real64, dimension(:), pointer :: eta1_coords
46  sll_real64, dimension(:), pointer :: eta2_coords
47  sll_real64, dimension(:, :), pointer :: charac_feet1
48  sll_real64, dimension(:, :), pointer :: charac_feet2
49  sll_int32 :: npts1
50  sll_int32 :: npts2
51 
52  contains
53 
54  procedure, pass(adv) :: init => sll_s_advector_2d_bsl_init
55  procedure, pass(adv) :: advect_2d => bsl_advect_2d
56 
57  end type sll_t_advector_2d_bsl
58 
59 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60 contains
61 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
62 
63  function sll_f_new_advector_2d_bsl(interp, charac, npts1, npts2, &
64  eta1_min, eta1_max, eta2_min, eta2_max, eta1_coords, eta2_coords) &
65  result(adv)
66 
67  type(sll_t_advector_2d_bsl), pointer :: adv
68  class(sll_c_interpolator_2d), pointer :: interp
69  class(sll_c_characteristics_2d_base), pointer :: charac
70  sll_int32, intent(in) :: npts1
71  sll_int32, intent(in) :: npts2
72  sll_real64, intent(in), optional :: eta1_min
73  sll_real64, intent(in), optional :: eta1_max
74  sll_real64, intent(in), optional :: eta2_min
75  sll_real64, intent(in), optional :: eta2_max
76  sll_real64, dimension(:), pointer, optional :: eta1_coords
77  sll_real64, dimension(:), pointer, optional :: eta2_coords
78  sll_int32 :: ierr
79 
80  sll_allocate(adv, ierr)
81 
82  call adv%init(interp, charac, npts1, npts2, eta1_min, eta1_max, &
83  eta2_min, eta2_max, eta1_coords, eta2_coords)
84 
85  end function sll_f_new_advector_2d_bsl
86 
87  subroutine sll_s_advector_2d_bsl_init(adv, interp, charac, npts1, npts2, &
88  eta1_min, eta1_max, eta2_min, eta2_max, eta1_coords, eta2_coords)
89 
90  class(sll_t_advector_2d_bsl) :: adv
91  class(sll_c_interpolator_2d), target :: interp
92  class(sll_c_characteristics_2d_base), target :: charac
93  sll_int32, intent(in) :: npts1
94  sll_int32, intent(in) :: npts2
95  sll_real64, intent(in), optional :: eta1_min
96  sll_real64, intent(in), optional :: eta1_max
97  sll_real64, intent(in), optional :: eta2_min
98  sll_real64, intent(in), optional :: eta2_max
99  sll_real64, dimension(:), pointer, optional :: eta1_coords
100  sll_real64, dimension(:), pointer, optional :: eta2_coords
101  sll_int32 :: ierr
102  sll_int32 :: i
103  sll_real64 :: delta_eta1
104  sll_real64 :: delta_eta2
105 
106  adv%npts1 = npts1
107  adv%npts2 = npts2
108  adv%interp => interp
109  adv%charac => charac
110 
111  sll_allocate(adv%eta1_coords(npts1), ierr)
112  sll_allocate(adv%eta2_coords(npts2), ierr)
113 
114  sll_allocate(adv%charac_feet1(npts1, npts2), ierr)
115  sll_allocate(adv%charac_feet2(npts1, npts2), ierr)
116 
117  if (present(eta1_min) .and. present(eta1_max)) then
118  if (present(eta1_coords)) then
119  sll_error("initialize_advector_2d_bsl", "provide either eta1_coords or eta1_min and eta1_max and not both")
120  else
121  delta_eta1 = (eta1_max - eta1_min)/real(npts1 - 1, f64)
122  do i = 1, npts1
123  adv%eta1_coords(i) = eta1_min + real(i - 1, f64)*delta_eta1
124  end do
125  end if
126  else if (present(eta1_coords)) then
127  if (size(eta1_coords, 1) < npts1) then
128  sll_error("initialize_advector_2d_bsl", "bad size for eta1_coords")
129  else
130  adv%eta1_coords(1:npts1) = eta1_coords(1:npts1)
131  end if
132  else
133  print *, '#Warning, we assume eta1_min = 0._f64 eta1_max = 1._f64'
134  delta_eta1 = 1._f64/real(npts1 - 1, f64)
135  do i = 1, npts1
136  adv%eta1_coords(i) = real(i - 1, f64)*delta_eta1
137  end do
138  end if
139 
140  if (present(eta2_min) .and. present(eta2_max)) then
141  if (present(eta2_coords)) then
142  sll_error("initialize_advector_2d_bsl", "provide either eta2_coords or eta2_min and eta2_max and not both")
143  else
144  delta_eta2 = (eta2_max - eta2_min)/real(npts2 - 1, f64)
145  do i = 1, npts2
146  adv%eta2_coords(i) = eta2_min + real(i - 1, f64)*delta_eta2
147  end do
148  end if
149  else if (present(eta2_coords)) then
150  if (size(eta2_coords, 1) < npts2) then
151  sll_error("initialize_advector_2d_bsl", "bad size for eta2_coords")
152  else
153  adv%eta2_coords(1:npts2) = eta2_coords(1:npts2)
154  end if
155  else
156  print *, '#Warning, we assume eta2_min = 0._f64 eta2_max = 1._f64'
157  delta_eta2 = 1._f64/real(npts2 - 1, f64)
158  do i = 1, npts2
159  adv%eta2_coords(i) = real(i - 1, f64)*delta_eta2
160  end do
161  end if
162 
163  end subroutine sll_s_advector_2d_bsl_init
164 
165  subroutine bsl_advect_2d(adv, a1, a2, dt, input, output)
166 
167  class(sll_t_advector_2d_bsl) :: adv
168  sll_real64, dimension(:, :), intent(in) :: a1
169  sll_real64, dimension(:, :), intent(in) :: a2
170  sll_real64, intent(in) :: dt
171  sll_real64, dimension(:, :), intent(in) :: input
172  sll_real64, dimension(:, :), intent(out) :: output
173 
174  call adv%charac%compute_characteristics( &
175  a1, &
176  a2, &
177  dt, &
178  adv%eta1_coords, &
179  adv%eta2_coords, &
180  adv%charac_feet1, &
181  adv%charac_feet2)
182 
183  !call adv%interp%compute_interpolants( &
184  ! input, &
185  ! adv%eta1_coords, &
186  ! adv%npts1, &
187  ! adv%eta2_coords, &
188  ! adv%npts2 )
189 
190  call adv%interp%interpolate_array( &
191  adv%npts1, &
192  adv%npts2, &
193  input, &
194  adv%charac_feet1, &
195  adv%charac_feet2, &
196  output)
197 
198  end subroutine bsl_advect_2d
199 
200 end module sll_m_advection_2d_bsl
subroutine bsl_advect_2d(adv, a1, a2, dt, input, output)
subroutine, public sll_s_advector_2d_bsl_init(adv, interp, charac, npts1, npts2, eta1_min, eta1_max, eta2_min, eta2_max, eta1_coords, eta2_coords)
type(sll_t_advector_2d_bsl) function, pointer, public sll_f_new_advector_2d_bsl(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