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_conservative.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  sll_p_user_defined
30 
36 
37  implicit none
38 
39  public :: &
41 
42  private
43 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
44 
46  sll_int32 :: npts
47  sll_real64 :: eta_min
48  sll_real64 :: eta_max
49  sll_int32 :: bc_type
50  procedure(sll_i_signature_process_outside_point_1d), pointer, nopass :: &
51  process_outside_point
52 
53  contains
54  procedure, pass(charac) :: initialize => &
56  procedure, pass(charac) :: compute_characteristics => &
59 
60 contains
62  Npts, &
63  bc_type, &
64  eta_min, &
65  eta_max, &
66  process_outside_point) &
67  result(charac)
68 
69  type(explicit_euler_conservative_1d_charac_computer), 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  sll_int32 :: ierr
77 
78  sll_allocate(charac, ierr)
80  charac, &
81  npts, &
82  bc_type, &
83  eta_min, &
84  eta_max, &
85  process_outside_point)
86 
88 
90  charac, &
91  Npts, &
92  bc_type, &
93  eta_min, &
94  eta_max, &
95  process_outside_point)
96 
98  sll_int32, intent(in) :: npts
99  sll_int32, intent(in), optional :: bc_type
100  sll_real64, intent(in), optional :: eta_min
101  sll_real64, intent(in), optional :: eta_max
102  procedure(sll_i_signature_process_outside_point_1d), optional :: &
103  process_outside_point
104 
105  charac%Npts = npts
106 
107  if (present(eta_min)) then
108  charac%eta_min = eta_min
109  else
110  charac%eta_min = 0._f64
111  end if
112  if (present(eta_max)) then
113  charac%eta_max = eta_max
114  else
115  charac%eta_max = 1._f64
116  end if
117 
118  if (present(process_outside_point)) then
119  charac%process_outside_point => process_outside_point
120  charac%bc_type = sll_p_user_defined
121  else if (.not. (present(bc_type))) then
122  print *, '#provide boundary condition'
123  print *, '#bc_type or process_outside_point function'
124  print *, '#in initialize_charac_1d_explicit_euler'
125  stop
126  else
127  charac%bc_type = bc_type
128  select case (bc_type)
129  case (sll_p_periodic)
130  charac%process_outside_point => sll_f_process_outside_point_periodic
131  case (sll_p_set_to_limit)
132  charac%process_outside_point => sll_f_process_outside_point_set_to_limit
133  case default
134  print *, '#bad value of boundary condition'
135  print *, '#in initialize_charac_1d_explicit_euler'
136  stop
137  end select
138  end if
139 
140  if ((present(process_outside_point)) .and. (present(bc_type))) then
141  print *, '#provide either process_outside_point or bc_type'
142  print *, '#and not both'
143  print *, '#in initialize_explicit_euler_2d_charac'
144  stop
145  end if
146 
148 
150  charac, &
151  A, &
152  dt, &
153  input, &
154  output)
155 
157  sll_real64, dimension(:), intent(in) :: a
158  sll_real64, intent(in) :: dt
159  sll_real64, dimension(:), intent(in) :: input
160  sll_real64, dimension(:), intent(out) :: output
161  sll_int32 :: i
162  sll_int32 :: npts
163  sll_real64 :: eta_min
164  sll_real64 :: eta_max
165  sll_real64 :: output_min
166  sll_real64 :: output_max
167 
168  npts = charac%Npts
169  eta_min = charac%eta_min
170  eta_max = charac%eta_max
171 
172  sll_assert(size(a) >= charac%Npts - 1)
173  sll_assert(size(input) >= charac%Npts)
174  sll_assert(size(output) >= charac%Npts)
175 
176  do i = 1, npts - 1
177  output(i) = 0.5_f64*(input(i) + input(i + 1)) - dt*a(i)
178  end do
179  select case (charac%bc_type)
180  case (sll_p_periodic)
181  output_min = output(npts - 1) - (eta_max - eta_min)
182  output_max = output(1) + (eta_max - eta_min)
183  !print *,"output_min=",output_min
184  !print *,"output_max=",output_max
185  !stop
186  case (sll_p_set_to_limit)
187  output_min = 2._f64*eta_min - output(1)
188  output_max = 2._f64*eta_max - output(npts - 1)
189  case default
190  print *, '#bad value for charac%bc_type'
191  stop
192  end select
193 
194  output(npts) = 0.5_f64*(output(npts - 1) + output_max)
195 
196  do i = npts - 1, 2, -1
197  output(i) = 0.5_f64*(output(i) + output(i - 1))
198  end do
199  output(1) = 0.5_f64*(output(1) + output_min)
200 
201 !print *,eta_min,eta_max
202 !print *,output_min,output_max
203 !
204 !do i=1,Npts
205 ! print *,i, input(i),output(i)
206 !enddo
207 
208 ! do i=1,Npts
209 ! if((output(i)<=eta_min).or.(output(i)>=eta_max))then
210 ! output(i)=charac%process_outside_point(output(i),eta_min,eta_max)
211 ! endif
212 ! enddo
213 
215 
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 conservative scheme
subroutine initialize_explicit_euler_conservative_1d_charac(charac, Npts, bc_type, eta_min, eta_max, process_outside_point)
type(explicit_euler_conservative_1d_charac_computer) function, pointer, public sll_f_new_explicit_euler_conservative_1d_charac(Npts, bc_type, eta_min, eta_max, process_outside_point)
    Report Typos and Errors