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 logical :: contained(1:nn)
69 class(box_shape_t),
intent(in) :: this
70 integer,
intent(in) :: nn
71 real(real64),
contiguous,
intent(in) :: xx(:,:)
72 logical :: contained(1:nn)
76 contained = this%shape_contains_points(nn, this%axes%from_cartesian(nn, xx))
81 subroutine box_shape_init(this, namespace, dim, center, bounding_box_min, bounding_box_max, axes)
82 class(box_shape_t),
intent(inout) :: this
83 type(namespace_t),
intent(in) :: namespace
84 integer,
intent(in) :: dim
85 real(real64),
intent(in) :: center(dim)
86 real(real64),
intent(in) :: bounding_box_min(dim)
87 real(real64),
intent(in) :: bounding_box_max(dim)
88 real(real64),
optional,
intent(in) :: axes(dim, dim)
91 real(real64) :: normalized_axes(dim, dim)
95 safe_allocate(this%center(1:dim))
96 safe_allocate(this%bounding_box_l(1:dim))
97 this%bounding_box_l =
m_zero
99 this%center(1:dim) = center(1:dim)
101 if (
present(axes))
then
103 normalized_axes(:, idir) = axes(:, idir)/norm2(axes(:, idir))
110 if (
allocated(this%bounding_box))
then
111 safe_deallocate_a(this%bounding_box)
113 safe_allocate(this%bounding_box(1:2, 1:dim))
114 this%bounding_box(1,:) = bounding_box_min + this%center
115 this%bounding_box(2,:) = bounding_box_max + this%center
128 class(box_shape_t),
intent(in) :: this
129 class(basis_vectors_t),
optional,
intent(in) :: axes
130 real(real64) :: bounds(2, this%dim)
133 real(real64) :: vertex_red(this%dim), vertex_cart(this%dim)
137 if (this%is_inside_out())
then
148 do idir = 1, this%dim
152 vertex_red(idir) = this%bounding_box(ib, idir)
155 vertex_cart = this%axes%to_cartesian(vertex_red)
158 if (
present(axes))
then
159 vertex_red = axes%from_cartesian(vertex_cart)
161 vertex_red = vertex_cart
164 where (vertex_red < bounds(1,:))
165 bounds(1, :) = vertex_red
166 elsewhere (vertex_red > bounds(2,:))
167 bounds(2, :) = vertex_red
180 safe_deallocate_a(this%center)
181 safe_deallocate_a(this%bounding_box)
182 safe_deallocate_a(this%bounding_box_l)
subroutine, public box_shape_init(this, namespace, dim, center, bounding_box_min, bounding_box_max, axes)
recursive logical function, dimension(1:nn) box_shape_contains_points(this, nn, xx)
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...