36  use, 
intrinsic :: iso_fortran_env, only: error_unit
 
   43  use json_module, 
only : json_file
 
   50     type(
field_t), 
private, 
allocatable :: fields(:)
 
   52     type(json_file), 
private, 
allocatable :: aliases(:)
 
   54     integer, 
private :: n_fields_
 
   56     integer, 
private :: n_aliases_
 
   58     integer, 
private :: expansion_size
 
   63     procedure, 
private, pass(this) :: expand_aliases => &
 
   78     procedure, pass(this) :: get_field_by_index => &
 
   81     procedure, pass(this) :: get_field_by_name => &
 
   84     procedure, pass(this) :: get_expansion_size => &
 
   90     generic :: get_field => get_field_by_index, get_field_by_name
 
 
  102    integer, 
optional, 
intent(in) :: size
 
  103    integer, 
optional, 
intent(in) :: expansion_size
 
  107    if (
present(size)) 
then 
  108       allocate (this%fields(size))
 
  109       allocate (this%aliases(size))
 
  111       allocate (this%fields(50))
 
  112       allocate (this%aliases(50))
 
  115    if (
present(expansion_size)) 
then 
  116       this%expansion_size = expansion_size
 
  118       this%expansion_size = 50
 
 
  129    if (
allocated(this%fields)) 
then 
  130       do i = 1, this%n_fields()
 
  131          call this%fields(i)%free()
 
  133       deallocate(this%fields)
 
  136    if (
allocated(this%aliases)) 
then 
  137       deallocate(this%aliases)
 
  142    this%expansion_size = 0
 
 
  148    type(
field_t), 
allocatable :: temp(:)
 
  150    allocate(temp(this%n_fields_ + this%expansion_size))
 
  151    temp(1:this%n_fields_) = this%fields(1:this%n_fields_)
 
  152    call move_alloc(temp, this%fields)
 
 
  158    type(json_file), 
allocatable :: temp(:)
 
  160    allocate(temp(this%n_aliases() + this%expansion_size))
 
  161    temp(1:this%n_aliases()) = this%aliases(1:this%n_fields_)
 
  162    call move_alloc(temp, this%aliases)
 
 
  172    type(
dofmap_t), 
target, 
intent(in) :: dof
 
  173    character(len=*), 
target, 
intent(in) :: fld_name
 
  174    logical, 
optional, 
intent(in) :: ignore_existing
 
  176    if (this%field_exists(fld_name)) 
then 
  177       if (
present(ignore_existing) .and. ignore_existing .eqv. .true.) 
then 
  180          call neko_error(
"Field with name " // fld_name // &
 
  181               " is already registered")
 
  185    if (this%n_fields() == 
size(this%fields)) 
then 
  189    this%n_fields_ = this%n_fields_ + 1
 
  192    call this%fields(this%n_fields_)%init( dof, fld_name)
 
 
  201    character(len=*), 
target, 
intent(in) :: alias
 
  202    character(len=*), 
target, 
intent(in) :: fld_name
 
  204    if (this%field_exists(alias)) 
then 
  205       call neko_error(
"Cannot create alias. Field " // alias // &
 
  206            " already exists in the registry")
 
  209    if (this%field_exists(fld_name)) 
then 
  210       if (this%n_aliases_ == 
size(this%aliases)) 
then 
  211          call this%expand_aliases()
 
  214       this%n_aliases_ = this%n_aliases_ + 1
 
  216       call this%aliases(this%n_aliases_)%initialize()
 
  217       call this%aliases(this%n_aliases_)%add(
"alias", alias)
 
  218       call this%aliases(this%n_aliases_)%add(
"target", fld_name)
 
  220       call neko_error(
"Cannot create alias. Field " // fld_name // &
 
  221            " could not be found in the registry")
 
 
  246    n = 
size(this%fields)
 
 
  254    n = this%expansion_size
 
 
  260    integer, 
intent(in) :: i
 
  265    else if (i > this%n_fields()) 
then 
  266       call neko_error(
"Field index exceeds number of stored fields")
 
 
  275    character(len=*), 
intent(in) :: name
 
  276    character(len=:), 
allocatable :: alias
 
  277    character(len=:), 
allocatable :: alias_target
 
  281    type(json_file), 
pointer :: alias_json 
 
  285    do i = 1, this%n_fields()
 
  286       if (this%fields(i)%name == trim(name)) 
then 
  293    do i = 1, this%n_aliases()
 
  294       alias_json => this%aliases(i)
 
  295       call json_get(alias_json, 
"alias", alias)
 
  296       if (alias == trim(name)) 
then 
  297          call json_get(alias_json, 
"target", alias_target)
 
  298          f => this%get_field_by_name(alias_target)
 
  304    if (.not. found) 
then 
  306          write(error_unit,*) 
"Current field_registry contents:" 
  308          do i=1, this%n_fields()
 
  309             write(error_unit,*) 
"- ", this%fields(i)%name
 
  313            " could not be found in the registry")
 
 
  320    character(len=*), 
intent(in) :: name
 
  321    character(len=:), 
allocatable :: alias
 
  324    type(json_file), 
pointer :: alias_json
 
  327    do i=1, this%n_fields()
 
  328       if (this%fields(i)%name == name) 
then 
  334    do i=1, this%n_aliases()
 
  335       alias_json => this%aliases(i)
 
  336       call json_get(alias_json, 
"alias", alias)
 
  337       if (alias == name) 
then 
 
Retrieves a parameter by name or throws an error.
 
integer, public pe_rank
MPI rank.
 
Defines a mapping of the degrees of freedom.
 
Defines a registry for storing solution fields.
 
subroutine field_registry_add_field(this, dof, fld_name, ignore_existing)
Add a field to the registry.
 
pure integer function field_registry_n_aliases(this)
Get the number of aliases stored in the registry.
 
subroutine field_registry_add_alias(this, alias, fld_name)
Add an alias for an existing field in the registry.
 
pure integer function field_registry_get_size(this)
Get the size of the fields array.
 
logical function field_registry_field_exists(this, name)
Check if a field with a given name is already in the registry.
 
subroutine field_registry_free(this)
Destructor.
 
pure integer function field_registry_get_expansion_size(this)
Get the expansion size.
 
type(field_registry_t), target, public neko_field_registry
Global field registry.
 
type(field_t) function, pointer field_registry_get_field_by_index(this, i)
Get pointer to a stored field by index.
 
subroutine field_registry_expand(this)
Expand the fields array so as to accomodate more fields.
 
pure integer function field_registry_n_fields(this)
Get the number of fields stored in the registry.
 
subroutine field_registry_init(this, size, expansion_size)
Constructor.
 
subroutine field_registry_expand_aliases(this)
Expand the aliases array so as to accomodate more aliases.
 
recursive type(field_t) function, pointer field_registry_get_field_by_name(this, name)
Get pointer to a stored field by field name.
 
Implements a hash table ADT.
 
Utilities for retrieving parameters from the case files.