5 #include "sll_working_precision.h"
6 #include "sll_assert.h"
12 class(sll_coordinate_transformation_2d_base),
pointer :: transf
14 sll_real64 :: sigma_x, sigma_y
24 class(sll_coordinate_transformation_2d_base),
target :: transf
25 sll_int32 :: data_position
26 sll_real64,
intent(in),
optional :: xc, yc, sigma_x, sigma_y
27 init_obj%data_position = data_position
29 init_obj%transf => transf
40 if (
present(sigma_x))
then
41 init_obj%sigma_x = sigma_x
43 init_obj%sigma_x = 1.0_f64
45 if (
present(sigma_y))
then
46 init_obj%sigma_y = sigma_y
48 init_obj%sigma_y = 1.0_f64
54 class(sll_coordinate_transformation_2d_base),
pointer :: transf
55 sll_real64,
dimension(:, :),
intent(out) :: data_out
56 class(sll_t_cartesian_mesh_2d),
pointer :: mesh
65 mesh => init_obj%transf%get_cartesian_mesh()
67 if (init_obj%data_position == cell_centered_field)
then
68 num_pts1 = mesh%num_cells1
69 num_pts2 = mesh%num_cells2
70 else if (init_obj%data_position == node_centered_field)
then
71 num_pts1 = mesh%num_cells1 + 1
72 num_pts2 = mesh%num_cells2 + 1
74 print *,
'sll_m_gaussian_2d_initializer: Pb with data_position', init_obj%data_position
76 sll_assert(
size(data_out, 1) .ge. num_pts1)
77 sll_assert(
size(data_out, 2) .ge. num_pts2)
78 if (init_obj%data_position == node_centered_field)
then
81 y = transf%x2_at_node(i, j)
82 x = transf%x1_at_node(i, j)
84 1.0_f64/(2*
sll_p_pi*init_obj%sigma_x*init_obj%sigma_y)*exp(-0.5_f64*( &
85 (x - init_obj%xc)**2/init_obj%sigma_x**2 + &
86 (y - init_obj%yc)**2/init_obj%sigma_y**2))
89 else if (init_obj%data_position == cell_centered_field)
then
93 y = transf%x2_at_cell(i, j)
94 x = transf%x1_at_cell(i, j)
95 jac = transf%jacobian_at_cell(i, j)
97 jac/(2*
sll_p_pi*init_obj%sigma_x*init_obj%sigma_y)*exp(-0.5_f64*( &
98 (x - init_obj%xc)**2/init_obj%sigma_x**2 + &
99 (y - init_obj%yc)**2/init_obj%sigma_y**2))
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
Initializes a Gaussian of the form exp -((x-xc)**2/(2*sigma_x)**2 + (y-yc)**2/(2*sigma_y)**2)
subroutine f_x1x2_gaussian_2d(init_obj, data_out)
subroutine initialize_gaussian_2d(init_obj, transf, data_position, xc, yc, sigma_x, sigma_y)