23 #include "sll_memory.h"
24 #include "sll_working_precision.h"
45 sll_int32 :: num_cells
48 sll_real64,
dimension(:),
pointer :: node_positions
49 sll_real64,
dimension(:),
pointer :: buf
50 sll_int32,
dimension(:),
pointer :: ibuf
51 sll_real64,
dimension(:),
pointer :: node_pos
52 sll_real64,
dimension(:),
pointer :: coeffs
53 sll_real64,
dimension(:),
pointer :: xstar
55 procedure, pass(adv) :: init => &
57 procedure, pass(adv) :: advect_1d_constant => &
59 procedure, pass(adv) :: advect_1d => &
79 sll_int32,
intent(in) :: num_cells
80 sll_real64,
intent(in) :: xmin
81 sll_real64,
intent(in) :: xmax
82 sll_int32,
intent(in) :: order
83 sll_real64,
dimension(:),
intent(in),
optional :: node_positions
86 sll_allocate(adv, ierr)
106 sll_int32,
intent(in) :: num_cells
107 sll_real64,
intent(in) :: xmin
108 sll_real64,
intent(in) :: xmax
109 sll_int32,
intent(in) :: order
110 sll_real64,
dimension(:),
intent(in),
optional :: node_positions
121 adv%num_cells = num_cells
125 dx = (xmax - xmin)/real(num_cells, f64)
127 if (order .ne. 4)
then
128 print *,
'#Warning order=4 is enforced'
129 print *,
'#in initialize_sll_t_advector_1d_non_uniform_cubic_splines'
132 if (
present(node_positions))
then
133 if (
size(node_positions, 1) < num_cells + 1)
then
134 print *,
'#size problem for node_positions'
135 print *,
'#in subroutine initialize_sll_t_advector_1d_non_uniform_cubic_splines'
138 sll_allocate(adv%node_positions(num_cells + 1), ierr)
139 adv%node_positions(1:num_cells + 1) = &
140 (node_positions(1:num_cells + 1) - xmin)/(xmax - xmin)
142 sll_allocate(adv%node_positions(num_cells + 1), ierr)
143 do i = 1, num_cells + 1
145 adv%node_positions(i) = real(i - 1, f64)/real(num_cells, f64)
149 sll_clear_allocate(adv%buf(10*num_cells), ierr)
150 sll_allocate(adv%ibuf(num_cells), ierr)
152 sll_clear_allocate(adv%node_pos(-2:num_cells + 2), ierr)
153 sll_clear_allocate(adv%coeffs(-1:num_cells + 1), ierr)
155 sll_clear_allocate(adv%Xstar(1:num_cells + 1), ierr)
157 adv%node_pos(0:num_cells) = adv%node_positions(1:num_cells + 1)
169 sll_real64,
intent(in) :: a
170 sll_real64,
intent(in) :: dt
171 sll_real64,
dimension(:),
intent(in) :: input
172 sll_real64,
dimension(:),
intent(out) :: output
176 sll_int32 :: num_cells
179 num_cells = adv%num_cells
182 shift = a*dt/(xmax - xmin)*real(num_cells, f64)
184 alpha = a*dt/(xmax - xmin)
186 output(1:num_cells + 1) = input(1:num_cells + 1)
191 adv%node_positions, &
219 sll_real64,
dimension(:),
intent(in) :: a
220 sll_real64,
intent(in) :: dt
221 sll_real64,
dimension(:),
intent(in) :: input
222 sll_real64,
dimension(:),
intent(out) :: output
224 print *,
'#non_uniform_cubic_splines_advect_1d'
225 print *,
'#not implemented for the moment'
228 print *, maxval(input)
230 print *, adv%num_cells
249 sll_real64,
dimension(:),
intent(inout) :: f
250 sll_real64,
dimension(:),
intent(in) :: node_positions
252 sll_int32,
intent(in):: n
253 sll_real64,
intent(in)::alpha
257 sll_real64,
dimension(:),
pointer :: buf, xstar, node_pos, coeffs
258 sll_int32,
dimension(:),
pointer :: ibuf
260 dx = 1._f64/real(n, f64)
283 xstar(i) = node_positions(i) - alpha
287 do while (xstar(i) .gt. 1._f64)
288 xstar(i) = xstar(i) - 1._f64
290 do while (xstar(i) .lt. 0._f64)
291 xstar(i) = xstar(i) + 1._f64
346 sll_deallocate(adv%node_positions, ierr)
347 sll_deallocate(adv%buf, ierr)
348 sll_deallocate(adv%ibuf, ierr)
349 sll_deallocate(adv%node_pos, ierr)
350 sll_deallocate(adv%coeffs, ierr)
351 sll_deallocate(adv%Xstar, ierr)
Abstract class for advection.