Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_split_advection_2d.F90
Go to the documentation of this file.
1 
4 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 #include "sll_errors.h"
6 #include "sll_memory.h"
7 #include "sll_working_precision.h"
8 
10  sll_p_periodic
11 
12  use sll_m_cartesian_meshes, only: &
14 
18 
21 
25 
26  use sll_m_interpolators_1d_base, only: &
28 
29  use sll_m_operator_splitting, only: &
32 
33  implicit none
34 
35  public :: &
40 
41  private
42 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 
44  sll_int32, parameter :: sll_p_advective = 0
45  sll_int32, parameter :: sll_p_conservative = 1
46 
55  class(sll_c_interpolator_1d), pointer :: interp1
57  class(sll_c_interpolator_1d), pointer :: interp2
59  class(sll_c_characteristics_1d_base), pointer :: charac1
60  procedure(sll_i_signature_process_outside_point_1d), pointer, nopass :: process_outside_point1
62  class(sll_c_characteristics_1d_base), pointer :: charac2
63  procedure(sll_i_signature_process_outside_point_1d), pointer, nopass :: process_outside_point2
65  type(sll_t_cartesian_mesh_2d), pointer :: mesh_2d
67  sll_real64, dimension(:, :), pointer :: f
69  sll_int32 :: num_dof1
71  sll_int32 :: num_dof2
73  sll_real64, dimension(:), pointer :: dof_positions1
75  sll_real64, dimension(:), pointer :: dof_positions2
77  sll_int32 :: advection_form
79  sll_real64, dimension(:, :), pointer :: a1
81  sll_real64, dimension(:, :), pointer :: a2
82 
83  class(sll_c_coordinate_transformation_2d_base), pointer :: transformation
84  type(sll_t_cubic_nonunif_spline_1d), pointer :: spl_eta1
85  type(sll_t_cubic_nonunif_spline_1d), pointer :: spl_eta2
86 
88  sll_real64, dimension(:), pointer :: input1
89  sll_real64, dimension(:), pointer :: output1
90  sll_real64, dimension(:), pointer :: origin1
91  sll_real64, dimension(:), pointer :: origin_middle1
92  sll_real64, dimension(:), pointer :: feet1
93  sll_real64, dimension(:), pointer :: feet_middle1
94  sll_real64, dimension(:), pointer :: feet_inside1
95  sll_real64, dimension(:), pointer :: input2
96  sll_real64, dimension(:), pointer :: output2
97  sll_real64, dimension(:), pointer :: origin2
98  sll_real64, dimension(:), pointer :: origin_middle2
99  sll_real64, dimension(:), pointer :: feet2
100  sll_real64, dimension(:), pointer :: feet_middle2
101  sll_real64, dimension(:), pointer :: feet_inside2
102 
103  logical :: csl_2012
104 
105  sll_real64, dimension(:), pointer :: primitive1
106  sll_real64, dimension(:), pointer :: primitive2
107  sll_real64, dimension(:), pointer :: xi1
108  sll_real64, dimension(:), pointer :: xi2
109  sll_real64, dimension(:), pointer :: a1jac
110  sll_real64, dimension(:), pointer :: a2jac
111 
112  contains
113  procedure, pass(this) :: operatort => adv1
114  procedure, pass(this) :: operatorv => adv2
115  end type sll_t_split_advection_2d
116 
117 contains
119  f, &
120  a1, &
121  a2, &
122  interp1, &
123  charac1, &
124  process_outside_point1, &
125  interp2, &
126  charac2, &
127  process_outside_point2, &
128  mesh_2d, &
129  advection_form, &
130  split_case, &
131  split_step, &
132  nb_split_step, &
133  split_begin_T, &
134  dt, &
135  transformation, &
136  csl_2012) &
137  result(this)
138  class(sll_t_split_advection_2d), pointer :: this
139  sll_real64, dimension(:, :), pointer, intent(in) :: f
140  sll_real64, dimension(:, :), pointer, intent(in) :: a1
141  sll_real64, dimension(:, :), pointer, intent(in) :: a2
142  class(sll_c_interpolator_1d), pointer :: interp1
143  class(sll_c_interpolator_1d), pointer :: interp2
144  class(sll_c_characteristics_1d_base), pointer :: charac1
145  procedure(sll_i_signature_process_outside_point_1d), pointer :: process_outside_point1
146  class(sll_c_characteristics_1d_base), pointer :: charac2
147  procedure(sll_i_signature_process_outside_point_1d), pointer :: process_outside_point2
148  type(sll_t_cartesian_mesh_2d), pointer :: mesh_2d
149  sll_int32, intent(in) :: advection_form
150  sll_int32, intent(in) :: split_case
151  sll_real64, dimension(:), intent(in), optional :: split_step
152  sll_int32, intent(in), optional :: nb_split_step
153  logical, intent(in), optional :: split_begin_t
154  sll_real64, intent(in), optional :: dt
155  class(sll_c_coordinate_transformation_2d_base), pointer, optional :: transformation
156  logical, intent(in), optional :: csl_2012
157  ! local variable
158  sll_int32 :: ierr
159 
160  sll_allocate(this, ierr)
162  this, &
163  f, &
164  a1, &
165  a2, &
166  interp1, &
167  charac1, &
168  process_outside_point1, &
169  interp2, &
170  charac2, &
171  process_outside_point2, &
172  mesh_2d, &
173  advection_form, &
174  split_case, &
175  split_step, &
176  nb_split_step, &
177  split_begin_t, &
178  dt, &
179  transformation, &
180  csl_2012)
181 
182  end function
183 
186  this, &
187  f, &
188  a1, &
189  a2, &
190  interp1, &
191  charac1, &
192  process_outside_point1, &
193  interp2, &
194  charac2, &
195  process_outside_point2, &
196  mesh_2d, &
197  advection_form, &
198  split_case, &
199  split_step, &
200  nb_split_step, &
201  split_begin_T, &
202  dt, &
203  transformation, &
204  csl_2012)
205  class(sll_t_split_advection_2d), intent(inout) :: this
206  sll_real64, dimension(:, :), pointer, intent(in) :: f
207  sll_real64, dimension(:, :), pointer, intent(in) :: a1
208  sll_real64, dimension(:, :), pointer, intent(in) :: a2
209  class(sll_c_interpolator_1d), pointer :: interp1
210  class(sll_c_interpolator_1d), pointer :: interp2
211  class(sll_c_characteristics_1d_base), pointer :: charac1
212  procedure(sll_i_signature_process_outside_point_1d), pointer :: process_outside_point1
213  class(sll_c_characteristics_1d_base), pointer :: charac2
214  procedure(sll_i_signature_process_outside_point_1d), pointer :: process_outside_point2
215  type(sll_t_cartesian_mesh_2d), pointer :: mesh_2d
216  sll_int32, intent(in) :: advection_form
217  sll_int32, intent(in) :: split_case
218  sll_real64, dimension(:), intent(in), optional :: split_step
219  sll_int32, intent(in), optional :: nb_split_step
220  logical, intent(in), optional :: split_begin_T
221  sll_real64, intent(in), optional :: dt
222  class(sll_c_coordinate_transformation_2d_base), pointer, optional :: transformation
223  logical, intent(in), optional :: csl_2012
224  sll_int32 :: ierr
225  sll_int32 :: n1
226  sll_int32 :: n2
227  sll_int32 :: i
228  sll_real64 :: eta1_min
229  sll_real64 :: eta1_max
230  sll_real64 :: eta2_min
231  sll_real64 :: eta2_max
232 
233  this%f => f
234  this%a1 => a1
235  this%a2 => a2
236  this%interp1 => interp1
237  this%interp2 => interp2
238  this%charac1 => charac1
239  this%process_outside_point1 => process_outside_point1
240  this%process_outside_point2 => process_outside_point2
241  this%charac2 => charac2
242  this%mesh_2d => mesh_2d
243 
244  this%advection_form = advection_form
245 
246  if (present(transformation)) then
247  this%transformation => transformation
248  end if
249  if (present(csl_2012)) then
250  this%csl_2012 = csl_2012
251  else
252  this%csl_2012 = .false.
253  end if
254 
255  n1 = mesh_2d%num_cells1 + 1
256  n2 = mesh_2d%num_cells2 + 1
257 
258  eta1_min = mesh_2d%eta1_min
259  eta1_max = mesh_2d%eta1_max
260  eta2_min = mesh_2d%eta2_min
261  eta2_max = mesh_2d%eta2_max
262 
263  select case (this%advection_form)
264  case (sll_p_advective)
265  this%num_dof1 = n1
266  this%num_dof2 = n2
267  case (sll_p_conservative)
268  this%num_dof1 = n1 - 1
269  this%num_dof2 = n2 - 1
270  case default
271  sll_error("initialize_split_advection_2d", "bad value of advection_form")
272  print *, 'advection_form', advection_form
273  stop
274  end select
275 
276  if ((size(f, 1) /= this%num_dof1) .or. (size(f, 2) /= this%num_dof2)) then
277  sll_error("initialize_split_advection_2d", "bad size of f")
278  print *, 'size of f=', size(f)
279  stop
280  end if
281  if ((size(a1, 1) /= n1) .or. (size(a1, 2) /= this%num_dof2)) then
282  sll_error("initialize_split_advection_2d", "bad size of a1")
283  print *, 'size of a1=', size(a1)
284  stop
285  end if
286  if ((size(a2, 1) /= this%num_dof1) .or. (size(a2, 2) /= n2)) then
287  sll_error("initialize_split_advection_2d", "bad size of a2")
288  print *, 'size of a2=', size(a2)
289  stop
290  end if
291 
292  sll_allocate(this%input1(n1), ierr)
293  sll_allocate(this%output1(n1), ierr)
294  sll_allocate(this%origin1(n1), ierr)
295  sll_allocate(this%origin_middle1(n1 - 1), ierr)
296  sll_allocate(this%feet_middle1(n1 - 1), ierr)
297  sll_allocate(this%feet1(n1), ierr)
298  sll_allocate(this%feet_inside1(n1), ierr)
299 
300  sll_allocate(this%input2(n2), ierr)
301  sll_allocate(this%output2(n2), ierr)
302  sll_allocate(this%origin2(n2), ierr)
303  sll_allocate(this%origin_middle2(n2 - 1), ierr)
304  sll_allocate(this%feet_middle2(n2 - 1), ierr)
305  sll_allocate(this%feet2(n2), ierr)
306  sll_allocate(this%feet_inside2(n2), ierr)
307 
308  sll_allocate(this%primitive1(n1), ierr)
309  sll_allocate(this%primitive2(n2), ierr)
310  sll_allocate(this%xi1(n1), ierr)
311  sll_allocate(this%xi2(n2), ierr)
312  sll_allocate(this%A1jac(n1), ierr)
313  sll_allocate(this%A2jac(n2), ierr)
314 
315  do i = 1, n1
316  this%origin1(i) = real(i - 1, f64)/real(n1 - 1, f64)
317  this%origin1(i) = &
318  eta1_min + this%origin1(i)*(eta1_max - eta1_min)
319  end do
320  do i = 1, n2
321  this%origin2(i) = real(i - 1, f64)/real(n2 - 1, f64)
322  this%origin2(i) = &
323  eta2_min + this%origin2(i)*(eta2_max - eta2_min)
324  end do
325 
326  do i = 1, n1 - 1
327  this%origin_middle1(i) = 0.5_f64*(this%origin1(i) + this%origin1(i + 1))
328  end do
329  do i = 1, n2 - 1
330  this%origin_middle2(i) = 0.5_f64*(this%origin2(i) + this%origin2(i + 1))
331  end do
332 
333  this%spl_eta1 => sll_f_new_cubic_nonunif_spline_1d( &
334  n1 - 1, &
335  sll_p_periodic)
336  this%spl_eta2 => sll_f_new_cubic_nonunif_spline_1d(n2 - 1, sll_p_periodic)
337 
339  this, &
340  split_case, &
341  split_step, &
342  nb_split_step, &
343  split_begin_t, &
344  dt)
345  end subroutine
346 
348  subroutine adv1(this, dt)
349  class(sll_t_split_advection_2d), intent(inout) :: this
350  sll_real64, intent(in) :: dt
351  ! local variables
352  sll_int32 :: i
353  sll_int32 :: j
354  sll_int32 :: n1
355  sll_int32 :: n2
356  sll_int32 :: num_dof1
357  sll_int32 :: num_dof2
358  sll_real64 :: eta1_min
359  sll_real64 :: eta1_max
360  sll_real64 :: mean
361  !sll_real64 :: eta1
362  !sll_real64 :: eta2
363  !sll_real64 :: xi_max
364  sll_real64 :: delta_eta1
365  !sll_real64 :: lperiod
366  !sll_real64 :: xi_new
367  !sll_real64 :: mean_init
368 
369  n1 = this%mesh_2d%num_cells1 + 1
370  n2 = this%mesh_2d%num_cells2 + 1
371  num_dof1 = this%num_dof1
372  num_dof2 = this%num_dof2
373  eta1_min = this%mesh_2d%eta1_min
374  eta1_max = this%mesh_2d%eta1_max
375  delta_eta1 = (eta1_max - eta1_min)/real(n1 - 1, f64)
376  if (this%csl_2012) then
377 
378  !Let Fn(eta) = \int_0^{eta} (Jf)(tn,s)ds
379  ! such that Fn'(eta_j) = Jf(tn,eta_j)
380  !Let F_h(eta) = Fn(H(tn;eta,t_{n+1}))
381  !we know F_h(eta_k)=Fn(eta_k^*)
382  !we reconstruct F_h
383  !Jf(t_{n+1},eta_j) = F_h'(eta_j)
384  !we suppose here periodic boundary conditions
385 
386  ! on [0,1] mesh
387  ! eta_k = (k-1/2)/num_dof, k=1,num_dof
388  !we have to know
389  ! eta_k^*,k=1,num_dof
390  !at first order eta_k^*=eta_k-a(eta_k)dt
391  !input: a_k, k=1,num_dof
392  ! Jf(tn,eta_k), k=1,num_dof
393  ! dt
394  ! interp1d => new_cubic_spline_interpolator_1d( &
395  ! num_dof+1, &
396  ! eta_1, &
397  ! eta_1+eta_max-eta_min, &
398  ! sll_p_periodic)
399 
400 ! do j=1,num_dof2
401 !
402 !
403 ! eta2 = 0.5_f64*(this%origin2(j)+this%origin2(j+1))
404 ! do i=1,n1
405 ! eta1 = this%origin1(i)
406 ! this%A1jac(i) = &
407 ! this%A1(i,j)*this%transformation%jacobian(eta1,eta2)
408 ! enddo
409 !
410 !! do i=1,n1-1
411 !! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
412 !! this%A1jac(i) = &
413 !! this%A1(i,j)*this%transformation%jacobian(eta1,eta2)
414 !! print *,'A1=', this%A1jac(i)
415 !! enddo
416 !!stop
417 !
418 !!! do i=1,n1
419 !! print*,i,this%A1(i,j)
420 !! enddo
421 !! stop
422 !! print *,'#this%f',minval(this%f(1:num_dof1,j)),maxval(this%f(1:num_dof1,j))
423 !!
424 ! this%input1(1:num_dof1) = this%f(1:num_dof1,j)
425 ! eta2 = 0.5_f64*(this%origin2(j)+this%origin2(j+1))
426 !! do i=1,num_dof1
427 !! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
428 !! this%input1(i) = &
429 !! this%input1(i)/this%transformation%jacobian(eta1,eta2)
430 !! enddo
431 !!
432 ! print *,'#input1=',minval(this%input1(1:num_dof1)),maxval(this%input1(1:num_dof1))
433 !
434 !
435 ! this%primitive1(1) = 0._f64
436 ! do i=2,num_dof1+1
437 ! this%primitive1(i) = this%primitive1(i-1) &
438 ! +delta_eta1*this%input1(i-1)
439 ! enddo
440 !
441 !! do i=1,n1
442 !! print *,this%primitive1(i)
443 !! enddo
444 !
445 !
446 !
447 !
448 ! this%xi1(1) = 0._f64
449 ! do i=2,num_dof1+1
450 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i-1))
451 ! this%xi1(i) = this%xi1(i-1) &
452 ! +delta_eta1*this%transformation%jacobian(eta1,eta2)
453 ! enddo
454 ! !jacobian(i1) = df_jac_at_i( i1-1, i2 )
455 !
456 ! mean = this%primitive1(n1)/this%xi1(n1)
457 ! print *,'#mean init'
458 ! !modify primitive so that it becomes periodic
459 ! do i = 2,num_dof1+1
460 ! this%primitive1(i) = this%primitive1(i)-mean*this%xi1(i)
461 ! end do
462 ! xi_max = this%xi1(n1)
463 !
464 !! print *,'#this%primitive1=',minval(this%primitive1(1:n1)),maxval(this%primitive1(1:n1))
465 !! do i=1,n1
466 !! print *,this%primitive1(i)
467 !! enddo
468 !! stop
469 ! call implicit_ode_nonuniform( &
470 ! 2, &
471 ! dt, &
472 ! this%xi1, &
473 ! num_dof1, &
474 ! PERIODIC_ODE, &
475 ! this%feet_inside1, &
476 ! this%A1jac(1:n1),&
477 ! this%A1jac)
478 !
479 ! do i=1,n1
480 ! this%feet1(i) = this%xi1(i)-this%A1jac(i)*dt
481 ! enddo
482 !
483 ! call sll_s_compute_spline_nonunif( &
484 ! this%primitive1, &
485 ! this%spl_eta1, &
486 ! this%xi1)
487 ! ! interpolate primitive at origin of characteritics
488 ! call sll_s_interpolate_array_value_nonunif( &
489 ! this%feet_inside1, &
490 ! this%primitive1, &
491 ! n1, &
492 ! this%spl_eta1)
493 ! ! come back to real primitive by adding average
494 ! if (this%feet1(1) > 0.5_f64*(xi_max)) then
495 ! lperiod = -1.0_f64
496 ! else
497 ! lperiod = 0.0_f64
498 ! end if
499 ! !print *,'lperiod=',lperiod
500 ! xi_new = this%feet1(1) + lperiod*xi_max
501 ! this%primitive1(1) = this%primitive1(1) + mean*xi_new
502 ! !if ((xi_new > xi_max) .or. (xi_new <xi(1))) then
503 ! ! print*, 1, xi_new, xi_out(1), primitive(1)
504 ! !end if
505 ! do i = 2,n1
506 ! ! We need here to find the points where it has been modified by periodicity
507 ! if (this%feet1(i) < this%feet1(i-1)) then
508 ! lperiod = lperiod+1.0_f64
509 ! end if
510 ! !print *,'lperiod=',i,lperiod
511 ! xi_new = this%feet1(i)+lperiod*xi_max
512 ! this%primitive1(i) = this%primitive1(i)+mean*xi_new
513 ! !if (i>98) then
514 ! ! print*, 'iii', i, xi_new, xi_out(i),xi_max, primitive(i), primitive(i-1)
515 ! !endif
516 ! end do
517 !
518 ! do i=1,num_dof1
519 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
520 ! !print *,this%feet1(i+1)-this%feet1(i), &
521 ! ! this%xi1(i+1)-this%xi1(i), &
522 ! ! this%primitive1(i+1)-this%primitive1(i), &
523 ! ! this%transformation%jacobian(eta1,eta2)*delta_eta1
524 ! enddo
525 !
526 ! do i = 1,num_dof1
527 ! this%f(i,j) = (this%primitive1(i+1)-this%primitive1(i))/delta_eta1
528 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
529 ! !print *,i,this%f(i,j)/this%transformation%jacobian(eta1,eta2)
530 ! !call sll_set_df_val( dist_func_2D, i1, i2, val )
531 ! !if (val/df_jac_at_i(i1,i2)>1.) then
532 ! ! print*, 'val', i1,i2, val, primitive1(i1) , primitive1(i1+1), df_jac_at_i(i1,i2), delta_eta1
533 ! !end if
534 ! end do
535 !
536 ! !
537 !! print *,'#output1=',minval(this%f(1:num_dof1,j)),maxval(this%f(1:num_dof1,j))
538 !! print *,'#mean=',mean
539 !! !print *,'#this%f',minval(this%f(1:num_dof1,j)),maxval(this%f(1:num_dof1,j))
540 !! !stop
541 !
542 !
543 ! enddo
544 
545  else
546 
547  do j = 1, num_dof2
548  this%input1(1:num_dof1) = this%f(1:num_dof1, j)
549 
550 ! print *,'this%input1(1:num_dof1)=', &
551 ! minval(this%input1(1:num_dof1)), &
552 ! maxval(this%input1(1:num_dof1))
553 
554  if (this%advection_form == sll_p_conservative) then
556  this%input1, &
557  this%origin1, &
558  num_dof1, &
559  mean)
560 ! this%input1(1:num_dof1) = this%f(1:num_dof1,j)
561 ! eta2 = 0.5_f64*(this%origin2(j)+this%origin2(j+1))
562 ! do i=1,num_dof1
563 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
564 ! this%input1(i) = &
565 ! this%input1(i)/this%transformation%jacobian(eta1,eta2)-mean
566 ! this%input1(i) = &
567 ! this%input1(i)*this%transformation%jacobian(eta1,eta2)
568 ! enddo
569 ! mean_init = mean
570 ! call function_to_primitive_adv( &
571 ! this%input1, &
572 ! this%origin1, &
573 ! num_dof1, &
574 ! mean)
575 ! !print *,'new mean=',mean
576 ! !stop
577  end if
578 
579  !advection
580 ! if(this%advection_form==sll_p_conservative)then
581 ! do i=1,num_dof1
582 ! this%A1jac(i) = 0.5_f64*(this%A1(i,j)+this%A1(i+1,j))
583 ! enddo
584 ! call this%charac1%compute_characteristics( &
585 ! this%A1jac(1:num_dof1), &
586 ! dt, &
587 ! this%origin_middle1(1:num_dof1), &
588 ! this%feet_middle1(1:num_dof1))
589 !
590 ! this%feet1(1) = 0.5_f64*(this%feet_middle1(1)+this%feet_middle1(n1-1)) &
591 ! -0.5_f64*(this%origin1(n1)-this%origin1(1))
592 !
593 ! do i=2,n1-1
594 ! this%feet1(i) = 0.5_f64*(this%feet_middle1(i)+this%feet_middle1(i-1))
595 ! enddo
596 !
597 ! this%feet1(n1) = this%feet1(1) &
598 ! +(this%origin1(n1)-this%origin1(1))
599 !
600 ! else
601  call this%charac1%compute_characteristics( &
602  this%A1(1:n1, j), &
603  dt, &
604  this%origin1(1:n1), &
605  this%feet1(1:n1))
606 ! endif
607 
608  do i = 1, n1
609  this%feet_inside1(i) = this%process_outside_point1( &
610  this%feet1(i), &
611  eta1_min, &
612  eta1_max)
613  end do
614 
615  call this%interp1%interpolate_array( &
616  n1, &
617  this%input1(1:n1), &
618  -this%feet_inside1(1:n1), &
619  this%output1(1:n1))
620 
621  if (this%advection_form == sll_p_conservative) then
623  this%output1(1:n1), &
624  this%origin1(1:n1), &
625  this%feet1(1:n1), &
626  num_dof1, &
627  mean)
628 ! eta2 = 0.5_f64*(this%origin2(j)+this%origin2(j+1))
629 ! do i=1,num_dof1
630 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
631 ! this%output1(i) = &
632 ! this%output1(i)/this%transformation%jacobian(eta1,eta2)+mean_init
633 ! this%output1(i) = &
634 ! this%output1(i)*this%transformation%jacobian(eta1,eta2)
635 ! enddo
636 
637  end if
638 
639  this%f(1:num_dof1, j) = this%output1(1:num_dof1)
640 
641 ! print *,'this%output1(1:num_dof1)=', &
642 ! minval(this%output1(1:num_dof1)), &
643 ! maxval(this%output1(1:num_dof1))
644 !
645 ! print *,'#mean_adv1=',mean
646 
647 ! if(this%advection_form==sll_p_conservative)then
648 ! call function_to_primitive_adv( &
649 ! this%output1, &
650 ! this%origin1, &
651 ! num_dof1, &
652 ! mean)
653 ! endif
654 !
655 ! print *,'#mean_adv1b=',mean
656 
657  end do
658  end if
659 
660  end subroutine
661 
663  subroutine adv2(this, dt)
664  class(sll_t_split_advection_2d), intent(inout) :: this
665  sll_real64, intent(in) :: dt
666  ! local variables
667  sll_int32 :: i
668  sll_int32 :: j
669  sll_int32 :: n1
670  sll_int32 :: n2
671  sll_int32 :: num_dof1
672  sll_int32 :: num_dof2
673  sll_real64 :: eta2_min
674  sll_real64 :: eta2_max
675  sll_real64 :: mean
676  !sll_real64 :: mean_init
677  !sll_real64 :: eta1
678  !sll_real64 :: eta2
679 
680  n1 = this%mesh_2d%num_cells1 + 1
681  n2 = this%mesh_2d%num_cells2 + 1
682  num_dof1 = this%num_dof1
683  num_dof2 = this%num_dof2
684  eta2_min = this%mesh_2d%eta2_min
685  eta2_max = this%mesh_2d%eta2_max
686 
687  !return
688  do i = 1, num_dof1
689  this%input2(1:num_dof2) = this%f(i, 1:num_dof2)
690  !print *,'#input2=',minval(this%input2(1:num_dof2)),maxval(this%input2(1:num_dof2))
691 
692  if (this%advection_form == sll_p_conservative) then
694  this%input2, &
695  this%origin2, &
696  num_dof2, &
697  mean)
698 
699 ! this%input2(1:num_dof1) = this%f(i,1:num_dof2)
700 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
701 ! do j=1,num_dof2
702 ! eta2 = 0.5_f64*(this%origin2(j)+this%origin2(j+1))
703 ! this%input2(j) = &
704 ! this%input2(j)/this%transformation%jacobian(eta1,eta2)-mean
705 ! this%input2(j) = &
706 ! this%input2(j)*this%transformation%jacobian(eta1,eta2)
707 ! enddo
708 ! mean_init = mean
709 ! call function_to_primitive_adv( &
710 ! this%input2, &
711 ! this%origin2, &
712 ! num_dof2, &
713 ! mean)
714 
715  end if
716 
717  !advection
718 ! if(this%advection_form==sll_p_conservative)then
719 ! do j=1,num_dof2
720 ! this%A2jac(j) = 0.5_f64*(this%A2(i,j)+this%A2(i,j+1))
721 ! enddo
722 ! call this%charac2%compute_characteristics( &
723 ! this%A2jac(1:num_dof2), &
724 ! dt, &
725 ! this%origin_middle2(1:num_dof2), &
726 ! this%feet_middle2(1:num_dof2))
727 !
728 ! this%feet2(1) = 0.5_f64*(this%feet_middle2(1)+this%feet_middle2(n2-1)) &
729 ! -0.5_f64*(this%origin2(n2)-this%origin2(1))
730 !
731 ! do j=2,n2-1
732 ! this%feet2(j) = 0.5_f64*(this%feet_middle2(j)+this%feet_middle2(j-1))
733 ! enddo
734 !
735 ! this%feet2(n2) = this%feet2(1) &
736 ! +(this%origin2(n2)-this%origin2(1))
737 !
738 ! else
739  call this%charac2%compute_characteristics( &
740  this%A2(i, 1:n2), &
741  dt, &
742  this%origin2(1:n2), &
743  this%feet2(1:n2))
744 ! endif
745  !print *,'err=',maxval(this%origin2-this%feet2)
746 
747  do j = 1, n2
748  this%feet_inside2(j) = this%process_outside_point2( &
749  this%feet2(j), &
750  eta2_min, &
751  eta2_max)
752  end do
753  call this%interp2%interpolate_array( &
754  n2, &
755  this%input2(1:n2), &
756  -this%feet_inside2(1:n2), &
757  this%output2(1:n2))
758 
759  if (this%advection_form == sll_p_conservative) then
761  this%output2(1:n2), &
762  this%origin2(1:n2), &
763  this%feet2(1:n2), &
764  num_dof2, &
765  mean)
766 ! eta1 = 0.5_f64*(this%origin1(i)+this%origin1(i+1))
767 ! do j=1,num_dof2
768 ! eta2 = 0.5_f64*(this%origin2(j)+this%origin2(j+1))
769 ! this%output2(j) = &
770 ! this%output2(j)/this%transformation%jacobian(eta1,eta2)+mean_init
771 ! this%output2(j) = &
772 ! this%output2(j)*this%transformation%jacobian(eta1,eta2)
773 ! enddo
774 
775  end if
776 
777  this%f(i, 1:num_dof2) = this%output2(1:num_dof2)
778 ! print *,'#output2=',minval(this%output2(1:num_dof2)),maxval(this%output2(1:num_dof2))
779 !
780 ! print *,'#mean_adv2=',mean
781 ! stop
782 
783  end do
784  end subroutine
785 
786  subroutine function_to_primitive_adv(f, node_positions, N, M)
787  sll_real64, dimension(:), intent(inout) :: f
788  sll_real64, dimension(:), intent(in) :: node_positions
789  sll_int32, intent(in):: n
790  sll_real64, intent(out)::m
791  sll_int32::i
792  sll_real64::tmp, tmp2
793 
794  !from f compute the mean
795  m = 0._f64
796  do i = 1, n
797  m = m + f(i)*(node_positions(i + 1) - node_positions(i))
798  end do
799  !begin new
800  m = m/(node_positions(n + 1) - node_positions(1))
801  !end new
802 
803  f(1) = (f(1) - m)*(node_positions(2) - node_positions(1))
804  tmp = f(1)
805  f(1) = 0._f64
806  do i = 2, n!+1
807  f(i) = (f(i) - m)*(node_positions(i + 1) - node_positions(i))
808  tmp2 = f(i)
809  f(i) = f(i - 1) + tmp
810  tmp = tmp2
811  end do
812  f(n + 1) = f(n) + tmp
813 
814  !print *,M,f(1),f(N+1)
815 
816  end subroutine function_to_primitive_adv
817 
819  f, &
820  node_positions, &
821  node_positions_back, &
822  N, &
823  M)
824  sll_real64, dimension(:), intent(inout) :: f
825  sll_real64, dimension(:), intent(in) :: node_positions
826  sll_real64, dimension(:), intent(in) :: node_positions_back
827  sll_int32, intent(in):: n
828  sll_real64, intent(in)::m
829  sll_int32::i
830  sll_real64::tmp!,tmp2
831 
832  tmp = f(1)
833  do i = 1, n - 1
834  f(i) = f(i + 1) - f(i) + m*(node_positions_back(i + 1) - node_positions_back(i))
835  end do
836  f(n) = tmp - f(n) + m*(node_positions_back(n + 1) - node_positions_back(n))
837 
838  !from mean compute f
839  do i = 1, n
840  f(i) = f(i)/(node_positions(i + 1) - node_positions(i))
841  end do
842  !f(N+1) = f(1)
843  end subroutine primitive_to_function_adv
844 
845 end module sll_m_split_advection_2d
Cartesian mesh basic types.
Abstract class for characteristic derived type.
Abstract class for coordinate transformations.
Provides capabilities for data interpolation with cubic B-splines on non-uniform meshes.
type(sll_t_cubic_nonunif_spline_1d) function, pointer, public sll_f_new_cubic_nonunif_spline_1d(n_cells, bc_type)
create new spline object
Module for 1D interpolation and reconstruction.
Base class of operator splitting library. It is only used with particle-in-cell method.
subroutine, public sll_s_operator_splitting_init(split, split_case, split_step, nb_split_step, split_begin_T, dt)
Initialises data for operator splitting.
Implements split operators for constant coefficient advection.
integer(kind=i32), parameter, public sll_p_advective
subroutine initialize_split_advection_2d(this, f, a1, a2, interp1, charac1, process_outside_point1, interp2, charac2, process_outside_point2, mesh_2d, advection_form, split_case, split_step, nb_split_step, split_begin_T, dt, transformation, csl_2012)
Initialise advection_2d object.
class(sll_t_split_advection_2d) function, pointer, public sll_f_new_split_advection_2d(f, a1, a2, interp1, charac1, process_outside_point1, interp2, charac2, process_outside_point2, mesh_2d, advection_form, split_case, split_step, nb_split_step, split_begin_T, dt, transformation, csl_2012)
subroutine primitive_to_function_adv(f, node_positions, node_positions_back, N, M)
subroutine adv1(this, dt)
Advection operator in first direction.
subroutine adv2(this, dt)
Advection operator in second direction.
subroutine function_to_primitive_adv(f, node_positions, N, M)
integer(kind=i32), parameter, public sll_p_conservative
Abstract class for 1D interpolation and reconstruction.
Simple operator splitting type for 2D advection Extends operator splitting.
    Report Typos and Errors