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
101 if (
present(size))
then
102 allocate (this%fields(size))
104 allocate(this%fields(i)%ptr)
106 allocate (this%inuse(size))
108 allocate (this%fields(10))
109 allocate (this%inuse(10))
112 this%inuse(:) = .false.
113 if (
present(expansion_size))
then
114 this%expansion_size = expansion_size
116 this%expansion_size = 10
120 this%nfields_inuse = 0
128 if (
allocated(this%fields))
then
130 call this%fields(i)%ptr%free()
131 deallocate(this%fields(i)%ptr)
134 deallocate(this%fields)
135 deallocate(this%inuse)
138 if (
associated(this%dof))
then
158 do i=1,this%get_size()
159 if (this%inuse(i)) n = n + 1
168 n =
size(this%fields)
176 n = this%expansion_size
181 type(field_ptr_t),
allocatable :: temp(:)
182 logical,
allocatable :: temp2(:)
185 allocate(temp(this%get_size() + this%expansion_size))
186 temp(1:this%nfields) = this%fields(1:this%nfields)
188 do i=this%nfields +1,
size(temp)
189 allocate(temp(i)%ptr)
192 call move_alloc(temp, this%fields)
194 allocate(temp2(this%get_size() + this%expansion_size))
195 temp2(1:this%nfields) = this%inuse(1:this%nfields)
196 temp2(this%nfields+1:) = .false.
204 type(field_t),
pointer,
intent(inout) :: f
205 integer,
intent(inout) :: index
206 character(len=10) :: name
209 associate(nfields => this%nfields, nfields_inuse => this%nfields_inuse)
211 do index=1,this%get_size()
212 if (this%inuse(index) .eqv. .false.)
then
213 write (name,
"(A3,I0.3)")
"wrk", index
215 if (.not.
allocated(this%fields(index)%ptr%x))
then
216 call this%fields(index)%ptr%init(this%dof, trim(name))
217 nfields = nfields + 1
219 f => this%fields(index)%ptr
220 this%inuse(index) = .true.
221 this%nfields_inuse = this%nfields_inuse + 1
228 nfields = nfields + 1
229 nfields_inuse = nfields_inuse + 1
230 this%inuse(nfields) = .true.
231 write (name,
"(A3,I0.3)")
"wrk", index
232 call this%fields(nfields)%ptr%init(this%dof, trim(name))
233 f => this%fields(nfields)%ptr
241 integer,
intent(inout) :: index
243 this%inuse(index) = .false.
244 this%nfields_inuse = this%nfields_inuse - 1
249 integer,
intent(inout) :: indices(:)
252 do i=1,
size(indices)
253 this%inuse(indices(i)) = .false.
255 this%nfields_inuse = this%nfields_inuse -
size(indices)
260 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