43 real(real64),
allocatable,
public :: center(:)
44 type(basis_vectors_t),
public :: axes
45 real(real64),
allocatable :: bounding_box(:,:)
51 procedure(box_shape_shape_contains_points),
deferred :: shape_contains_points
58 class(box_shape_t),
intent(in) :: this
59 integer,
intent(in) :: nn
60 real(real64),
contiguous,
intent(in) :: xx(:,:)
61 real(real64),
optional,
intent(in) :: tol
62 logical :: contained(1:nn)
70 class(box_shape_t),
intent(in) :: this
71 integer,
intent(in) :: nn
72 real(real64),
contiguous,
intent(in) :: xx(:,:)
73 real(real64),
optional,
intent(in) :: tol
74 logical :: contained(1:nn)
78 contained = this%shape_contains_points(nn, this%axes%from_cartesian(nn, xx), tol)
83 subroutine box_shape_init(this, namespace, dim, center, bounding_box_min, bounding_box_max, axes)
84 class(box_shape_t),
intent(inout) :: this
85 type(namespace_t),
intent(in) :: namespace
86 integer,
intent(in) :: dim
87 real(real64),
intent(in) :: center(dim)
88 real(real64),
intent(in) :: bounding_box_min(dim)
89 real(real64),
intent(in) :: bounding_box_max(dim)
90 real(real64),
optional,
intent(in) :: axes(dim, dim)
93 real(real64) :: normalized_axes(dim, dim)
97 safe_allocate(this%center(1:dim))
98 safe_allocate(this%bounding_box_l(1:dim))
99 this%bounding_box_l =
m_zero
101 this%center(1:dim) = center(1:dim)
103 if (
present(axes))
then
105 normalized_axes(:, idir) = axes(:, idir)/norm2(axes(:, idir))
112 if (
allocated(this%bounding_box))
then
113 safe_deallocate_a(this%bounding_box)
115 safe_allocate(this%bounding_box(1:2, 1:dim))
116 this%bounding_box(1,:) = bounding_box_min + this%center
117 this%bounding_box(2,:) = bounding_box_max + this%center
130 class(box_shape_t),
intent(in) :: this
131 class(basis_vectors_t),
optional,
intent(in) :: axes
132 real(real64) :: bounds(2, this%dim)
135 real(real64) :: vertex_red(this%dim), vertex_cart(this%dim)
139 if (this%is_inside_out())
then
150 do idir = 1, this%dim
154 vertex_red(idir) = this%bounding_box(ib, idir)
157 vertex_cart = this%axes%to_cartesian(vertex_red)
160 if (
present(axes))
then
161 vertex_red = axes%from_cartesian(vertex_cart)
163 vertex_red = vertex_cart
166 where (vertex_red < bounds(1,:))
167 bounds(1, :) = vertex_red
168 elsewhere (vertex_red > bounds(2,:))
169 bounds(2, :) = vertex_red
182 safe_deallocate_a(this%center)
183 safe_deallocate_a(this%bounding_box)
184 safe_deallocate_a(this%bounding_box_l)
recursive logical function, dimension(1:nn) box_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) function, dimension(2, this%dim) box_shape_bounds(this, axes)
Returns the bounding box of the shape. This is a bounding box aligned with some given axes (if presen...
real(real64), parameter, public m_huge
real(real64), parameter, public m_zero
real(real64), parameter, public m_one
This module is intended to contain "only mathematical" functions and procedures.
Vectors defining a basis in a vector space. This class provides methods to convert vector coordinates...
class to tell whether a point is inside or outside
Base class for more specialized boxes that are defined by a shape and have a center and basis vectors...