Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_characteristics_1d_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 :: npts
47  sll_real64 :: eta_min
48  sll_real64 :: eta_max
49  procedure(sll_i_signature_process_outside_point_1d), pointer, nopass :: &
50  process_outside_point
51  logical :: feet_inside
52 
53  contains
54  procedure, pass(charac) :: init => initialize_charac_1d_explicit_euler
55  procedure, pass(charac) :: compute_characteristics => &
58 
59 contains
61  Npts, &
62  bc_type, &
63  eta_min, &
64  eta_max, &
65  process_outside_point, &
66  feet_inside) &
67  result(charac)
68 
69  type(sll_t_charac_1d_explicit_euler), pointer :: charac
70  sll_int32, intent(in) :: npts
71  sll_int32, intent(in), optional :: bc_type
72  sll_real64, intent(in), optional :: eta_min
73  sll_real64, intent(in), optional :: eta_max
74  procedure(sll_i_signature_process_outside_point_1d), optional :: &
75  process_outside_point
76  logical, optional :: feet_inside
77  sll_int32 :: ierr
78 
79  sll_allocate(charac, ierr)
81  charac, &
82  npts, &
83  bc_type, &
84  eta_min, &
85  eta_max, &
86  process_outside_point, &
87  feet_inside)
88 
90 
92  charac, &
93  Npts, &
94  bc_type, &
95  eta_min, &
96  eta_max, &
97  process_outside_point, &
98  feet_inside)
99 
100  class(sll_t_charac_1d_explicit_euler) :: charac
101  sll_int32, intent(in) :: npts
102  sll_int32, intent(in), optional :: bc_type
103  sll_real64, intent(in), optional :: eta_min
104  sll_real64, intent(in), optional :: eta_max
105  procedure(sll_i_signature_process_outside_point_1d), optional :: &
106  process_outside_point
107  logical, optional :: feet_inside
108 
109  charac%Npts = npts
110 
111  if (present(eta_min)) then
112  charac%eta_min = eta_min
113  else
114  charac%eta_min = 0._f64
115  end if
116  if (present(eta_max)) then
117  charac%eta_max = eta_max
118  else
119  charac%eta_max = 1._f64
120  end if
121 
122  if (present(process_outside_point)) then
123  charac%process_outside_point => process_outside_point
124  else if (.not. (present(bc_type))) then
125  print *, '#provide boundary condition'
126  print *, '#bc_type or process_outside_point function'
127  print *, '#in initialize_charac_1d_explicit_euler'
128  stop
129  else
130  select case (bc_type)
131  case (sll_p_periodic)
132  charac%process_outside_point => sll_f_process_outside_point_periodic
133  case (sll_p_set_to_limit)
134  charac%process_outside_point => sll_f_process_outside_point_set_to_limit
135  case default
136  print *, '#bad value of boundary condition'
137  print *, '#in initialize_charac_1d_explicit_euler'
138  stop
139  end select
140  end if
141 
142  if ((present(process_outside_point)) .and. (present(bc_type))) then
143  print *, '#provide either process_outside_point or bc_type'
144  print *, '#and not both'
145  print *, '#in initialize_explicit_euler_2d_charac'
146  stop
147  end if
148 
149  if (present(feet_inside)) then
150  charac%feet_inside = feet_inside
151  else
152  charac%feet_inside = .true.
153  end if
154 
156 
158  charac, &
159  A, &
160  dt, &
161  input, &
162  output)
163 
164  class(sll_t_charac_1d_explicit_euler) :: charac
165  sll_real64, dimension(:), intent(in) :: a
166  sll_real64, intent(in) :: dt
167  sll_real64, dimension(:), intent(in) :: input
168  sll_real64, dimension(:), intent(out) :: output
169  sll_int32 :: i
170  sll_int32 :: npts
171  sll_real64 :: eta_min
172  sll_real64 :: eta_max
173 
174  npts = charac%Npts
175  eta_min = charac%eta_min
176  eta_max = charac%eta_max
177 
178  sll_assert(size(a) >= charac%Npts)
179  sll_assert(size(input) >= charac%Npts)
180  sll_assert(size(output) >= charac%Npts)
181 
182  do i = 1, npts
183  output(i) = input(i) - dt*a(i)
184  if (((output(i) <= eta_min) .or. (output(i) >= eta_max)) .and. (charac%feet_inside)) then
185  output(i) = charac%process_outside_point(output(i), eta_min, eta_max)
186  end if
187  end do
188 
189  end subroutine compute_charac_1d_explicit_euler
190 
Abstract class for characteristic derived type.
function, public sll_f_process_outside_point_set_to_limit(eta, eta_min, eta_max)
function, public sll_f_process_outside_point_periodic(eta, eta_min, eta_max)
computes the characteristic with explicit euler scheme
subroutine initialize_charac_1d_explicit_euler(charac, Npts, bc_type, eta_min, eta_max, process_outside_point, feet_inside)
type(sll_t_charac_1d_explicit_euler) function, pointer, public sll_f_new_charac_1d_explicit_euler(Npts, bc_type, eta_min, eta_max, process_outside_point, feet_inside)
subroutine compute_charac_1d_explicit_euler(charac, A, dt, input, output)
    Report Typos and Errors