39 subroutine api_ic_callback(scheme_name, scheme_name_len)
bind(c)
40 use,
intrinsic :: iso_c_binding
42 character(kind=c_char),
dimension(*) :: scheme_name
43 integer(c_int),
value :: scheme_name_len
44 end subroutine api_ic_callback
49 subroutine api_bc_callback(msk, msk_size, t, tstep)
bind(c)
50 use,
intrinsic :: iso_c_binding
53 type(c_ptr),
value :: msk
54 integer(c_int),
value :: msk_size
55 real(kind=c_rp),
value :: t
56 integer(c_int),
value :: tstep
57 end subroutine api_bc_callback
63 subroutine api_ft_callback(scheme_name, scheme_name_len, t, tstep)
bind(c)
64 use,
intrinsic :: iso_c_binding
67 character(kind=c_char),
dimension(*) :: scheme_name
68 integer(c_int),
value :: scheme_name_len
69 real(kind=c_rp),
value :: t
70 integer(c_int),
value :: tstep
71 end subroutine api_ft_callback
77 subroutine api_gn_callback(t, tstep)
bind(c)
78 use,
intrinsic :: iso_c_binding
81 real(kind=c_rp),
value :: t
82 integer(c_int),
value :: tstep
83 end subroutine api_gn_callback
88 procedure(api_ic_callback),
nopass,
pointer :: initial
89 procedure(api_gn_callback),
nopass,
pointer :: preprocess
90 procedure(api_gn_callback),
nopass,
pointer :: compute
91 procedure(api_bc_callback),
nopass,
pointer :: dirichlet
92 procedure(api_ft_callback),
nopass,
pointer :: material
93 procedure(api_ft_callback),
nopass,
pointer :: source
97 type(api_user_cb),
allocatable :: neko_api_user_cb
100 type(field_list_t),
pointer :: neko_api_cb_field_list => null()
112 module subroutine neko_api_user_cb_register(
user, initial_cb, preprocess_cb, &
113 compute_cb, dirichlet_cb, material_cb, source_cb)
114 type(user_t),
intent(inout) :: user
115 type(c_funptr),
value :: initial_cb, preprocess_cb, compute_cb
116 type(c_funptr),
value :: dirichlet_cb, material_cb, source_cb
121 if (.not.
allocated(neko_api_user_cb))
then
122 allocate(neko_api_user_cb)
123 neko_api_user_cb%initial => null()
124 neko_api_user_cb%preprocess => null()
125 neko_api_user_cb%compute => null()
126 neko_api_user_cb%dirichlet => null()
127 neko_api_user_cb%material => null()
128 neko_api_user_cb%source => null()
134 if (c_associated(initial_cb))
then
135 user%initial_conditions => neko_api_user_initial_condition
137 procedure(api_ic_callback),
pointer :: tmp
138 call c_f_procpointer(initial_cb, tmp)
139 neko_api_user_cb%initial => tmp
143 if (c_associated(preprocess_cb))
then
144 user%preprocess => neko_api_user_preprocess
146 procedure(api_gn_callback),
pointer :: tmp
147 call c_f_procpointer(preprocess_cb, tmp)
148 neko_api_user_cb%preprocess => tmp
152 if (c_associated(compute_cb))
then
153 user%compute => neko_api_user_compute
155 procedure(api_gn_callback),
pointer :: tmp
156 call c_f_procpointer(compute_cb, tmp)
157 neko_api_user_cb%compute => tmp
161 if (c_associated(dirichlet_cb))
then
162 user%dirichlet_conditions => neko_api_user_dirichlet_condition
164 procedure(api_bc_callback),
pointer :: tmp
165 call c_f_procpointer(dirichlet_cb, tmp)
166 neko_api_user_cb%dirichlet => tmp
170 if (c_associated(material_cb))
then
171 user%material_properties => neko_api_user_material_properties
173 procedure(api_ft_callback),
pointer :: tmp
174 call c_f_procpointer(material_cb, tmp)
175 neko_api_user_cb%material => tmp
179 if (c_associated(source_cb))
then
180 user%source_term => neko_api_user_source_term
182 procedure(api_ft_callback),
pointer :: tmp
183 call c_f_procpointer(source_cb, tmp)
184 neko_api_user_cb%source => tmp
188 end subroutine neko_api_user_cb_register
191 subroutine neko_api_user_initial_condition(scheme_name, fields)
192 character(len=*),
intent(in) :: scheme_name
193 type(field_list_t),
intent(inout) :: fields
195 if (
associated(neko_api_user_cb%initial))
then
196 call neko_api_user_cb%initial(trim(scheme_name), len_trim(scheme_name))
198 call neko_error(
"Initial condition callback not defined")
201 end subroutine neko_api_user_initial_condition
204 subroutine neko_api_user_preprocess(time)
205 type(time_state_t),
intent(in) :: time
207 if (
associated(neko_api_user_cb%preprocess))
then
208 call neko_api_user_cb%preprocess(time%t, time%tstep)
210 call neko_error(
"Preprocessing callback not defined")
213 end subroutine neko_api_user_preprocess
216 subroutine neko_api_user_compute(time)
217 type(time_state_t),
intent(in) :: time
219 if (
associated(neko_api_user_cb%compute))
then
220 call neko_api_user_cb%compute(time%t, time%tstep)
222 call neko_error(
"Compute callback not defined")
225 end subroutine neko_api_user_compute
228 subroutine neko_api_user_dirichlet_condition(fields, bc, time)
229 type(field_list_t),
intent(inout) :: fields
230 type(field_dirichlet_t),
intent(in) :: bc
231 type(time_state_t),
intent(in) :: time
232 type(c_ptr) :: bc_msk
234 call neko_api_set_cb_field_list(fields)
236 bc_msk = neko_api_user_bc_msk_ptr(
bc)
238 if (
associated(neko_api_user_cb%dirichlet))
then
239 call neko_api_user_cb%dirichlet(bc_msk,
bc%msk(0), time%t, time%tstep)
241 call neko_error(
"Dirichlet condition callback not defined")
243 nullify(neko_api_cb_field_list)
248 function neko_api_user_bc_msk_ptr(bc)
result(bc_ptr)
249 type(field_dirichlet_t),
intent(in),
target :: bc
250 type(c_ptr) :: bc_ptr
251 bc_ptr = c_loc(
bc%msk(1))
252 end function neko_api_user_bc_msk_ptr
254 end subroutine neko_api_user_dirichlet_condition
257 subroutine neko_api_user_material_properties(scheme_name, properties, time)
258 character(len=*),
intent(in) :: scheme_name
259 type(field_list_t),
intent(inout) :: properties
260 type(time_state_t),
intent(in) :: time
262 call neko_api_set_cb_field_list(properties)
264 if (
associated(neko_api_user_cb%material))
then
265 call neko_api_user_cb%material(trim(scheme_name), &
266 len_trim(scheme_name),time%t, time%tstep)
268 call neko_error(
"Material properties callback not defined")
271 nullify(neko_api_cb_field_list)
272 end subroutine neko_api_user_material_properties
275 subroutine neko_api_user_source_term(scheme_name, rhs, time)
276 character(len=*),
intent(in) :: scheme_name
277 type(field_list_t),
intent(inout) :: rhs
278 type(time_state_t),
intent(in) :: time
280 call neko_api_set_cb_field_list(rhs)
282 if (
associated(neko_api_user_cb%source))
then
283 call neko_api_user_cb%source(trim(scheme_name), &
284 len_trim(scheme_name),time%t, time%tstep)
286 call neko_error(
"Source term callback not defined")
289 nullify(neko_api_cb_field_list)
290 end subroutine neko_api_user_source_term
293 subroutine neko_api_set_cb_field_list(fields)
294 type(field_list_t),
target,
intent(inout) :: fields
296 if (
associated(neko_api_cb_field_list))
then
297 call neko_error(
"Callback field list already defined")
299 neko_api_cb_field_list => fields
300 end subroutine neko_api_set_cb_field_list
304 module function neko_api_user_cb_get_field_by_name(field_name) result(f)
305 character(len=*),
intent(in) :: field_name
306 type(field_t),
pointer :: f
308 if (.not.
associated(neko_api_cb_field_list))
then
309 call neko_error(
"Callback field list not defined")
312 f => neko_api_cb_field_list%get(trim(field_name))
314 end function neko_api_user_cb_get_field_by_name
318 module function neko_api_user_cb_get_field_by_index(field_idx) result(f)
319 integer,
intent(in) :: field_idx
320 type(field_t),
pointer :: f
322 if (.not.
associated(neko_api_cb_field_list))
then
323 call neko_error(
"Callback field list not defined")
326 f => neko_api_cb_field_list%get(field_idx)
328 end function neko_api_user_cb_get_field_by_index
330end submodule neko_api_user
Defines a boundary condition.