Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_mapping_3d.F90
Go to the documentation of this file.
1 
12 
14  !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 #include "sll_assert.h"
16 #include "sll_memory.h"
17 #include "sll_errors.h"
18 #include "sll_working_precision.h"
19 
20  use sll_m_constants, only: &
21  sll_p_pi
22 
24 
25  use sll_m_linear_operator_kron, only : &
27 
28  use sll_m_linear_solver_kron, only : &
30 
31  use sll_m_linear_solver_mgmres, only : &
33 
34  use sll_m_matrix_csr, only: &
36 
37  use sll_m_splines_pp, only :&
47 
48  implicit none
49 
50  public :: &
52 
53  private
55  abstract interface
56  function sll_i_eval_function( xi, params ) result(res)
58  sll_real64, intent(in) :: xi(3)
59  sll_real64, intent(in) :: params(:)
60  sll_real64 :: res
61  end function sll_i_eval_function
62  end interface
63 
65  procedure(sll_i_eval_function), pointer, nopass :: f
66  end type matrix_element
69 
70  type(matrix_element), dimension(:,:), pointer :: j_matrix
71  procedure(sll_i_eval_function), pointer, nopass :: jacob
72  procedure(sll_i_eval_function), pointer, nopass :: x1_func
73  procedure(sll_i_eval_function), pointer, nopass :: x2_func
74  procedure(sll_i_eval_function), pointer, nopass :: x3_func
75  procedure(sll_i_eval_function), pointer, nopass :: xi1_func
76  procedure(sll_i_eval_function), pointer, nopass :: xi2_func
77  procedure(sll_i_eval_function), pointer, nopass :: xi3_func
78  sll_real64, dimension(:), pointer :: params
79  !sll_real64 :: cylinder_params(3) !< parameter for cylindrical mapping
80  logical :: flag = .false.
81  logical :: flag2d = .false.
82  logical :: flag3d = .false.
83  logical :: singular = .false.
84  logical :: inverse = .false.
85 
86  type(sll_t_spline_pp_3d) :: spline_3d
87 
88  sll_real64, allocatable :: x1_func_dofs_pp(:,:)
89  sll_real64, allocatable :: x2_func_dofs_pp(:,:)
90  sll_real64, allocatable :: x3_func_dofs_pp(:,:)
91 
92  sll_int32 :: n_cells(3)
93  sll_int32 :: deg(3)
94  sll_real64 :: volume = 1._f64
95  sll_real64 :: lx(3) = 1._f64
96 
97  contains
98 
99  procedure :: get_x1
100 
101  procedure :: get_x2
102 
103  procedure :: get_x3
104 
105  procedure :: get_x
106 
107  procedure :: get_xi
108 
109  procedure :: jacobian
110 
111  procedure :: jacobian_matrix
112 
114 
116 
118 
119  procedure :: metric
120 
121  procedure :: metric_inverse
122 
123  procedure :: metric_single
124 
126 
128 
130 
131  procedure :: init
132 
133  procedure :: init_from_file
134 
135  procedure :: free
136 
137  end type sll_t_mapping_3d
138 
139 contains
140 
141 
143  function get_x1( self, xi ) result(x1)
144  class(sll_t_mapping_3d), intent( inout ) :: self
145  sll_real64, intent( in ) :: xi(3)
146  sll_real64 :: x1
147  !local variables
148  sll_int32 :: box(3)
149  sll_real64 :: xbox(3)
150 
151  if(self%flag)then
152  x1 = self%x1_func( xi, self%params )
153  else
154  call convert_x_to_xbox( self, xi, xbox, box )
155  x1 = sll_f_spline_pp_horner_3d(self%deg, self%x1_func_dofs_pp, xbox, box, self%n_cells)
156  end if
157 
158  end function get_x1
159 
160 
162  function get_x2( self, xi ) result(x2)
163  class(sll_t_mapping_3d), intent( inout ) :: self
164  sll_real64, intent( in ) :: xi(3)
165  sll_real64 :: x2
166  !local variables
167  sll_int32 :: box(3)
168  sll_real64 :: xbox(3)
169 
170  if(self%flag)then
171  x2 = self%x2_func( xi, self%params )
172  else
173  call convert_x_to_xbox( self, xi, xbox, box )
174  x2 = sll_f_spline_pp_horner_3d(self%deg, self%x2_func_dofs_pp, xbox, box, self%n_cells)
175  end if
176 
177  end function get_x2
178 
179 
181  function get_x3( self, xi ) result(x3)
182  class(sll_t_mapping_3d), intent( inout ) :: self
183  sll_real64, intent( in ) :: xi(3)
184  sll_real64 :: x3
185  !local variables
186  sll_int32 :: box(3)
187  sll_real64 :: xbox(3)
188 
189  if(self%flag)then
190  x3 = self%x3_func( xi, self%params )
191  else
192  call convert_x_to_xbox( self, xi, xbox, box )
193  x3 = sll_f_spline_pp_horner_3d(self%deg, self%x3_func_dofs_pp, xbox, box, self%n_cells)
194  end if
195 
196  end function get_x3
197 
198 
200  function get_x( self, xi ) result(x)
201  class(sll_t_mapping_3d), intent( inout ) :: self
202  sll_real64, intent( in ) :: xi(3)
203  sll_real64 :: x(3)
204  !local variables
205  sll_int32 :: box(3)
206  sll_real64 :: xbox(3)
207 
208  if(self%flag)then
209  x(1) = self%x1_func( xi, self%params )
210  x(2) = self%x2_func( xi, self%params )
211  x(3) = self%x3_func( xi, self%params )
212  else
213  call convert_x_to_xbox( self, xi, xbox, box )
214  x(1) = sll_f_spline_pp_horner_3d(self%deg, self%x1_func_dofs_pp, xbox, box, self%n_cells)
215  x(2) = sll_f_spline_pp_horner_3d(self%deg, self%x2_func_dofs_pp, xbox, box, self%n_cells)
216  x(3) = sll_f_spline_pp_horner_3d(self%deg, self%x3_func_dofs_pp, xbox, box, self%n_cells)
217  end if
218 
219  end function get_x
220 
221 
223  function get_xi( self, x ) result(xi)
224  class(sll_t_mapping_3d), intent( inout ) :: self
225  sll_real64, intent( in ) :: x(3)
226  sll_real64 :: xi(3)
227 
228  xi(1) = self%xi1_func( x, self%params )
229  xi(2) = self%xi2_func( x, self%params )
230  xi(3) = self%xi3_func( x, self%params )
231  end function get_xi
232 
233 
235  function jacobian( self, xi )result(x)
236  class(sll_t_mapping_3d), intent( inout ) :: self
237  sll_real64, intent( in ) :: xi(3)
238  sll_real64 :: x ! jacobian
239  !local variables
240  sll_real64 :: y(3,3)
241 
242  if(self%flag)then
243  x = self%jacob( xi, self%params )
244  else
245  y = self%jacobian_matrix( xi )
246  if( self%flag3d) then
247  x = y(1,1) * y(2,2) * y(3,3) +&
248  y(1,2) * y(2,3) * y(3,1) +&
249  y(1,3) * y(2,1) * y(3,2) -&
250  y(1,3) * y(2,2) * y(3,1) -&
251  y(1,2) * y(2,1) * y(3,3) -&
252  y(1,1) * y(2,3) * y(3,2)
253  else
254  x = y(3,3) * ( y(1,1) * y(2,2) - y(1,2) * y(2,1) )
255  end if
256  end if
257 
258  end function jacobian
259 
260 
262  function jacobian_matrix( self, xi )result(y)
263  class(sll_t_mapping_3d), intent( inout ) :: self
264  sll_real64, intent( in ) :: xi(3)
265  sll_real64 :: y(3,3)
266  !local variables
267  sll_int32 :: box(3)
268  sll_real64 :: xbox(3)
269 
270  y = 0._f64
271 
272  if(self%flag)then
273  y(1,1) = self%j_matrix(1,1)%f( xi, self%params )
274  y(2,2) = self%j_matrix(2,2)%f( xi, self%params )
275  y(3,3) = self%j_matrix(3,3)%f( xi, self%params )
276  y(1,2) = self%j_matrix(1,2)%f( xi, self%params )
277  y(2,1) = self%j_matrix(2,1)%f( xi, self%params )
278  if( self%flag3d ) then
279  y(1,3) = self%j_matrix(1,3)%f( xi, self%params )
280  y(2,3) = self%j_matrix(2,3)%f( xi, self%params )
281  y(3,1) = self%j_matrix(3,1)%f( xi, self%params )
282  y(3,2) = self%j_matrix(3,2)%f( xi, self%params )
283  end if
284  else
285  call convert_x_to_xbox( self, xi, xbox, box )
286  y(1,1) = sll_f_spline_pp_horner_3d_d1( self%deg, self%x1_func_dofs_pp, xbox, box, self%n_cells)
287  y(2,2) = sll_f_spline_pp_horner_3d_d2( self%deg, self%x2_func_dofs_pp, xbox, box, self%n_cells)
288  y(3,3) = sll_f_spline_pp_horner_3d_d3( self%deg, self%x3_func_dofs_pp, xbox, box, self%n_cells)
289  y(1,2) = sll_f_spline_pp_horner_3d_d2( self%deg, self%x1_func_dofs_pp, xbox, box, self%n_cells)
290  y(2,1) = sll_f_spline_pp_horner_3d_d1( self%deg, self%x2_func_dofs_pp, xbox, box, self%n_cells)
291  if( self%flag3d ) then
292  y(1,3) = sll_f_spline_pp_horner_3d_d3( self%deg, self%x1_func_dofs_pp, xbox, box, self%n_cells)
293  y(2,3) = sll_f_spline_pp_horner_3d_d3( self%deg, self%x2_func_dofs_pp, xbox, box, self%n_cells)
294  y(3,1) = sll_f_spline_pp_horner_3d_d1( self%deg, self%x3_func_dofs_pp, xbox, box, self%n_cells)
295  y(3,2) = sll_f_spline_pp_horner_3d_d2( self%deg, self%x3_func_dofs_pp, xbox, box, self%n_cells)
296  end if
297  end if
298 
299  end function jacobian_matrix
300 
301 
303  function jacobian_matrix_transposed( self, xi )result(y)
304  class(sll_t_mapping_3d), intent( inout ) :: self
305  sll_real64, intent( in ) :: xi(3)
306  sll_real64 :: y(3,3)
307  !local variables
308  sll_real64 :: w(3,3)
309  w = self%jacobian_matrix(xi)
310 
311  y(1,1) = w(1,1)
312  y(1,2) = w(2,1)
313  y(1,3) = w(3,1)
314  y(2,1) = w(1,2)
315  y(2,2) = w(2,2)
316  y(2,3) = w(3,2)
317  y(3,1) = w(1,3)
318  y(3,2) = w(2,3)
319  y(3,3) = w(3,3)
320 
321  end function jacobian_matrix_transposed
322 
323 
325  function jacobian_matrix_inverse( self, xi )result(y)
326  class(sll_t_mapping_3d), intent( inout ) :: self
327  sll_real64, intent( in ) :: xi(3)
328  sll_real64 :: y(3,3)
329  !local variables
330  sll_real64 :: w(3,3)
331 
332  w = self%jacobian_matrix(xi)
333 
334  if( self%flag3d ) then
335  y(1,1) = w(2,2) * w(3,3) - w(2,3) * w(3,2)
336  y(1,2) = w(1,3) * w(3,2) - w(1,2) * w(3,3)
337  y(1,3) = w(1,2) * w(2,3) - w(1,3) * w(2,2)
338  y(2,1) = w(2,3) * w(3,1) - w(2,1) * w(3,3)
339  y(2,2) = w(1,1) * w(3,3) - w(1,3) * w(3,1)
340  y(2,3) = w(1,3) * w(2,1) - w(1,1) * w(2,3)
341  y(3,1) = w(2,1) * w(3,2) - w(2,2) * w(3,1)
342  y(3,2) = w(1,2) * w(3,1) - w(1,1) * w(3,2)
343  y(3,3) = w(1,1) * w(2,2) - w(1,2) * w(2,1)
344 
345  y = y/(w(1,1) * w(2,2) * w(3,3) +&
346  w(1,2) * w(2,3) * w(3,1) +&
347  w(1,3) * w(2,1) * w(3,2) -&
348  w(1,3) * w(2,2) * w(3,1) -&
349  w(1,2) * w(2,1) * w(3,3) -&
350  w(1,1) * w(2,3) * w(3,2) )
351 
352 
353  else
354  y = 0._f64
355  y(1,1) = w(2,2) /( w(1,1) * w(2,2) - w(1,2) * w(2,1) )
356  y(1,2) = - w(1,2) /( w(1,1) * w(2,2) - w(1,2) * w(2,1) )
357  y(2,1) = - w(2,1) /( w(1,1) * w(2,2) - w(1,2) * w(2,1) )
358  y(2,2) = w(1,1) /( w(1,1) * w(2,2) - w(1,2) * w(2,1) )
359  y(3,3) = 1._f64/w(3,3)
360  end if
361 
362  end function jacobian_matrix_inverse
363 
364 
366  function jacobian_matrix_inverse_transposed( self, xi )result(y)
367  class(sll_t_mapping_3d), intent( inout ) :: self
368  sll_real64, intent( in ) :: xi(3)
369  sll_real64 :: y(3,3)
370  !local variable
371  sll_real64 :: w(3,3)
372 
373  w=self%jacobian_matrix_inverse(xi)
374 
375  y(1,1) = w(1,1)
376  y(1,2) = w(2,1)
377  y(1,3) = w(3,1)
378  y(2,1) = w(1,2)
379  y(2,2) = w(2,2)
380  y(2,3) = w(3,2)
381  y(3,1) = w(1,3)
382  y(3,2) = w(2,3)
383  y(3,3) = w(3,3)
384 
386 
387 
389  function metric( self, xi )result(g)
390  class(sll_t_mapping_3d), intent( inout ) :: self
391  sll_real64, intent( in ) :: xi(3)
392  sll_real64 :: g(3,3)
393  sll_real64 :: y(3,3)
394 
395  y=self%jacobian_matrix( xi )
396  g(1,1) = y(1,1)**2+y(2,1)**2+y(3,1)**2
397  g(1,2) = y(1,1)*y(1,2)+y(2,1)*y(2,2)+y(3,1)*y(3,2)
398  g(1,3) = y(1,1)*y(1,3)+y(2,1)*y(2,3)+y(3,1)*y(3,3)
399  g(2,1) = g(1,2)
400  g(2,2) = y(1,2)**2+y(2,2)**2+y(3,2)**2
401  g(2,3) = y(1,2)*y(1,3)+y(2,2)*y(2,3)+y(3,2)*y(3,3)
402  g(3,1) = g(1,3)
403  g(3,2) = g(2,3)
404  g(3,3) = y(1,3)**2+y(2,3)**2+y(3,3)**2
405 
406  end function metric
407 
408 
410  function metric_single( self, xi, component1, component2 )result(g)
411  class(sll_t_mapping_3d), intent( inout ) :: self
412  sll_real64, intent( in ) :: xi(3)
413  sll_int32, intent( in ) :: component1, component2
414  sll_real64 :: g
415  !local variable
416  sll_real64 :: w(3,3)
417  w = self%jacobian_matrix(xi)
418 
419  g = w(1,component1)*w(1,component2)+&
420  w(2,component1)*w(2,component2)+&
421  w(3,component1)*w(3,component2)
422 
423  end function metric_single
424 
425 
427  function metric_inverse( self, xi )result(g)
428  class(sll_t_mapping_3d), intent( inout ) :: self
429  sll_real64, intent( in ) :: xi(3)
430  sll_real64 :: g(3,3)
431  sll_real64 :: y(3,3)
432 
433  y=self%jacobian_matrix_inverse_transposed(xi)
434  g(1,1) = y(1,1)**2+y(2,1)**2+y(3,1)**2
435  g(1,2) = y(1,1)*y(1,2)+y(2,1)*y(2,2)+y(3,1)*y(3,2)
436  g(1,3) = y(1,1)*y(1,3)+y(2,1)*y(2,3)+y(3,1)*y(3,3)
437  g(2,1) = g(1,2)
438  g(2,2) = y(1,2)**2+y(2,2)**2+y(3,2)**2
439  g(2,3) = y(1,2)*y(1,3)+y(2,2)*y(2,3)+y(3,2)*y(3,3)
440  g(3,1) = g(1,3)
441  g(3,2) = g(2,3)
442  g(3,3) = y(1,3)**2+y(2,3)**2+y(3,3)**2
443 
444  end function metric_inverse
445 
446 
448  function metric_inverse_single( self, xi, component1, component2 )result(g)
449  class(sll_t_mapping_3d), intent( inout ) :: self
450  sll_real64, intent( in ) :: xi(3)
451  sll_int32, intent( in ) :: component1, component2
452  sll_real64 :: g
453  sll_real64 :: y(3,3)
454 
455  y = self%jacobian_matrix_inverse(xi)
456  g = y(component1,1)*y(component2,1)+&
457  y(component1,2)*y(component2,2)+&
458  y(component1,3)*y(component2,3)
459 
460  end function metric_inverse_single
461 
462 
464  function metric_single_jacobian( self, xi, component1, component2 )result(g)
465  class(sll_t_mapping_3d), intent( inout ) :: self
466  sll_real64, intent( in ) :: xi(3)
467  sll_int32, intent( in ) :: component1, component2
468  sll_real64 :: g
469  !local variables
470  sll_real64 :: y(3,3)
471 
472  y = self%jacobian_matrix(xi)
473 
474  if( self%flag3d) then
475  g = (y(1,component1)*y(1,component2)+&
476  y(2,component1)*y(2,component2)+&
477  y(3,component1)*y(3,component2) )/ (y(1,1) * y(2,2) * y(3,3) +&
478  y(1,2) * y(2,3) * y(3,1) +&
479  y(1,3) * y(2,1) * y(3,2) -&
480  y(1,3) * y(2,2) * y(3,1) -&
481  y(1,2) * y(2,1) * y(3,3) -&
482  y(1,1) * y(2,3) * y(3,2))
483  else
484  g = (y(1,component1)*y(1,component2)+&
485  y(2,component1)*y(2,component2)+&
486  y(3,component1)*y(3,component2) )/ (y(3,3) * ( y(1,1) * y(2,2) - y(1,2) * y(2,1) ) )
487  end if
488 
489  end function metric_single_jacobian
490 
491 
493  function metric_inverse_single_jacobian( self, xi, component1, component2 )result(g)
494  class(sll_t_mapping_3d), intent( inout ) :: self
495  sll_real64, intent( in ) :: xi(3)
496  sll_int32, intent( in ) :: component1, component2
497  sll_real64 :: g
498  !local variables
499  sll_real64 :: w(3,3), y(3,3)
500 
501 
502 !!$ if( self%flag3d) then
503  y = self%jacobian_matrix_inverse(xi)
504  w(1,1) = self%jacobian(xi)
505  g = (y(component1,1)*y(component2,1)+&
506  y(component1,2)*y(component2,2)+&
507  y(component1,3)*y(component2,3)) * w(1,1)
508 !!$ else
509 !!$ w = self%jacobian_matrix(xi)
510 !!$ y = 0._f64
511 !!$ y(1,1) = w(2,2) * w(3,3)
512 !!$ y(1,2) = - w(1,2) * w(3,3)
513 !!$ y(2,1) = - w(2,1) * w(3,3)
514 !!$ y(2,2) = w(1,1) * w(3,3)
515 !!$ y(3,3) = w(1,1) * w(2,2) - w(1,2) * w(2,1)
516 !!$
517 !!$ g = (y(component1,1)*y(component2,1)+&
518 !!$ y(component1,2)*y(component2,2)+&
519 !!$ y(component1,3)*y(component2,3))* (w(3,3) * ( w(1,1) * w(2,2) - w(1,2) * w(2,1) ) )
520 !!$ end if
521 
522  end function metric_inverse_single_jacobian
523 
524 
526  subroutine init( self, params, x1_func, x2_func, x3_func, jac11, jac12, jac13, jac21, jac22, jac23, jac31, jac32, jac33, jacob, xi1_func, xi2_func, xi3_func, flag2d, flag3d, n_cells, deg, Lx, volume )
527  class(sll_t_mapping_3d), intent( out ) :: self
528  sll_real64, dimension(:), intent( in ) :: params
529  procedure(sll_i_eval_function) :: x1_func
530  procedure(sll_i_eval_function) :: x2_func
531  procedure(sll_i_eval_function) :: x3_func
532  procedure(sll_i_eval_function), optional :: jac11
533  procedure(sll_i_eval_function), optional :: jac12
534  procedure(sll_i_eval_function), optional :: jac13
535  procedure(sll_i_eval_function), optional :: jac21
536  procedure(sll_i_eval_function), optional :: jac22
537  procedure(sll_i_eval_function), optional :: jac23
538  procedure(sll_i_eval_function), optional :: jac31
539  procedure(sll_i_eval_function), optional :: jac32
540  procedure(sll_i_eval_function), optional :: jac33
541  procedure(sll_i_eval_function), optional :: jacob
542  procedure(sll_i_eval_function), optional :: xi1_func
543  procedure(sll_i_eval_function), optional :: xi2_func
544  procedure(sll_i_eval_function), optional :: xi3_func
545  logical, optional :: flag2d
546  logical, optional :: flag3d
547  sll_int32, optional :: n_cells(3)
548  sll_int32, optional :: deg(3)
549  sll_real64, optional :: lx(3)
550  sll_real64, optional :: volume
551  !local variables
552  sll_int32 :: ierr
553  sll_real64, allocatable :: x1_func_dofs(:)
554  sll_real64, allocatable :: x2_func_dofs(:)
555  sll_real64, allocatable :: x3_func_dofs(:)
556  type(sll_t_matrix_csr) :: matrix(3)
557  type(sll_t_linear_solver_mgmres) :: matrix_solver(3)
558  type(sll_t_linear_solver_kron) :: kron_solver
559  sll_real64, allocatable :: rhs(:,:)
560  sll_real64, allocatable :: tk(:,:), xk(:,:)
561  sll_int32 :: ntotal0, n_dofs0(3), ntotal1, n_dofs1(3)
562  sll_int32 :: i, j, k
563  sll_int32 :: deg1(3)
564 
565  sll_allocate(self%j_matrix(1:3,1:3), ierr)
566  sll_allocate(self%params(1:size(params)),ierr)
567  self%params = params
568  self%x1_func => x1_func
569  self%x2_func => x2_func
570  self%x3_func => x3_func
571 
572  if( present(xi1_func) .and. present(xi2_func) .and. present(xi3_func) ) then
573  self%xi1_func => xi1_func
574  self%xi2_func => xi2_func
575  self%xi3_func => xi3_func
576  !self%cylinder_params = self%params(1:3)
577  self%inverse = .true.
578  end if
579  if( present(jac11) .and. present(jacob)) then
580  self%j_matrix(1,1)%f => jac11
581  self%j_matrix(1,2)%f => jac12
582  self%j_matrix(1,3)%f => jac13
583  self%j_matrix(2,1)%f => jac21
584  self%j_matrix(2,2)%f => jac22
585  self%j_matrix(2,3)%f => jac23
586  self%j_matrix(3,1)%f => jac31
587  self%j_matrix(3,2)%f => jac32
588  self%j_matrix(3,3)%f => jac33
589 
590  self%flag= .true.
591  self%jacob => jacob
592  end if
593  if(params(1) == 0._f64) then
594  self%singular = .true.
595  print*, 'Error: singular mapping not yet implemented'
596  end if
597 
598 
599  if( present(flag2d) )then
600  self%flag2d = flag2d
601  end if
602 
603  if( present(flag3d) )then
604  self%flag2d = flag2d
605  self%flag3d = flag3d
606  end if
607 
608  if( present(lx) )then
609  self%Lx = lx
610  end if
611 
612  if( present(volume) )then
613  self%volume = volume
614  end if
615 
616  if( present(n_cells) .and. present(deg) ) then
617  self%n_cells = n_cells
618  self%deg = deg
619  deg1 = deg-1
620  self%flag= .false.
621 
622  n_dofs0 = self%n_cells
623  n_dofs0(1) = self%n_cells(1)+self%deg(1)
624  n_dofs0(3) = self%n_cells(3)+self%deg(3)
625  n_dofs1 = n_dofs0
626  n_dofs1(1) = self%n_cells(1)+deg1(1)
627  ntotal0 = product(n_dofs0)
628  ntotal1 = product(n_dofs1)
629 
630  call sll_s_spline_pp_init_3d(self%spline_3d, self%deg, self%n_cells, [1,0,1])
631  allocate( x1_func_dofs(1:ntotal0) )
632  allocate( x2_func_dofs(1:ntotal0) )
633  allocate( x3_func_dofs(1:ntotal0) )
634  allocate( self%x1_func_dofs_pp(1:product(self%deg+1), product(self%n_cells)) )
635  allocate( self%x2_func_dofs_pp(1:product(self%deg+1), product(self%n_cells)) )
636  allocate( self%x3_func_dofs_pp(1:product(self%deg+1), product(self%n_cells)) )
637  x1_func_dofs = 0._f64
638  x2_func_dofs = 0._f64
639  x3_func_dofs = 0._f64
640  self%x1_func_dofs_pp = 0._f64
641  self%x2_func_dofs_pp = 0._f64
642  self%x3_func_dofs_pp = 0._f64
643 
644  allocate( tk(maxval(self%n_cells)+2*maxval(self%deg)+1, 3) )
645  allocate( xk(maxval(n_dofs0), 3) )
646  allocate( rhs(1:ntotal0, 3) )
647  tk = 0._f64
648  xk = 0._f64
649  rhs = 0._f64
650 
651 
652  ! knot sequence
653  !open
654  tk(1:self%deg(1),1) = 0._f64
655  do i = 1, self%n_cells(1)+1
656  tk(self%deg(1)+i,1) = real(i-1,f64)/real(self%n_cells(1),f64)
657  end do
658  tk(self%n_cells(1)+self%deg(1)+2:self%n_cells(1)+2*self%deg(1)+1,1) = 1._f64
659 
660  tk(1:self%deg(3),3) = 0._f64
661  do i = 1, self%n_cells(3)+1
662  tk(self%deg(3)+i,3) = real(i-1,f64)/real(self%n_cells(3),f64)
663  end do
664  tk(self%n_cells(3)+self%deg(3)+2:self%n_cells(3)+2*self%deg(3)+1,3) = 1._f64
665 
666  !periodic
667  do j = 2, 2
668  do i = 1, self%n_cells(j)
669  tk(self%deg(j)+i,j) = real(i-1,f64)/real(self%n_cells(j),f64)
670  end do
671  do i = 1, self%deg(j)
672  tk(i,j) = tk(self%n_cells(j)+i,j)-1._f64
673  tk(self%n_cells(j)+self%deg(j)+i,j) = tk(self%deg(j)+i,j) + 1._f64
674  end do
675  end do
676 
677 
678  !greville points
679  do i = 1, n_dofs0(1)
680  xk(i,1) = sum(tk(1+i:i+self%deg(1),1))/real(self%deg(1),f64)
681  end do
682 
683  do i = 1, n_dofs0(3)
684  xk(i,3) = sum(tk(1+i:i+self%deg(3),3))/real(self%deg(3),f64)
685  end do
686 
687  !periodic
688  do j = 2, 2
689  if( modulo(real(self%deg(j),f64),2._f64) == 0._f64) then
690  xk(1:n_dofs0(j),j) = 0.5_f64*(tk(self%deg(j)+1:self%deg(j)+self%n_cells(j),j)+tk(self%deg(j)+2:self%deg(j)+1+self%n_cells(j),j))
691  else
692  xk(1:n_dofs0(j),j) = tk(self%deg(j)+1:self%deg(j)+self%n_cells(j),j)
693  end if
694  end do
695 
696  ! interpolation matrix
697  call calculate_interpolation_matrix_1d( self%n_cells(1), self%deg(1), xk(1:n_dofs0(1),1), self%spline_3d%spline1, matrix(1) )
698  call calculate_interpolation_matrix_1d_periodic( self%n_cells(2), self%deg(2), self%spline_3d%spline2, matrix(2) )
699  call calculate_interpolation_matrix_1d( self%n_cells(3), self%deg(3), xk(1:n_dofs0(3),3), self%spline_3d%spline3, matrix(3) )
700 
701  do j = 1, 3
702  call matrix_solver(j)%create( matrix(j) )
703  matrix_solver(j)%atol = 1d-13
704  end do
705  !matrix_solver(2)%verbose = .true.
706 
707  call kron_solver%create( linear_solver_a=matrix_solver(1), &
708  linear_solver_b=matrix_solver(2), &
709  linear_solver_c=matrix_solver(3) )
710 
711 
712  !rhs evaluation from transformation function
713  do k = 1, n_dofs0(3)
714  do j = 1, n_dofs0(2)
715  do i = 1, n_dofs0(1)
716  rhs( i + (j-1)*n_dofs0(1) + (k-1)*n_dofs0(1)*n_dofs0(2), 1 ) = x1_func( [xk(i,1), xk(j,2), xk(k,3)], params )
717  rhs( i + (j-1)*n_dofs0(1) + (k-1)*n_dofs0(1)*n_dofs0(2), 2 ) = x2_func( [xk(i,1), xk(j,2), xk(k,3)], params )
718  rhs( i + (j-1)*n_dofs0(1) + (k-1)*n_dofs0(1)*n_dofs0(2), 3 ) = x3_func( [xk(i,1), xk(j,2), xk(k,3)], params )
719  end do
720  end do
721  end do
722 
723  call kron_solver%solve( rhs(:,1), x1_func_dofs)
724  call kron_solver%solve( rhs(:,2), x2_func_dofs)
725  call kron_solver%solve( rhs(:,3), x3_func_dofs)
726 
727 
728  call sll_s_spline_pp_b_to_pp_3d_clamped_2full( self%spline_3d, self%n_cells, x1_func_dofs, self%x1_func_dofs_pp)
729  call sll_s_spline_pp_b_to_pp_3d_clamped_2full( self%spline_3d, self%n_cells, x2_func_dofs, self%x2_func_dofs_pp)
730  call sll_s_spline_pp_b_to_pp_3d_clamped_2full( self%spline_3d, self%n_cells, x3_func_dofs, self%x3_func_dofs_pp)
731 
732  end if
733 
734  end subroutine init
735 
736 
738  subroutine init_from_file( self, filename )
739  class(sll_t_mapping_3d), intent( out ) :: self
740  character(len=*), intent( in ) :: filename
741  !local variables
742  sll_int32 :: input_file
743  sll_int32 :: io_stat
744  sll_int32 :: nparams
745  sll_real64 :: params(12)
746  character(len=256) :: mapping_case
747  sll_int32 :: n_cells(3) = 3
748  sll_int32 :: deg(3) = 1
749  sll_real64 :: vol = 1._f64
750  sll_real64 :: lx(3) = 1._f64
751  namelist /trafo/ nparams, params, mapping_case, n_cells, deg
752 
753  ! Read parameters from file
754  open(newunit = input_file, file=trim(filename), iostat=io_stat)
755  if (io_stat /= 0) then
756  print*, 'init_mapping() failed to open file ', filename
757  stop
758  end if
759 
760  read(input_file, trafo)
761  close(input_file)
762 
764  select case(trim(mapping_case))
765  case( "cylindrical_sqrt" )
766  lx(1:2) = 2._f64*(params(2)-params(1))
767  lx(3) = params(3)
768  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
773  sll_f_cylindrical_sqrt_jacobian, lx=lx, volume=vol)
774  case( "cylindrical_sqrt_discrete" )
775  lx(1:2) = 2._f64*(params(2)-params(1))
776  lx(3) = params(3)
777  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
779  n_cells=n_cells, deg=deg, lx=lx, volume=vol )
780  case( "cylindrical_sqrt_inverse" )
781  lx(1:2) = 2._f64*(params(2)-params(1))
782  lx(3) = params(3)
783  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
790  lx=lx, volume=vol)
791  case( "cylindrical_sqrt_discrete_inverse" )
792  lx(1:2) = 2._f64*(params(2)-params(1))
793  lx(3) = params(3)
794  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
797  n_cells=n_cells, deg=deg, lx=lx, volume=vol )
798  case( "cylindrical" )
799  lx(1:2) = 2._f64*(params(2)-params(1))
800  lx(3) = params(3)
801  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
806  sll_f_cylindrical_jacobian, lx=lx, volume=vol)
807 
808  case( "cylindrical_discrete" )
809  lx(1:2) = 2._f64*(params(2)-params(1))
810  lx(3) = params(3)
811  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
813  flag2d = .true., n_cells=n_cells, deg=deg, lx=lx, volume=vol )
814  case( "cylindrical_inverse" )
815  lx(1:2) = 2._f64*(params(2)-params(1))
816  lx(3) = params(3)
817  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
824  lx=lx, volume=vol)
825  case( "cylindrical_discrete_inverse" )
826  lx(1:2) = 2._f64*(params(2)-params(1))
827  lx(3) = params(3)
828  vol = sll_p_pi * (params(2)-params(1))**2 * params(3)
831  n_cells=n_cells, deg=deg, lx=lx, volume=vol )
832  case( "spherical" )
833  vol = 4._f64/3._f64 * sll_p_pi * (params(2)-params(1))**3
834  call self%init(params, sll_f_spherical_x1, sll_f_spherical_x2, sll_f_spherical_x3, &
838  sll_f_spherical_jacobian, flag3d = .true., lx=lx, volume=vol)
839  case( "elliptical" )
840  lx(1) = 3.1_f64*params(2)
841  lx(1) = 2.4_f64*params(2)
842  lx(3) = params(3)
843  vol = sll_p_pi * 7.44_f64* params(2)**2 * params(3)
848  sll_f_elliptical_jacobian, lx=lx, volume=vol)
849  case( "parallelogram" )
850  lx = params(1:3)
851  vol = product(params(1:3))
856  sll_f_parallelogram_jacobian, flag2d = .true., lx=lx, volume=vol)
857  case( "colbound" )
858  lx = params(1:3)
859  vol = product(params(1:3))
860  call self%init(params, sll_f_colbound_x1, sll_f_colbound_x2, sll_f_colbound_x3, &
864  sll_f_colbound_jacobian, flag2d = .true., lx=lx, volume=vol)
865  case( "colella" )
866  lx = params(1:3)
867  vol = product(params(1:3))
868  call self%init(params, sll_f_colella_x1, sll_f_colella_x2, sll_f_colella_x3, &
872  sll_f_colella_jacobian, flag2d = .true., lx=lx, volume=vol)
873  case( "colella_discrete" )
874  lx = params(1:3)
875  vol = product(params(1:3))
876  call self%init(params, sll_f_colella_x1, sll_f_colella_x2, sll_f_colella_x3, &
877  flag2d = .true., n_cells=n_cells, deg=deg, lx=lx, volume=vol )
878  case( "orthogonal" )
879  lx = params(1:3)
880  vol = product(params(1:3))
885  sll_f_orthogonal_jacobian, lx=lx, volume=vol )
886  case( "orthogonal_discrete" )
887  vol = product(params(1:3))
889  n_cells=n_cells, deg=deg, lx=lx, volume=vol)
890  case( "polynomial" )
891  lx = params(1:3)
892  vol = product(params(1:3))
897  sll_f_polynomial_jacobian, lx=lx, volume=vol)
898  case( "polynomial_discrete" )
899  lx = params(1:3)
900  vol = product(params(1:3))
902  n_cells=n_cells, deg=deg, lx=lx, volume=vol)
903  case( "scaling")
904  lx = params(1:3)
905  vol = product(params(1:3))
906  call self%init(params, sll_f_scaling_x1, sll_f_scaling_x2, sll_f_scaling_x3, &
910  sll_f_scaling_jacobian, lx=lx, volume=vol)
911  case( "scaling_discrete")
912  lx = params(1:3)
913  vol = product(params(1:3))
914  call self%init(params, sll_f_scaling_x1, sll_f_scaling_x2, sll_f_scaling_x3, &
915  n_cells=n_cells, deg=deg, lx=lx, volume=vol)
916  case default
917  print*, 'error init_mapping: mapping name not implemented'
918  end select
919 
920  end subroutine init_from_file
921 
922 
924  subroutine free (self )
925  class(sll_t_mapping_3d), intent(inout) :: self
926 
927 
928  self%x1_func => null()
929  self%x2_func => null()
930  self%x3_func => null()
931  DEALLOCATE(self%j_matrix)
932  DEALLOCATE(self%params)
933 
934  end subroutine free
935 
936 
938  subroutine calculate_interpolation_matrix_1d( n_cells, deg, xk, spline, matrix )
939  sll_int32, intent( in ) :: n_cells
940  sll_int32, intent( in ) :: deg
941  sll_real64, intent( in ) :: xk(:)
942  type( sll_t_spline_pp_1d), intent( in ) :: spline
943  type(sll_t_matrix_csr), intent( out ) :: matrix
944  !local variables
945  sll_int32 :: row, column, ind, i
946  sll_int32 :: box, n_nnz, n_dofs
947  sll_real64 :: xi
948 
949  n_dofs = n_cells + deg
950  n_nnz = n_dofs*(deg+1)
951 
952  call matrix%create( n_rows=n_dofs, n_cols=n_dofs, n_nnz=n_nnz )
953  matrix%arr_ia(1)=1
954  do row = 2, n_dofs+1
955  matrix%arr_ia(row) = matrix%arr_ia(row-1) + deg+1
956  end do
957 
958  ind = 1
959  do row = 1, floor(0.5_f64*real(deg,f64))
960  do column = 1, deg+1
961  matrix%arr_ja(ind) = column
962  ind = ind+1
963  end do
964  end do
965  do row = 1, n_cells
966  do column = row, row+deg
967  matrix%arr_ja(ind) = column
968  ind = ind+1
969  end do
970  end do
971  do row = 1, ceiling(0.5_f64*real(deg,f64))
972  do column = n_cells, n_dofs
973  matrix%arr_ja(ind) = column
974  ind = ind+1
975  end do
976  end do
977  matrix%arr_a = 0.0_f64
978  sll_assert( ind == matrix%n_nnz+1 )
979  ind = 1
980 
981  do row = 1, n_dofs
982  xi = xk(row)*real(n_cells,f64)
983  box = floor( xi ) + 1
984  xi = xi - real(box-1, f64)
985  if( box == n_cells + 1 ) then
986  xi = 1._f64
987  box = n_cells
988  end if
989 
990  if(box <= deg-1)then
991  do i = 1, deg+1
992  matrix%arr_a(1,ind) = sll_f_spline_pp_horner_1d( deg, spline%poly_coeffs_boundary_left(:,:,box), xi, i)
993  ind = ind+1
994  end do
995  else if(box >= n_cells-deg+2)then
996  do i = 1, deg+1
997  matrix%arr_a(1,ind) = sll_f_spline_pp_horner_1d( deg, spline%poly_coeffs_boundary_right(:,:,box-1-n_cells+deg), xi, i)
998  ind = ind+1
999  end do
1000  else
1001  do i = 1, deg+1
1002  matrix%arr_a(1,ind) = sll_f_spline_pp_horner_1d( deg, spline%poly_coeffs, xi, i)
1003  ind = ind+1
1004  end do
1005  end if
1006  end do
1007  sll_assert( ind == matrix%n_nnz+1 )
1008 
1009  end subroutine calculate_interpolation_matrix_1d
1010 
1011 
1013  subroutine calculate_interpolation_matrix_1d_periodic( n_cells, deg, spline, matrix )
1014  sll_int32, intent( in ) :: n_cells
1015  sll_int32, intent( in ) :: deg
1016  type( sll_t_spline_pp_1d), intent( in ) :: spline
1017  type(sll_t_matrix_csr), intent( out ) :: matrix
1018  !local variables
1019  sll_int32 :: row, column, ind, i
1020  sll_int32 :: n_nnz
1021  sll_real64 :: xi, val(1:deg+1)
1022 
1023  n_nnz = n_cells*(deg+1)
1024 
1025  call matrix%create( n_rows=n_cells, n_cols=n_cells, n_nnz=n_nnz )
1026  matrix%arr_ia(1)=1
1027  do row = 2, n_cells+1
1028  matrix%arr_ia(row) = matrix%arr_ia(row-1) + deg+1
1029  end do
1030 
1031  ind = 1
1032  do row = 1, deg
1033  do column = 1, row
1034  matrix%arr_ja(ind) = column
1035  ind = ind+1
1036  end do
1037  do column = n_cells+row-deg, n_cells
1038  matrix%arr_ja(ind) = column
1039  ind = ind+1
1040  end do
1041  end do
1042 
1043  do row = deg+1, n_cells
1044  do column = row-deg, row
1045  matrix%arr_ja(ind) = column
1046  ind = ind+1
1047  end do
1048  end do
1049 
1050 
1051 
1052  matrix%arr_a = 0.0_f64
1053  sll_assert( ind == matrix%n_nnz+1 )
1054 
1055  if( modulo(real(deg,f64),2._f64) == 0._f64)then
1056  xi = 0.5_f64
1057  else
1058  xi = 0._f64
1059  end if
1060 
1061  do i = 1, deg+1
1062  val(i) = sll_f_spline_pp_horner_1d( deg, spline%poly_coeffs, xi, i)
1063  end do
1064 
1065  ind = 1
1066  do row = 1, deg
1067  do i = deg+2-row, deg+1
1068  matrix%arr_a(1,ind) = val(i)
1069  ind = ind+1
1070  end do
1071  do i = 1, deg+1-row
1072  matrix%arr_a(1,ind) = val(i)
1073  ind = ind+1
1074  end do
1075  end do
1076 
1077  do row = deg+1, n_cells
1078  matrix%arr_a(1,ind:ind+deg) = val
1079  ind = ind+deg+1
1080  end do
1081 
1082  sll_assert( ind == matrix%n_nnz+1 )
1083 
1085 
1086 
1088  subroutine convert_x_to_xbox( self, position, xi, box )
1089  class(sll_t_mapping_3d), intent(inout) :: self
1090  sll_real64, intent( in ) :: position(3)
1091  sll_real64, intent( out ) :: xi(3)
1092  sll_int32, intent( out ) :: box(3)
1093 
1094  xi = position * real(self%n_cells,f64)
1095  box = floor( xi ) + 1
1096  xi = xi - real(box-1, f64)
1097 
1098  if( box(1) == self%n_cells(1) + 1 ) then
1099  if( xi(1) == 0._f64)then
1100  xi(1) = 1._f64
1101  box(1) = self%n_cells(1)
1102  else
1103  print*, 'box, x, xbox', box, position(1), xi(1)
1104  sll_error('convert_x_to_xbox', 'box1 value to high' )
1105  end if
1106  else if( box(1) == 0 ) then
1107  print*, 'box, x, xbox', box, position(1), xi(1)
1108  sll_error('convert_x_to_xbox', 'box1 value to low' )
1109  end if
1110 
1111  if( box(2) == self%n_cells(2) + 1 ) then
1112  if( xi(2) == 0._f64)then
1113  xi(2) = 1._f64
1114  box(2) = self%n_cells(2)
1115  else
1116  print*, 'box, x, xbox', box, position(2), xi(2)
1117  sll_error('convert_x_to_xbox', 'box2 value to high' )
1118  end if
1119  else if( box(2) == 0 ) then
1120  print*, 'box, x, xbox', box, position(2), xi(2)
1121  sll_error('convert_x_to_xbox', 'box2 value to low' )
1122  end if
1123 
1124 
1125  if( box(3) == self%n_cells(3) + 1 ) then
1126  if( xi(3) == 0._f64)then
1127  xi(3) = 1._f64
1128  box(3) = self%n_cells(3)
1129  else
1130  print*, 'box, x, xbox', box, position(3), xi(3)
1131  sll_error('convert_x_to_xbox', 'box3 value to high' )
1132  end if
1133  else if( box(3) == 0 ) then
1134  print*, 'box, x, xbox', box, position(3), xi(3)
1135  sll_error('convert_x_to_xbox', 'box3 value to low' )
1136  end if
1137 
1138  end subroutine convert_x_to_xbox
1139 
1140 
1141 end module sll_m_mapping_3d
abstract interface for mapping functions
definition of analytical coordinate transformations and their jacobi matrix, inverse jacobi matrix an...
real(kind=f64) function, public sll_f_colbound_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_polynomial_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_scaling_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_orthogonal_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_scaling_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_scaling_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_scaling_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_parallelogram_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_scaling_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_orthogonal_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_scaling_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colella_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colbound_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_orthogonal_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_scaling_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_polynomial_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_xi2(x, params)
direct mapping
real(kind=f64) function, public sll_f_spherical_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_xi1(x, params)
direct mapping
real(kind=f64) function, public sll_f_scaling_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_cylindrical_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colella_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_spherical_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_spherical_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_orthogonal_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_scaling_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_cylindrical_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_polynomial_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_scaling_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_sqrt_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_polynomial_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colella_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_orthogonal_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_polynomial_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_xi1(x, params)
direct mapping
real(kind=f64) function, public sll_f_elliptical_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_parallelogram_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_colbound_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_xi2(x, params)
direct mapping
real(kind=f64) function, public sll_f_spherical_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_parallelogram_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_elliptical_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jac12(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac23(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_scaling_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_xi3(x, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_orthogonal_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colbound_jac31(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_x2(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colella_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_spherical_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_spherical_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jac22(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_scaling_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_jac11(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colella_x3(xi, params)
direct mapping
real(kind=f64) function, public sll_f_colbound_jac13(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_polynomial_jac21(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_sqrt_x1(xi, params)
direct mapping
real(kind=f64) function, public sll_f_cylindrical_jac33(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_colbound_jac32(xi, params)
jacobian matrix
real(kind=f64) function, public sll_f_cylindrical_xi3(x, params)
direct mapping
real(kind=f64) function, public sll_f_spherical_jacobian(xi, params)
jacobian
real(kind=f64) function, public sll_f_scaling_jac22(xi, params)
jacobian matrix
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
module for a linear operator of kronecker solver
module for kronecker linear solver
module for a sequential gmres
Module interfaces for coordinate transformation.
real(kind=f64) function, dimension(3) get_xi(self, x)
Compute the logical coordinate vector Xi.
subroutine free(self)
Finalize the coordinate transformation.
real(kind=f64) function, dimension(3, 3) jacobian_matrix_inverse(self, xi)
Compute the entries of the inverse Jacobi matrix.
real(kind=f64) function, dimension(3, 3) jacobian_matrix(self, xi)
Compute the entries of the Jacobi matrix.
real(kind=f64) function metric_inverse_single(self, xi, component1, component2)
Compute a single entriy of the inverse metric.
subroutine init(self, params, x1_func, x2_func, x3_func, jac11, jac12, jac13, jac21, jac22, jac23, jac31, jac32, jac33, jacob, xi1_func, xi2_func, xi3_func, flag2d, flag3d, n_cells, deg, Lx, volume)
Initialize the coordinate transformation.
real(kind=f64) function, dimension(3) get_x(self, xi)
Compute all three components of X.
real(kind=f64) function metric_single(self, xi, component1, component2)
Compute a single entriy of the metric.
real(kind=f64) function jacobian(self, xi)
Compute the determinant of the Jacobi matrix.
real(kind=f64) function, dimension(3, 3) jacobian_matrix_inverse_transposed(self, xi)
Compute the entries of the transposed inverse Jacobi matrix.
real(kind=f64) function get_x3(self, xi)
Compute x3.
subroutine calculate_interpolation_matrix_1d_periodic(n_cells, deg, spline, matrix)
Helper function for spline mapping.
real(kind=f64) function metric_inverse_single_jacobian(self, xi, component1, component2)
Compute a single entriy of the inverse metric multiplied by the jacobian.
real(kind=f64) function get_x1(self, xi)
Compute x1.
real(kind=f64) function, dimension(3, 3) metric(self, xi)
Compute the entries of the metric.
subroutine init_from_file(self, filename)
Initialize the coordinate transformation from nml file.
real(kind=f64) function get_x2(self, xi)
Compute x2.
subroutine convert_x_to_xbox(self, position, xi, box)
Helper function to compute xbox.
real(kind=f64) function, dimension(3, 3) metric_inverse(self, xi)
Compute the entries of the inverse metric.
subroutine calculate_interpolation_matrix_1d(n_cells, deg, xk, spline, matrix)
Helper function for spline mapping.
real(kind=f64) function metric_single_jacobian(self, xi, component1, component2)
Compute a single entriy of the metric divided by the jacobian.
real(kind=f64) function, dimension(3, 3) jacobian_matrix_transposed(self, xi)
Compute the entries of the transposed Jacobi matrix.
module for Compressed Sparse Row Matrix (CSR)
Splines in pp form.
subroutine, public sll_s_spline_pp_b_to_pp_3d_clamped_2full(self, n_cells, b_coeffs, pp_coeffs)
Convert 3d spline in B form to spline in pp form for clamped spline.
subroutine, public sll_s_spline_pp_init_3d(self, degree, n_cells, boundary)
Initialize sll_t_spline_pp_3d object.
real(kind=f64) function, public sll_f_spline_pp_horner_3d(degree, pp_coeffs, x, indices, n_cells)
Perform a 3d hornerschema on the pp_coeffs at the indices.
real(kind=f64) function, public sll_f_spline_pp_horner_3d_d1(degree, pp_coeffs, x, indices, n_cells)
Perform a 3d hornerschema on the pp_coeffs at the indices.
real(kind=f64) function, public sll_f_spline_pp_horner_1d(degree, pp_coeffs, x, index)
Perform a 1d hornerschema on the pp_coeffs at index.
real(kind=f64) function, public sll_f_spline_pp_horner_3d_d3(degree, pp_coeffs, x, indices, n_cells)
Perform a 3d hornerschema on the pp_coeffs at the indices.
real(kind=f64) function, public sll_f_spline_pp_horner_3d_d2(degree, pp_coeffs, x, indices, n_cells)
Perform a 3d hornerschema on the pp_coeffs at the indices.
Module to select the kind parameter.
type collecting functions for analytical coordinate mapping
    Report Typos and Errors