43 type(
oct_t),
pointer :: ptr => null()
51 real(kind=
dp) :: width
58 type(
oct_t),
pointer :: root => null()
71 real(kind=
dp),
intent(in) :: width
73 integer,
parameter :: top_level = 0
77 origin = (/ 0d0, 0d0, 0d0 /)
112 type(
oct_t),
intent(inout),
pointer :: o
114 type(
point_t) :: tmp_pt, offset, new_origin
117 if (.not.
associated(o%oct(1)%ptr))
then
118 if (.not. o%valid)
then
123 if (o%point .eq. p)
then
130 offset = (/ -0.5d0, -0.5d0, -0.5d0 /)
131 if (iand((i - 1), 4) .gt. 0) offset%x(1) = 0.5d0
132 if (iand((i - 1), 2) .gt. 0) offset%x(2) = 0.5d0
133 if (iand((i - 1), 1) .gt. 0) offset%x(3) = 0.5d0
135 new_origin = o%origin%x + (o%width * offset%x)
137 o%width * 0.5d0, o%level + 1)
152 type(
oct_t),
pointer,
intent(in) :: o
159 if (.not.
associated(o%oct(1)%ptr))
then
173 type(
oct_t),
pointer,
intent(inout) :: o
174 type(
point_t),
intent(in) :: origin
175 real(kind=
dp),
intent(in) :: width
176 integer,
intent(in) :: level
179 if (
associated(o))
then
180 call neko_error(
'Octree octant already initialized')
189 nullify(o%oct(i)%ptr)
197 type(
oct_t),
pointer,
intent(inout) :: o
200 if (.not.
associated(o))
then
202 else if (.not.
associated(o%oct(1)%ptr))
then
219 type(
oct_t),
pointer,
intent(in) :: oct
224 if (
point%x(1) .ge. oct%origin%x(1)) oct_idx = ior(oct_idx, 4)
225 if (
point%x(2) .ge. oct%origin%x(2)) oct_idx = ior(oct_idx, 2)
226 if (
point%x(3) .ge. oct%origin%x(3)) oct_idx = ior(oct_idx, 1)
227 oct_idx = oct_idx + 1
233 type(
oct_t),
pointer,
intent(in) :: oct
238 if ((
point%x(1) .ge. (oct%origin%x(1) - oct%width) .and. &
239 point%x(1) .le. (oct%origin%x(1) + oct%width)) .and. &
240 (
point%x(2) .ge. (oct%origin%x(2) - oct%width) .and. &
241 point%x(2) .le. (oct%origin%x(2) + oct%width)) .and. &
242 (
point%x(3) .ge. (oct%origin%x(3) - oct%width) .and. &
243 point%x(3) .le. (oct%origin%x(3) + oct%width)))
then
integer, parameter, public dp
pure logical function octree_oct_inside(oct, point)
Return if a point is inside an octant.
subroutine octree_free(t)
Destroy an octree.
subroutine octree_insert(t, p)
Insert a point p into the octree.
recursive subroutine octree_oct_insert(o, p)
Insert a point p into the octree rooted at o.
recursive subroutine octree_free_oct(o)
Deallocate an oct in an octree.
logical function octree_find(t, p)
Find a point p in an octree.
pure integer function octree_oct(oct, point)
Return the octant for a given point.
subroutine octree_oct_init(o, origin, width, level)
Initialize an octant width a given width, origin and level.
recursive integer function octree_oct_find(o, p)
Find the octant containing a point p.
subroutine octree_init(t, width)
Initialize an octree.
Defines an octree octant.
A point in with coordinates .