41 integer :: image_size(2)
42 real(real64),
public :: pixel_size(2)
44 character(len=:),
allocatable :: filename
53 procedure box_image_constructor
60 real(real64),
intent(in) :: center(2)
61 real(real64),
intent(in) :: axes(2, 2)
62 real(real64),
intent(in) :: lsize(2)
66 character(len=*),
intent(in) :: filename
67 integer,
intent(in) :: periodic_dim
68 type(namespace_t),
intent(in) :: namespace
69 class(box_image_t),
pointer :: box
72 integer :: idir, box_npts
73 real(real64) :: lsize_adjusted(2)
81 box%filename = trim(filename)
82 inquire(file=trim(box%filename), exist=found)
84 deallocate(box%filename)
85 box%filename = trim(
conf%share) //
'/' // trim(filename)
86 inquire(file=trim(box%filename), exist=found)
89 message(1) =
"Could not find file '" // trim(filename) //
"' for BoxShape = box_image."
94 if (.not. c_associated(box%image))
then
95 message(1) =
"Could not open file '" // trim(box%filename) //
"' for BoxShape = box_image."
102 box_npts = box%image_size(idir)
103 if ((idir > periodic_dim .and.
even(box%image_size(idir))) .or. &
104 (idir <= periodic_dim .and.
odd(box%image_size(idir))))
then
105 box_npts = box_npts + 1
106 lsize_adjusted(idir) = lsize(idir) * box_npts / box%image_size(idir)
108 lsize_adjusted(idir) = lsize(idir)
114 box%pixel_size(1:2) =
m_two*lsize_adjusted(1:2)/box%image_size(1:2)
116 call box_shape_init(box, namespace, 2, center, bounding_box_min=-lsize_adjusted, bounding_box_max=lsize_adjusted, axes=axes)
118 box%bounding_box_l = lsize_adjusted + abs(center)
125 type(box_image_t),
intent(inout) :: this
130 if (
allocated(this%filename))
then
131 deallocate(this%filename)
140 integer,
intent(in) :: nn
141 real(real64),
contiguous,
intent(in) :: xx(:,:)
142 real(real64),
optional,
intent(in) :: tol
143 logical :: contained(1:nn)
146 integer :: red, green, blue, ix, iy
153 ix = nint((xx(ip, 1) - this%center(1))/this%pixel_size(1)) + (this%image_size(1) - 1)/2
154 iy = - nint((xx(ip, 2) - this%center(2))/this%pixel_size(2)) + (this%image_size(2) - 1)/2
155 contained(ip) = (red == 255 .and. green == 255 .and. blue == 255) .neqv. this%is_inside_out()
163 integer,
optional,
intent(in) :: iunit
164 type(
namespace_t),
optional,
intent(in) :: namespace
168 write(
message(1),
'(2x,3a,i6,a,i6)')
'Type = defined by image "', trim(this%filename),
'"', this%image_size(1),
' x ', &
178 type(
unit_t),
intent(in) :: unit_length
182 write(
info,
'(2a)')
'BoxShape = box_image; BoxShapeImage = ', trim(this%filename)
character(len=box_info_len) function box_image_short_info(this, unit_length)
class(box_image_t) function, pointer box_image_constructor(center, axes, lsize, filename, periodic_dim, namespace)
subroutine box_image_finalize(this)
subroutine box_image_write_info(this, iunit, namespace)
logical function, dimension(1:nn) box_image_shape_contains_points(this, nn, xx, tol)
subroutine, public box_shape_init(this, namespace, dim, center, bounding_box_min, bounding_box_max, axes)
subroutine, public box_shape_end(this)
real(real64), parameter, public m_two
type(conf_t), public conf
Global instance of Octopus configuration.
This module is intended to contain "only mathematical" functions and procedures.
logical pure function, public even(n)
Returns if n is even.
logical pure function, public odd(n)
Returns if n is odd.
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_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Class implementing a box generated from a 2D image.
Base class for more specialized boxes that are defined by a shape and have a center and basis vectors...