48 character(len=80),
private :: name =
""
50 character(len=80),
private ::
type =
""
52 logical,
private :: allocated = .false.
55 real(kind=
rp),
private :: real_scalar = 0.0_rp
56 integer,
private :: integer_scalar = 0
57 type(
vector_t),
private,
pointer :: vector_ptr => null()
58 type(
matrix_t),
private,
pointer :: matrix_ptr => null()
59 type(
field_t),
private,
pointer :: field_ptr => null()
89 type(
dofmap_t),
target,
intent(in) :: dof
90 character(len=*),
intent(in) :: name
92 if (this%allocated)
then
94 //
"Register entry is already allocated.")
99 allocate(this%field_ptr)
100 call this%field_ptr%init(dof, trim(name))
102 this%name = trim(name)
104 this%allocated = .true.
111 integer,
intent(in) :: n
112 character(len=*),
optional,
intent(in) :: name
114 if (this%allocated)
then
116 //
"Register entry is already allocated.")
121 allocate(this%vector_ptr)
122 call this%vector_ptr%init(n)
124 if (
present(name)) this%name = trim(name)
126 this%allocated = .true.
133 integer,
intent(in) :: nrows, ncols
134 character(len=*),
optional,
intent(in) :: name
136 if (this%allocated)
then
138 //
"Register entry is already allocated.")
143 allocate(this%matrix_ptr)
144 call this%matrix_ptr%init(nrows, ncols)
146 if (
present(name)) this%name = trim(name)
148 this%allocated = .true.
155 real(kind=
rp),
intent(in) :: val
156 character(len=*),
optional,
intent(in) :: name
158 if (this%allocated)
then
159 call neko_error(
"init_register_real_scalar: " &
160 //
"Register entry is already allocated.")
165 this%real_scalar = val
167 if (
present(name)) this%name = trim(name)
168 this%type =
'real_scalar'
169 this%allocated = .true.
176 integer,
intent(in) :: val
177 character(len=*),
optional,
intent(in) :: name
179 if (this%allocated)
then
180 call neko_error(
"init_register_integer_scalar: " &
181 //
"Register entry is already allocated.")
186 this%integer_scalar = val
188 if (
present(name)) this%name = trim(name)
189 this%type =
'integer_scalar'
190 this%allocated = .true.
198 if (
associated(this%field_ptr))
then
199 call this%field_ptr%free()
200 deallocate(this%field_ptr)
203 if (
associated(this%vector_ptr))
then
204 call this%vector_ptr%free()
205 deallocate(this%vector_ptr)
208 if (
associated(this%matrix_ptr))
then
209 call this%matrix_ptr%free()
210 deallocate(this%matrix_ptr)
213 this%real_scalar = 0.0_rp
214 this%integer_scalar = 0
218 this%allocated = .false.
225 character(len=:),
allocatable :: name
226 name = trim(this%name)
232 character(len=:),
allocatable :: type
233 type = trim(this%type)
240 allocated = this%allocated
246 type(
field_t),
pointer :: field_ptr
247 if (this%get_type() .ne.
'field')
then
248 call neko_error(
"registry_entry::get_field: " &
249 //
"Registry entry is not of type 'field'.")
251 field_ptr => this%field_ptr
257 type(
vector_t),
pointer :: vector_ptr
258 if (this%get_type() .ne.
'vector')
then
259 call neko_error(
"registry_entry::get_vector: " &
260 //
"Registry entry is not of type 'vector'.")
262 vector_ptr => this%vector_ptr
268 type(
matrix_t),
pointer :: matrix_ptr
269 if (this%get_type() .ne.
'matrix')
then
270 call neko_error(
"registry_entry::get_field: " &
271 //
"Registry entry is not of type 'matrix'.")
273 matrix_ptr => this%matrix_ptr
279 real(kind=
rp),
pointer :: scalar_ptr
280 if (this%get_type() .ne.
'real_scalar')
then
281 call neko_error(
"registry_entry::get_real_scalar: " &
282 //
"Registry entry is not of type 'real_scalar'.")
284 scalar_ptr => this%real_scalar
290 integer,
pointer :: scalar_ptr
291 if (this%get_type() .ne.
'integer_scalar')
then
292 call neko_error(
"registry_entry::get_integer_scalar: " &
293 //
"Registry entry is not of type 'integer_scalar'.")
295 scalar_ptr => this%integer_scalar
303 if (.not. source%is_allocated())
return
306 this%name = source%name
307 this%type = source%type
308 this%allocated = source%allocated
310 select case (trim(this%type))
312 this%real_scalar = source%real_scalar
313 case (
'integer_scalar')
314 this%integer_scalar = source%integer_scalar
316 this%vector_ptr => source%vector_ptr
317 nullify(source%vector_ptr)
319 this%matrix_ptr => source%matrix_ptr
320 nullify(source%matrix_ptr)
322 this%field_ptr => source%field_ptr
323 nullify(source%field_ptr)
325 call neko_error(
"move_from_registry_entry: " // &
326 "Unsupported registry entry type: " // trim(this%type))
Defines a mapping of the degrees of freedom.
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.
subroutine init_register_field(this, dof, name)
Initialize a register entry.
pure character(len=:) function, allocatable get_name(this)
Get the name of the registry entry.
subroutine init_register_real_scalar(this, val, name)
Initialize a scalar register entry.
subroutine init_register_matrix(this, nrows, ncols, name)
Initialize a register entry.
subroutine init_register_vector(this, n, name)
Initialize a register entry.
subroutine init_register_integer_scalar(this, val, name)
Initialize an integer scalar register entry.
subroutine move_from_registry_entry(this, source)
Move a registry entry from another entry.
type(field_t) function, pointer get_field(this)
Get the field pointer of the registry entry.
subroutine free_register(this)
Free a register entry.
pure logical function is_allocated(this)
Check if the registry entry is allocated.
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.
pure character(len=:) function, allocatable get_type(this)
Get the type of the registry entry.
integer function, pointer get_integer_scalar(this)
Get the integer scalar pointer of the registry entry.