30 use,
intrinsic :: iso_fortran_env
51 integer,
public :: abtype
52 real(real64),
allocatable,
public :: mf(:)
53 type(cube_function_t) :: cf
54 logical :: ab_user_def
55 real(real64),
allocatable :: ab_ufn(:)
58 integer,
public,
parameter :: &
67 type(absorbing_boundaries_t),
intent(out) :: this
68 type(namespace_t),
intent(in) :: namespace
69 class(space_t),
intent(in) :: space
70 type(grid_t),
intent(in) :: gr
73 real(real64) :: bounds(space%dim, 2)
74 integer :: cols_abshape_block, imdim, maxdim
76 real(real64) :: xx(space%dim), rr
77 real(real64) :: ufn_re, ufn_im
78 character(len=1024) :: user_def_expr
80 real(real64),
allocatable :: mf(:)
81 real(real64) :: abheight, abwidth, abwidth_def
88 this%ab_user_def = .false.
105 call parse_variable(namespace,
'AbsorbingBoundaries', not_absorbing, this%abtype)
110 if (this%abtype /= not_absorbing)
then
145 cols_abshape_block = 0
147 message(1) =
"Input: ABShape not specified. Using default values for absorbing boundaries."
150 select type (sb=>gr%box)
152 bounds(1,1) = sb%radius/
m_two
153 bounds(1,2) = sb%radius
155 bounds(:,1) = sb%half_length/
m_two
156 bounds(:,2) = sb%half_length
158 bounds(1,2) = sb%half_length
159 bounds(2,2) = sb%radius
160 bounds(1,1) = bounds(1,1)/
m_two
164 bounds(:,2) = 0.4_real64
169 select case (cols_abshape_block)
174 bounds(:,1) = bounds(1,1)
175 bounds(:,2) = bounds(1,2)
177 select type (sb=>gr%box)
179 if (bounds(1,2) > sb%radius)
then
180 bounds(1,2) = sb%radius
182 message(1) =
"Info: using spherical absorbing boundaries."
185 do imdim = 1, space%dim
186 if (bounds(imdim,2) > sb%half_length(imdim))
then
187 bounds(imdim,2) = sb%half_length(imdim)
190 message(1) =
"Info: using cubic absorbing boundaries."
193 if (bounds(1,2) > sb%half_length)
then
194 bounds(1,2) = sb%half_length
196 if (bounds(2,2) > sb%radius)
then
197 bounds(2,2) = sb%radius
199 message(1) =
"Info: using cylindrical absorbing boundaries."
204 this%ab_user_def = .
true.
205 safe_allocate(this%ab_ufn(1:gr%np))
214 this%ab_ufn(ip) = ufn_re
216 message(1) =
"Input: using user-defined function from expression:"
217 write(
message(2),
'(a,a)')
' F(x,y,z) = ', trim(user_def_expr)
220 message(1) =
"Input: ABShape block must have at least 2 columns."
234 abwidth_def = bounds(1,2) - bounds(1,1)
236 bounds(:, 1) = bounds(:, 2) - abwidth
238 select type (sb=>gr%box)
244 if (this%ab_user_def)
then
250 write(
message(1),
'(a,2a,9f12.6)') &
253 write(
message(2),
'(a,2a,9f12.6)') &
259 safe_allocate(mf(1:gr%np))
263 safe_allocate(this%mf(1:gr%np))
265 select case (this%abtype)
269 this%mf(:) = abheight * mf(:)
276 safe_deallocate_a(mf)
288 if (this%abtype /= not_absorbing)
then
289 safe_deallocate_a(this%mf)
298 class(
mesh_t),
intent(in) :: mesh
300 class(
space_t),
intent(in) :: space
304 if (space%dim < 3)
return
330 class(
space_t),
intent(in) :: space
331 type(
grid_t),
intent(in) :: gr
332 real(real64),
intent(in) :: bounds(1:space%dim, 1:2)
333 real(real64),
contiguous,
intent(inout) :: mf(:)
336 real(real64) :: width(space%dim)
337 real(real64) :: xx(space%dim), rr, dd, ddv(space%dim), tmp(space%dim)
344 width = bounds(:, 2) - bounds(:,1)
349 if (this%ab_user_def)
then
350 dd = this%ab_ufn(ip) - bounds(1,1)
352 if (this%ab_ufn(ip) < bounds(1,2))
then
361 select type (sb => gr%box)
363 rr = norm2(xx - sb%center)
364 dd = rr - bounds(1,1)
366 if (dd < width(1))
then
377 ddv = abs(xx - sb%center) - bounds(:, 1)
378 do dir = 1, space%dim
379 if (ddv(dir) >
m_zero)
then
380 if (ddv(dir) < width(dir))
then
386 mf(ip) = mf(ip) * tmp(dir)
388 mf(ip) =
m_one - mf(ip)
391 rr = norm2(xx(2:space%dim) - sb%center(2:space%dim))
394 ddv(1) = abs(xx(1) - sb%center(1)) - bounds(1,1)
395 ddv(2) = rr - bounds(2,1)
397 if (ddv(dir) >
m_zero)
then
398 if (ddv(dir) < width(dir))
then
404 mf(ip) = mf(ip) * tmp(dir)
406 mf(ip) =
m_one - mf(ip)
415 if (this%ab_user_def)
then
416 safe_deallocate_a(this%ab_ufn)
double sin(double __x) __attribute__((__nothrow__
integer, parameter, public imaginary_absorbing
subroutine absorbing_boundaries_write_info(this, mesh, namespace, space)
integer, parameter, public mask_absorbing
subroutine absorbing_boundaries_generate_mf(this, space, gr, bounds, mf)
subroutine, public absorbing_boundaries_end(this)
subroutine, public absorbing_boundaries_init(this, namespace, space, gr)
type(debug_t), save, public debug
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_pi
some mathematical constants
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
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...
This module defines the meshes, which are used in Octopus.
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)
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
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 cylinder box. The cylinder axis is always along the first direction defined by t...
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.