24 #include "sll_assert.h" 
   25 #include "sll_memory.h" 
   26 #include "sll_working_precision.h" 
   62       procedure, pass(charac) :: init => &
 
   64       procedure, pass(charac) :: compute_characteristics => &
 
   75       process_outside_point, &
 
   81       sll_int32, 
intent(in) :: npts
 
   82       sll_int32, 
intent(in), 
optional :: bc_type
 
   83       sll_real64, 
intent(in), 
optional  :: eta_min
 
   84       sll_real64, 
intent(in), 
optional  :: eta_max
 
   88       sll_int32, 
intent(in), 
optional :: maxiter
 
   89       sll_real64, 
intent(in), 
optional :: tol
 
   92       sll_allocate(charac, ierr)
 
  100          process_outside_point, &
 
  112       process_outside_point, &
 
  117       sll_int32, 
intent(in) :: npts
 
  118       sll_int32, 
intent(in), 
optional :: bc_type
 
  119       sll_real64, 
intent(in), 
optional  :: eta_min
 
  120       sll_real64, 
intent(in), 
optional  :: eta_max
 
  122          process_outside_point
 
  124       sll_int32, 
intent(in), 
optional :: maxiter
 
  125       sll_real64, 
intent(in), 
optional :: tol
 
  129       if (
present(eta_min)) 
then 
  130          charac%eta_min = eta_min
 
  132          charac%eta_min = 0._f64
 
  134       if (
present(eta_max)) 
then 
  135          charac%eta_max = eta_max
 
  137          charac%eta_max = 1._f64
 
  140       if (
present(process_outside_point)) 
then 
  141          charac%process_outside_point => process_outside_point
 
  142          charac%bc_type = sll_p_user_defined
 
  143       else if (.not. (
present(bc_type))) 
then 
  144          print *, 
'#provide boundary condition' 
  145          print *, 
'#bc_type or process_outside_point function' 
  146          print *, 
'#in initialize_trapezoid_conservative_1d_charac' 
  149          charac%bc_type = bc_type
 
  150          select case (bc_type)
 
  151          case (sll_p_periodic)
 
  153          case (sll_p_set_to_limit)
 
  156             print *, 
'#bad value of boundary condition' 
  157             print *, 
'#in initialize_trapezoid_conservative_1d_charac' 
  162       if ((
present(process_outside_point)) .and. (
present(bc_type))) 
then 
  163          print *, 
'#provide either process_outside_point or bc_type' 
  164          print *, 
'#and not both' 
  165          print *, 
'#in initialize_trapezoid_conservative_1d_charac' 
  169       charac%A_interp => a_interp
 
  171       if (
present(maxiter)) 
then 
  172          charac%maxiter = maxiter
 
  174          charac%maxiter = 1000
 
  177       if (
present(tol)) 
then 
  180          charac%tol = 1.e-12_f64
 
  193       sll_real64, 
dimension(:), 
intent(in) :: a
 
  194       sll_real64, 
intent(in) :: dt
 
  195       sll_real64, 
dimension(:), 
intent(in) ::  input
 
  196       sll_real64, 
dimension(:), 
intent(out) :: output
 
  204       sll_real64 :: eta_min
 
  205       sll_real64 :: eta_max
 
  206       sll_real64 :: output_min
 
  207       sll_real64 :: output_max
 
  210       eta_min = charac%eta_min
 
  211       eta_max = charac%eta_max
 
  213       sll_assert(
size(a) >= npts)
 
  214       sll_assert(
size(input) >= npts)
 
  215       sll_assert(
size(output) >= npts)
 
  222       call charac%A_interp%compute_interpolants(a)
 
  232          x2 = 0.5_f64*(input(j) + input(j + 1)) - dt*a(j)
 
  235          do while (iter < charac%maxiter .and. abs(x2_old - x2) > charac%tol)
 
  238             if ((x2 <= eta_min) .or. (x2 >= eta_max)) 
then 
  239                x2_i = charac%process_outside_point(x2, eta_min, eta_max)
 
  243             x2 = 0.5_f64*(input(j) + input(j + 1)) &
 
  244                  - 0.5_f64*dt*(charac%A_interp%interpolate_from_interpolant_value(x2_i) + a(j))
 
  246          if (iter == charac%maxiter .and. abs(x2_old - x2) > charac%tol) 
then 
  247             print *, 
'#not enough iterations for compute_trapezoid_conservative_1d_charac', &
 
  248                iter, abs(x2_old - x2)
 
  257       select case (charac%bc_type)
 
  258       case (sll_p_periodic)
 
  259          output_min = output(npts - 1) - (eta_max - eta_min)
 
  260          output_max = output(1) + (eta_max - eta_min)
 
  261       case (sll_p_set_to_limit)
 
  262          output_min = 2._f64*eta_min - output(1)
 
  263          output_max = 2._f64*eta_max - output(npts - 1)
 
  265          print *, 
'#bad value for charac%bc_type' 
  269       output(npts) = 0.5_f64*(output(npts - 1) + output_max)
 
  271       do i = npts - 1, 2, -1
 
  272          output(i) = 0.5_f64*(output(i) + output(i - 1))
 
  274       output(1) = 0.5_f64*(output(1) + output_min)
 
Describe different boundary conditions.
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)
conservative version of trapezoid
subroutine initialize_trapezoid_conservative_1d_charac(charac, Npts, A_interp, bc_type, eta_min, eta_max, process_outside_point, maxiter, tol)
type(sll_t_trapezoid_conservative_1d_charac) function, pointer, public sll_f_new_trapezoid_conservative_1d_charac(Npts, A_interp, bc_type, eta_min, eta_max, process_outside_point, maxiter, tol)
subroutine compute_trapezoid_conservative_1d_charac(charac, A, dt, input, output)
Module for 1D interpolation and reconstruction.
Abstract class for 1D interpolation and reconstruction.