156 subroutine neko_api_case_init(case_json, case_len, case_iptr) &
157 bind(c, name="neko_case_init")
158 type(c_ptr),
intent(in) :: case_json
159 integer(c_int),
value :: case_len
160 integer(c_intptr_t),
intent(inout) :: case_iptr
161 type(json_file) :: json_case
162 type(case_t),
pointer :: C
167 cp = transfer(case_iptr, c_null_ptr)
168 if (c_associated(cp))
then
169 call c_f_pointer(cp, c)
173 case_iptr = transfer(cp, 0_c_intptr_t)
178 if (c_associated(case_json))
then
180 character(kind=c_char,len=case_len+1),
pointer :: s
181 character(len=:),
allocatable :: fcase_json
182 call c_f_pointer(case_json, s)
183 fcase_json = s(1:case_len)
184 call json_case%load_from_string(fcase_json)
185 deallocate(fcase_json)
193 call case_init(c, json_case)
198 call neko_simcomps%init(c)
299 subroutine neko_api_step(case_iptr) &
300 bind(c, name="neko_step")
302 integer(c_intptr_t),
intent(inout) :: case_iptr
303 type(case_t),
pointer :: C
305 type(json_file) :: dt_params
307 real(kind=dp),
save :: step_loop_start = 0.0_dp
309 cptr = transfer(case_iptr, c_null_ptr)
310 if (c_associated(cptr))
then
311 call c_f_pointer(cptr, c)
313 if (.not.
allocated(dt_controller))
then
314 allocate(dt_controller)
315 call json_get(c%params,
'case.time', dt_params)
316 call dt_controller%init(dt_params)
319 if (c%time%tstep .eq. 0)
then
320 call simulation_init(c, dt_controller)
322 step_loop_start = mpi_wtime()
325 if (.not. c%time%is_done())
then
326 call simulation_step(c, dt_controller, step_loop_start)
329 if (c%time%is_done())
then
330 call simulation_finalize(c)
331 if (
allocated(dt_controller))
then
332 deallocate(dt_controller)
337 call neko_error(
'Invalid Neko case')
465 subroutine neko_api_field_dofmap(field_name, dof_ptr, x_ptr, y_ptr, z_ptr) &
466 bind(c, name=
'neko_field_dofmap')
467 character(kind=c_char),
dimension(*),
intent(in) :: field_name
468 type(c_ptr),
intent(inout) :: dof_ptr, x_ptr, y_ptr, z_ptr
469 character(len=8192) :: name
470 type(field_t),
pointer :: field
475 if (field_name(len+1) .eq. c_null_char)
exit
477 name(len:len) = field_name(len)
480 field => neko_field_registry%get_field(trim(name(1:len)))
481 call neko_api_wrap_dofmap(
field%dof, dof_ptr, x_ptr, y_ptr, z_ptr)
492 subroutine neko_api_case_fluid_dofmap(case_iptr, dof_ptr, &
493 x_ptr, y_ptr, z_ptr, size) bind(c, name='neko_case_fluid_dofmap')
494 integer(c_intptr_t),
intent(inout) :: case_iptr
495 type(case_t),
pointer :: C
497 type(c_ptr),
intent(inout) :: dof_ptr, x_ptr, y_ptr, z_ptr
498 integer,
intent(inout) :: size
500 cptr = transfer(case_iptr, c_null_ptr)
501 if (c_associated(cptr))
then
502 call c_f_pointer(cptr, c)
503 call neko_api_wrap_dofmap(c%fluid%dm_Xh, dof_ptr, x_ptr, y_ptr, z_ptr)
504 size = c%fluid%dm_Xh%size()
506 call neko_error(
'Invalid Neko case')
536 subroutine neko_api_field_space(field_name, lx, zg, &
537 dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz) &
538 bind(c, name=
'neko_field_space')
539 character(kind=c_char),
dimension(*),
intent(in) :: field_name
540 integer,
intent(inout) :: lx
541 type(c_ptr),
intent(inout) :: zg, dr_inv, ds_inv, dt_inv
542 type(c_ptr),
intent(inout) :: wx, wy, wz, dx, dy, dz
543 character(len=8192) :: name
544 type(field_t),
pointer :: field
549 if (field_name(len+1) .eq. c_null_char)
exit
551 name(len:len) = field_name(len)
554 field => neko_field_registry%get_field(trim(name(1:len)))
555 call neko_api_wrap_space(
field%Xh, lx, zg, dr_inv, ds_inv, dt_inv, &
556 wx, wy, wz, dx, dy, dz)
573 subroutine neko_api_case_fluid_space(case_iptr, lx, zg, &
574 dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz) &
575 bind(c, name=
'neko_case_fluid_space')
576 integer(c_intptr_t),
intent(inout) :: case_iptr
577 type(case_t),
pointer :: C
579 integer,
intent(inout) :: lx
580 type(c_ptr),
intent(inout) :: zg, dr_inv, ds_inv, dt_inv
581 type(c_ptr),
intent(inout) :: wx, wy, wz, dx, dy, dz
584 cptr = transfer(case_iptr, c_null_ptr)
585 if (c_associated(cptr))
then
586 call c_f_pointer(cptr, c)
587 call neko_api_wrap_space(c%fluid%Xh, lx, zg, dr_inv, ds_inv, dt_inv, &
588 wx, wy, wz, dx, dy, dz)
590 call neko_error(
'Invalid Neko case')
596 subroutine neko_api_wrap_space(Xh, lx, zg, dr_inv, ds_inv, dt_inv, &
597 wx, wy, wz, dx, dy, dz)
598 type(space_t),
target,
intent(in) :: Xh
599 integer,
intent(inout) :: lx
600 type(c_ptr),
intent(inout) :: zg, dr_inv, ds_inv, dt_inv
601 type(c_ptr),
intent(inout) :: wx, wy, wz, dx, dy, dz
605 dr_inv = c_loc(xh%dr_inv)
606 ds_inv = c_loc(xh%ds_inv)
607 dt_inv = c_loc(xh%dt_inv)
619 subroutine neko_api_case_fluid_coef(case_iptr, G11, G22, G33, G12, G13, G23, &
620 mult, dxdr, dydr, dzdr, dxds, dyds, dzds, dxdt, dydt, dzdt, &
621 drdx, drdy, drdz, dsdx, dsdy, dsdz, dtdx, dtdy, dtdz, &
622 jac, B, area, nx, ny, nz) bind(c, name='neko_case_fluid_coef')
623 integer(c_intptr_t),
intent(inout) :: case_iptr
624 type(case_t),
pointer :: C
626 type(c_ptr),
intent(inout) :: G11, G22, G33, G12, G13, G23
627 type(c_ptr),
intent(inout) :: mult
628 type(c_ptr),
intent(inout) :: dxdr, dydr, dzdr
629 type(c_ptr),
intent(inout) :: dxds, dyds, dzds
630 type(c_ptr),
intent(inout) :: dxdt, dydt, dzdt
631 type(c_ptr),
intent(inout) :: drdx, drdy, drdz
632 type(c_ptr),
intent(inout) :: dsdx, dsdy, dsdz
633 type(c_ptr),
intent(inout) :: dtdx, dtdy, dtdz
634 type(c_ptr),
intent(inout) :: jac, B, area, nx, ny, nz
637 cptr = transfer(case_iptr, c_null_ptr)
638 if (c_associated(cptr))
then
639 call c_f_pointer(cptr, c)
640 g11 = c_loc(c%fluid%c_Xh%G11)
641 g22 = c_loc(c%fluid%c_Xh%G22)
642 g33 = c_loc(c%fluid%c_Xh%G33)
643 g12 = c_loc(c%fluid%c_Xh%G12)
644 g13 = c_loc(c%fluid%c_Xh%G13)
645 g23 = c_loc(c%fluid%c_Xh%G23)
646 mult = c_loc(c%fluid%c_Xh%mult)
647 dxdr = c_loc(c%fluid%c_Xh%dxdr)
648 dydr = c_loc(c%fluid%c_Xh%dydr)
649 dzdr = c_loc(c%fluid%c_Xh%dzdr)
650 dxds = c_loc(c%fluid%c_Xh%dxds)
651 dyds = c_loc(c%fluid%c_Xh%dyds)
652 dzds = c_loc(c%fluid%c_Xh%dzds)
653 dxdt = c_loc(c%fluid%c_Xh%dxdt)
654 dydt = c_loc(c%fluid%c_Xh%dydt)
655 dzdt = c_loc(c%fluid%c_Xh%dzdt)
656 drdx = c_loc(c%fluid%c_Xh%drdx)
657 drdy = c_loc(c%fluid%c_Xh%drdy)
658 drdz = c_loc(c%fluid%c_Xh%drdz)
659 dsdx = c_loc(c%fluid%c_Xh%dsdx)
660 dsdy = c_loc(c%fluid%c_Xh%dsdy)
661 dsdz = c_loc(c%fluid%c_Xh%dsdz)
662 dtdx = c_loc(c%fluid%c_Xh%dtdx)
663 dtdy = c_loc(c%fluid%c_Xh%dtdy)
664 dtdz = c_loc(c%fluid%c_Xh%dtdz)
665 jac = c_loc(c%fluid%c_Xh%jac)
666 b = c_loc(c%fluid%c_Xh%B)
667 area = c_loc(c%fluid%c_Xh%area)
668 nx = c_loc(c%fluid%c_Xh%nx)
669 ny = c_loc(c%fluid%c_Xh%ny)
670 nz = c_loc(c%fluid%c_Xh%nz)
672 call neko_error(
'Invalid Neko case')
685 subroutine neko_api_user_setup(case_iptr, initial_cb, preprocess_cb, &
686 compute_cb, dirichlet_cb, material_cb, source_cb) &
687 bind(c, name=
'neko_user_setup')
688 integer(c_intptr_t),
intent(inout) :: case_iptr
689 type(c_funptr),
value :: initial_cb, preprocess_cb, compute_cb
690 type(c_funptr),
value :: dirichlet_cb, material_cb, source_cb
691 type(case_t),
pointer :: C
694 cptr = transfer(case_iptr, c_null_ptr)
695 if (c_associated(cptr))
then
696 call c_f_pointer(cptr, c)
697 call neko_api_user_cb_register(c%user, initial_cb, preprocess_cb, &
698 compute_cb, dirichlet_cb, material_cb, source_cb)
700 call neko_error(
'Invalid Neko case')
745 function neko_api_user_cb_field_name_at_index(field_idx, field_name) &
746 result(same_name) bind(c, name=
'neko_cb_field_name_at_index')
747 integer,
intent(in) :: field_idx
748 character(kind=c_char),
dimension(*),
intent(in) :: field_name
749 character(len=8192) :: name
750 type(field_t),
pointer :: f1, f2
751 type(c_ptr) :: field_ptr
753 logical(c_bool) :: same_name
757 if (field_name(len+1) .eq. c_null_char)
exit
759 name(len:len) = field_name(len)
762 f1 => neko_api_user_cb_get_field(field_idx)
763 f2 => neko_api_user_cb_get_field(trim(name(1:len)))
765 same_name = trim(f1%name) .eq. trim(f2%name)