Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
registry.f90
Go to the documentation of this file.
1! Copyright (c) 2018-2026, 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 use num_types, only : rp
36 use field, only : field_t
37 use vector, only : vector_t
38 use matrix, only : matrix_t
39 use tensor3, only : tensor3_t
40 use tensor4, only : tensor4_t
42 use dofmap, only : dofmap_t
43 use utils, only : neko_error
44 use json_module, only : json_file
46 implicit none
47 private
48
49 type, public :: registry_t
51 type(registry_entry_t), private, allocatable :: entries(:)
53 type(json_file), private :: aliases
55 integer, private :: n_entries_ = 0
57 integer, private :: n_aliases_ = 0
59 integer, private :: expansion_size_ = 5
60 contains
62 procedure, pass(this) :: init => registry_init
64 procedure, pass(this) :: free => registry_free
66 procedure, private, pass(this) :: expand => registry_expand
67
69 procedure, pass(this) :: add_field => registry_add_field
71 procedure, pass(this) :: add_vector => registry_add_vector
73 procedure, pass(this) :: add_matrix => registry_add_matrix
75 procedure, pass(this) :: add_tensor3 => registry_add_tensor3
77 procedure, pass(this) :: add_tensor4 => registry_add_tensor4
79 procedure, pass(this) :: add_real_scalar => registry_add_real_scalar
81 procedure, pass(this) :: add_integer_scalar => registry_add_integer_scalar
83 procedure, pass(this) :: add_alias => registry_add_alias
84
86 procedure, pass(this) :: get_field => registry_get_field
88 procedure, pass(this) :: get_vector => registry_get_vector
90 procedure, pass(this) :: get_matrix => registry_get_matrix
92 procedure, pass(this) :: get_tensor3 => registry_get_tensor3
94 procedure, pass(this) :: get_tensor4 => registry_get_tensor4
96 procedure, pass(this) :: get_real_scalar => registry_get_real_scalar
99
100 ! Just to retain the old API for backwards compatibility.
101 generic :: get_field_by_name => get_field
102 generic :: get_vector_by_name => get_vector
103 generic :: get_matrix_by_name => get_matrix
104 generic :: get_tensor3_by_name => get_tensor3
105 generic :: get_tensor4_by_name => get_tensor4
106 generic :: get_real_scalar_by_name => get_real_scalar
107 generic :: get_integer_scalar_by_name => get_integer_scalar
108
110 procedure, pass(this) :: entry_exists => registry_entry_exists
112 procedure, pass(this) :: field_exists => registry_field_exists
114 procedure, pass(this) :: vector_exists => registry_vector_exists
116 procedure, pass(this) :: matrix_exists => registry_matrix_exists
118 procedure, pass(this) :: tensor3_exists => registry_tensor3_exists
120 procedure, pass(this) :: tensor4_exists => registry_tensor4_exists
122 procedure, pass(this) :: real_scalar_exists => registry_real_scalar_exists
124 procedure, pass(this) :: integer_scalar_exists => &
127 procedure, pass(this) :: scalar_exists => registry_real_scalar_exists
128
130 procedure, pass(this) :: get_size => registry_get_size
132 procedure, pass(this) :: n_entries => registry_n_entries
134 procedure, pass(this) :: n_fields => registry_n_fields
136 procedure, pass(this) :: n_vectors => registry_n_vectors
138 procedure, pass(this) :: n_matrices => registry_n_matrices
140 procedure, pass(this) :: n_tensor3s => registry_n_tensor3s
142 procedure, pass(this) :: n_tensor4s => registry_n_tensor4s
144 procedure, pass(this) :: n_real_scalars => registry_n_real_scalars
146 procedure, pass(this) :: n_integer_scalars => registry_n_integer_scalars
148 procedure, pass(this) :: n_scalars => registry_n_real_scalars
150 procedure, pass(this) :: n_aliases => registry_n_aliases
152 procedure, pass(this) :: get_expansion_size => registry_get_expansion_size
154 procedure, pass(this) :: print_contents => registry_print_contents
155 end type registry_t
156
158 type(registry_t), public, target :: neko_registry
159
164 type(registry_t), public, target :: neko_const_registry
165
166contains
167 ! ========================================================================== !
168 ! Constructors/Destructors
169
174 subroutine registry_init(this, size, expansion_size)
175 class(registry_t), intent(inout):: this
176 integer, optional, intent(in) :: size
177 integer, optional, intent(in) :: expansion_size
178
179 call this%free()
180
181 if (present(size)) then
182 allocate(this%entries(size))
183 else
184 allocate(this%entries(25))
185 end if
186
187 call this%aliases%initialize()
188
189 if (present(expansion_size)) then
190 this%expansion_size_ = expansion_size
191 end if
192
193 end subroutine registry_init
194
196 subroutine registry_free(this)
197 class(registry_t), intent(inout):: this
198 integer :: i
199
200 if (allocated(this%entries)) then
201 do i = 1, this%n_entries()
202 call this%entries(i)%free()
203 end do
204 deallocate(this%entries)
205 end if
206
207 call this%aliases%destroy()
208
209 this%n_entries_ = 0
210 this%n_aliases_ = 0
211 this%expansion_size_ = 5
212 end subroutine registry_free
213
215 subroutine registry_expand(this)
216 class(registry_t), intent(inout) :: this
217 type(registry_entry_t), allocatable :: temp(:)
218 integer :: n, i
219
220 n = this%get_size()
221
222 if (n .gt. 0) then
223 call move_alloc(this%entries, temp)
224 end if
225
226 allocate(this%entries(n + this%expansion_size_))
227
228 if (n .gt. 0) then
229 do i = 1, n
230 call this%entries(i)%move_from(temp(i))
231 call temp(i)%free()
232 end do
233 end if
234
235 if (allocated(temp)) deallocate(temp)
236 end subroutine registry_expand
237
238 ! ========================================================================== !
239 ! Methods for adding objects to the registry
240
246 subroutine registry_add_field(this, dof, name, ignore_existing)
247 class(registry_t), intent(inout) :: this
248 type(dofmap_t), target, intent(in) :: dof
249 character(len=*), target, intent(in) :: name
250 logical, optional, intent(in) :: ignore_existing
251 logical :: ignore_existing_
252
253 ignore_existing_ = .false.
254 if (present(ignore_existing)) then
255 ignore_existing_ = ignore_existing
256 end if
257
258 if (this%field_exists(name)) then
259 if (ignore_existing_) then
260 return
261 else
262 call neko_error("Field with name " // name // &
263 " is already registered")
264 end if
265 end if
266
267 if (this%n_entries() .eq. this%get_size()) then
268 call this%expand()
269 end if
270
271 this%n_entries_ = this%n_entries_ + 1
272
273 ! initialize the field at the appropriate index
274 call this%entries(this%n_entries_)%init_field(dof, name)
275
276 call neko_log%message("Field " // trim(name) // " added to the registry", &
277 lvl=neko_log_debug)
278
279 end subroutine registry_add_field
280
286 subroutine registry_add_vector(this, n, name, ignore_existing)
287 class(registry_t), intent(inout) :: this
288 integer, intent(in) :: n
289 character(len=*), target, intent(in) :: name
290 logical, optional, intent(in) :: ignore_existing
291 logical :: ignore_existing_
292
293 ignore_existing_ = .false.
294 if (present(ignore_existing)) then
295 ignore_existing_ = ignore_existing
296 end if
297
298 if (this%vector_exists(name)) then
299 if (ignore_existing_) then
300 return
301 else
302 call neko_error("Vector with name " // name // &
303 " is already registered")
304 end if
305 end if
306
307 if (this%n_entries() .eq. this%get_size()) then
308 call this%expand()
309 end if
310
311 this%n_entries_ = this%n_entries_ + 1
312
313 ! Initialize the named vector at the appropriate index
314 call this%entries(this%n_entries_)%init_vector(n, name)
315
316 call neko_log%message("Vector " // trim(name) // " added to the registry", &
317 lvl=neko_log_debug)
318
319 end subroutine registry_add_vector
320
326 subroutine registry_add_matrix(this, nrows, ncols, name, ignore_existing)
327 class(registry_t), intent(inout) :: this
328 integer, intent(in) :: nrows, ncols
329 character(len=*), target, intent(in) :: name
330 logical, optional, intent(in) :: ignore_existing
331 logical :: ignore_existing_
332
333 ignore_existing_ = .false.
334 if (present(ignore_existing)) then
335 ignore_existing_ = ignore_existing
336 end if
337
338 if (this%matrix_exists(name)) then
339 if (ignore_existing_) then
340 return
341 else
342 call neko_error("Matrix with name " // name // &
343 " is already registered")
344 end if
345 end if
346
347 if (this%n_entries() .eq. this%get_size()) then
348 call this%expand()
349 end if
350
351 this%n_entries_ = this%n_entries_ + 1
352
353 ! Initialize the named matrix at the appropriate index
354 call this%entries(this%n_entries_)%init_matrix(nrows, ncols, name)
355
356 call neko_log%message("Matrix " // trim(name) // " added to the registry", &
357 lvl=neko_log_debug)
358
359 end subroutine registry_add_matrix
360
366 subroutine registry_add_tensor3(this, n, m, k, name, ignore_existing)
367 class(registry_t), intent(inout) :: this
368 integer, intent(in) :: n, m, k
369 character(len=*), target, intent(in) :: name
370 logical, optional, intent(in) :: ignore_existing
371 logical :: ignore_existing_
372
373 ignore_existing_ = .false.
374 if (present(ignore_existing)) then
375 ignore_existing_ = ignore_existing
376 end if
377
378 if (this%tensor3_exists(name)) then
379 if (ignore_existing_) then
380 return
381 else
382 call neko_error("Tensor3 with name " // name // &
383 " is already registered")
384 end if
385 end if
386
387 if (this%n_entries() .eq. this%get_size()) then
388 call this%expand()
389 end if
390
391 this%n_entries_ = this%n_entries_ + 1
392
393 ! Initialize the named tensor3 at the appropriate index
394 call this%entries(this%n_entries_)%init_tensor3(n, m, k, name)
395
396 call neko_log%message("Tensor3 " // trim(name) // &
397 " added to the registry", lvl=neko_log_debug)
398
399 end subroutine registry_add_tensor3
400
406 subroutine registry_add_tensor4(this, n, m, k, l, name, ignore_existing)
407 class(registry_t), intent(inout) :: this
408 integer, intent(in) :: n, m, k, l
409 character(len=*), target, intent(in) :: name
410 logical, optional, intent(in) :: ignore_existing
411 logical :: ignore_existing_
412
413 ignore_existing_ = .false.
414 if (present(ignore_existing)) then
415 ignore_existing_ = ignore_existing
416 end if
417
418 if (this%tensor4_exists(name)) then
419 if (ignore_existing_) then
420 return
421 else
422 call neko_error("Tensor4 with name " // name // &
423 " is already registered")
424 end if
425 end if
426
427 if (this%n_entries() .eq. this%get_size()) then
428 call this%expand()
429 end if
430
431 this%n_entries_ = this%n_entries_ + 1
432
433 ! Initialize the named tensor4 at the appropriate index
434 call this%entries(this%n_entries_)%init_tensor4(n, m, k, l, name)
435
436 call neko_log%message("Tensor4 " // trim(name) // &
437 " added to the registry", lvl=neko_log_debug)
438
439 end subroutine registry_add_tensor4
440
445 subroutine registry_add_real_scalar(this, value, name, ignore_existing)
446 class(registry_t), intent(inout) :: this
447 real(kind=rp), intent(in) :: value
448 character(len=*), target, intent(in) :: name
449 logical, optional, intent(in) :: ignore_existing
450 logical :: ignore_existing_
451
452 ignore_existing_ = .false.
453 if (present(ignore_existing)) then
454 ignore_existing_ = ignore_existing
455 end if
456
457 if (this%real_scalar_exists(name)) then
458 if (ignore_existing_) then
459 return
460 else
461 call neko_error("Scalar with name " // name // &
462 " is already registered")
463 end if
464 end if
465
466 if (this%n_entries() .eq. this%get_size()) then
467 call this%expand()
468 end if
469
470 this%n_entries_ = this%n_entries_ + 1
471
472 ! Initialize the named scalar at the appropriate index
473 call this%entries(this%n_entries_)%init_real_scalar(value, name)
474
475 end subroutine registry_add_real_scalar
476
481 subroutine registry_add_integer_scalar(this, value, name, ignore_existing)
482 class(registry_t), intent(inout) :: this
483 integer, intent(in) :: value
484 character(len=*), target, intent(in) :: name
485 logical, optional, intent(in) :: ignore_existing
486 logical :: ignore_existing_
487
488 ignore_existing_ = .false.
489 if (present(ignore_existing)) then
490 ignore_existing_ = ignore_existing
491 end if
492
493 if (this%integer_scalar_exists(name)) then
494 if (ignore_existing_) then
495 return
496 else
497 call neko_error("Scalar with name " // name // &
498 " is already registered")
499 end if
500 end if
501
502 if (this%n_entries() .eq. this%get_size()) then
503 call this%expand()
504 end if
505
506 this%n_entries_ = this%n_entries_ + 1
507
508 ! Initialize the named scalar at the appropriate index
509 call this%entries(this%n_entries_)%init_integer_scalar(value, name)
510
511 end subroutine registry_add_integer_scalar
512
516 subroutine registry_add_alias(this, alias, name)
517 class(registry_t), intent(inout) :: this
518 character(len=*), intent(in) :: alias
519 character(len=*), intent(in) :: name
520
521 if (this%entry_exists(alias)) then
522 call neko_error("Cannot create alias. Entry " // alias // &
523 " already exists in the registry")
524 end if
525
526 if (this%entry_exists(name)) then
527 this%n_aliases_ = this%n_aliases_ + 1
528 call this%aliases%add(trim(alias), trim(name))
529 else
530 call neko_error("Cannot create alias. Entry " // name // &
531 " could not be found in the registry")
532 end if
533 end subroutine registry_add_alias
534
535 ! ========================================================================== !
536 ! Methods for retrieving objects from the registry by name
537
539 recursive function registry_get_field(this, name) result(f)
540 class(registry_t), target, intent(inout) :: this
541 character(len=*), intent(in) :: name
542 character(len=:), allocatable :: alias_target
543 type(field_t), pointer :: f
544 logical :: found
545 integer :: i
546
547 do i = 1, this%n_entries()
548 if (this%entries(i)%get_type() .eq. 'field' .and. &
549 this%entries(i)%get_name() .eq. trim(name)) then
550 f => this%entries(i)%get_field()
551 return
552 end if
553 end do
554
555 call this%aliases%get(name, alias_target, found)
556 if (found) then
557 f => this%get_field(alias_target)
558 return
559 end if
560
561 call this%print_contents()
562 call neko_error("Field " // name // " could not be found in the registry")
563
564 end function registry_get_field
565
566
568 recursive function registry_get_vector(this, name) result(f)
569 class(registry_t), target, intent(inout) :: this
570 character(len=*), intent(in) :: name
571 character(len=:), allocatable :: alias_target
572 type(vector_t), pointer :: f
573 logical :: found
574 integer :: i
575
576 found = .false.
577
578 do i = 1, this%n_entries()
579 if (this%entries(i)%get_type() .eq. 'vector' .and. &
580 this%entries(i)%get_name() .eq. trim(name)) then
581 f => this%entries(i)%get_vector()
582 return
583 end if
584 end do
585
586 call this%aliases%get(name, alias_target, found)
587 if (found) then
588 f => this%get_vector(alias_target)
589 return
590 end if
591
592 call this%print_contents()
593 call neko_error("Vector " // name // " could not be found in the registry")
594
595 end function registry_get_vector
596
598 recursive function registry_get_matrix(this, name) result(f)
599 class(registry_t), target, intent(inout) :: this
600 character(len=*), intent(in) :: name
601 character(len=:), allocatable :: alias_target
602 type(matrix_t), pointer :: f
603 logical :: found
604 integer :: i
605
606 found = .false.
607
608 do i = 1, this%n_entries()
609 if (this%entries(i)%get_type() .eq. 'matrix' .and. &
610 this%entries(i)%get_name() .eq. trim(name)) then
611 f => this%entries(i)%get_matrix()
612 return
613 end if
614 end do
615
616 call this%aliases%get(name, alias_target, found)
617 if (found) then
618 f => this%get_matrix(alias_target)
619 return
620 end if
621
622 call this%print_contents()
623 call neko_error("Matrix " // name // " could not be found in the registry")
624
625 end function registry_get_matrix
626
628 recursive function registry_get_tensor3(this, name) result(f)
629 class(registry_t), target, intent(inout) :: this
630 character(len=*), intent(in) :: name
631 character(len=:), allocatable :: alias_target
632 type(tensor3_t), pointer :: f
633 logical :: found
634 integer :: i
635
636 found = .false.
637
638 do i = 1, this%n_entries()
639 if (this%entries(i)%get_type() .eq. 'tensor3' .and. &
640 this%entries(i)%get_name() .eq. trim(name)) then
641 f => this%entries(i)%get_tensor3()
642 return
643 end if
644 end do
645
646 call this%aliases%get(name, alias_target, found)
647 if (found) then
648 f => this%get_tensor3(alias_target)
649 return
650 end if
651
652 call this%print_contents()
653 call neko_error("Tensor3 " // name // " could not be found in the registry")
654
655 end function registry_get_tensor3
656
658 recursive function registry_get_tensor4(this, name) result(f)
659 class(registry_t), target, intent(inout) :: this
660 character(len=*), intent(in) :: name
661 character(len=:), allocatable :: alias_target
662 type(tensor4_t), pointer :: f
663 logical :: found
664 integer :: i
665
666 found = .false.
667
668 do i = 1, this%n_entries()
669 if (this%entries(i)%get_type() .eq. 'tensor4' .and. &
670 this%entries(i)%get_name() .eq. trim(name)) then
671 f => this%entries(i)%get_tensor4()
672 return
673 end if
674 end do
675
676 call this%aliases%get(name, alias_target, found)
677 if (found) then
678 f => this%get_tensor4(alias_target)
679 return
680 end if
681
682 call this%print_contents()
683 call neko_error("Tensor4 " // name // " could not be found in the registry")
684
685 end function registry_get_tensor4
686
688 recursive function registry_get_real_scalar(this, name) result(s)
689 class(registry_t), target, intent(inout) :: this
690 character(len=*), intent(in) :: name
691 character(len=:), allocatable :: alias_target
692 real(kind=rp), pointer :: s
693 logical :: found
694 integer :: i
695
696 found = .false.
697
698 do i = 1, this%n_entries()
699 if (this%entries(i)%get_type() .eq. 'real_scalar' .and. &
700 this%entries(i)%get_name() .eq. trim(name)) then
701 s => this%entries(i)%get_real_scalar()
702 return
703 end if
704 end do
705
706 call this%aliases%get(name, alias_target, found)
707 if (found) then
708 s => this%get_real_scalar(alias_target)
709 return
710 end if
711
712 call this%print_contents()
713 call neko_error("Real scalar " // name // " could not be found in the registry")
714
715 end function registry_get_real_scalar
716
718 recursive function registry_get_integer_scalar(this, name) result(s)
719 class(registry_t), target, intent(inout) :: this
720 character(len=*), intent(in) :: name
721 character(len=:), allocatable :: alias_target
722 integer, pointer :: s
723 logical :: found
724 integer :: i
725
726 found = .false.
727
728 do i = 1, this%n_entries()
729 if (this%entries(i)%get_type() .eq. 'integer_scalar' .and. &
730 this%entries(i)%get_name() .eq. trim(name)) then
731 s => this%entries(i)%get_integer_scalar()
732 return
733 end if
734 end do
735
736 call this%aliases%get(name, alias_target, found)
737 if (found) then
738 s => this%get_integer_scalar(alias_target)
739 return
740 end if
741
742 call this%print_contents()
743 call neko_error("Integer scalar " // name // &
744 " could not be found in the registry")
745
746 end function registry_get_integer_scalar
747
748 ! ========================================================================== !
749 ! Methods for checking existence of objects in the registry
750
755 function registry_entry_exists(this, name, type) result(found)
756 class(registry_t), target, intent(inout) :: this
757 character(len=*), intent(in) :: name
758 character(len=*), intent(in), optional :: type
759 logical :: found
760 integer :: i
761
762 found = .false.
763 do i = 1, this%n_entries()
764 if (trim(this%entries(i)%get_name()) .eq. trim(name)) then
765 if (present(type)) then
766 if (trim(this%entries(i)%get_type()) .eq. trim(type)) then
767 found = .true.
768 return
769 end if
770 else
771 found = .true.
772 return
773 end if
774 end if
775 end do
776
777 found = this%aliases%valid_path(name)
778 end function registry_entry_exists
779
781 function registry_field_exists(this, name) result(found)
782 class(registry_t), target, intent(inout) :: this
783 character(len=*), intent(in) :: name
784 logical :: found
785
786 found = this%entry_exists(name, 'field')
787 if (.not. found) found = this%aliases%valid_path(name)
788
789 end function registry_field_exists
790
792 function registry_vector_exists(this, name) result(found)
793 class(registry_t), target, intent(inout) :: this
794 character(len=*), intent(in) :: name
795 logical :: found
796
797 found = this%entry_exists(name, 'vector')
798 if (.not. found) found = this%aliases%valid_path(name)
799
800 end function registry_vector_exists
801
803 function registry_matrix_exists(this, name) result(found)
804 class(registry_t), target, intent(inout) :: this
805 character(len=*), intent(in) :: name
806 logical :: found
807
808 found = this%entry_exists(name, 'matrix')
809 if (.not. found) found = this%aliases%valid_path(name)
810
811 end function registry_matrix_exists
812
814 function registry_tensor3_exists(this, name) result(found)
815 class(registry_t), target, intent(inout) :: this
816 character(len=*), intent(in) :: name
817 logical :: found
818
819 found = this%entry_exists(name, 'tensor3')
820 if (.not. found) found = this%aliases%valid_path(name)
821
822 end function registry_tensor3_exists
823
825 function registry_tensor4_exists(this, name) result(found)
826 class(registry_t), target, intent(inout) :: this
827 character(len=*), intent(in) :: name
828 logical :: found
829
830 found = this%entry_exists(name, 'tensor4')
831 if (.not. found) found = this%aliases%valid_path(name)
832
833 end function registry_tensor4_exists
834
836 function registry_real_scalar_exists(this, name) result(found)
837 class(registry_t), target, intent(inout) :: this
838 character(len=*), intent(in) :: name
839 logical :: found
840
841 found = this%entry_exists(name, 'real_scalar')
842 if (.not. found) found = this%aliases%valid_path(name)
843
844 end function registry_real_scalar_exists
845
847 function registry_integer_scalar_exists(this, name) result(found)
848 class(registry_t), target, intent(inout) :: this
849 character(len=*), intent(in) :: name
850 logical :: found
851
852 found = this%entry_exists(name, 'integer_scalar')
853 if (.not. found) found = this%aliases%valid_path(name)
854
856
857 ! ========================================================================== !
858 ! Generic component accessor methods
859
861 pure function registry_n_entries(this, type) result(n)
862 class(registry_t), intent(in) :: this
863 character(len=*), intent(in), optional :: type
864 integer :: n, i
865
866 if (present(type)) then
867 n = 0
868 do i = 1, this%n_entries_
869 if (this%entries(i)%get_type() .eq. trim(type)) then
870 n = n + 1
871 end if
872 end do
873 else
874 n = this%n_entries_
875 end if
876
877 end function registry_n_entries
878
880 pure function registry_n_fields(this) result(n)
881 class(registry_t), intent(in) :: this
882 integer :: n, i
883 n = this%n_entries('field')
884 end function registry_n_fields
885
887 pure function registry_n_vectors(this) result(n)
888 class(registry_t), intent(in) :: this
889 integer :: n, i
890 n = this%n_entries('vector')
891 end function registry_n_vectors
892
894 pure function registry_n_matrices(this) result(n)
895 class(registry_t), intent(in) :: this
896 integer :: n, i
897 n = this%n_entries('matrix')
898 end function registry_n_matrices
899
901 pure function registry_n_tensor3s(this) result(n)
902 class(registry_t), intent(in) :: this
903 integer :: n, i
904 n = this%n_entries('tensor3')
905 end function registry_n_tensor3s
906
908 pure function registry_n_tensor4s(this) result(n)
909 class(registry_t), intent(in) :: this
910 integer :: n, i
911 n = this%n_entries('tensor4')
912 end function registry_n_tensor4s
913
915 pure function registry_n_real_scalars(this) result(n)
916 class(registry_t), intent(in) :: this
917 integer :: n, i
918 n = this%n_entries('real_scalar')
919 end function registry_n_real_scalars
920
922 pure function registry_n_integer_scalars(this) result(n)
923 class(registry_t), intent(in) :: this
924 integer :: n, i
925 n = this%n_entries('integer_scalar')
926 end function registry_n_integer_scalars
927
929 pure function registry_n_aliases(this) result(n)
930 class(registry_t), intent(in) :: this
931 integer :: n
932 n = this%n_aliases_
933 end function registry_n_aliases
934
936 pure function registry_get_size(this) result(n)
937 class(registry_t), intent(in) :: this
938 integer :: n
939
940 if (allocated(this%entries)) then
941 n = size(this%entries)
942 else
943 n = 0
944 end if
945 end function registry_get_size
946
948 pure function registry_get_expansion_size(this) result(n)
949 class(registry_t), intent(in) :: this
950 integer :: n
951
952 n = this%expansion_size_
953 end function registry_get_expansion_size
954
956 subroutine registry_print(this)
957 class(registry_t), intent(in) :: this
958 character(len=LOG_SIZE), allocatable :: buffer
959 integer :: i
960
961 call neko_log%section("Field Registry Contents")
962 do i = 1, this%n_entries()
963 write(buffer, '(A,I4,A,A)') "- [", i, "] ", &
964 this%entries(i)%get_type(), ": ", this%entries(i)%get_name()
965 call neko_log%message(trim(buffer))
966 end do
967
968 call neko_log%end_section()
969 end subroutine registry_print
970
972 subroutine registry_print_contents(this, type)
973 class(registry_t), intent(in) :: this
974 character(len=*), optional, intent(in) :: type
975 character(len=:), allocatable :: filter_type
976 character(len=14), parameter :: types(7) = [ &
977 'field ', &
978 'vector ', &
979 'matrix ', &
980 'tensor3 ', &
981 'tensor4 ', &
982 'real_scalar ', &
983 'integer_scalar' ]
984 logical :: filter_active
985 integer :: i
986 logical :: known_type
987
988 filter_active = .false.
989 if (present(type)) then
990 filter_type = trim(type)
991 filter_active = .true.
992 known_type = .false.
993 do i = 1, size(types)
994 if (filter_type == types(i)) then
995 known_type = .true.
996 exit
997 end if
998 end do
999 if (.not. known_type) then
1000 call neko_error("registry::print_contents: Unsupported type " &
1001 // trim(filter_type))
1002 end if
1003 end if
1004
1005 call neko_log%section("Registry Contents")
1006 do i = 1, size(types)
1007 if (filter_active .and. (filter_type .ne. types(i))) cycle
1008 call registry_print_section(this, types(i))
1009 end do
1010 call neko_log%end_section()
1011 end subroutine registry_print_contents
1012
1014 subroutine registry_print_section(this, entity_type)
1015 class(registry_t), intent(in) :: this
1016 character(len=*), intent(in) :: entity_type
1017 integer :: i
1018 logical :: found
1019 character(len=LOG_SIZE) :: buffer
1020
1021 call neko_log%message(" "//trim(entity_type)//" entries:")
1022 found = .false.
1023 do i = 1, this%n_entries()
1024 if (this%entries(i)%get_type() .eq. entity_type) then
1025 found = .true.
1026 write(buffer, '(A,I4,A,A)') " [", i, "] ", &
1027 trim(this%entries(i)%get_name())
1028 call neko_log%message(trim(buffer))
1029 end if
1030 end do
1031 if (.not. found) then
1032 call neko_log%message(" <none>")
1033 end if
1034 end subroutine registry_print_section
1035
1036end module registry
Generic buffer that is extended with buffers of varying rank.
Definition buffer.F90:34
Defines a mapping of the degrees of freedom.
Definition dofmap.f90:35
Defines a field.
Definition field.f90:34
Logging routines.
Definition log.f90:34
integer, parameter, public neko_log_debug
Debug.
Definition log.f90:56
type(log_t), public neko_log
Global log stream.
Definition log.f90:91
integer, parameter, public log_size
Definition log.f90:46
Defines a matrix.
Definition matrix.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a registry entry for storing and requesting temporary objects This is used in the registries ...
real(kind=rp) function, pointer get_real_scalar(this)
Get the real scalar pointer of the registry entry.
type(tensor3_t) function, pointer get_tensor3(this)
Get the tensor3 pointer of the registry entry.
type(tensor4_t) function, pointer get_tensor4(this)
Get the tensor4 pointer of the registry entry.
type(field_t) function, pointer get_field(this)
Get the field pointer of the registry entry.
type(vector_t) function, pointer get_vector(this)
Get the vector pointer of the registry entry.
type(matrix_t) function, pointer get_matrix(this)
Get the matrix pointer of the registry entry.
integer function, pointer get_integer_scalar(this)
Get the integer scalar pointer of the registry entry.
Defines a registry for storing solution fields.
Definition registry.f90:34
pure integer function registry_n_tensor4s(this)
Get the number of tensor4 stored in the registry.
Definition registry.f90:909
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:158
recursive integer function, pointer registry_get_integer_scalar(this, name)
Get pointer to a stored integer scalar by name.
Definition registry.f90:719
subroutine registry_free(this)
Destructor.
Definition registry.f90:197
recursive type(tensor3_t) function, pointer registry_get_tensor3(this, name)
Get pointer to a stored tensor3 by name.
Definition registry.f90:629
subroutine registry_add_integer_scalar(this, value, name, ignore_existing)
Add an integer scalar to the registry.
Definition registry.f90:482
pure integer function registry_get_size(this)
Get the size of the fields array.
Definition registry.f90:937
subroutine registry_print(this)
Print the contents of the registry to standard output.
Definition registry.f90:957
logical function registry_entry_exists(this, name, type)
Check if an entry with a given name is already in the registry.
Definition registry.f90:756
subroutine registry_add_matrix(this, nrows, ncols, name, ignore_existing)
Add a matrix to the registry.
Definition registry.f90:327
subroutine registry_print_contents(this, type)
Print the registry contents grouped by entity type.
Definition registry.f90:973
recursive type(matrix_t) function, pointer registry_get_matrix(this, name)
Get pointer to a stored matrix by name.
Definition registry.f90:599
subroutine registry_init(this, size, expansion_size)
Constructor.
Definition registry.f90:175
logical function registry_tensor3_exists(this, name)
Check if a tensor3 with a given name is already in the registry.
Definition registry.f90:815
subroutine registry_add_real_scalar(this, value, name, ignore_existing)
Add a real scalar to the registry.
Definition registry.f90:446
recursive type(vector_t) function, pointer registry_get_vector(this, name)
Get pointer to a stored vector by name.
Definition registry.f90:569
recursive type(field_t) function, pointer registry_get_field(this, name)
Get pointer to a stored field by field name.
Definition registry.f90:540
subroutine registry_add_tensor3(this, n, m, k, name, ignore_existing)
Add a tensor3 to the registry.
Definition registry.f90:367
pure integer function registry_get_expansion_size(this)
Get the expansion size.
Definition registry.f90:949
pure integer function registry_n_tensor3s(this)
Get the number of tensor3 stored in the registry.
Definition registry.f90:902
type(registry_t), target, public neko_const_registry
This registry is used to store user-defined scalars and vectors, provided under the constants section...
Definition registry.f90:164
pure integer function registry_n_real_scalars(this)
Get the number of real scalars stored in the registry.
Definition registry.f90:916
pure integer function registry_n_vectors(this)
Get the number of vector stored in the registry.
Definition registry.f90:888
pure integer function registry_n_aliases(this)
Get the number of aliases stored in the registry.
Definition registry.f90:930
logical function registry_matrix_exists(this, name)
Check if a matrix with a given name is already in the registry.
Definition registry.f90:804
pure integer function registry_n_fields(this)
Get the number of fields stored in the registry.
Definition registry.f90:881
recursive real(kind=rp) function, pointer registry_get_real_scalar(this, name)
Get pointer to a stored real scalar by name.
Definition registry.f90:689
subroutine registry_add_alias(this, alias, name)
Add an alias for an existing entry in the registry.
Definition registry.f90:517
subroutine registry_add_field(this, dof, name, ignore_existing)
Add a field to the registry.
Definition registry.f90:247
logical function registry_tensor4_exists(this, name)
Check if a tensor4 with a given name is already in the registry.
Definition registry.f90:826
subroutine registry_print_section(this, entity_type)
Print a single section of the registry for the given type.
pure integer function registry_n_entries(this, type)
Get number of registered entries.
Definition registry.f90:862
pure integer function registry_n_integer_scalars(this)
Get the number of integer scalars stored in the registry.
Definition registry.f90:923
logical function registry_integer_scalar_exists(this, name)
Check if an integer scalar with a given name is already in the registry.
Definition registry.f90:848
subroutine registry_add_tensor4(this, n, m, k, l, name, ignore_existing)
Add a tensor4 to the registry.
Definition registry.f90:407
subroutine registry_expand(this)
Expand the fields array so as to accommodate more fields.
Definition registry.f90:216
pure integer function registry_n_matrices(this)
Get the number of matrix stored in the registry.
Definition registry.f90:895
logical function registry_vector_exists(this, name)
Check if a vector with a given name is already in the registry.
Definition registry.f90:793
recursive type(tensor4_t) function, pointer registry_get_tensor4(this, name)
Get pointer to a stored tensor4 by name.
Definition registry.f90:659
subroutine registry_add_vector(this, n, name, ignore_existing)
Add a vector to the registry.
Definition registry.f90:287
logical function registry_real_scalar_exists(this, name)
Check if a real scalar with a given name is already in the registry.
Definition registry.f90:837
logical function registry_field_exists(this, name)
Check if a field with a given name is already in the registry.
Definition registry.f90:782
Defines a rank-3 tensor.
Definition tensor3.f90:34
Defines a rank-4 tensor.
Definition tensor4.f90:34
Utilities.
Definition utils.f90:35
Defines a vector.
Definition vector.f90:34