48 logical,
private,
allocatable :: inuse(:)
50 integer,
private :: nfields
52 integer,
private :: nfields_inuse
54 integer,
private :: expansion_size
58 procedure,
private, pass(this) ::
expand
92 type(
dofmap_t),
target,
intent(in) :: dof
93 integer,
optional,
intent(in) :: size
94 integer,
optional,
intent(in) :: expansion_size
99 if (
present(size))
then
100 allocate (this%fields(size))
102 allocate(this%fields(i)%f)
104 allocate (this%inuse(size))
106 allocate (this%fields(10))
107 allocate (this%inuse(10))
110 this%inuse(:) = .false.
111 if (
present(expansion_size))
then
112 this%expansion_size = expansion_size
114 this%expansion_size = 10
118 this%nfields_inuse = 0
126 if (
allocated(this%fields))
then
128 call this%fields(i)%f%free()
129 deallocate(this%fields(i)%f)
132 deallocate(this%fields)
133 deallocate(this%inuse)
154 do i=1,this%get_size()
155 if (this%inuse(i)) n = n + 1
164 n =
size(this%fields)
172 n = this%expansion_size
177 type(field_ptr_t),
allocatable :: temp(:)
178 logical,
allocatable :: temp2(:)
181 allocate(temp(this%get_size() + this%expansion_size))
182 temp(1:this%nfields) = this%fields(1:this%nfields)
184 do i=this%nfields +1,
size(temp)
188 call move_alloc(temp, this%fields)
190 allocate(temp2(this%get_size() + this%expansion_size))
191 temp2(1:this%nfields) = this%inuse(1:this%nfields)
192 temp2(this%nfields+1:) = .false.
200 type(field_t),
pointer,
intent(inout) :: f
201 integer,
intent(inout) :: index
202 character(len=10) :: name
205 associate(nfields => this%nfields, nfields_inuse => this%nfields_inuse)
207 do index=1,this%get_size()
208 if (this%inuse(index) .eqv. .false.)
then
209 write (name,
"(A3,I0.3)")
"wrk", index
211 if (.not.
allocated(this%fields(index)%f%x))
then
212 call this%fields(index)%f%init(this%dof, trim(name))
213 nfields = nfields + 1
215 f => this%fields(index)%f
216 this%inuse(index) = .true.
217 this%nfields_inuse = this%nfields_inuse + 1
224 nfields = nfields + 1
225 nfields_inuse = nfields_inuse + 1
226 this%inuse(nfields) = .true.
227 write (name,
"(A3,I0.3)")
"wrk", index
228 call this%fields(nfields)%f%init(this%dof, trim(name))
229 f => this%fields(nfields)%f
237 integer,
intent(inout) :: index
239 this%inuse(index) = .false.
240 this%nfields_inuse = this%nfields_inuse - 1
245 integer,
intent(inout) :: indices(:)
248 do i=1,
size(indices)
249 this%inuse(indices(i)) = .false.
251 this%nfields_inuse = this%nfields_inuse -
size(indices)
256 integer,
intent(inout) :: index
Defines a mapping of the degrees of freedom.
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
logical function get_inuse(this, index)
pure integer function get_nfields_inuse(this)
subroutine scratch_registry_free(this)
Destructor.
type(scratch_registry_t) function init(dof, size, expansion_size)
Constructor, optionally taking initial registry and expansion size as argument.
subroutine relinquish_field_single(this, index)
Relinquish the use of a field in the registry.
pure integer function get_size(this)
Get the size of the fields array.
subroutine relinquish_field_multiple(this, indices)
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
subroutine request_field(this, f, index)
Get a field from the registry by assigning it to a pointer.
pure integer function get_nfields(this)
Get the number of fields stored in the registry.
pure integer function get_expansion_size(this)
Get the expansion size.
field_ptr_t, To easily obtain a pointer to a field