Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
neko_api.f90
Go to the documentation of this file.
1! Copyright (c) 2022-2026, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use neko
38 use, intrinsic :: iso_c_binding
39 implicit none
40 private
41
42contains
43
45 subroutine neko_api_init() bind(c, name="neko_init")
46
47 call neko_init()
48
49 end subroutine neko_api_init
50
52 subroutine neko_api_finalize() bind(c, name="neko_finalize")
53
54 call neko_finalize()
55
56 end subroutine neko_api_finalize
57
59 subroutine neko_api_device_init() bind(c, name="neko_device_init")
60
61 call device_init
62
63 end subroutine neko_api_device_init
64
66 subroutine neko_api_device_finalize() bind(c, name="neko_device_finalize")
67
68 call device_finalize
69
70 end subroutine neko_api_device_finalize
71
73 subroutine neko_api_job_info() bind(c, name="neko_job_info")
74 logical :: initialized
75
76 call mpi_initialized(initialized)
77
78 if (.not.initialized) then
79 call neko_warning('Neko has not been initialised')
80 else
81 call neko_job_info()
82 call neko_log%newline()
83 end if
84
85 end subroutine neko_api_job_info
86
88 subroutine neko_api_registry_init() bind(c, name="neko_registry_init")
89
90 call neko_registry%init()
91 call neko_const_registry%init()
92
93 end subroutine neko_api_registry_init
94
96 subroutine neko_api_registry_free() bind(c, name="neko_registry_free")
97
98 call neko_registry%free()
99
100 end subroutine neko_api_registry_free
101
104 bind(c, name="neko_scratch_registry_init")
105
106 call neko_scratch_registry%init()
107
108 end subroutine neko_api_scratch_registry_init
109
112 bind(c, name="neko_scratch_registry_free")
113
114 call neko_scratch_registry%free()
115
116 end subroutine neko_api_scratch_registry_free
117
120 subroutine neko_api_case_allocate(case_iptr) &
121 bind(c, name="neko_case_allocate")
122 integer(c_intptr_t), intent(inout) :: case_iptr
123 type(case_t), pointer :: C
124 type(c_ptr) :: cp
125
126 allocate(c)
127 cp = c_loc(c)
128 case_iptr = transfer(cp, 0_c_intptr_t)
129
130 end subroutine neko_api_case_allocate
131
135 subroutine neko_api_case_init(case_json, case_len, case_iptr) &
136 bind(c, name="neko_case_init")
137 type(c_ptr), intent(in) :: case_json
138 integer(c_int), value :: case_len
139 integer(c_intptr_t), intent(inout) :: case_iptr
140 type(json_file) :: json_case
141 type(case_t), pointer :: C
142 type(c_ptr) :: cp
143
144 ! Check if the case has already been allocated
145 ! e.g. if a user callback has been injected
146 cp = transfer(case_iptr, c_null_ptr)
147 if (c_associated(cp)) then
148 call c_f_pointer(cp, c)
149 else
150 allocate(c)
151 cp = c_loc(c)
152 case_iptr = transfer(cp, 0_c_intptr_t)
153 end if
154
155 ! Convert passed in serialised JSON object into a Fortran
156 ! character string and create a json_file object
157 if (c_associated(case_json)) then
158 block
159 character(kind=c_char,len=case_len+1),pointer :: s
160 character(len=:), allocatable :: fcase_json
161 call c_f_pointer(case_json, s)
162 fcase_json = s(1:case_len)
163 call json_case%load_from_string(fcase_json)
164 deallocate(fcase_json)
165 nullify(s)
166 end block
167 end if
168
169 !
170 ! Create case
171 !
172 call c%init(json_case)
173
174 !
175 ! Create simulation components
176 !
177 call neko_simcomps%init(c)
178
179 end subroutine neko_api_case_init
180
181
184 subroutine neko_api_case_free(case_iptr) bind(c, name="neko_case_free")
185 integer(c_intptr_t), intent(inout) :: case_iptr
186 type(case_t), pointer :: C
187 type(c_ptr) :: cp
188
189 cp = transfer(case_iptr, c_null_ptr)
190 if (c_associated(cp)) then
191 call c_f_pointer(cp, c)
192 call c%free()
193 else
194 call neko_error('Invalid Neko case')
195 end if
196
197 end subroutine neko_api_case_free
198
202 function neko_api_case_time(case_iptr) result(time) &
203 bind(c, name="neko_case_time")
204 integer(c_intptr_t), intent(inout) :: case_iptr
205 real(kind=c_rp) :: time
206 type(case_t), pointer :: c
207 type(c_ptr) :: cptr
208
209 cptr = transfer(case_iptr, c_null_ptr)
210 if (c_associated(cptr)) then
211 call c_f_pointer(cptr, c)
212 time = c%time%t
213 else
214 call neko_error('Invalid Neko case')
215 end if
216
217 end function neko_api_case_time
218
222 function neko_api_case_end_time(case_iptr) result(end_time) &
223 bind(c, name="neko_case_end_time")
224 integer(c_intptr_t), intent(inout) :: case_iptr
225 real(kind=c_rp) :: end_time
226 type(case_t), pointer :: c
227 type(c_ptr) :: cptr
228
229 cptr = transfer(case_iptr, c_null_ptr)
230 if (c_associated(cptr)) then
231 call c_f_pointer(cptr, c)
232 end_time = c%time%end_time
233 else
234 call neko_error('Invalid Neko case')
235 end if
236
237 end function neko_api_case_end_time
238
242 function neko_api_case_tstep(case_iptr) result(tstep) &
243 bind(c, name="neko_case_tstep")
244 integer(c_intptr_t), intent(inout) :: case_iptr
245 type(case_t), pointer :: c
246 type(c_ptr) :: cptr
247 integer(c_int) :: tstep
248
249 cptr = transfer(case_iptr, c_null_ptr)
250 if (c_associated(cptr)) then
251 call c_f_pointer(cptr, c)
252 tstep = c%time%tstep
253 else
254 call neko_error('Invalid Neko case')
255 end if
256
257 end function neko_api_case_tstep
258
264 function neko_api_case_is_done(case_iptr) result(is_done) &
265 bind(c, name="neko_case_is_done")
266 integer(c_intptr_t), intent(inout) :: case_iptr
267 type(case_t), pointer :: c
268 type(c_ptr) :: cptr
269 integer(c_int) :: is_done
270
271 cptr = transfer(case_iptr, c_null_ptr)
272 if (c_associated(cptr)) then
273 call c_f_pointer(cptr, c)
274 is_done = merge(1_c_int, 0_c_int, c%time%is_done())
275 else
276 call neko_error('Invalid Neko case')
277 end if
278
279 end function neko_api_case_is_done
280
283 subroutine neko_api_solve(case_iptr) bind(c, name="neko_solve")
284 integer(c_intptr_t), intent(inout) :: case_iptr
285 type(case_t), pointer :: C
286 type(c_ptr) :: cp
287
288 cp = transfer(case_iptr, c_null_ptr)
289 if (c_associated(cp)) then
290 call c_f_pointer(cp, c)
291 call neko_solve(c)
292 else
293 call neko_error('Invalid Neko case')
294 end if
295
296 end subroutine neko_api_solve
297
300 subroutine neko_api_step(case_iptr) &
301 bind(c, name="neko_step")
303 integer(c_intptr_t), intent(inout) :: case_iptr
304 type(case_t), pointer :: C
305 type(c_ptr) :: cptr
306 type(json_file) :: dt_params
307 type(time_step_controller_t), save, allocatable :: dt_controller
308 real(kind=dp), save :: step_loop_start = 0.0_dp
309
310 cptr = transfer(case_iptr, c_null_ptr)
311 if (c_associated(cptr)) then
312 call c_f_pointer(cptr, c)
313
314 ! The case has already been finalized, nothing more to do
315 if (c%time%is_done()) return
316
317 if (.not. allocated(dt_controller)) then
318 allocate(dt_controller)
319 call json_get(c%params, 'case.time', dt_params)
320 call dt_controller%init(dt_params)
321 end if
322
323 if (c%time%tstep .eq. 0) then
324 call simulation_init(c, dt_controller)
325
326 step_loop_start = mpi_wtime()
327 end if
328
329 if (.not. c%time%is_done()) then
330 call simulation_step(c, dt_controller, step_loop_start)
331 end if
332
333 if (c%time%is_done()) then
334 call simulation_finalize(c)
335 if (allocated(dt_controller)) then
336 deallocate(dt_controller)
337 end if
338 end if
339
340 else
341 call neko_error('Invalid Neko case')
342 end if
343
344 end subroutine neko_api_step
345
350 subroutine neko_api_output_ctrl_execute(case_iptr, force_output) &
351 bind(c, name="neko_output_ctrl_execute")
352 integer(c_intptr_t), intent(inout) :: case_iptr
353 logical(kind=c_bool), value :: force_output
354 logical :: f_force_output
355 type(case_t), pointer :: C
356 type(c_ptr) :: cp
357 type(time_state_t) :: f_time
358
359 cp = transfer(case_iptr, c_null_ptr)
360 if (c_associated(cp)) then
361 call c_f_pointer(cp, c)
362 else
363 call neko_error('Invalid Neko case')
364 end if
365
366 f_force_output = transfer(force_output, f_force_output)
367 call c%output_controller%execute(c%time, f_force_output)
368
369 end subroutine neko_api_output_ctrl_execute
370
373 function neko_api_field(field_name) result(field_ptr) &
374 bind(c, name='neko_field')
375 character(kind=c_char), dimension(*), intent(in) :: field_name
376 character(len=8192) :: name
377 type(field_t), pointer :: field
378 type(c_ptr) :: field_ptr
379 integer :: len
380
381 len = 0
382 do
383 if (field_name(len+1) .eq. c_null_char) exit
384 len = len + 1
385 name(len:len) = field_name(len)
386 end do
387
388 field => neko_registry%get_field(trim(name(1:len)))
389
390 field_ptr = c_loc(field%x)
391
392 end function neko_api_field
393
396 function neko_api_field_order(field_name) result(field_lx) &
397 bind(c, name='neko_field_order')
398 character(kind=c_char), dimension(*), intent(in) :: field_name
399 character(len=8192) :: name
400 type(field_t), pointer :: field
401 integer(c_int) :: field_lx
402 integer :: len
403
404 len = 0
405 do
406 if (field_name(len+1) .eq. c_null_char) exit
407 len = len + 1
408 name(len:len) = field_name(len)
409 end do
410
411 field => neko_registry%get_field(trim(name(1:len)))
412
413 field_lx = field%Xh%lx
414
415 end function neko_api_field_order
416
419 function neko_api_field_nelements(field_name) result(field_nelv) &
420 bind(c, name='neko_field_nelements')
421 character(kind=c_char), dimension(*), intent(in) :: field_name
422 character(len=8192) :: name
423 type(field_t), pointer :: field
424 integer(c_int) :: field_nelv
425 integer :: len
426
427 len = 0
428 do
429 if (field_name(len+1) .eq. c_null_char) exit
430 len = len + 1
431 name(len:len) = field_name(len)
432 end do
433
434 field => neko_registry%get_field(trim(name(1:len)))
435
436 field_nelv = field%msh%nelv
437
438 end function neko_api_field_nelements
439
442 function neko_api_field_size(field_name) result(field_size) &
443 bind(c, name='neko_field_size')
444 character(kind=c_char), dimension(*), intent(in) :: field_name
445 character(len=8192) :: name
446 type(field_t), pointer :: field
447 integer(c_int) :: field_size
448 integer :: len
449
450 len = 0
451 do
452 if (field_name(len+1) .eq. c_null_char) exit
453 len = len + 1
454 name(len:len) = field_name(len)
455 end do
456
457 field => neko_registry%get_field(trim(name(1:len)))
458
459 field_size = field%dof%size()
460
461 end function neko_api_field_size
462
469 subroutine neko_api_field_dofmap(field_name, dof_ptr, x_ptr, y_ptr, z_ptr) &
470 bind(c, name='neko_field_dofmap')
471 character(kind=c_char), dimension(*), intent(in) :: field_name
472 type(c_ptr), intent(inout) :: dof_ptr, x_ptr, y_ptr, z_ptr
473 character(len=8192) :: name
474 type(field_t), pointer :: field
475 integer :: len
476
477 len = 0
478 do
479 if (field_name(len+1) .eq. c_null_char) exit
480 len = len + 1
481 name(len:len) = field_name(len)
482 end do
483
484 field => neko_registry%get_field(trim(name(1:len)))
485 call neko_api_wrap_dofmap(field%dof, dof_ptr, x_ptr, y_ptr, z_ptr)
486
487 end subroutine neko_api_field_dofmap
488
496 subroutine neko_api_case_fluid_dofmap(case_iptr, dof_ptr, &
497 x_ptr, y_ptr, z_ptr, size) bind(c, name='neko_case_fluid_dofmap')
498 integer(c_intptr_t), intent(inout) :: case_iptr
499 type(case_t), pointer :: C
500 type(c_ptr) :: cptr
501 type(c_ptr), intent(inout) :: dof_ptr, x_ptr, y_ptr, z_ptr
502 integer, intent(inout) :: size
503
504 cptr = transfer(case_iptr, c_null_ptr)
505 if (c_associated(cptr)) then
506 call c_f_pointer(cptr, c)
507 call neko_api_wrap_dofmap(c%fluid%dm_Xh, dof_ptr, x_ptr, y_ptr, z_ptr)
508 size = c%fluid%dm_Xh%size()
509 else
510 call neko_error('Invalid Neko case')
511 end if
512
513 end subroutine neko_api_case_fluid_dofmap
514
516 subroutine neko_api_wrap_dofmap(dm, dof_ptr, x_ptr, y_ptr, z_ptr)
517 type(dofmap_t), target, intent(in) :: dm
518 type(c_ptr), intent(inout) :: dof_ptr, x_ptr, y_ptr, z_ptr
519
520 dof_ptr = c_loc(dm%dof)
521 x_ptr = c_loc(dm%x)
522 y_ptr = c_loc(dm%y)
523 z_ptr = c_loc(dm%z)
524
525 end subroutine neko_api_wrap_dofmap
526
540 subroutine neko_api_field_space(field_name, lx, zg, &
541 dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz) &
542 bind(c, name='neko_field_space')
543 character(kind=c_char), dimension(*), intent(in) :: field_name
544 integer, intent(inout) :: lx
545 type(c_ptr), intent(inout) :: zg, dr_inv, ds_inv, dt_inv
546 type(c_ptr), intent(inout) :: wx, wy, wz, dx, dy, dz
547 character(len=8192) :: name
548 type(field_t), pointer :: field
549 integer :: len
550
551 len = 0
552 do
553 if (field_name(len+1) .eq. c_null_char) exit
554 len = len + 1
555 name(len:len) = field_name(len)
556 end do
557
558 field => neko_registry%get_field(trim(name(1:len)))
559 call neko_api_wrap_space(field%Xh, lx, zg, dr_inv, ds_inv, dt_inv, &
560 wx, wy, wz, dx, dy, dz)
561
562 end subroutine neko_api_field_space
563
577 subroutine neko_api_case_fluid_space(case_iptr, lx, zg, &
578 dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz) &
579 bind(c, name='neko_case_fluid_space')
580 integer(c_intptr_t), intent(inout) :: case_iptr
581 type(case_t), pointer :: C
582 type(c_ptr) :: cptr
583 integer, intent(inout) :: lx
584 type(c_ptr), intent(inout) :: zg, dr_inv, ds_inv, dt_inv
585 type(c_ptr), intent(inout) :: wx, wy, wz, dx, dy, dz
586
587
588 cptr = transfer(case_iptr, c_null_ptr)
589 if (c_associated(cptr)) then
590 call c_f_pointer(cptr, c)
591 call neko_api_wrap_space(c%fluid%Xh, lx, zg, dr_inv, ds_inv, dt_inv, &
592 wx, wy, wz, dx, dy, dz)
593 else
594 call neko_error('Invalid Neko case')
595 end if
596
597 end subroutine neko_api_case_fluid_space
598
600 subroutine neko_api_wrap_space(Xh, lx, zg, dr_inv, ds_inv, dt_inv, &
601 wx, wy, wz, dx, dy, dz)
602 type(space_t), target, intent(in) :: Xh
603 integer, intent(inout) :: lx
604 type(c_ptr), intent(inout) :: zg, dr_inv, ds_inv, dt_inv
605 type(c_ptr), intent(inout) :: wx, wy, wz, dx, dy, dz
606
607 lx = xh%lx
608 zg = c_loc(xh%zg)
609 dr_inv = c_loc(xh%dr_inv)
610 ds_inv = c_loc(xh%ds_inv)
611 dt_inv = c_loc(xh%dt_inv)
612 wx = c_loc(xh%wx)
613 wy = c_loc(xh%wy)
614 wz = c_loc(xh%wz)
615 dx = c_loc(xh%dx)
616 dy = c_loc(xh%dy)
617 dz = c_loc(xh%dz)
618
619 end subroutine neko_api_wrap_space
620
623 subroutine neko_api_case_fluid_coef(case_iptr, G11, G22, G33, G12, G13, G23, &
624 mult, dxdr, dydr, dzdr, dxds, dyds, dzds, dxdt, dydt, dzdt, &
625 drdx, drdy, drdz, dsdx, dsdy, dsdz, dtdx, dtdy, dtdz, &
626 jac, B, area, nx, ny, nz) bind(c, name='neko_case_fluid_coef')
627 integer(c_intptr_t), intent(inout) :: case_iptr
628 type(case_t), pointer :: C
629 type(c_ptr) :: cptr
630 type(c_ptr), intent(inout) :: G11, G22, G33, G12, G13, G23
631 type(c_ptr), intent(inout) :: mult
632 type(c_ptr), intent(inout) :: dxdr, dydr, dzdr
633 type(c_ptr), intent(inout) :: dxds, dyds, dzds
634 type(c_ptr), intent(inout) :: dxdt, dydt, dzdt
635 type(c_ptr), intent(inout) :: drdx, drdy, drdz
636 type(c_ptr), intent(inout) :: dsdx, dsdy, dsdz
637 type(c_ptr), intent(inout) :: dtdx, dtdy, dtdz
638 type(c_ptr), intent(inout) :: jac, B, area, nx, ny, nz
639
640
641 cptr = transfer(case_iptr, c_null_ptr)
642 if (c_associated(cptr)) then
643 call c_f_pointer(cptr, c)
644 g11 = c_loc(c%fluid%c_Xh%G11)
645 g22 = c_loc(c%fluid%c_Xh%G22)
646 g33 = c_loc(c%fluid%c_Xh%G33)
647 g12 = c_loc(c%fluid%c_Xh%G12)
648 g13 = c_loc(c%fluid%c_Xh%G13)
649 g23 = c_loc(c%fluid%c_Xh%G23)
650 mult = c_loc(c%fluid%c_Xh%mult)
651 dxdr = c_loc(c%fluid%c_Xh%dxdr)
652 dydr = c_loc(c%fluid%c_Xh%dydr)
653 dzdr = c_loc(c%fluid%c_Xh%dzdr)
654 dxds = c_loc(c%fluid%c_Xh%dxds)
655 dyds = c_loc(c%fluid%c_Xh%dyds)
656 dzds = c_loc(c%fluid%c_Xh%dzds)
657 dxdt = c_loc(c%fluid%c_Xh%dxdt)
658 dydt = c_loc(c%fluid%c_Xh%dydt)
659 dzdt = c_loc(c%fluid%c_Xh%dzdt)
660 drdx = c_loc(c%fluid%c_Xh%drdx)
661 drdy = c_loc(c%fluid%c_Xh%drdy)
662 drdz = c_loc(c%fluid%c_Xh%drdz)
663 dsdx = c_loc(c%fluid%c_Xh%dsdx)
664 dsdy = c_loc(c%fluid%c_Xh%dsdy)
665 dsdz = c_loc(c%fluid%c_Xh%dsdz)
666 dtdx = c_loc(c%fluid%c_Xh%dtdx)
667 dtdy = c_loc(c%fluid%c_Xh%dtdy)
668 dtdz = c_loc(c%fluid%c_Xh%dtdz)
669 jac = c_loc(c%fluid%c_Xh%jac)
670 b = c_loc(c%fluid%c_Xh%B)
671 area = c_loc(c%fluid%c_Xh%area)
672 nx = c_loc(c%fluid%c_Xh%nx)
673 ny = c_loc(c%fluid%c_Xh%ny)
674 nz = c_loc(c%fluid%c_Xh%nz)
675 else
676 call neko_error('Invalid Neko case')
677 end if
678
679 end subroutine neko_api_case_fluid_coef
680
689 subroutine neko_api_user_setup(case_iptr, initial_cb, preprocess_cb, &
690 compute_cb, dirichlet_cb, material_cb, source_cb) &
691 bind(c, name='neko_user_setup')
692 integer(c_intptr_t), intent(inout) :: case_iptr
693 type(c_funptr), value :: initial_cb, preprocess_cb, compute_cb
694 type(c_funptr), value :: dirichlet_cb, material_cb, source_cb
695 type(case_t), pointer :: C
696 type(c_ptr) :: cptr
697
698 cptr = transfer(case_iptr, c_null_ptr)
699 if (c_associated(cptr)) then
700 call c_f_pointer(cptr, c)
701 call neko_api_user_cb_register(c%user, initial_cb, preprocess_cb, &
702 compute_cb, dirichlet_cb, material_cb, source_cb)
703 else
704 call neko_error('Invalid Neko case')
705 end if
706
707 end subroutine neko_api_user_setup
708
711 function neko_api_user_cb_field_by_name(field_name) result(field_ptr) &
712 bind(c, name='neko_cb_field_by_name')
713 character(kind=c_char), dimension(*), intent(in) :: field_name
714 character(len=8192) :: name
715 type(field_t), pointer :: field
716 type(c_ptr) :: field_ptr
717 integer :: len
718
719 len = 0
720 do
721 if (field_name(len+1) .eq. c_null_char) exit
722 len = len + 1
723 name(len:len) = field_name(len)
724 end do
725
726 field => neko_api_user_cb_get_field(trim(name(1:len)))
727
728 field_ptr = c_loc(field%x)
729
731
735 result(field_ptr) bind(c, name='neko_cb_field_by_index')
736 integer, intent(in) :: field_idx
737 type(field_t), pointer :: field
738 type(c_ptr) :: field_ptr
739
740 field => neko_api_user_cb_get_field(field_idx)
741
742 field_ptr = c_loc(field%x)
743
745
749 function neko_api_user_cb_field_name_at_index(field_idx, field_name) &
750 result(same_name) bind(c, name='neko_cb_field_name_at_index')
751 integer, intent(in) :: field_idx
752 character(kind=c_char), dimension(*), intent(in) :: field_name
753 character(len=8192) :: name
754 type(field_t), pointer :: f1, f2
755 type(c_ptr) :: field_ptr
756 integer :: len
757 logical(c_bool) :: same_name
758
759 len = 0
760 do
761 if (field_name(len+1) .eq. c_null_char) exit
762 len = len + 1
763 name(len:len) = field_name(len)
764 end do
765
766 f1 => neko_api_user_cb_get_field(field_idx)
767 f2 => neko_api_user_cb_get_field(trim(name(1:len)))
768
769 same_name = trim(f1%name) .eq. trim(f2%name)
770
771 nullify(f1, f2)
772
774
775
776end module neko_api
Defines a field.
Definition field.f90:34
Neko API user callbacks.
subroutine, public neko_api_user_cb_register(user, initial_cb, preprocess_cb, compute_cb, dirichlet_cb, material_cb, source_cb)
Register callbacks.
Neko C API.
Definition neko_api.f90:34
subroutine neko_api_wrap_dofmap(dm, dof_ptr, x_ptr, y_ptr, z_ptr)
Helper function to assign pointers to a dofmap's data.
Definition neko_api.f90:517
subroutine neko_api_finalize()
Finalize Neko.
Definition neko_api.f90:53
subroutine neko_api_wrap_space(xh, lx, zg, dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz)
Helper function to assign pointers to a space's data.
Definition neko_api.f90:602
subroutine neko_api_user_setup(case_iptr, initial_cb, preprocess_cb, compute_cb, dirichlet_cb, material_cb, source_cb)
Setup user-provided callbacks.
Definition neko_api.f90:692
subroutine neko_api_step(case_iptr)
Compute a time-step for a neko case.
Definition neko_api.f90:302
integer(c_int) function neko_api_field_nelements(field_name)
Retrive the number of elements in a field.
Definition neko_api.f90:421
subroutine neko_api_device_finalize()
Finalize Neko device layer.
Definition neko_api.f90:67
subroutine neko_api_job_info()
Display job information.
Definition neko_api.f90:74
subroutine neko_api_registry_init()
Initialise a Neko field registry.
Definition neko_api.f90:89
subroutine neko_api_field_space(field_name, lx, zg, dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz)
Retrive the space associated with a field.
Definition neko_api.f90:543
subroutine neko_api_case_free(case_iptr)
Destroy a Neko case.
Definition neko_api.f90:185
subroutine neko_api_case_allocate(case_iptr)
Allocate memory for a Neko case.
Definition neko_api.f90:122
subroutine neko_api_output_ctrl_execute(case_iptr, force_output)
Execute the Case's output controller.
Definition neko_api.f90:352
subroutine neko_api_case_init(case_json, case_len, case_iptr)
Initalise a Neko case.
Definition neko_api.f90:137
subroutine neko_api_field_dofmap(field_name, dof_ptr, x_ptr, y_ptr, z_ptr)
Retrive the dofmap associated with a field.
Definition neko_api.f90:471
subroutine neko_api_case_fluid_space(case_iptr, lx, zg, dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz)
Retrive the space associated with a case's fluid solver.
Definition neko_api.f90:580
real(kind=c_rp) function neko_api_case_end_time(case_iptr)
Retrive the end time of a case.
Definition neko_api.f90:224
type(c_ptr) function neko_api_user_cb_field_by_index(field_idx)
Retrive a pointer to a user callback field.
Definition neko_api.f90:736
logical(c_bool) function neko_api_user_cb_field_name_at_index(field_idx, field_name)
Check if the user callback field at a given index has a given name.
Definition neko_api.f90:751
subroutine neko_api_scratch_registry_init()
Initialise a Neko scratch registry.
Definition neko_api.f90:105
type(c_ptr) function neko_api_field(field_name)
Retrive a pointer to a flow field.
Definition neko_api.f90:375
integer(c_int) function neko_api_field_size(field_name)
Retrive the total number of degrees of freedom of a field.
Definition neko_api.f90:444
subroutine neko_api_scratch_registry_free()
Destroy a Neko scratch registry.
Definition neko_api.f90:113
subroutine neko_api_solve(case_iptr)
Solve a neko case.
Definition neko_api.f90:284
subroutine neko_api_case_fluid_coef(case_iptr, g11, g22, g33, g12, g13, g23, mult, dxdr, dydr, dzdr, dxds, dyds, dzds, dxdt, dydt, dzdt, drdx, drdy, drdz, dsdx, dsdy, dsdz, dtdx, dtdy, dtdz, jac, b, area, nx, ny, nz)
Retrive the coefficient associated with a case's fluid solver.
Definition neko_api.f90:627
subroutine neko_api_registry_free()
Destroy a Neko field registry.
Definition neko_api.f90:97
type(c_ptr) function neko_api_user_cb_field_by_name(field_name)
Retrive a pointer to a user callback field.
Definition neko_api.f90:713
integer(c_int) function neko_api_case_is_done(case_iptr)
Check if a case has reached its end time.
Definition neko_api.f90:266
subroutine neko_api_case_fluid_dofmap(case_iptr, dof_ptr, x_ptr, y_ptr, z_ptr, size)
Retrive the dofmap associated with a case's fluid solver.
Definition neko_api.f90:498
integer(c_int) function neko_api_field_order(field_name)
Retrive the order of a field.
Definition neko_api.f90:398
subroutine neko_api_device_init()
Initialise Neko device layer.
Definition neko_api.f90:60
real(kind=c_rp) function neko_api_case_time(case_iptr)
Retrive the current time of a case.
Definition neko_api.f90:204
integer(c_int) function neko_api_case_tstep(case_iptr)
Retrive the time-step of a case.
Definition neko_api.f90:244
subroutine neko_api_init()
Initialise Neko.
Definition neko_api.f90:46
Master module.
Definition neko.f90:34
Implements type time_step_controller.
void neko_finalize()
void neko_init()
void neko_job_info()
void neko_solve(int **case_iptr)