Neko  0.8.99
A portable framework for high-order spectral element flow simulations
stack.f90
Go to the documentation of this file.
1 ! Copyright (c) 2019-2023, The Neko Authors
2 ! All rights reserved.
3 !
4 ! Redistribution and use in source and binary forms, with or without
5 ! modification, are permitted provided that the following conditions
6 ! are met:
7 !
8 ! * Redistributions of source code must retain the above copyright
9 ! notice, this list of conditions and the following disclaimer.
10 !
11 ! * Redistributions in binary form must reproduce the above
12 ! copyright notice, this list of conditions and the following
13 ! disclaimer in the documentation and/or other materials provided
14 ! with the distribution.
15 !
16 ! * Neither the name of the authors nor the names of its
17 ! contributors may be used to endorse or promote products derived
18 ! from this software without specific prior written permission.
19 !
20 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 ! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 ! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 ! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 ! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 ! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 ! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 ! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 ! POSSIBILITY OF SUCH DAMAGE.
32 !
35 module stack
36  use num_types
37  use nmsh
38  use utils, only : neko_error, neko_warning
39  use point, only : point_t
40  use structs, only : struct_curve_t
41  use math, only : neko_m_ln2
43  implicit none
44  private
45 
46  integer, parameter :: neko_stack_size_t = 32
47 
49  type, abstract, private :: stack_t
50  class(*), allocatable :: data(:)
51  integer :: top_
52  integer :: size_
53  contains
54  procedure, non_overridable, pass(this) :: init => stack_init
55  procedure, non_overridable, pass(this) :: free => stack_free
56  procedure, non_overridable, pass(this) :: clear => stack_clear
57  procedure, non_overridable, pass(this) :: size => stack_size
58  procedure, non_overridable, pass(this) :: is_empty => stack_is_empty
59  procedure, non_overridable, pass(this) :: push => stack_push
60  end type stack_t
61 
63  type, public, extends(stack_t) :: stack_i4_t
64  contains
65  procedure, public, pass(this) :: pop => stack_i4_pop
66  procedure, public, pass(this) :: array => stack_i4_data
67  end type stack_i4_t
68 
70  type, public, extends(stack_t) :: stack_i8_t
71  contains
72  procedure, public, pass(this) :: pop => stack_i8_pop
73  procedure, public, pass(this) :: array => stack_i8_data
74  end type stack_i8_t
75 
77  type, public, extends(stack_t) :: stack_r8_t
78  contains
79  procedure, public, pass(this) :: pop => stack_r8_pop
80  procedure, public, pass(this) :: array => stack_r8_data
81  end type stack_r8_t
82 
84  type, public, extends(stack_t) :: stack_i4t2_t
85  contains
86  procedure, public, pass(this) :: pop => stack_i4t2_pop
87  procedure, public, pass(this) :: array => stack_i4t2_data
88  end type stack_i4t2_t
89 
91  type, public, extends(stack_t) :: stack_i4t4_t
92  contains
93  procedure, public, pass(this) :: pop => stack_i4t4_pop
94  procedure, public, pass(this) :: array => stack_i4t4_data
95  end type stack_i4t4_t
96 
98  type, public, extends(stack_t) :: stack_i4r8t2_t
99  contains
100  procedure, public, pass(this) :: pop => stack_i4r8t2_pop
101  procedure, public, pass(this) :: array => stack_i4r8t2_data
102  end type stack_i4r8t2_t
103 
105  type, public, extends(stack_t) :: stack_2i4r8t3_t
106  contains
107  procedure, public, pass(this) :: pop => stack_2i4r8t3_pop
108  procedure, public, pass(this) :: array => stack_2i4r8t3_data
109  end type stack_2i4r8t3_t
110 
112  type, public, extends(stack_t) :: stack_curve_t
113  contains
114  procedure, public, pass(this) :: pop => stack_curve_element_pop
115  procedure, public, pass(this) :: array => stack_curve_element_data
116  end type stack_curve_t
117 
119  type, public, extends(stack_t) :: stack_nq_t
120  contains
121  procedure, public, pass(this) :: pop => stack_nq_pop
122  procedure, public, pass(this) :: array => stack_nq_data
123  end type stack_nq_t
124 
126  type, public, extends(stack_t) :: stack_nh_t
127  contains
128  procedure, public, pass(this) :: pop => stack_nh_pop
129  procedure, public, pass(this) :: array => stack_nh_data
130  end type stack_nh_t
131 
133  type, public, extends(stack_t) :: stack_nz_t
134  contains
135  procedure, public, pass(this) :: pop => stack_nz_pop
136  procedure, public, pass(this) :: array => stack_nz_data
137  end type stack_nz_t
138 
140  type, public, extends(stack_t) :: stack_nc_t
141  contains
142  procedure, public, pass(this) :: pop => stack_nc_pop
143  procedure, public, pass(this) :: array => stack_nc_data
144  end type stack_nc_t
145 
147  type, public, extends(stack_t) :: stack_pt_t
148  contains
149  procedure, public, pass(this) :: pop => stack_pt_pop
150  procedure, public, pass(this) :: array => stack_pt_data
151  end type stack_pt_t
152 
153 contains
154 
156  subroutine stack_init(this, size)
157  class(stack_t), intent(inout) :: this
158  integer, optional :: size
159  integer :: size_t
160 
161  if (present(size)) then
162  if (size .gt. 0) then
163  size_t = size
164  else
165  call neko_warning('Invalid stack size, using default')
166  size_t = neko_stack_size_t
167  end if
168  else
169  size_t = neko_stack_size_t
170  end if
171 
172  this%size_ = ishft(1, ceiling(log(real(size_t, rp)) / neko_m_ln2))
173  this%top_ = 0
174  select type(this)
175  type is(stack_i4_t)
176  allocate(integer::this%data(this%size_))
177  type is(stack_i8_t)
178  allocate(integer(i8)::this%data(this%size_))
179  type is (stack_r8_t)
180  allocate(double precision::this%data(this%size_))
181  type is (stack_i4t2_t)
182  allocate(tuple_i4_t::this%data(this%size_))
183  type is (stack_i4t4_t)
184  allocate(tuple4_i4_t::this%data(this%size_))
185  type is (stack_i4r8t2_t)
186  allocate(tuple_i4r8_t::this%data(this%size_))
187  type is (stack_2i4r8t3_t)
188  allocate(tuple_2i4r8_t::this%data(this%size_))
189  type is (stack_curve_t)
190  allocate(struct_curve_t::this%data(this%size_))
191  type is (stack_nq_t)
192  allocate(nmsh_quad_t::this%data(this%size_))
193  type is (stack_nh_t)
194  allocate(nmsh_hex_t::this%data(this%size_))
195  type is (stack_nz_t)
196  allocate(nmsh_zone_t::this%data(this%size_))
197  type is (stack_nc_t)
198  allocate(nmsh_curve_el_t::this%data(this%size_))
199  type is (stack_pt_t)
200  allocate(point_t::this%data(this%size_))
201  class default
202  call neko_error('Invalid data type')
203  end select
204 
205  end subroutine stack_init
206 
208  subroutine stack_free(this)
209  class(stack_t), intent(inout) :: this
210 
211  if (allocated(this%data)) then
212  deallocate(this%data)
213  this%size_ = 0
214  this%top_ = 0
215  end if
216 
217  end subroutine stack_free
218 
220  subroutine stack_clear(this)
221  class(stack_t), intent(inout) :: this
222  this%top_ = 0
223  end subroutine stack_clear
224 
226  pure function stack_size(this) result(size)
227  class(stack_t), intent(in) :: this
228  integer :: size
229  size = this%top_
230  end function stack_size
231 
233  pure function stack_is_empty(this) result(is_empty)
234  class(stack_t), intent(in) :: this
235  logical :: is_empty
236  is_empty = this%top_ .eq. 0
237  end function stack_is_empty
238 
240  subroutine stack_push(this, data)
241  class(stack_t), target, intent(inout) :: this
242  class(*), intent(inout) :: data
243  class(*), allocatable :: tmp(:)
244  integer :: i
245 
246  if (this%top_ .eq. this%size_) then
247  this%size_ = ishft(this%size_, 1)
248  select type(data)
249  type is(integer)
250  allocate(integer::tmp(this%size_))
251  type is(integer(i8))
252  allocate(integer(i8)::tmp(this%size_))
253  type is(double precision)
254  allocate(double precision::tmp(this%size_))
255  type is(tuple_i4_t)
256  allocate(tuple_i4_t::tmp(this%size_))
257  type is(tuple4_i4_t)
258  allocate(tuple4_i4_t::tmp(this%size_))
259  type is(tuple_i4r8_t)
260  allocate(tuple_i4r8_t::tmp(this%size_))
261  type is(tuple_2i4r8_t)
262  allocate(tuple_2i4r8_t::tmp(this%size_))
263  type is(struct_curve_t)
264  allocate(struct_curve_t::tmp(this%size_))
265  type is (nmsh_quad_t)
266  allocate(nmsh_quad_t::tmp(this%size_))
267  type is (nmsh_hex_t)
268  allocate(nmsh_hex_t::tmp(this%size_))
269  type is (nmsh_zone_t)
270  allocate(nmsh_zone_t::tmp(this%size_))
271  type is (nmsh_curve_el_t)
272  allocate(nmsh_curve_el_t::tmp(this%size_))
273  type is (point_t)
274  allocate(point_t::tmp(this%size_))
275  class default
276  call neko_error('Invalid data type (stack_push)')
277  end select
278 
279  select type(tmp)
280  type is (integer)
281  select type(sdp=>this%data)
282  type is (integer)
283  tmp(1:this%top_) = sdp
284  end select
285  type is (integer(i8))
286  select type(sdp=>this%data)
287  type is (integer(i8))
288  tmp(1:this%top_) = sdp
289  end select
290  type is (double precision)
291  select type(sdp=>this%data)
292  type is (double precision)
293  tmp(1:this%top_) = sdp
294  end select
295  type is (tuple_i4_t)
296  select type(sdp=>this%data)
297  type is (tuple_i4_t)
298  do i = 1, this%top_
299  tmp(i) = sdp(i)
300  end do
301  end select
302  type is (tuple4_i4_t)
303  select type(sdp=>this%data)
304  type is (tuple4_i4_t)
305  do i = 1, this%top_
306  tmp(i) = sdp(i)
307  end do
308  end select
309  type is (tuple_i4r8_t)
310  select type(sdp=>this%data)
311  type is (tuple_i4r8_t)
312  do i = 1, this%top_
313  tmp(i) = sdp(i)
314  end do
315  end select
316  type is (tuple_2i4r8_t)
317  select type(sdp=>this%data)
318  type is (tuple_2i4r8_t)
319  do i = 1, this%top_
320  tmp(i) = sdp(i)
321  end do
322  end select
323  type is (struct_curve_t)
324  select type(sdp=>this%data)
325  type is (struct_curve_t)
326  tmp(1:this%top_) = sdp
327  end select
328  type is (nmsh_quad_t)
329  select type(sdp=>this%data)
330  type is(nmsh_quad_t)
331  tmp(1:this%top_) = sdp
332  end select
333  type is (nmsh_hex_t)
334  select type(sdp=>this%data)
335  type is(nmsh_hex_t)
336  tmp(1:this%top_) = sdp
337  end select
338  type is (nmsh_zone_t)
339  select type(sdp=>this%data)
340  type is(nmsh_zone_t)
341  tmp(1:this%top_) = sdp
342  end select
343  type is (nmsh_curve_el_t)
344  select type(sdp=>this%data)
345  type is(nmsh_curve_el_t)
346  tmp(1:this%top_) = sdp
347  end select
348  type is (point_t)
349  select type(sdp=>this%data)
350  type is(point_t)
351  tmp(1:this%top_) = sdp
352  end select
353  class default
354  call neko_error('Invalid data type (stack_push tmp)')
355  end select
356  call move_alloc(tmp, this%data)
357  end if
358 
359  this%top_ = this%top_ + 1
360 
361  select type(sdp=>this%data)
362  type is (integer)
363  select type(data)
364  type is (integer)
365  sdp(this%top_) = data
366  end select
367  type is (integer(i8))
368  select type(data)
369  type is (integer(i8))
370  sdp(this%top_) = data
371  end select
372  type is (double precision)
373  select type(data)
374  type is (double precision)
375  sdp(this%top_) = data
376  end select
377  type is (tuple_i4_t)
378  select type(data)
379  type is (tuple_i4_t)
380  sdp(this%top_) = data
381  end select
382  type is (tuple4_i4_t)
383  select type(data)
384  type is (tuple4_i4_t)
385  sdp(this%top_) = data
386  end select
387  type is (tuple_i4r8_t)
388  select type(data)
389  type is (tuple_i4r8_t)
390  sdp(this%top_) = data
391  end select
392  type is (tuple_2i4r8_t)
393  select type(data)
394  type is (tuple_2i4r8_t)
395  sdp(this%top_) = data
396  end select
397  type is (struct_curve_t)
398  select type(data)
399  type is (struct_curve_t)
400  sdp(this%top_) = data
401  end select
402  type is (nmsh_quad_t)
403  select type(data)
404  type is (nmsh_quad_t)
405  sdp(this%top_) = data
406  end select
407  type is (nmsh_hex_t)
408  select type(data)
409  type is (nmsh_hex_t)
410  sdp(this%top_) = data
411  end select
412  type is (nmsh_zone_t)
413  select type(data)
414  type is (nmsh_zone_t)
415  sdp(this%top_) = data
416  end select
417  type is (nmsh_curve_el_t)
418  select type(data)
419  type is (nmsh_curve_el_t)
420  sdp(this%top_) = data
421  end select
422  type is (point_t)
423  select type(data)
424  type is (point_t)
425  sdp(this%top_) = data
426  end select
427  class default
428  call neko_error('Invalid data type in stack (stack_push)')
429  end select
430  end subroutine stack_push
431 
433  function stack_i4_pop(this) result(data)
434  class(stack_i4_t), target, intent(inout) :: this
435  integer :: data
436 
437  select type (sdp=>this%data)
438  type is (integer)
439  data = sdp(this%top_)
440  class default
441  call neko_error('Invalid data type (i4 pop)')
442  end select
443  this%top_ = this%top_ - 1
444  end function stack_i4_pop
445 
447  function stack_i4_data(this) result(data)
448  class(stack_i4_t), target, intent(inout) :: this
449  integer, contiguous, pointer :: data(:)
450 
451  select type (sdp=>this%data)
452  type is (integer)
453  data => sdp
454  class default
455  call neko_error('Invalid data type (i4 array)')
456  end select
457  end function stack_i4_data
458 
460  function stack_i8_pop(this) result(data)
461  class(stack_i8_t), target, intent(inout) :: this
462  integer(kind=i8) :: data
463 
464  select type (sdp=>this%data)
465  type is (integer(i8))
466  data = sdp(this%top_)
467  class default
468  call neko_error('Invalid data type (i8 pop)')
469  end select
470  this%top_ = this%top_ - 1
471  end function stack_i8_pop
472 
474  function stack_i8_data(this) result(data)
475  class(stack_i8_t), target, intent(inout) :: this
476  integer(kind=i8), contiguous, pointer :: data(:)
477 
478  select type (sdp=>this%data)
479  type is (integer(i8))
480  data => sdp
481  class default
482  call neko_error('Invalid data type (i8 array)')
483  end select
484  end function stack_i8_data
485 
487  function stack_r8_pop(this) result(data)
488  class(stack_r8_t), target, intent(inout) :: this
489  real(kind=dp) :: data
490 
491  select type (sdp=>this%data)
492  type is (double precision)
493  data = sdp(this%top_)
494  class default
495  call neko_error('Invalid data type (r8 pop)')
496  end select
497  this%top_ = this%top_ -1
498  end function stack_r8_pop
499 
501  function stack_r8_data(this) result(data)
502  class(stack_r8_t), target, intent(inout) :: this
503  real(kind=dp), contiguous, pointer :: data(:)
504 
505  select type (sdp=>this%data)
506  type is (double precision)
507  data => sdp
508  class default
509  call neko_error('Invalid data type (r8 array)')
510  end select
511  end function stack_r8_data
512 
514  function stack_i4t2_pop(this) result(data)
515  class(stack_i4t2_t), target, intent(inout) :: this
516  type(tuple_i4_t) :: data
517 
518  select type (sdp=>this%data)
519  type is (tuple_i4_t)
520  data = sdp(this%top_)
521  class default
522  call neko_error('Invalid data type (i4t2 pop)')
523  end select
524  this%top_ = this%top_ -1
525  end function stack_i4t2_pop
526 
528  function stack_i4t2_data(this) result(data)
529  class(stack_i4t2_t), target, intent(inout) :: this
530  type(tuple_i4_t), contiguous, pointer :: data(:)
531 
532  select type (sdp=>this%data)
533  type is (tuple_i4_t)
534  data => sdp
535  class default
536  call neko_error('Invalid data type (i4t2 array)')
537  end select
538  end function stack_i4t2_data
539 
541  function stack_i4t4_pop(this) result(data)
542  class(stack_i4t4_t), target, intent(inout) :: this
543  type(tuple4_i4_t) :: data
544 
545  select type (sdp=>this%data)
546  type is (tuple4_i4_t)
547  data = sdp(this%top_)
548  class default
549  call neko_error('Invalid data type (i4t4 pop)')
550  end select
551  this%top_ = this%top_ -1
552  end function stack_i4t4_pop
553 
555  function stack_i4t4_data(this) result(data)
556  class(stack_i4t4_t), target, intent(inout) :: this
557  type(tuple4_i4_t), contiguous, pointer :: data(:)
558 
559  select type (sdp=>this%data)
560  type is (tuple4_i4_t)
561  data => sdp
562  class default
563  call neko_error('Invalid data type (i4t4 array)')
564  end select
565  end function stack_i4t4_data
566 
568  function stack_i4r8t2_pop(this) result(data)
569  class(stack_i4r8t2_t), target, intent(inout) :: this
570  type(tuple_i4r8_t) :: data
571 
572  select type (sdp=>this%data)
573  type is (tuple_i4r8_t)
574  data = sdp(this%top_)
575  class default
576  call neko_error('Invalid data type (i4r8t2 pop)')
577  end select
578  this%top_ = this%top_ -1
579  end function stack_i4r8t2_pop
580 
582  function stack_i4r8t2_data(this) result(data)
583  class(stack_i4r8t2_t), target, intent(inout) :: this
584  type(tuple_i4r8_t), contiguous, pointer :: data(:)
585 
586  select type (sdp=>this%data)
587  type is (tuple_i4r8_t)
588  data => sdp
589  class default
590  call neko_error('Invalid data type (i4r8t2 array)')
591  end select
592  end function stack_i4r8t2_data
593 
595  function stack_2i4r8t3_pop(this) result(data)
596  class(stack_2i4r8t3_t), target, intent(inout) :: this
597  type(tuple_2i4r8_t) :: data
598 
599  select type (sdp=>this%data)
600  type is (tuple_2i4r8_t)
601  data = sdp(this%top_)
602  class default
603  call neko_error('Invalid data type (i4r8t2 pop)')
604  end select
605  this%top_ = this%top_ -1
606  end function stack_2i4r8t3_pop
607 
609  function stack_2i4r8t3_data(this) result(data)
610  class(stack_2i4r8t3_t), target, intent(inout) :: this
611  type(tuple_2i4r8_t), contiguous, pointer :: data(:)
612 
613  select type (sdp=>this%data)
614  type is (tuple_2i4r8_t)
615  data => sdp
616  class default
617  call neko_error('Invalid data type (i4r8t2 array)')
618  end select
619  end function stack_2i4r8t3_data
620 
622  function stack_curve_element_pop(this) result(data)
623  class(stack_curve_t), target, intent(inout) :: this
624  type(struct_curve_t) :: data
625 
626  select type (sdp=>this%data)
627  type is (struct_curve_t)
628  data = sdp(this%top_)
629  class default
630  call neko_error('Invalid data type (curve pop)')
631  end select
632  this%top_ = this%top_ -1
633  end function stack_curve_element_pop
634 
636  function stack_curve_element_data(this) result(data)
637  class(stack_curve_t), target, intent(inout) :: this
638  type(struct_curve_t), contiguous, pointer :: data(:)
639 
640  select type (sdp=>this%data)
641  type is (struct_curve_t)
642  data => sdp
643  class default
644  call neko_error('Invalid data type (curve array)')
645  end select
646  end function stack_curve_element_data
647 
649  function stack_nq_pop(this) result(data)
650  class(stack_nq_t), target, intent(inout) :: this
651  type(nmsh_quad_t) :: data
652 
653  select type (sdp=>this%data)
654  type is (nmsh_quad_t)
655  data = sdp(this%top_)
656  class default
657  call neko_error('Invalid data type (nq pop)')
658  end select
659  this%top_ = this%top_ -1
660  end function stack_nq_pop
661 
663  function stack_nq_data(this) result(data)
664  class(stack_nq_t), target, intent(inout) :: this
665  type(nmsh_quad_t), contiguous, pointer :: data(:)
666 
667  select type (sdp=>this%data)
668  type is (nmsh_quad_t)
669  data => sdp
670  class default
671  call neko_error('Invalid data type (nq array)')
672  end select
673  end function stack_nq_data
674 
676  function stack_nh_pop(this) result(data)
677  class(stack_nh_t), target, intent(inout) :: this
678  type(nmsh_hex_t) :: data
679 
680  select type (sdp=>this%data)
681  type is (nmsh_hex_t)
682  data = sdp(this%top_)
683  class default
684  call neko_error('Invalid data type (nh pop)')
685  end select
686  this%top_ = this%top_ -1
687  end function stack_nh_pop
688 
690  function stack_nh_data(this) result(data)
691  class(stack_nh_t), target, intent(inout) :: this
692  type(nmsh_hex_t), contiguous, pointer :: data(:)
693 
694  select type (sdp => this%data)
695  type is (nmsh_hex_t)
696  data => sdp
697  class default
698  call neko_error('Invalid data type (nh array)')
699  end select
700  end function stack_nh_data
701 
703  function stack_nz_pop(this) result(data)
704  class(stack_nz_t), target, intent(inout) :: this
705  type(nmsh_zone_t) :: data
706 
707  select type (sdp=>this%data)
708  type is (nmsh_zone_t)
709  data = sdp(this%top_)
710  class default
711  call neko_error('Invalid data type (nz pop)')
712  end select
713  this%top_ = this%top_ -1
714  end function stack_nz_pop
715 
717  function stack_nz_data(this) result(data)
718  class(stack_nz_t), target, intent(inout) :: this
719  type(nmsh_zone_t), contiguous, pointer :: data(:)
720 
721  select type (sdp=>this%data)
722  type is (nmsh_zone_t)
723  data => sdp
724  class default
725  call neko_error('Invalid data type (nz array)')
726  end select
727  end function stack_nz_data
728 
730  function stack_nc_pop(this) result(data)
731  class(stack_nc_t), target, intent(inout) :: this
732  type(nmsh_curve_el_t) :: data
733 
734  select type (sdp=>this%data)
735  type is (nmsh_curve_el_t)
736  data = sdp(this%top_)
737  class default
738  call neko_error('Invalid data type (nc pop)')
739  end select
740  this%top_ = this%top_ -1
741  end function stack_nc_pop
742 
744  function stack_nc_data(this) result(data)
745  class(stack_nc_t), target, intent(inout) :: this
746  type(nmsh_curve_el_t), pointer :: data(:)
747 
748  select type (sdp=>this%data)
749  type is (nmsh_curve_el_t)
750  data => sdp
751  class default
752  call neko_error('Invalid data type (nc array)')
753  end select
754  end function stack_nc_data
755 
757  function stack_pt_pop(this) result(data)
758  class(stack_pt_t), target, intent(inout) :: this
759  type(point_t) :: data
760 
761  select type (sdp=>this%data)
762  type is (point_t)
763  data = sdp(this%top_)
764  class default
765  call neko_error('Invalid data type (point pop)')
766  end select
767  this%top_ = this%top_ -1
768  end function stack_pt_pop
769 
771  function stack_pt_data(this) result(data)
772  class(stack_pt_t), target, intent(inout) :: this
773  type(point_t), contiguous, pointer :: data(:)
774 
775  select type (sdp=>this%data)
776  type is (point_t)
777  data => sdp
778  class default
779  call neko_error('Invalid data type (point array)')
780  end select
781  end function stack_pt_data
782 
783 end module stack
double real
Definition: device_config.h:12
Definition: math.f90:60
real(kind=rp), parameter, public neko_m_ln2
Definition: math.f90:70
Neko binary mesh format.
Definition: nmsh.f90:2
integer, parameter, public i8
Definition: num_types.f90:7
integer, parameter, public dp
Definition: num_types.f90:9
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Implements a point.
Definition: point.f90:35
Implements a dynamic stack ADT.
Definition: stack.f90:35
type(struct_curve_t) function stack_curve_element_pop(this)
Pop a curve element of the stack.
Definition: stack.f90:623
type(tuple_2i4r8_t) function, dimension(:), pointer, contiguous stack_2i4r8t3_data(this)
Return a pointer to the internal 2-tuple array.
Definition: stack.f90:610
subroutine stack_free(this)
Destroy a stack.
Definition: stack.f90:209
type(tuple_2i4r8_t) function stack_2i4r8t3_pop(this)
Pop a mixed integer-double precision 3-tuple of the stack.
Definition: stack.f90:596
type(point_t) function stack_pt_pop(this)
Pop a point of the stack.
Definition: stack.f90:758
subroutine stack_clear(this)
Clear all entries of a stack.
Definition: stack.f90:221
type(nmsh_zone_t) function, dimension(:), pointer, contiguous stack_nz_data(this)
Return a pointer to the internal Neko zone array.
Definition: stack.f90:718
type(nmsh_quad_t) function stack_nq_pop(this)
Pop a Neko quad element of the stack.
Definition: stack.f90:650
type(tuple_i4_t) function, dimension(:), pointer, contiguous stack_i4t2_data(this)
Return a pointer to the interal 2-tuple array.
Definition: stack.f90:529
type(tuple_i4_t) function stack_i4t2_pop(this)
Pop an integer 2-tuple of the stack.
Definition: stack.f90:515
real(kind=dp) function, dimension(:), pointer, contiguous stack_r8_data(this)
Return a pointer to the internal double precision array.
Definition: stack.f90:502
pure integer function stack_size(this)
Return number of entries in the stack.
Definition: stack.f90:227
type(tuple4_i4_t) function, dimension(:), pointer, contiguous stack_i4t4_data(this)
Return a pointer to the internal 4-tuple array.
Definition: stack.f90:556
pure logical function stack_is_empty(this)
Return true if the stack is empty.
Definition: stack.f90:234
subroutine stack_push(this, data)
Push data onto the stack.
Definition: stack.f90:241
integer function, dimension(:), pointer, contiguous stack_i4_data(this)
Return a pointer to the internal integer array.
Definition: stack.f90:448
type(tuple4_i4_t) function stack_i4t4_pop(this)
Pop an integer 4-tuple of the stack.
Definition: stack.f90:542
real(kind=dp) function stack_r8_pop(this)
Pop a double precision value of the stack.
Definition: stack.f90:488
type(nmsh_zone_t) function stack_nz_pop(this)
Pop a Neko zone of the stack.
Definition: stack.f90:704
type(nmsh_quad_t) function, dimension(:), pointer, contiguous stack_nq_data(this)
Return a pointer to the internal Neko quad array.
Definition: stack.f90:664
subroutine stack_init(this, size)
Initialize a stack of arbitrary type.
Definition: stack.f90:157
integer function stack_i4_pop(this)
Pop an integer of the stack.
Definition: stack.f90:434
integer, parameter neko_stack_size_t
Definition: stack.f90:46
integer(kind=i8) function, dimension(:), pointer, contiguous stack_i8_data(this)
Return a pointer to the internal integer*8 array.
Definition: stack.f90:475
type(tuple_i4r8_t) function, dimension(:), pointer, contiguous stack_i4r8t2_data(this)
Return a pointer to the internal 2-tuple array.
Definition: stack.f90:583
type(nmsh_hex_t) function stack_nh_pop(this)
Pop a Neko hex element of the stack.
Definition: stack.f90:677
type(struct_curve_t) function, dimension(:), pointer, contiguous stack_curve_element_data(this)
Return a pointer to the internal curve element array.
Definition: stack.f90:637
type(tuple_i4r8_t) function stack_i4r8t2_pop(this)
Pop a mixed integer-double precision 2-tuple of the stack.
Definition: stack.f90:569
integer(kind=i8) function stack_i8_pop(this)
Pop an integer*8 of the stack.
Definition: stack.f90:461
type(nmsh_curve_el_t) function stack_nc_pop(this)
Pop a Neko curve info of the stack.
Definition: stack.f90:731
type(point_t) function, dimension(:), pointer, contiguous stack_pt_data(this)
Return a pointer to the internal point array.
Definition: stack.f90:772
type(nmsh_hex_t) function, dimension(:), pointer, contiguous stack_nh_data(this)
Return a pointer to the internal Neko quad array.
Definition: stack.f90:691
type(nmsh_curve_el_t) function, dimension(:), pointer stack_nc_data(this)
Return a pointer to the internal Neko curve info array.
Definition: stack.f90:745
Defines structs that are used... Dont know if we should keep it though.
Definition: structs.f90:2
Implements a n-tuple.
Definition: tuple.f90:34
Utilities.
Definition: utils.f90:35
subroutine, public neko_warning(warning_msg)
Definition: utils.f90:198
Neko curve data.
Definition: nmsh.f90:39
Neko hex element data.
Definition: nmsh.f90:24
Neko quad element data.
Definition: nmsh.f90:19
Neko zone data.
Definition: nmsh.f90:29
A point in with coordinates .
Definition: point.f90:43
Mixed integer-double precision 3-tuple based stack.
Definition: stack.f90:105
Curved element stack.
Definition: stack.f90:112
Integer based stack.
Definition: stack.f90:63
Mixed integer-double precision 2-tuple based stack.
Definition: stack.f90:98
Integer 2-tuple based stack.
Definition: stack.f90:84
Integer 4-tuple based stack.
Definition: stack.f90:91
Integer*8 based stack.
Definition: stack.f90:70
Neko curve info based stack.
Definition: stack.f90:140
Neko hex element based stack.
Definition: stack.f90:126
Neko quad element based stack.
Definition: stack.f90:119
Neko zone based stack.
Definition: stack.f90:133
Point based stack.
Definition: stack.f90:147
Double precision based stack.
Definition: stack.f90:77
Base type for a stack.
Definition: stack.f90:49
Integer based 4-tuple.
Definition: tuple.f90:69
Mixed integer ( ) double precision ( ) 3-tuple.
Definition: tuple.f90:97
Integer based 2-tuple.
Definition: tuple.f90:51
Mixed integer ( ) double precision ( ) 2-tuple .
Definition: tuple.f90:87