44 use json_module,
only : json_file
53 type(json_file),
private :: aliases
55 integer,
private :: n_entries_ = 0
57 integer,
private :: n_aliases_ = 0
59 integer,
private :: expansion_size_ = 5
124 procedure, pass(this) :: integer_scalar_exists => &
176 integer,
optional,
intent(in) :: size
177 integer,
optional,
intent(in) :: expansion_size
181 if (
present(size))
then
182 allocate(this%entries(size))
184 allocate(this%entries(25))
187 call this%aliases%initialize()
189 if (
present(expansion_size))
then
190 this%expansion_size_ = expansion_size
200 if (
allocated(this%entries))
then
201 do i = 1, this%n_entries()
202 call this%entries(i)%free()
204 deallocate(this%entries)
207 call this%aliases%destroy()
211 this%expansion_size_ = 5
223 call move_alloc(this%entries, temp)
226 allocate(this%entries(n + this%expansion_size_))
230 call this%entries(i)%move_from(temp(i))
235 if (
allocated(temp))
deallocate(temp)
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_
253 ignore_existing_ = .false.
254 if (
present(ignore_existing))
then
255 ignore_existing_ = ignore_existing
258 if (this%field_exists(name))
then
259 if (ignore_existing_)
then
262 call neko_error(
"Field with name " // name // &
263 " is already registered")
267 if (this%n_entries() .eq. this%get_size())
then
271 this%n_entries_ = this%n_entries_ + 1
274 call this%entries(this%n_entries_)%init_field(dof, name)
276 call neko_log%message(
"Field " // trim(name) //
" added to the registry", &
288 integer,
intent(in) :: n
289 character(len=*),
target,
intent(in) :: name
290 logical,
optional,
intent(in) :: ignore_existing
291 logical :: ignore_existing_
293 ignore_existing_ = .false.
294 if (
present(ignore_existing))
then
295 ignore_existing_ = ignore_existing
298 if (this%vector_exists(name))
then
299 if (ignore_existing_)
then
302 call neko_error(
"Vector with name " // name // &
303 " is already registered")
307 if (this%n_entries() .eq. this%get_size())
then
311 this%n_entries_ = this%n_entries_ + 1
314 call this%entries(this%n_entries_)%init_vector(n, name)
316 call neko_log%message(
"Vector " // trim(name) //
" added to the registry", &
328 integer,
intent(in) :: nrows, ncols
329 character(len=*),
target,
intent(in) :: name
330 logical,
optional,
intent(in) :: ignore_existing
331 logical :: ignore_existing_
333 ignore_existing_ = .false.
334 if (
present(ignore_existing))
then
335 ignore_existing_ = ignore_existing
338 if (this%matrix_exists(name))
then
339 if (ignore_existing_)
then
342 call neko_error(
"Matrix with name " // name // &
343 " is already registered")
347 if (this%n_entries() .eq. this%get_size())
then
351 this%n_entries_ = this%n_entries_ + 1
354 call this%entries(this%n_entries_)%init_matrix(nrows, ncols, name)
356 call neko_log%message(
"Matrix " // trim(name) //
" added to the registry", &
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_
373 ignore_existing_ = .false.
374 if (
present(ignore_existing))
then
375 ignore_existing_ = ignore_existing
378 if (this%tensor3_exists(name))
then
379 if (ignore_existing_)
then
382 call neko_error(
"Tensor3 with name " // name // &
383 " is already registered")
387 if (this%n_entries() .eq. this%get_size())
then
391 this%n_entries_ = this%n_entries_ + 1
394 call this%entries(this%n_entries_)%init_tensor3(n, m, k, name)
396 call neko_log%message(
"Tensor3 " // trim(name) // &
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_
413 ignore_existing_ = .false.
414 if (
present(ignore_existing))
then
415 ignore_existing_ = ignore_existing
418 if (this%tensor4_exists(name))
then
419 if (ignore_existing_)
then
422 call neko_error(
"Tensor4 with name " // name // &
423 " is already registered")
427 if (this%n_entries() .eq. this%get_size())
then
431 this%n_entries_ = this%n_entries_ + 1
434 call this%entries(this%n_entries_)%init_tensor4(n, m, k, l, name)
436 call neko_log%message(
"Tensor4 " // trim(name) // &
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_
452 ignore_existing_ = .false.
453 if (
present(ignore_existing))
then
454 ignore_existing_ = ignore_existing
457 if (this%real_scalar_exists(name))
then
458 if (ignore_existing_)
then
461 call neko_error(
"Scalar with name " // name // &
462 " is already registered")
466 if (this%n_entries() .eq. this%get_size())
then
470 this%n_entries_ = this%n_entries_ + 1
473 call this%entries(this%n_entries_)%init_real_scalar(
value, name)
483 integer,
intent(in) :: value
484 character(len=*),
target,
intent(in) :: name
485 logical,
optional,
intent(in) :: ignore_existing
486 logical :: ignore_existing_
488 ignore_existing_ = .false.
489 if (
present(ignore_existing))
then
490 ignore_existing_ = ignore_existing
493 if (this%integer_scalar_exists(name))
then
494 if (ignore_existing_)
then
497 call neko_error(
"Scalar with name " // name // &
498 " is already registered")
502 if (this%n_entries() .eq. this%get_size())
then
506 this%n_entries_ = this%n_entries_ + 1
509 call this%entries(this%n_entries_)%init_integer_scalar(
value, name)
518 character(len=*),
intent(in) :: alias
519 character(len=*),
intent(in) :: name
521 if (this%entry_exists(alias))
then
522 call neko_error(
"Cannot create alias. Entry " // alias // &
523 " already exists in the registry")
526 if (this%entry_exists(name))
then
527 this%n_aliases_ = this%n_aliases_ + 1
528 call this%aliases%add(trim(alias), trim(name))
530 call neko_error(
"Cannot create alias. Entry " // name // &
531 " could not be found in the registry")
540 class(
registry_t),
target,
intent(inout) :: this
541 character(len=*),
intent(in) :: name
542 character(len=:),
allocatable :: alias_target
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()
555 call this%aliases%get(name, alias_target, found)
557 f => this%get_field(alias_target)
561 call this%print_contents()
562 call neko_error(
"Field " // name //
" could not be found in the registry")
569 class(
registry_t),
target,
intent(inout) :: this
570 character(len=*),
intent(in) :: name
571 character(len=:),
allocatable :: alias_target
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()
586 call this%aliases%get(name, alias_target, found)
588 f => this%get_vector(alias_target)
592 call this%print_contents()
593 call neko_error(
"Vector " // name //
" could not be found in the registry")
599 class(
registry_t),
target,
intent(inout) :: this
600 character(len=*),
intent(in) :: name
601 character(len=:),
allocatable :: alias_target
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()
616 call this%aliases%get(name, alias_target, found)
618 f => this%get_matrix(alias_target)
622 call this%print_contents()
623 call neko_error(
"Matrix " // name //
" could not be found in the registry")
629 class(
registry_t),
target,
intent(inout) :: this
630 character(len=*),
intent(in) :: name
631 character(len=:),
allocatable :: alias_target
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()
646 call this%aliases%get(name, alias_target, found)
648 f => this%get_tensor3(alias_target)
652 call this%print_contents()
653 call neko_error(
"Tensor3 " // name //
" could not be found in the registry")
659 class(
registry_t),
target,
intent(inout) :: this
660 character(len=*),
intent(in) :: name
661 character(len=:),
allocatable :: alias_target
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()
676 call this%aliases%get(name, alias_target, found)
678 f => this%get_tensor4(alias_target)
682 call this%print_contents()
683 call neko_error(
"Tensor4 " // name //
" could not be found in the registry")
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
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()
706 call this%aliases%get(name, alias_target, found)
708 s => this%get_real_scalar(alias_target)
712 call this%print_contents()
713 call neko_error(
"Real scalar " // name //
" could not be found in the registry")
719 class(
registry_t),
target,
intent(inout) :: this
720 character(len=*),
intent(in) :: name
721 character(len=:),
allocatable :: alias_target
722 integer,
pointer :: s
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()
736 call this%aliases%get(name, alias_target, found)
738 s => this%get_integer_scalar(alias_target)
742 call this%print_contents()
743 call neko_error(
"Integer scalar " // name // &
744 " could not be found in the registry")
756 class(
registry_t),
target,
intent(inout) :: this
757 character(len=*),
intent(in) :: name
758 character(len=*),
intent(in),
optional :: type
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
777 found = this%aliases%valid_path(name)
782 class(
registry_t),
target,
intent(inout) :: this
783 character(len=*),
intent(in) :: name
786 found = this%entry_exists(name,
'field')
787 if (.not. found) found = this%aliases%valid_path(name)
793 class(
registry_t),
target,
intent(inout) :: this
794 character(len=*),
intent(in) :: name
797 found = this%entry_exists(name,
'vector')
798 if (.not. found) found = this%aliases%valid_path(name)
804 class(
registry_t),
target,
intent(inout) :: this
805 character(len=*),
intent(in) :: name
808 found = this%entry_exists(name,
'matrix')
809 if (.not. found) found = this%aliases%valid_path(name)
815 class(
registry_t),
target,
intent(inout) :: this
816 character(len=*),
intent(in) :: name
819 found = this%entry_exists(name,
'tensor3')
820 if (.not. found) found = this%aliases%valid_path(name)
826 class(
registry_t),
target,
intent(inout) :: this
827 character(len=*),
intent(in) :: name
830 found = this%entry_exists(name,
'tensor4')
831 if (.not. found) found = this%aliases%valid_path(name)
837 class(
registry_t),
target,
intent(inout) :: this
838 character(len=*),
intent(in) :: name
841 found = this%entry_exists(name,
'real_scalar')
842 if (.not. found) found = this%aliases%valid_path(name)
848 class(
registry_t),
target,
intent(inout) :: this
849 character(len=*),
intent(in) :: name
852 found = this%entry_exists(name,
'integer_scalar')
853 if (.not. found) found = this%aliases%valid_path(name)
863 character(len=*),
intent(in),
optional :: type
866 if (
present(type))
then
868 do i = 1, this%n_entries_
869 if (this%entries(i)%get_type() .eq. trim(type))
then
883 n = this%n_entries(
'field')
890 n = this%n_entries(
'vector')
897 n = this%n_entries(
'matrix')
904 n = this%n_entries(
'tensor3')
911 n = this%n_entries(
'tensor4')
918 n = this%n_entries(
'real_scalar')
925 n = this%n_entries(
'integer_scalar')
940 if (
allocated(this%entries))
then
941 n =
size(this%entries)
952 n = this%expansion_size_
958 character(len=LOG_SIZE),
allocatable :: buffer
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()
974 character(len=*),
optional,
intent(in) :: type
975 character(len=:),
allocatable :: filter_type
976 character(len=14),
parameter :: types(7) = [ &
984 logical :: filter_active
986 logical :: known_type
988 filter_active = .false.
989 if (
present(type))
then
990 filter_type = trim(type)
991 filter_active = .true.
993 do i = 1,
size(types)
994 if (filter_type == types(i))
then
999 if (.not. known_type)
then
1000 call neko_error(
"registry::print_contents: Unsupported type " &
1001 // trim(filter_type))
1005 call neko_log%section(
"Registry Contents")
1006 do i = 1,
size(types)
1007 if (filter_active .and. (filter_type .ne. types(i))) cycle
1016 character(len=*),
intent(in) :: entity_type
1019 character(len=LOG_SIZE) :: buffer
1021 call neko_log%message(
" "//trim(entity_type)//
" entries:")
1023 do i = 1, this%n_entries()
1024 if (this%entries(i)%get_type() .eq. entity_type)
then
1026 write(
buffer,
'(A,I4,A,A)')
" [", i,
"] ", &
1027 trim(this%entries(i)%get_name())
1031 if (.not. found)
then
Generic buffer that is extended with buffers of varying rank.
Defines a mapping of the degrees of freedom.
integer, parameter, public neko_log_debug
Debug.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public rp
Global precision used in computations.
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.
pure integer function registry_n_tensor4s(this)
Get the number of tensor4 stored in the registry.
type(registry_t), target, public neko_registry
Global field registry.
recursive integer function, pointer registry_get_integer_scalar(this, name)
Get pointer to a stored integer scalar by name.
subroutine registry_free(this)
Destructor.
recursive type(tensor3_t) function, pointer registry_get_tensor3(this, name)
Get pointer to a stored tensor3 by name.
subroutine registry_add_integer_scalar(this, value, name, ignore_existing)
Add an integer scalar to the registry.
pure integer function registry_get_size(this)
Get the size of the fields array.
subroutine registry_print(this)
Print the contents of the registry to standard output.
logical function registry_entry_exists(this, name, type)
Check if an entry with a given name is already in the registry.
subroutine registry_add_matrix(this, nrows, ncols, name, ignore_existing)
Add a matrix to the registry.
subroutine registry_print_contents(this, type)
Print the registry contents grouped by entity type.
recursive type(matrix_t) function, pointer registry_get_matrix(this, name)
Get pointer to a stored matrix by name.
subroutine registry_init(this, size, expansion_size)
Constructor.
logical function registry_tensor3_exists(this, name)
Check if a tensor3 with a given name is already in the registry.
subroutine registry_add_real_scalar(this, value, name, ignore_existing)
Add a real scalar to the registry.
recursive type(vector_t) function, pointer registry_get_vector(this, name)
Get pointer to a stored vector by name.
recursive type(field_t) function, pointer registry_get_field(this, name)
Get pointer to a stored field by field name.
subroutine registry_add_tensor3(this, n, m, k, name, ignore_existing)
Add a tensor3 to the registry.
pure integer function registry_get_expansion_size(this)
Get the expansion size.
pure integer function registry_n_tensor3s(this)
Get the number of tensor3 stored in the registry.
type(registry_t), target, public neko_const_registry
This registry is used to store user-defined scalars and vectors, provided under the constants section...
pure integer function registry_n_real_scalars(this)
Get the number of real scalars stored in the registry.
pure integer function registry_n_vectors(this)
Get the number of vector stored in the registry.
pure integer function registry_n_aliases(this)
Get the number of aliases stored in the registry.
logical function registry_matrix_exists(this, name)
Check if a matrix with a given name is already in the registry.
pure integer function registry_n_fields(this)
Get the number of fields stored in the registry.
recursive real(kind=rp) function, pointer registry_get_real_scalar(this, name)
Get pointer to a stored real scalar by name.
subroutine registry_add_alias(this, alias, name)
Add an alias for an existing entry in the registry.
subroutine registry_add_field(this, dof, name, ignore_existing)
Add a field to the registry.
logical function registry_tensor4_exists(this, name)
Check if a tensor4 with a given name is already in the registry.
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.
pure integer function registry_n_integer_scalars(this)
Get the number of integer scalars stored in the registry.
logical function registry_integer_scalar_exists(this, name)
Check if an integer scalar with a given name is already in the registry.
subroutine registry_add_tensor4(this, n, m, k, l, name, ignore_existing)
Add a tensor4 to the registry.
subroutine registry_expand(this)
Expand the fields array so as to accommodate more fields.
pure integer function registry_n_matrices(this)
Get the number of matrix stored in the registry.
logical function registry_vector_exists(this, name)
Check if a vector with a given name is already in the registry.
recursive type(tensor4_t) function, pointer registry_get_tensor4(this, name)
Get pointer to a stored tensor4 by name.
subroutine registry_add_vector(this, n, name, ignore_existing)
Add a vector to the registry.
logical function registry_real_scalar_exists(this, name)
Check if a real scalar with a given name is already in the registry.
logical function registry_field_exists(this, name)
Check if a field with a given name is already in the registry.