Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
field_list.f90
Go to the documentation of this file.
2 use, intrinsic :: iso_fortran_env, only : error_unit
3 use field, only : field_ptr_t, field_t
4 use iso_c_binding, only : c_ptr
5 use num_types, only : rp
6 use space, only : space_t
7 use dofmap, only : dofmap_t
8 use mesh, only : mesh_t
9 use utils, only : neko_error
10 use comm, only : pe_rank
11 implicit none
12 private
13
15 type, public :: field_list_t
16 type(field_ptr_t), allocatable :: items(:)
17 contains
19 procedure, pass(this) :: init => field_list_init
21 procedure, pass(this) :: free => field_list_free
23 procedure, pass(this) :: append => field_list_append
24 generic :: get => get_by_index, get_by_name
26 procedure, pass(this) :: get_by_index => field_list_get_by_index
28 procedure, pass(this) :: get_by_name => field_list_get_by_name
30 generic :: assign => assign_to_ptr, assign_to_field_ptr
31 procedure, pass(this) :: assign_to_ptr => field_list_assign_to_ptr
32 procedure, pass(this) :: assign_to_field_ptr => &
34 procedure, pass(this) :: assign_to_field => field_list_assign_to_field
35
37 procedure, pass(this) :: x_d => field_list_x_d
39 procedure, pass(this) :: x => field_list_x
41 procedure, pass(this) :: size => field_list_size
43 procedure, pass(this) :: item_size => field_list_item_size
45 procedure, pass(this) :: dof => field_list_dof
47 procedure, pass(this) :: xh => field_list_space
49 procedure, pass(this) :: msh => field_list_msh
51 procedure, pass(this) :: internal_dofmap => field_list_internal_dofmap
53 procedure, pass(this) :: name => field_list_name
54 end type field_list_t
55
56contains
59 subroutine field_list_init(this, size)
60 class(field_list_t), intent(inout) :: this
61 integer, intent(in) :: size
62
63 call this%free()
64
65 allocate(this%items(size))
66 end subroutine field_list_init
67
69 pure function field_list_size(this) result(n)
70 class(field_list_t), intent(in) :: this
71 integer :: n
72 n = size(this%items)
73 end function field_list_size
74
77 function field_list_get_by_index(this, i) result(f)
78 class(field_list_t), intent(inout) :: this
79 type(field_t), pointer :: f
80 integer, intent(in) :: i
81 f => this%items(i)%ptr
82 end function field_list_get_by_index
83
86 function field_list_get_by_name(this, name) result(f)
87 class(field_list_t), intent(inout) :: this
88 type(field_t), pointer :: f
89 character(len=*), intent(in) :: name
90 integer :: i
91
92 nullify(f)
93
94 do i = 1, this%size()
95 if (this%name(i) .eq. trim(name)) then
96 f => this%items(i)%ptr
97 return
98 end if
99 end do
100
101 if (pe_rank .eq. 0) then
102 write(error_unit,*) "Current field list contents:"
103
104 do i = 1, this%size()
105 write(error_unit,*) "- ", this%name(i)
106 end do
107 end if
108
109 call neko_error("No field with name " // trim(name) // " found in list")
110 end function field_list_get_by_name
111
114 subroutine field_list_append(this, f)
115 class(field_list_t), intent(inout) :: this
116 class(field_t), intent(in), target :: f
117 type(field_ptr_t), allocatable :: tmp(:)
118 integer :: len
119
120 len = size(this%items)
121
122 allocate(tmp(len+1))
123 tmp(1:len) = this%items
124 call move_alloc(tmp, this%items)
125 call this%items(len+1)%init(f)
126
127 end subroutine field_list_append
128
130 subroutine field_list_free(this)
131 class(field_list_t), intent(inout) :: this
132 integer :: i, n_fields
133
134 if (allocated(this%items)) then
135 n_fields = this%size()
136 do i = 1, n_fields
137 call this%items(i)%free()
138 end do
139 deallocate(this%items)
140 end if
141
142 end subroutine field_list_free
143
146 function field_list_x_d(this, i) result(ptr)
147 class(field_list_t), intent(in) :: this
148 integer, intent(in) :: i
149 type(c_ptr) :: ptr
150
151 ptr = this%items(i)%ptr%x_d
152 end function field_list_x_d
153
154 function field_list_x(this, i) result(x)
155 class(field_list_t), target, intent(in) :: this
156 real(kind=rp), pointer, contiguous :: x(:,:,:,:)
157 integer, intent(in) :: i
158 x => this%items(i)%ptr%x
159 end function field_list_x
160
163 function field_list_item_size(this, i) result(size)
164 class(field_list_t), target, intent(in) :: this
165 integer, intent(in) :: i
166 integer :: size
167
168 size = this%items(i)%ptr%size()
169
170 end function field_list_item_size
171
175 subroutine field_list_assign_to_ptr(this, i, ptr)
176 class(field_list_t), intent(inout) :: this
177 integer, intent(in) :: i
178 type(field_t), pointer, intent(in) :: ptr
179
180 call this%items(i)%init(ptr)
181
182 end subroutine field_list_assign_to_ptr
183
187 subroutine field_list_assign_to_field_ptr(this, i, ptr)
188 class(field_list_t), intent(inout) :: this
189 integer, intent(in) :: i
190 type(field_ptr_t), target, intent(in) :: ptr
191
192 call this%items(i)%init(ptr%ptr)
193 end subroutine field_list_assign_to_field_ptr
194
198 subroutine field_list_assign_to_field(this, i, fld)
199 class(field_list_t), intent(inout) :: this
200 integer, intent(in) :: i
201 type(field_t), target, intent(in) :: fld
202
203 call this%items(i)%init(fld)
204 end subroutine field_list_assign_to_field
205
208 function field_list_dof(this, i) result(result)
209 class(field_list_t), target, intent(in) :: this
210 integer, intent(in) :: i
211 type(dofmap_t), pointer :: result
212
213 result => this%items(i)%ptr%dof
214 end function field_list_dof
215
218 function field_list_space(this, i) result(result)
219 class(field_list_t), target, intent(in) :: this
220 integer, intent(in) :: i
221 type(space_t), pointer :: result
222
223 result => this%items(i)%ptr%Xh
224 end function field_list_space
225
228 function field_list_msh(this, i) result(result)
229 class(field_list_t), target, intent(in) :: this
230 integer, intent(in) :: i
231 type(mesh_t), pointer :: result
232
233 result => this%items(i)%ptr%msh
234 end function field_list_msh
235
238 function field_list_internal_dofmap(this, i) result(result)
239 class(field_list_t), target, intent(in) :: this
240 integer, intent(in) :: i
241 logical :: result
242
243 result = this%items(i)%ptr%internal_dofmap
244 end function field_list_internal_dofmap
245
248 function field_list_name(this, i) result(result)
249 class(field_list_t), target, intent(in) :: this
250 integer, intent(in) :: i
251 character(len=80) :: result
252
253 result = this%items(i)%ptr%name
254 end function field_list_name
255
256
257end module field_list
Definition comm.F90:1
integer, public pe_rank
MPI rank.
Definition comm.F90:56
Defines a mapping of the degrees of freedom.
Definition dofmap.f90:35
type(dofmap_t) function, pointer field_list_dof(this, i)
Get the the dofmap for item i.
subroutine field_list_init(this, size)
Constructor. Just allocates the array.
type(space_t) function, pointer field_list_space(this, i)
Get the the space for item i.
subroutine field_list_assign_to_ptr(this, i, ptr)
Point item at a given index.
pure integer function field_list_size(this)
Get number of items in the list.
subroutine field_list_assign_to_field_ptr(this, i, ptr)
Point item at a given index.
integer function field_list_item_size(this, i)
Get the size of the dofmap for item i.
character(len=80) function field_list_name(this, i)
Get the name for an item in the list.
logical function field_list_internal_dofmap(this, i)
Whether the dofmap is internal for item i.
real(kind=rp) function, dimension(:,:,:,:), pointer, contiguous field_list_x(this, i)
type(field_t) function, pointer field_list_get_by_index(this, i)
Get an item pointer by array index.
type(mesh_t) function, pointer field_list_msh(this, i)
Get the the mesh for item i.
subroutine field_list_assign_to_field(this, i, fld)
Point item at a given index.
type(c_ptr) function field_list_x_d(this, i)
Get device pointer for a given index.
subroutine field_list_free(this)
Destructor.
subroutine field_list_append(this, f)
Append a field to the list.
type(field_t) function, pointer field_list_get_by_name(this, name)
Get an item pointer by array index.
Defines a field.
Definition field.f90:34
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a function space.
Definition space.f90:34
Utilities.
Definition utils.f90:35
field_ptr_t, To easily obtain a pointer to a field
Definition field.f90:82
field_list_t, To be able to group fields together
The function space for the SEM solution fields.
Definition space.f90:63