66 integer :: points_number
67 integer,
allocatable :: points_map(:)
68 integer,
allocatable :: points_map_inv(:)
70 real(real64) :: refl_error
71 real(real64),
allocatable :: kappa(:,:)
72 real(real64),
allocatable :: sigma_e(:,:)
73 real(real64),
allocatable :: sigma_m(:,:)
74 real(real64),
allocatable :: a(:,:)
75 real(real64),
allocatable :: b(:,:)
76 real(real64),
allocatable :: c(:,:)
77 real(real64),
allocatable :: mask(:)
78 complex(real64),
allocatable :: aux_ep(:,:,:)
79 complex(real64),
allocatable :: aux_mu(:,:,:)
80 complex(real64),
allocatable :: conv_plus(:,:,:)
81 complex(real64),
allocatable :: conv_minus(:,:,:)
82 complex(real64),
allocatable :: conv_plus_old(:,:,:)
83 complex(real64),
allocatable :: conv_minus_old(:,:,:)
84 logical :: parameters_initialized = .false.
86 type(accel_mem_t) :: buff_a, buff_b, buff_c, buff_conv_plus, buff_conv_minus, buff_map, buff_conv_plus_old
91 integer :: bc_ab_type(3)
92 real(real64) :: bc_bounds(2, 3)
93 logical :: ab_user_def
94 real(real64),
allocatable :: ab_ufn(:)
96 real(real64) :: ab_width
97 real(real64) :: mask_width
98 integer :: mask_points_number(3)
99 integer,
allocatable :: mask_points_map(:,:)
100 real(real64),
allocatable :: mask(:,:)
103 type(single_medium_box_t) :: medium(3)
105 integer :: constant_points_number
106 integer,
allocatable :: constant_points_map(:)
107 complex(real64),
allocatable :: constant_rs_state(:,:)
108 type(accel_mem_t) :: buff_constant_points_map
110 integer :: mirror_points_number(3) = 0
111 integer,
allocatable :: mirror_points_map(:,:)
113 logical :: do_plane_waves = .false.
114 type(external_waves_t) :: plane_wave
115 logical :: plane_waves_dims(1:3) = .false.
117 real(real64) :: zero_width
118 integer :: zero_points_number(3)
119 integer,
allocatable :: zero_points_map(:,:)
120 real(real64),
allocatable :: zero(:,:)
123 integer,
public,
parameter :: &
131 integer,
parameter :: &
132 MXLL_PLANE_WAVES_NEGATIVE_SIDE = -1, &
135 integer,
public,
parameter :: &
136 MXLL_AB_NOT_ABSORBING = 0, &
146 type(namespace_t),
intent(in) :: namespace
151 integer :: idim, nlines, icol, ncols, ab_shape_dim
152 real(real64) :: bounds(2, space%dim), ab_bounds(2, space%dim)
154 character(len=1024) :: string
155 character(len=50) :: ab_type_str
156 character(len=1),
dimension(3),
parameter :: dims = [
"x",
"y",
"z"]
157 logical :: plane_waves_check, ab_mask_check, ab_pml_check, plane_waves_set
158 logical :: constant_check, zero_check
159 real(real64) :: ep_factor, mu_factor, sigma_e_factor, sigma_m_factor
165 plane_waves_set = .false.
166 bc%bc_type(:) = mxll_bc_zero
167 bc%medium(:)%points_number = 0
168 bc%medium(:)%bdry_number = 0
198 if (
parse_block(namespace,
'MaxwellBoundaryConditions', blk) == 0)
then
203 if (nlines /= 1)
then
208 call messages_input_error(namespace,
'MaxwellBoundaryConditions',
'should consist of three columns')
217 select case (bc%bc_type(icol))
223 string =
'PEC Mirror'
225 string =
'PMC Mirror'
227 string =
'Plane waves'
229 string =
'Medium boundary'
231 write(
message(1),
'(a)')
'Unknown Maxwell boundary condition'
234 write(
message(1),
'(a,I1,a,a)')
'Maxwell boundary condition in direction ', icol,
': ', trim(string)
236 if (plane_waves_set .and. .not. (
parse_is_defined(namespace,
'MaxwellIncidentWaves')))
then
237 write(
message(1),
'(a)')
'Input: Maxwell boundary condition option is set to "plane_waves".'
238 write(
message(2),
'(a)')
'Input: User defined Maxwell plane waves have to be defined!'
243 plane_waves_check = .false.
244 ab_mask_check = .false.
245 ab_pml_check = .false.
246 constant_check = .false.
249 bc%ab_user_def = .false.
250 bc%bc_ab_type(:) = mxll_ab_not_absorbing
274 if (
parse_block(namespace,
'MaxwellAbsorbingBoundaries', blk) == 0)
then
277 if (nlines /= 1)
then
278 message(1) =
'MaxwellAbsorbingBounaries has to consist of one line!'
284 message(1) =
'MaxwellAbsorbingBoundaries has to consist of three columns!'
299 if (bc%bc_type(idim) == mxll_bc_zero) zero_check = .
true.
302 if (ab_mask_check .or. ab_pml_check)
then
305 write(
message(1),
'(a)')
"Please keep in mind that"
306 write(
message(2),
'(a)')
"with larger ABWidth, comes great responsibility."
307 write(
message(3),
'(a)')
"AbsorbingBoundaries occupy space in the simulation box,"
308 write(
message(4),
'(a)')
"hence choose your Lsize wisely."
313 bounds(1, :) = (gr%idx%nr(2, :) - gr%idx%enlarge(:))*gr%spacing(:)
314 bounds(2, :) = gr%idx%nr(2, :) * gr%spacing(:)
316 select case (bc%bc_type(idim))
320 bounds(1, idim) = (gr%idx%nr(2, idim) - gr%idx%enlarge(idim))*gr%spacing(idim)
321 bounds(2, idim) = (gr%idx%nr(2, idim)) * gr%spacing(idim)
325 bounds(1, idim) = (gr%idx%nr(2, idim) - 2*gr%idx%enlarge(idim))*gr%spacing(idim)
326 bounds(2, idim) = (gr%idx%nr(2, idim)) * gr%spacing(idim)
330 bounds(1, idim) = (gr%idx%nr(2, idim) - 2*gr%idx%enlarge(idim))*gr%spacing(idim)
331 bounds(2, idim) = (gr%idx%nr(2, idim)) * gr%spacing(idim)
332 plane_waves_check = .
true.
333 bc%do_plane_waves = .
true.
336 call bc_mxll_medium_init(gr, namespace, bounds, idim, ep_factor, mu_factor, sigma_e_factor, sigma_m_factor)
342 select type (box => gr%box)
345 if (space%is_periodic())
then
346 message(1) =
"Sphere box shape can only work for non-periodic systems"
349 ab_bounds(1, idim) = bounds(1, idim)
350 ab_bounds(2, idim) = bounds(1, idim)
352 if (.not. box%axes%orthogonal)
then
353 message(1) =
"Maxwell propagation does not work for non-orthogonal grids."
357 ab_shape_dim = space%dim
358 ab_bounds(1, idim) = bounds(1, idim)
359 ab_bounds(2, idim) = bounds(1, idim)
361 message(1) =
"Box shape for Maxwell propagation not supported yet"
365 if (bc%bc_ab_type(idim) /= mxll_ab_not_absorbing)
then
369 select case (bc%bc_ab_type(idim))
372 bc%zero_width = bc%ab_width
376 bc%mask_width = bc%ab_width
382 message(1) =
"Absorbing boundary type not implemented for Maxwell propagation"
388 select case (bc%bc_ab_type(idim))
390 bounds(1, idim) = ab_bounds(1, idim)
391 bounds(2, idim) = bounds(2, idim)
392 bc%bc_bounds(:, idim) = bounds(:, idim)
394 bc%bc_bounds(:, idim) = bounds(:, idim)
397 select type (box => gr%box)
399 select case (bc%bc_ab_type(idim))
412 string = trim(ab_type_str)//
" Absorbing Boundary"
413 write(string,
'(2a, f10.3,3a)') trim(string),
" in "//dims(idim)//
' direction spans from: ', &
416 write(
message(1),
'(a)') trim(string)
419 write(string,
'(a,f10.3,3a)') trim(string),&
423 write(
message(2),
'(a)') trim(string)
429 write(
message(1),
'(a,es10.3,3a)') &
432 write(
message(2),
'(a,es10.3,3a)') &
445 if (ab_mask_check)
then
450 if (ab_pml_check)
then
455 if (constant_check)
then
456 bounds(1, :) = gr%idx%nr(2, :) * gr%spacing(:)
457 bounds(2, :) = gr%idx%nr(2, :) * gr%spacing(:)
460 bounds(1, idim) = (gr%idx%nr(2, idim) - 2*gr%idx%enlarge(idim))*gr%spacing(idim)
461 bounds(2, idim) = (gr%idx%nr(2, idim)) * gr%spacing(idim)
468 if (plane_waves_check)
then
469 bounds(1, :) = gr%idx%nr(2, :) * gr%spacing(:)
470 bounds(2, :) = gr%idx%nr(2, :) * gr%spacing(:)
473 bounds(1, idim) = (gr%idx%nr(2, idim) - 2*gr%idx%enlarge(idim))*gr%spacing(idim)
474 bounds(2, idim) = (gr%idx%nr(2, idim)) * gr%spacing(idim)
483 bounds(1, :) = gr%idx%nr(2, :) * gr%spacing(:)
484 bounds(2, :) = gr%idx%nr(2, :) * gr%spacing(:)
486 if (bc%bc_type(idim) == mxll_bc_zero)
then
487 bounds(1, idim) = (gr%idx%nr(2, idim) - gr%idx%enlarge(idim))*gr%spacing(idim)
488 bounds(2, idim) = (gr%idx%nr(2, idim)) * gr%spacing(idim)
494 if (ab_mask_check)
then
498 if (ab_pml_check)
then
506 if (ab_mask_check .or. ab_pml_check)
then
523 safe_deallocate_a(bc%ab_ufn)
525 safe_deallocate_a(bc%mask_points_map)
526 safe_deallocate_a(bc%mask)
533 safe_deallocate_a(bc%constant_points_map)
534 safe_deallocate_a(bc%constant_rs_state)
539 safe_deallocate_a(bc%mirror_points_map)
543 safe_deallocate_a(bc%zero_points_map)
544 safe_deallocate_a(bc%zero)
551 type(
pml_t),
intent(inout) :: pml
555 safe_deallocate_a(pml%points_map)
556 safe_deallocate_a(pml%points_map_inv)
557 safe_deallocate_a(pml%kappa)
558 safe_deallocate_a(pml%sigma_e)
559 safe_deallocate_a(pml%sigma_m)
560 safe_deallocate_a(pml%a)
561 safe_deallocate_a(pml%b)
562 safe_deallocate_a(pml%c)
563 safe_deallocate_a(pml%mask)
564 safe_deallocate_a(pml%aux_ep)
565 safe_deallocate_a(pml%aux_mu)
566 safe_deallocate_a(pml%conv_plus)
567 safe_deallocate_a(pml%conv_minus)
568 safe_deallocate_a(pml%conv_plus_old)
569 safe_deallocate_a(pml%conv_minus_old)
587 subroutine bc_mxll_medium_init(gr, namespace, bounds, idim, ep_factor, mu_factor, sigma_e_factor, sigma_m_factor)
589 type(namespace_t),
intent(in) :: namespace
590 real(real64),
contiguous,
intent(inout) :: bounds(:,:)
591 integer,
intent(in) :: idim
592 real(real64),
intent(out) :: ep_factor
593 real(real64),
intent(out) :: mu_factor
594 real(real64),
intent(out) :: sigma_e_factor
595 real(real64),
intent(out) :: sigma_m_factor
597 real(real64) :: width
611 bounds(1,idim) = ( gr%idx%nr(2, idim) - gr%idx%enlarge(idim) ) * gr%spacing(idim)
612 bounds(1,idim) = bounds(1,idim) - width
613 bounds(2,idim) = ( gr%idx%nr(2, idim) ) * gr%spacing(idim)
660 type(namespace_t),
intent(in) :: namespace
661 real(real64),
contiguous,
intent(inout) :: ab_bounds(:,:)
662 integer,
intent(in) :: idim
664 real(real64) :: default_width
676 default_width =
m_two * gr%der%order * maxval(gr%spacing(1:3))
679 if (bc%ab_width < default_width)
then
680 bc%ab_width = default_width
681 write(
message(1),
'(a)')
'Absorbing boundary width has to be larger or equal than twice the derivatives order times spacing!'
682 write(
message(2),
'(a,es10.3)')
'Absorbing boundary width is set to: ', default_width
686 ab_bounds(1, idim) = ab_bounds(2, idim) - bc%ab_width
694 type(
grid_t),
intent(in) :: gr
695 type(namespace_t),
intent(in) :: namespace
696 real(real64),
contiguous,
intent(inout) :: ab_bounds(:,:)
697 integer,
intent(in) :: idim
702 bc%pml%width = bc%ab_width
721 call parse_variable(namespace,
'MaxwellABPMLReflectionError', 1.0e-16_real64, bc%pml%refl_error,
unit_one)
730 type(namespace_t),
intent(in) :: namespace
731 class(
space_t),
intent(in) :: space
733 integer :: err, idim, idim2
734 real(real64),
allocatable :: tmp(:)
735 logical :: mask_check, pml_check, medium_check
736 character(1) :: dim_label(3)
744 medium_check = .false.
746 dim_label = (/
'x',
'y',
'z'/)
756 medium_check = .
true.
761 safe_allocate(tmp(1:mesh%np))
767 safe_deallocate_a(tmp)
768 else if (pml_check)
then
769 safe_allocate(tmp(1:mesh%np))
774 call write_files(
"maxwell_sigma_e-"//dim_label(idim), tmp)
779 call write_files(
"maxwell_sigma_m-"//dim_label(idim), tmp)
784 call write_files(
"maxwell_sigma_pml_a_e-"//dim_label(idim), tmp)
786 safe_deallocate_a(tmp)
789 if (medium_check)
then
790 safe_allocate(tmp(1:mesh%np))
795 call write_files(
"maxwell_ep"//dim_label(idim), tmp)
803 call write_files(
"maxwell_c"//dim_label(idim), tmp)
808 call write_files(
"maxwell_aux_ep-"//dim_label(idim)//
"-"//dim_label(idim2), tmp)
813 call write_files(
"maxwell_aux_mu-"//dim_label(idim)//
"-"//dim_label(idim2), tmp)
817 safe_deallocate_a(tmp)
826 real(real64),
intent(in) :: pml_func(:)
828 real(real64),
contiguous,
intent(inout) :: io_func(:)
832 do ip_in = 1, bc%pml%points_number
833 ip = bc%pml%points_map(ip_in)
834 io_func(ip) = pml_func(ip_in)
840 real(real64),
contiguous,
intent(in) :: mask_func(:,:)
842 real(real64),
contiguous,
intent(inout) :: io_func(:)
843 integer,
intent(in) :: idim
847 do ip_in = 1, bc%mask_points_number(idim)
848 ip = bc%mask_points_map(ip_in, idim)
849 io_func(ip) = mask_func(ip_in, idim)
855 real(real64),
contiguous,
intent(in) :: medium_func(:)
857 real(real64),
contiguous,
intent(inout) :: io_func(:)
858 integer,
intent(in) :: idim
862 do ip_in = 1, bc%medium(idim)%points_number
863 ip = bc%medium(idim)%points_map(ip_in)
864 io_func(ip) = medium_func(ip_in)
870 character(len=*),
intent(in) :: filename
871 real(real64),
contiguous,
intent(in) :: tmp(:)
894 class(
mesh_t),
intent(in) :: mesh
895 real(real64),
contiguous,
intent(in) :: bounds(:,:)
897 integer :: ip, ip_in, ip_in_max, point_info, idim
909 if ((point_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
913 if (ip_in > ip_in_max) ip_in_max = ip_in
914 bc%mask_points_number(idim) = ip_in
917 safe_allocate(bc%mask(1:ip_in_max, 1:idim))
918 safe_allocate(bc%mask_points_map(1:ip_in_max, 1:idim))
926 if ((point_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
928 bc%mask_points_map(ip_in, idim) = ip
942 real(real64),
contiguous,
intent(in) :: bounds(:,:)
944 integer :: ip, ip_in, point_info
954 if (point_info == 1)
then
958 bc%pml%points_number = ip_in
959 safe_allocate(bc%pml%points_map(1:ip_in))
960 safe_allocate(bc%pml%points_map_inv(1:mesh%np))
961 bc%pml%points_map_inv = 0
965 if (point_info == 1)
then
967 bc%pml%points_map(ip_in) = ip
968 bc%pml%points_map_inv(ip) = ip_in
980 class(
mesh_t),
intent(in) :: mesh
981 real(real64),
contiguous,
intent(in) :: bounds(:,:)
983 integer :: ip, ip_in, point_info
993 if (point_info == 1)
then
997 bc%constant_points_number = ip_in
998 safe_allocate(bc%constant_points_map(1:ip_in))
999 safe_allocate(bc%constant_rs_state(1:ip_in, 1:3))
1005 if (point_info == 1)
then
1007 bc%constant_points_map(ip_in) = ip
1013 call accel_write_buffer(bc%buff_constant_points_map, bc%constant_points_number, bc%constant_points_map)
1024 class(
mesh_t),
intent(in) :: mesh
1025 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1027 integer :: ip, ip_in, point_info
1039 if (point_info == 1)
then
1043 bc%plane_wave%points_number = ip_in
1044 safe_allocate(bc%plane_wave%points_map(1:ip_in))
1050 if (point_info == 1)
then
1052 bc%plane_wave%points_map(ip_in) = ip
1058 call accel_write_buffer(bc%plane_wave%buff_map, bc%plane_wave%points_number, bc%plane_wave%points_map)
1069 class(
mesh_t),
intent(in) :: mesh
1070 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1072 integer :: ip, ip_in, ip_in_max, point_info, idim
1080 if (bc%bc_type(idim) == mxll_bc_zero)
then
1085 if ((point_info == 1) .and. (abs(mesh%x(idim, ip)) >= bounds(1, idim)))
then
1089 if (ip_in > ip_in_max) ip_in_max = ip_in
1092 bc%zero_points_number = ip_in
1093 safe_allocate(bc%zero(1:ip_in_max,3))
1094 safe_allocate(bc%zero_points_map(1:ip_in_max, 1:3))
1097 if (bc%bc_type(idim) == mxll_bc_zero)
then
1102 if ((point_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
1104 bc%zero_points_map(ip_in, idim) = ip
1118 class(
mesh_t),
intent(in) :: mesh
1119 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1121 integer :: ip, ip_in, ip_in_max, ip_bd, ip_bd_max, point_info, boundary_info, idim
1127 bc%medium(:)%points_number = 0
1128 bc%medium(:)%bdry_number = 0
1140 if ((point_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
1143 if ((boundary_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
1147 bc%medium(idim)%points_number = ip_in
1148 bc%medium(idim)%bdry_number = ip_bd
1149 ip_in_max = max(ip_in_max, ip_in)
1150 ip_bd_max = max(ip_bd_max, ip_bd)
1154 safe_allocate(bc%medium(idim)%points_map(1:ip_in_max))
1155 safe_allocate(bc%medium(idim)%bdry_map(1:ip_bd_max))
1165 if ((point_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
1167 bc%medium(idim)%points_map(ip_in) = ip
1169 if ((boundary_info == 1) .and. (abs(mesh%x_t(ip, idim)) >= bounds(1, idim)))
then
1171 bc%medium(idim)%bdry_map(ip_bd) = ip
1185 class(
space_t),
intent(in) :: space
1192 safe_allocate(bc%pml%kappa(1:bc%pml%points_number, 1:space%dim))
1193 safe_allocate(bc%pml%sigma_e(1:bc%pml%points_number, 1:space%dim))
1194 safe_allocate(bc%pml%sigma_m(1:bc%pml%points_number, 1:space%dim))
1195 safe_allocate(bc%pml%a(1:bc%pml%points_number, 1:space%dim))
1196 safe_allocate(bc%pml%b(1:bc%pml%points_number, 1:space%dim))
1197 safe_allocate(bc%pml%c(1:bc%pml%points_number, 1:3))
1198 safe_allocate(bc%pml%mask(1:bc%pml%points_number))
1199 safe_allocate(bc%pml%conv_plus(1:bc%pml%points_number, 1:3, 1:3))
1200 safe_allocate(bc%pml%conv_minus(1:bc%pml%points_number, 1:3, 1:3))
1201 safe_allocate(bc%pml%conv_plus_old(1:bc%pml%points_number, 1:3, 1:3))
1202 safe_allocate(bc%pml%conv_minus_old(1:bc%pml%points_number, 1:3, 1:3))
1203 safe_allocate(bc%pml%aux_ep(1:bc%pml%points_number, 1:3, 1:3))
1204 safe_allocate(bc%pml%aux_mu(1:bc%pml%points_number, 1:3, 1:3))
1206 bc%pml%kappa =
m_one
1213 bc%pml%conv_plus =
m_z0
1214 bc%pml%conv_minus =
m_z0
1215 bc%pml%conv_plus_old =
m_z0
1216 bc%pml%conv_minus_old =
m_z0
1224 int(bc%pml%points_number, int64)*space%dim*space%dim)
1226 int(bc%pml%points_number, int64)*space%dim*space%dim)
1228 int(bc%pml%points_number, int64)*space%dim*space%dim)
1233 call accel_write_buffer(bc%pml%buff_conv_plus, bc%pml%points_number, space%dim, space%dim, bc%pml%conv_plus)
1234 call accel_write_buffer(bc%pml%buff_conv_minus, bc%pml%points_number, space%dim, space%dim, bc%pml%conv_minus)
1235 call accel_write_buffer(bc%pml%buff_conv_plus_old, bc%pml%points_number, space%dim, space%dim, bc%pml%conv_plus_old)
1247 class(
space_t),
intent(in) :: space
1248 type(
grid_t),
intent(in) :: gr
1249 real(real64),
intent(in) :: c_factor
1250 real(real64),
optional,
intent(in) :: dt
1252 integer :: ip, ip_in, idim
1253 real(real64) :: width(3)
1254 real(real64) :: ddv(3), ss_e, ss_m, ss_max, aa_e, aa_m, bb_e, bb_m, gg, hh, kk, ll_e, ll_m
1255 real(real64),
allocatable :: tmp(:), tmp_grad(:,:)
1259 safe_allocate(tmp(gr%np_part))
1260 safe_allocate(tmp_grad(gr%np, 1:space%dim))
1266 width(1:3) = (/ bc%pml%width, bc%pml%width, bc%pml%width /)
1269 do ip_in = 1, bc%pml%points_number
1270 ip = bc%pml%points_map(ip_in)
1271 ddv(1:3) = abs(gr%x(1:3, ip)) - bc%bc_bounds(1, 1:3)
1272 do idim = 1, space%dim
1273 if (ddv(idim) >=
m_zero)
then
1274 gg = (ddv(idim)/bc%pml%width)**bc%pml%power
1275 hh = (
m_one-ddv(idim)/bc%pml%width)**bc%pml%power
1277 ss_max = -(bc%pml%power +
m_one)*
p_c*c_factor*
p_ep*
log(bc%pml%refl_error)/(
m_two * bc%pml%width)
1288 bc%pml%sigma_e(ip_in, idim) = ss_e
1289 bc%pml%sigma_m(ip_in, idim) = ss_m
1290 bc%pml%a(ip_in, idim) = aa_e
1291 bc%pml%b(ip_in, idim) = bb_e
1292 bc%pml%kappa(ip_in, idim) = kk
1293 bc%pml%mask(ip_in) = bc%pml%mask(ip_in) * (
m_one -
sin(ddv(idim)*
m_pi/(
m_two*(width(idim))))**2)
1295 bc%pml%kappa(ip_in, idim) =
m_one
1296 bc%pml%sigma_e(ip_in, idim) =
m_zero
1297 bc%pml%sigma_m(ip_in, idim) =
m_zero
1298 bc%pml%a(ip_in, idim) =
m_zero
1299 bc%pml%b(ip_in, idim) =
m_zero
1300 bc%pml%mask(ip_in) =
m_one
1306 do idim = 1, space%dim
1308 do ip_in = 1, bc%pml%points_number
1309 ip = bc%pml%points_map(ip_in)
1310 tmp(ip) =
p_ep / bc%pml%kappa(ip_in, idim)
1313 do ip_in = 1, bc%pml%points_number
1314 ip = bc%pml%points_map(ip_in)
1315 bc%pml%aux_ep(ip_in, :, idim) = tmp_grad(ip, :)/(
m_four*
p_ep*bc%pml%kappa(ip_in, idim))
1320 do idim = 1, space%dim
1322 tmp =
p_mu/c_factor**2
1323 do ip_in = 1, bc%pml%points_number
1324 ip = bc%pml%points_map(ip_in)
1325 tmp(ip) =
p_mu/c_factor**2 / bc%pml%kappa(ip_in, idim)
1328 do ip_in = 1, bc%pml%points_number
1329 ip = bc%pml%points_map(ip_in)
1330 bc%pml%aux_mu(ip_in, :, idim) = tmp_grad(ip, :)/(
m_four*
p_mu/c_factor**2 * bc%pml%kappa(ip_in, idim))
1335 do idim = 1, space%dim
1336 do ip_in = 1, bc%pml%points_number
1337 bc%pml%c(ip_in, idim) =
p_c*c_factor/bc%pml%kappa(ip_in, idim)
1340 safe_deallocate_a(tmp)
1341 safe_deallocate_a(tmp_grad)
1348 call accel_write_buffer(bc%pml%buff_conv_plus, bc%pml%points_number, space%dim, space%dim, bc%pml%conv_plus)
1349 call accel_write_buffer(bc%pml%buff_conv_minus, bc%pml%points_number, space%dim, space%dim, bc%pml%conv_minus)
1352 bc%pml%parameters_initialized = .
true.
1361 class(
space_t),
intent(in) :: space
1362 type(
grid_t),
intent(in) :: gr
1363 real(real64),
intent(in) :: c_factor
1364 real(real64),
intent(in) :: dt
1366 integer :: ip_in, ip, idir
1367 real(real64) :: ddv(1:space%dim), kappa, sigma, alpha
1371 do ip_in = 1, bc%pml%points_number
1372 ip = bc%pml%points_map(ip_in)
1373 ddv(1:3) = abs(gr%x(1:3, ip)) - bc%bc_bounds(1, 1:3)
1374 do idir = 1, space%dim
1375 if (ddv(idir) >=
m_zero)
then
1376 sigma = (ddv(idir)/bc%pml%width)**bc%pml%power * &
1382 bc%pml%b(ip_in, idir) =
exp(-(alpha + sigma/kappa)/
p_ep*dt)
1384 bc%pml%c(ip_in, idir) =
m_zero
1386 bc%pml%c(ip_in, idir) =
m_one/(kappa + kappa**2*alpha/sigma) * &
1387 (bc%pml%b(ip_in, idir) - 1)
1390 bc%pml%b(ip_in, idir) =
m_zero
1391 bc%pml%c(ip_in, idir) =
m_zero
1406 class(
mesh_t),
intent(in) :: mesh
1407 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1409 integer :: ip, ip_in, idim, ip_in_max
1410 real(real64) :: ddv(3), tmp(3), width(3)
1411 real(real64),
allocatable :: mask(:)
1417 ip_in_max = maxval(bc%mask_points_number(:))
1419 safe_allocate(mask(1:mesh%np))
1423 width(1:3) = bounds(2, 1:3) - bounds(1, 1:3)
1429 ddv(1:3) = abs(mesh%x(1:3, ip)) - bounds(1, 1:3)
1430 do idim = 1, mesh%box%dim
1432 if (ddv(idim) <= width(idim))
then
1438 mask(ip) = mask(ip) * tmp(idim)
1442 do idim = 1, mesh%box%dim
1443 do ip_in = 1, bc%mask_points_number(idim)
1444 ip = bc%mask_points_map(ip_in, idim)
1445 bc%mask(ip_in,idim) = mask(ip)
1449 safe_deallocate_a(mask)
1457 subroutine bc_mxll_generate_medium(bc, space, gr, bounds, ep_factor, mu_factor, sigma_e_factor, sigma_m_factor)
1459 class(
space_t),
intent(in) :: space
1460 type(
grid_t),
intent(in) :: gr
1461 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1462 real(real64),
intent(in) :: ep_factor
1463 real(real64),
intent(in) :: mu_factor
1464 real(real64),
intent(in) :: sigma_e_factor
1465 real(real64),
intent(in) :: sigma_m_factor
1467 integer :: ip, ipp, ip_in, ip_in_max, ip_bd, idim, point_info
1468 integer :: medium_points_number(3)
1469 real(real64) :: dd, dd_min, dd_max, xx(3), xxp(3)
1470 real(real64),
allocatable :: tmp(:), tmp_grad(:,:)
1476 ip_in_max = max(bc%medium(1)%points_number, bc%medium(2)%points_number, bc%medium(3)%points_number)
1477 medium_points_number(:) = [bc%medium(1)%points_number, bc%medium(2)%points_number, bc%medium(3)%points_number]
1478 dd_max = max(2*gr%spacing(1), 2*gr%spacing(2), 2*gr%spacing(3))
1479 safe_allocate(tmp(gr%np_part))
1480 safe_allocate(tmp_grad(1:gr%np_part,1:space%dim))
1484 bc%medium(idim)%points_number = medium_points_number(idim)
1485 bc%medium(idim)%aux_ep =
m_zero
1486 bc%medium(idim)%aux_mu =
m_zero
1487 bc%medium(idim)%c =
p_c
1491 do ip = 1, gr%np_part
1493 if ((point_info /= 0) .and. (abs(gr%x_t(ip, idim)) <= bounds(1, idim)))
then
1496 do ip_bd = 1, bc%medium(idim)%bdry_number
1497 ipp = bc%medium(idim)%bdry_map(ip_bd)
1498 xxp(:) = gr%x(:, ipp)
1499 dd = norm2(xx(1:3) - xxp(1:3))
1500 if (dd < dd_min) dd_min = dd
1506 do ip_in = 1, bc%medium(idim)%points_number
1507 ip = bc%medium(idim)%points_map(ip_in)
1508 bc%medium(idim)%aux_ep(ip_in, :) = &
1516 do ip = 1, gr%np_part
1518 if ((point_info == 1) .and. (abs(gr%x_t(ip, idim)) <= bounds(1, idim)))
then
1521 do ip_bd = 1, bc%medium(idim)%bdry_number
1522 ipp = bc%medium(idim)%bdry_map(ip_bd)
1523 xxp(:) = gr%x(:, ipp)
1524 dd = norm2(xx(1:3) - xxp(1:3))
1525 if (dd < dd_min) dd_min = dd
1531 do ip_in = 1, bc%medium(idim)%points_number
1532 ip = bc%medium(idim)%points_map(ip_in)
1533 bc%medium(idim)%aux_mu(ip_in, :) = &
1540 do ip_in = 1, bc%medium(idim)%points_number
1541 ip = bc%medium(idim)%points_map(ip_in)
1544 do ip_bd = 1, bc%medium(idim)%bdry_number
1545 ipp = bc%medium(idim)%bdry_map(ip_bd)
1546 xxp(:) = gr%x(:, ipp)
1547 dd = norm2(xx(1:3) - xxp(1:3))
1548 if (dd < dd_min) dd_min = dd
1550 bc%medium(idim)%ep(ip_in) =
p_ep * (
m_one + ep_factor &
1552 bc%medium(idim)%mu(ip_in) =
p_mu * (
m_one + mu_factor &
1554 bc%medium(idim)%sigma_e(ip_in) = (
m_one + sigma_e_factor &
1556 bc%medium(idim)%sigma_m(ip_in) = (
m_one + sigma_m_factor &
1558 bc%medium(idim)%c(ip_in) =
m_one /
sqrt(bc%medium(idim)%ep(ip_in) * bc%medium(idim)%mu(ip_in))
1562 safe_deallocate_a(tmp)
1563 safe_deallocate_a(tmp_grad)
1572 class(
mesh_t),
intent(in) :: mesh
1574 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1582 st%surface(1, 1)%spacing =
m_half*(mesh%spacing(2) + mesh%spacing(3))
1583 st%surface(1, 1)%origin(:) =
m_zero
1584 st%surface(1, 1)%origin(1) = -bounds(1, 1)
1585 st%surface(1, 1)%n(:) =
m_zero
1586 st%surface(1, 1)%n(1) = -
m_one
1587 st%surface(1, 1)%u(:) =
m_zero
1588 st%surface(1, 1)%u(2) = -
m_one
1589 st%surface(1, 1)%v(:) =
m_zero
1590 st%surface(1, 1)%v(3) =
m_one
1591 st%surface(1, 1)%nu = -int(bounds(1, 2)/mesh%spacing(2))
1592 st%surface(1, 1)%mu = int(bounds(1, 2)/mesh%spacing(2))
1593 st%surface(1, 1)%nv = -int(bounds(1, 3)/mesh%spacing(3))
1594 st%surface(1, 1)%mv = int(bounds(1, 3)/mesh%spacing(3))
1597 st%surface(2, 1)%spacing =
m_half*(mesh%spacing(2) + mesh%spacing(3))
1598 st%surface(2, 1)%origin(:) =
m_zero
1599 st%surface(2, 1)%origin(1) = bounds(1, 1)
1600 st%surface(2, 1)%n(:) =
m_zero
1601 st%surface(2, 1)%n(1) =
m_one
1602 st%surface(2, 1)%u(:) =
m_zero
1603 st%surface(2, 1)%u(2) =
m_one
1604 st%surface(2, 1)%v(:) =
m_zero
1605 st%surface(2, 1)%v(3) =
m_one
1606 st%surface(2, 1)%nu = -int(bounds(1, 2)/mesh%spacing(2))
1607 st%surface(2, 1)%mu = int(bounds(1, 2)/mesh%spacing(2))
1608 st%surface(2, 1)%nv = -int(bounds(1, 3)/mesh%spacing(3))
1609 st%surface(2, 1)%mv = int(bounds(1, 3)/mesh%spacing(3))
1612 st%surface(1, 2)%spacing =
m_half*(mesh%spacing(1) + mesh%spacing(3))
1613 st%surface(1, 2)%origin(:) =
m_zero
1614 st%surface(1, 2)%origin(2) = -bounds(1, 2)
1615 st%surface(1, 2)%n(:) =
m_zero
1616 st%surface(1, 2)%n(2) = -
m_one
1617 st%surface(1, 2)%u(:) =
m_zero
1618 st%surface(1, 2)%u(1) =
m_one
1619 st%surface(1, 2)%v(:) =
m_zero
1620 st%surface(1, 2)%v(3) =
m_one
1621 st%surface(1, 2)%nu = -int(bounds(1, 1)/mesh%spacing(1))
1622 st%surface(1, 2)%mu = int(bounds(1, 1)/mesh%spacing(1))
1623 st%surface(1, 2)%nv = -int(bounds(1, 3)/mesh%spacing(3))
1624 st%surface(1, 2)%mv = int(bounds(1, 3)/mesh%spacing(3))
1627 st%surface(2, 2)%spacing =
m_half*(mesh%spacing(1) + mesh%spacing(3))
1628 st%surface(2, 2)%origin(:) =
m_zero
1629 st%surface(2, 2)%origin(2) = bounds(1, 2)
1630 st%surface(2, 2)%n(:) =
m_zero
1631 st%surface(2, 2)%n(2) =
m_one
1632 st%surface(2, 2)%u(:) =
m_zero
1633 st%surface(2, 2)%u(1) =
m_one
1634 st%surface(2, 2)%v(:) =
m_zero
1635 st%surface(2, 2)%v(3) = -
m_one
1636 st%surface(2, 2)%nu = -int(bounds(1, 1)/mesh%spacing(1))
1637 st%surface(2, 2)%mu = int(bounds(1, 1)/mesh%spacing(1))
1638 st%surface(2, 2)%nv = -int(bounds(1, 3)/mesh%spacing(3))
1639 st%surface(2, 2)%mv = int(bounds(1, 3)/mesh%spacing(3))
1642 st%surface(1, 3)%spacing =
m_half*(mesh%spacing(1) + mesh%spacing(2))
1644 st%surface(1, 3)%origin(3) = -bounds(1, 3)
1645 st%surface(1, 3)%n(:) =
m_zero
1646 st%surface(1, 3)%n(3) = -
m_one
1647 st%surface(1, 3)%u(:) =
m_zero
1648 st%surface(1, 3)%u(1) =
m_one
1649 st%surface(1, 3)%v(:) =
m_zero
1650 st%surface(1, 3)%v(2) = -
m_one
1651 st%surface(1, 3)%nu = -int(bounds(1, 1)/mesh%spacing(1))
1652 st%surface(1, 3)%mu = int(bounds(1, 1)/mesh%spacing(1))
1653 st%surface(1, 3)%nv = -int(bounds(1, 2)/mesh%spacing(2))
1654 st%surface(1, 3)%mv = int(bounds(1, 2)/mesh%spacing(2))
1657 st%surface(2, 3)%spacing =
m_half*(mesh%spacing(1) + mesh%spacing(2))
1658 st%surface(2, 3)%origin(:) =
m_zero
1659 st%surface(2, 3)%origin(3) = bounds(1, 3)
1660 st%surface(2, 3)%n(:) =
m_zero
1661 st%surface(2, 3)%n(3) =
m_one
1662 st%surface(2, 3)%u(:) =
m_zero
1663 st%surface(2, 3)%u(1) =
m_one
1664 st%surface(2, 3)%v(:) =
m_zero
1665 st%surface(2, 3)%v(2) =
m_one
1666 st%surface(2, 3)%nu = -int(bounds(1, 1)/mesh%spacing(1))
1667 st%surface(2, 3)%mu = int(bounds(1, 1)/mesh%spacing(1))
1668 st%surface(2, 3)%nv = -int(bounds(1, 2)/mesh%spacing(2))
1669 st%surface(2, 3)%mv = int(bounds(1, 2)/mesh%spacing(2))
1679 class(
mesh_t),
intent(in) :: mesh
1680 integer,
intent(in) :: ip
1681 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1682 integer,
intent(out) :: point_info
1684 real(real64) :: rr, dd, xx(3), width(3)
1688 width(1:3) = bounds(2, 1:3) - bounds(1, 1:3)
1690 xx(1:mesh%box%dim) = mesh%x(1:mesh%box%dim, ip)
1692 if (bc%ab_user_def)
then
1694 dd = bc%ab_ufn(ip) - bounds(1, 1)
1696 if (bc%ab_ufn(ip) < bounds(2, 1))
then
1703 select type (box => mesh%box)
1705 rr = norm2(xx - box%center)
1706 dd = rr - bounds(1, 1)
1708 if (dd < width(1))
then
1715 if (all(abs(xx(1:3) - box%center) <= bounds(2, 1:3)))
then
1716 if (any(abs(xx(1:3) - box%center) > bounds(1, 1:3)))
then
1735 class(
mesh_t),
intent(in) :: mesh
1736 integer,
intent(in) :: ip
1737 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1738 integer,
intent(out) :: boundary_info
1740 real(real64) :: xx(3)
1745 xx(1:mesh%box%dim) = mesh%x(1:mesh%box%dim, ip)
1746 if (
is_close(abs(xx(1)), bounds(1, 1)) .and. (all(abs(xx(2:3)) <= bounds(1, 2:3))) .or. &
1747 is_close(abs(xx(2)), bounds(1, 2)) .and. (all(abs(xx(1:3:2)) <= bounds(1, 1:3:2))) .or. &
1748 is_close(abs(xx(3)), bounds(1, 3)) .and. (all(abs(xx(1:2)) <= bounds(1, 1:2))))
then
1761 class(
mesh_t),
intent(in) :: mesh
1763 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1764 integer,
intent(in) :: periodic_dim
1766 integer :: ip, ip_in, ip_bd, point_info, ndim
1767 real(real64) :: xx(mesh%box%dim)
1780 if (all(abs(xx(periodic_dim+1:ndim)) <= bounds(2, periodic_dim+1:ndim)))
then
1781 if (any(abs(xx(periodic_dim+1:ndim)) > bounds(1, periodic_dim+1:ndim)))
then
1789 if (point_info == 0)
then
1795 st%inner_points_number = ip_in
1796 safe_allocate(st%inner_points_map(1:ip_in))
1797 safe_allocate(st%inner_points_mask(1:mesh%np))
1798 st%boundary_points_number = ip_bd
1799 safe_allocate(st%boundary_points_map(1:ip_bd))
1800 safe_allocate(st%boundary_points_mask(1:mesh%np))
1801 st%inner_points_mask = .false.
1802 st%boundary_points_mask = .false.
1809 if (all(abs(xx(periodic_dim+1:ndim)) <= bounds(2, periodic_dim+1:ndim)))
then
1810 if (any(abs(xx(periodic_dim+1:ndim)) > bounds(1, periodic_dim+1:ndim)))
then
1818 if (point_info == 0)
then
1820 st%inner_points_map(ip_in) = ip
1821 st%inner_points_mask(ip) = .
true.
1824 st%boundary_points_map(ip_bd) = ip
1825 st%boundary_points_mask(ip) = .
true.
1831 call accel_write_buffer(st%buff_inner_points_map, st%inner_points_number, st%inner_points_map)
1833 call accel_write_buffer(st%buff_boundary_points_map, st%boundary_points_number, st%boundary_points_map)
1843 class(
mesh_t),
intent(in) :: mesh
1845 real(real64),
contiguous,
intent(in) :: bounds(:,:)
1847 integer :: ix, ix_max, iix, iy, iy_max, iiy, iz, iz_max, iiz, idx1, idx2, nn_max
1848 integer(int64) :: ip_global
1849 integer,
allocatable :: nn(:,:,:,:)
1850 real(real64) :: rr(3), delta(3), vec(2), min_1(3), max_1(3), min_2(3), max_2(3)
1856 st%surface_grid_rows_number(1) = 3
1857 ix_max = st%surface_grid_rows_number(1)
1858 st%surface_grid_rows_number(2) = 3
1859 iy_max = st%surface_grid_rows_number(2)
1860 st%surface_grid_rows_number(3) = 3
1861 iz_max = st%surface_grid_rows_number(3)
1863 delta(1) =
m_two * abs(bounds(1,1)) / real(ix_max, real64)
1864 delta(2) =
m_two * abs(bounds(1,2)) / real(iy_max, real64)
1865 delta(3) =
m_two * abs(bounds(1,3)) / real(iz_max, real64)
1867 st%surface_grid_element(1) = delta(2) * delta(3)
1868 st%surface_grid_element(2) = delta(1) * delta(3)
1869 st%surface_grid_element(3) = delta(1) * delta(2)
1871 safe_allocate(nn(1:2, 1:3, 1:3, 1:3))
1873 st%surface_grid_center(1, 1, :, :) = -int(bounds(1,1))
1876 rr(2) = -bounds(1,2) + delta(2)/
m_two + (iy-1) * delta(2)
1877 rr(3) = -bounds(1,3) + delta(3)/
m_two + (iz-1) * delta(3)
1878 st%surface_grid_center(1, 2, iy, iz) = int(rr(2))
1879 st%surface_grid_center(1, 3, iy, iz) = int(rr(3))
1882 st%surface_grid_center(2, 1, :, :) = int(bounds(1,1))
1885 rr(2) = -bounds(1,2) + delta(2)/
m_two + (iy-1) * delta(2)
1886 rr(3) = -bounds(1,3) + delta(3)/
m_two + (iz-1) * delta(3)
1887 st%surface_grid_center(2, 2, iy, iz) = int(rr(2))
1888 st%surface_grid_center(2, 3, iy, iz) = int(rr(3))
1892 st%surface_grid_center(1, 2, :, :) = -int(bounds(1,2))
1895 rr(1) = -bounds(1,1) + delta(1)/
m_two + (ix-1) * delta(1)
1896 rr(3) = -bounds(1,3) + delta(3)/
m_two + (iz-1) * delta(3)
1897 st%surface_grid_center(1, 1, ix, iz) = int(rr(1))
1898 st%surface_grid_center(1, 3, ix, iz) = int(rr(3))
1901 st%surface_grid_center(2, 2, :, :) = int(bounds(1,2))
1904 rr(1) = -bounds(1,2) + delta(1)/
m_two + (ix-1) * delta(1)
1905 rr(3) = -bounds(1,3) + delta(3)/
m_two + (iz-1) * delta(3)
1906 st%surface_grid_center(2, 1, ix, iz) = int(rr(1))
1907 st%surface_grid_center(2, 3, ix, iz) = int(rr(3))
1911 st%surface_grid_center(1, 3, :, :) = -int(bounds(1,3))
1914 rr(1) = -bounds(1,1) + delta(1)/
m_two + (ix-1) * delta(1)
1915 rr(2) = -bounds(1,2) + delta(2)/
m_two + (iy-1) * delta(2)
1916 st%surface_grid_center(1, 1, ix, iy) = int(rr(1))
1917 st%surface_grid_center(1, 2, ix, iy) = int(rr(2))
1920 st%surface_grid_center(2, 3, :, :) = int(bounds(1,3))
1923 rr(1) = -bounds(1,2) + delta(1)/
m_two + (ix-1) * delta(1)
1924 rr(2) = -bounds(1,2) + delta(2)/
m_two + (iy-1) * delta(2)
1925 st%surface_grid_center(2, 1, ix, iy) = int(rr(1))
1926 st%surface_grid_center(2, 2, ix, iy) = int(rr(2))
1930 st%surface_grid_points_number(:,:,:) = 0
1936 min_1(iy) = -bounds(1,2) + (iy-1) * delta(2)
1937 max_1(iy) = -bounds(1,2) + iy * delta(2)
1938 min_2(iz) = -bounds(1,3) + (iz-1) * delta(3)
1939 max_2(iz) = -bounds(1,3) + iz * delta(3)
1942 do iiy = mesh%idx%nr(1,2), mesh%idx%nr(2,2)
1943 do iiz = mesh%idx%nr(1,3), mesh%idx%nr(2,3)
1944 vec(1) = iiy * mesh%spacing(2)
1945 vec(2) = iiz * mesh%spacing(3)
1947 if (idx1 /= 0 .and. idx2 /= 0)
then
1948 st%surface_grid_points_number(1, idx1, idx2) = st%surface_grid_points_number(1, idx1, idx2) + 1
1949 if (nn_max < st%surface_grid_points_number(1, idx1, idx2))
then
1950 nn_max = st%surface_grid_points_number(1, idx1, idx2)
1958 min_1(ix) = -bounds(1,1) + (ix-1) * delta(1)
1959 max_1(ix) = -bounds(1,1) + ix * delta(1)
1960 min_2(iz) = -bounds(1,3) + (iz-1) * delta(3)
1961 max_2(iz) = -bounds(1,3) + iz * delta(3)
1964 do iix = mesh%idx%nr(1, 1), mesh%idx%nr(2, 1)
1965 do iiz = mesh%idx%nr(1, 3), mesh%idx%nr(2, 3)
1966 vec(1) = iix * mesh%spacing(1)
1967 vec(2) = iiz * mesh%spacing(3)
1969 if (idx1 /= 0 .and. idx2 /= 0)
then
1970 st%surface_grid_points_number(2,idx1,idx2) = st%surface_grid_points_number(2,idx1,idx2)+1
1971 if (nn_max < st%surface_grid_points_number(2, idx1, idx2))
then
1972 nn_max = st%surface_grid_points_number(2, idx1, idx2)
1980 min_1(ix) = -bounds(1,1) + (ix-1) * delta(1)
1981 max_1(ix) = -bounds(1,1) + ix * delta(1)
1982 min_2(iy) = -bounds(1,2) + (iy-1) * delta(2)
1983 max_2(iy) = -bounds(1,2) + iy * delta(2)
1986 do iix = mesh%idx%nr(1,1), mesh%idx%nr(2,1)
1987 do iiy = mesh%idx%nr(1,2), mesh%idx%nr(2,2)
1988 vec(1) = iix * mesh%spacing(1)
1989 vec(2) = iiy * mesh%spacing(2)
1991 if (idx1 /= 0 .and. idx2 /= 0)
then
1992 st%surface_grid_points_number(3, idx1, idx2) = st%surface_grid_points_number(3, idx1, idx2) + 1
1993 if (nn_max < st%surface_grid_points_number(3, idx1, idx2))
then
1994 nn_max = st%surface_grid_points_number(3, idx1, idx2)
2001 safe_allocate(st%surface_grid_points_map(1:2, 1:st%dim, 1:ix_max, 1:iy_max, 1:nn_max))
2007 min_1(iy) = -bounds(1,2) + (iy-1) * delta(2)
2008 max_1(iy) = -bounds(1,2) + iy * delta(2)
2009 min_2(iz) = -bounds(1,3) + (iz-1) * delta(3)
2010 max_2(iz) = -bounds(1,3) + iz * delta(3)
2013 do iiy = mesh%idx%nr(1,2), mesh%idx%nr(2,2)
2014 do iiz = mesh%idx%nr(1,3), mesh%idx%nr(2,3)
2015 vec(1) = iiy * mesh%spacing(2)
2016 vec(2) = iiz * mesh%spacing(3)
2018 if (idx1 /= 0 .and. idx2 /= 0)
then
2019 nn(1, 1, idx1, idx2) = nn(1, 1, idx1, idx2) + 1
2020 rr(1) = -bounds(1, 1)
2021 rr(2) = iiy * mesh%spacing(2)
2022 rr(3) = iiz * mesh%spacing(3)
2023 iix = int(-bounds(1,1)/mesh%spacing(1))
2025 st%surface_grid_points_map(1, 1, idx1, idx2, nn(1, 1, idx1, idx2)) = ip_global
2026 nn(2, 1, idx1, idx2) = nn(2, 1, idx1, idx2) + 1
2028 rr(2) = iiy * mesh%spacing(2)
2029 rr(3) = iiz * mesh%spacing(3)
2030 iix = int(bounds(1,1)/mesh%spacing(1))
2032 st%surface_grid_points_map(2, 1, idx1, idx2, nn(2, 1, idx1, idx2)) = ip_global
2039 min_1(ix) = -bounds(1,1) + (ix-1) * delta(1)
2040 max_1(ix) = -bounds(1,1) + ix * delta(1)
2041 min_2(iz) = -bounds(1,3) + (iz-1) * delta(3)
2042 max_2(iz) = -bounds(1,3) + iz * delta(3)
2045 do iix = mesh%idx%nr(1,1), mesh%idx%nr(2,1)
2046 do iiz = mesh%idx%nr(1,3), mesh%idx%nr(2,3)
2047 vec(1) = iix * mesh%spacing(1)
2048 vec(2) = iiz * mesh%spacing(3)
2050 if (idx1 /= 0 .and. idx2 /= 0)
then
2051 nn(1, 2, idx1, idx2) = nn(1, 2, idx1, idx2) + 1
2052 rr(1) = iix * mesh%spacing(1)
2053 rr(2) = -bounds(1, 2)
2054 rr(3) = iiz * mesh%spacing(3)
2055 iiy = int(-bounds(1,2)/mesh%spacing(2))
2057 st%surface_grid_points_map(1, 2, idx1, idx2, nn(1, 2, idx1, idx2)) = ip_global
2058 nn(2, 2, idx1, idx2) = nn(2, 2, idx1, idx2) + 1
2059 rr(1) = iix * mesh%spacing(1)
2061 rr(3) = iiz * mesh%spacing(3)
2062 iiy = int(bounds(1,2)/mesh%spacing(2))
2064 st%surface_grid_points_map(2, 2, idx1, idx2, nn(2, 2, idx1, idx2)) = ip_global
2071 min_1(ix) = -bounds(1,1) + (ix-1) * delta(1)
2072 max_1(ix) = -bounds(1,1) + ix * delta(1)
2073 min_2(iy) = -bounds(1,2) + (iy-1) * delta(2)
2074 max_2(iy) = -bounds(1,2) + iy * delta(2)
2077 do iix = mesh%idx%nr(1,1), mesh%idx%nr(2,1)
2078 do iiy = mesh%idx%nr(1,2), mesh%idx%nr(2,2)
2079 vec(1) = iix * mesh%spacing(1)
2080 vec(2) = iiy * mesh%spacing(2)
2082 if (idx1 /= 0 .and. idx2 /= 0)
then
2083 nn(1, 3, idx1, idx2) = nn(1, 3, idx1, idx2) + 1
2084 rr(1) = iix * mesh%spacing(1)
2085 rr(2) = iiy * mesh%spacing(2)
2086 rr(3) = -bounds(1,3)
2087 iiz = int(-bounds(1,3)/mesh%spacing(3))
2089 st%surface_grid_points_map(1, 3, idx1, idx2, nn(1, 3, idx1, idx2)) = ip_global
2090 nn(2, 3, idx1, idx2) = nn(2, 3, idx1, idx2) + 1
2091 rr(1) = iix * mesh%spacing(1)
2092 rr(2) = iiy * mesh%spacing(2)
2094 iiz = int(bounds(1,3)/mesh%spacing(3))
2096 st%surface_grid_points_map(2, 3, idx1, idx2, nn(2, 3, idx1, idx2)) = ip_global
2101 safe_deallocate_a(nn)
2109 real(real64),
contiguous,
intent(in) :: vec(:)
2110 real(real64),
contiguous,
intent(in) :: min_1(:)
2111 real(real64),
contiguous,
intent(in) :: max_1(:)
2112 real(real64),
contiguous,
intent(in) :: min_2(:)
2113 real(real64),
contiguous,
intent(in) :: max_2(:)
2114 integer,
intent(out) :: index_1
2115 integer,
intent(out) :: index_2
2117 if (vec(1) >= min_1(1) .and. vec(1) <= max_1(1) .and. vec(2) >= min_2(1) .and. vec(2) <= max_2(1))
then
2120 else if (vec(1) >= min_1(2) .and. vec(1) <= max_1(2) .and. vec(2) >= min_2(1) .and. vec(2) <= max_2(1))
then
2123 else if (vec(1) >= min_1(3) .and. vec(1) <= max_1(3) .and. vec(2) >= min_2(1) .and. vec(2) <= max_2(1))
then
2126 else if (vec(1) >= min_1(1) .and. vec(1) <= max_1(1) .and. vec(2) >= min_2(2) .and. vec(2) <= max_2(2))
then
2129 else if (vec(1) >= min_1(2) .and. vec(1) <= max_1(2) .and. vec(2) >= min_2(2) .and. vec(2) <= max_2(2))
then
2132 else if (vec(1) >= min_1(3) .and. vec(1) <= max_1(3) .and. vec(2) >= min_2(2) .and. vec(2) <= max_2(2))
then
2135 else if (vec(1) >= min_1(1) .and. vec(1) <= max_1(1) .and. vec(2) >= min_2(3) .and. vec(2) <= max_2(3))
then
2138 else if (vec(1) >= min_1(2) .and. vec(1) <= max_1(2) .and. vec(2) >= min_2(3) .and. vec(2) <= max_2(3))
then
2141 else if (vec(1) >= min_1(3) .and. vec(1) <= max_1(3) .and. vec(2) >= min_2(3) .and. vec(2) <= max_2(3))
then
double log(double __x) __attribute__((__nothrow__
double exp(double __x) __attribute__((__nothrow__
double sin(double __x) __attribute__((__nothrow__
subroutine get_surface_indices(vec, min_1, max_1, min_2, max_2, index_1, index_2)
subroutine get_medium_io_function(medium_func, bc, io_func, idim)
subroutine get_mask_io_function(mask_func, bc, io_func, idim)
subroutine write_files(filename, tmp)
subroutine get_pml_io_function(pml_func, bc, io_func)
subroutine, public accel_free_buffer(this, async)
integer, parameter, public accel_mem_read_write
pure logical function, public accel_is_enabled()
integer, parameter, public accel_mem_read_only
type(debug_t), save, public debug
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_grad(der, ff, op_ff, ghost_update, set_bc, to_cartesian)
apply the gradient to a mesh function
subroutine, public external_waves_end(external_waves)
subroutine, public external_waves_init(external_waves, namespace)
Here, plane wave is evaluated from analytical formulae on grid.
real(real64), parameter, public m_two
real(real64), parameter, public m_huge
real(real64), parameter, public m_zero
real(real64), parameter, public m_four
real(real64), parameter, public m_pi
some mathematical constants
real(real64), parameter, public p_mu
real(real64), parameter, public p_ep
complex(real64), parameter, public m_z0
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
real(real64), parameter, public p_c
Electron gyromagnetic ratio, see Phys. Rev. Lett. 130, 071801 (2023)
real(real64), parameter, public m_one
real(real64), parameter, public m_five
This module implements the underlying real-space grid.
This module implements the index, used for the mesh points.
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
integer(int64) function, public io_function_fill_how(where)
Use this function to quickly plot functions for debugging purposes: call dio_function_output(io_funct...
subroutine, public single_medium_box_allocate(medium_box, n_points)
Allocation of medium_box components.
subroutine, public single_medium_box_end(medium_box)
Deallocation of medium_box components.
This module is intended to contain "only mathematical" functions and procedures.
integer, parameter, public mxll_ab_mask_zero
subroutine maxwell_zero_points_mapping(bc, mesh, bounds)
integer, parameter, public mxll_bc_mirror_pmc
integer, parameter mxll_plane_waves_positive_side
subroutine maxwell_boundary_point_info(mesh, ip, bounds, boundary_info)
subroutine, public bc_mxll_init(bc, namespace, space, gr, st)
subroutine bc_mxll_generate_medium(bc, space, gr, bounds, ep_factor, mu_factor, sigma_e_factor, sigma_m_factor)
subroutine maxwell_surfaces_init(mesh, st, bounds)
subroutine maxwell_box_point_info(bc, mesh, ip, bounds, point_info)
integer, parameter, public mxll_bc_mirror_pec
integer, parameter, public mxll_ab_mask
subroutine, public inner_and_outer_points_mapping(mesh, st, bounds, periodic_dim)
Inner points (inside bounds(1, :)) and boundary points of the Maxwell grid. Periodic axes have no bou...
subroutine bc_mxll_medium_init(gr, namespace, bounds, idim, ep_factor, mu_factor, sigma_e_factor, sigma_m_factor)
subroutine, public surface_grid_points_mapping(mesh, st, bounds)
integer, parameter, public mxll_bc_plane_waves
subroutine, public bc_mxll_initialize_pml_simple(bc, space, gr, c_factor, dt)
integer, parameter, public mxll_bc_medium
subroutine maxwell_constant_points_mapping(bc, mesh, bounds)
subroutine bc_mxll_generate_pml(bc, space)
subroutine bc_mxll_write_info(bc, mesh, namespace, space)
subroutine, public bc_mxll_generate_pml_parameters(bc, space, gr, c_factor, dt)
subroutine bc_mxll_generate_mask(bc, mesh, bounds)
subroutine maxwell_plane_waves_points_mapping(bc, mesh, bounds)
integer, parameter, public mxll_bc_constant
subroutine bc_mxll_pml_init(bc, gr, namespace, ab_bounds, idim)
subroutine maxwell_medium_points_mapping(bc, mesh, bounds)
subroutine bc_mxll_ab_bounds_init(bc, gr, namespace, ab_bounds, idim)
subroutine, public bc_mxll_end(bc)
integer, parameter, public mxll_ab_cpml
subroutine maxwell_pml_points_mapping(bc, mesh, bounds)
subroutine maxwell_mask_points_mapping(bc, mesh, bounds)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
integer(int64) function, public mesh_global_index_from_coords(mesh, ix)
This function returns the true global index of the point for a given vector of integer coordinates.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
character(len=512), private msg
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Some general things and nomenclature:
logical function, public parse_is_defined(namespace, name)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
type(type_t), parameter, public type_cmplx
type(type_t), parameter, public type_integer
type(type_t), parameter, public type_float
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_inp
the units systems for reading and writing
type(unit_t), public unit_one
some special units required for particular quantities
Class implementing a parallelepiped box. Currently this is restricted to a rectangular cuboid (all th...
Class implementing a spherical box.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.