17from dataclasses
import dataclass
21initial_condition = CFUNCTYPE(
None, POINTER(c_char_p), c_int)
23preprocess = CFUNCTYPE(
None, c_double, c_int)
25compute = CFUNCTYPE(
None, c_double, c_int)
27dirichlet_condition = CFUNCTYPE(
None, POINTER(c_int), c_int, c_double, c_int)
29material_properties = CFUNCTYPE(
None, POINTER(c_char_p), c_int, c_double, c_int)
31source_term = CFUNCTYPE(
None, POINTER(c_char_p), c_int, c_double, c_int)
83 POINTER(POINTER(c_longlong)),
84 POINTER(POINTER(c_double)),
85 POINTER(POINTER(c_double)),
86 POINTER(POINTER(c_double))]
90 POINTER(POINTER(c_longlong)),
91 POINTER(POINTER(c_double)),
92 POINTER(POINTER(c_double)),
93 POINTER(POINTER(c_double)),
99 POINTER(POINTER(c_double)),
100 POINTER(POINTER(c_double)),
101 POINTER(POINTER(c_double)),
102 POINTER(POINTER(c_double)),
103 POINTER(POINTER(c_double)),
104 POINTER(POINTER(c_double)),
105 POINTER(POINTER(c_double)),
106 POINTER(POINTER(c_double)),
107 POINTER(POINTER(c_double)),
108 POINTER(POINTER(c_double))]
113 POINTER(POINTER(c_double)),
114 POINTER(POINTER(c_double)),
115 POINTER(POINTER(c_double)),
116 POINTER(POINTER(c_double)),
117 POINTER(POINTER(c_double)),
118 POINTER(POINTER(c_double)),
119 POINTER(POINTER(c_double)),
120 POINTER(POINTER(c_double)),
121 POINTER(POINTER(c_double)),
122 POINTER(POINTER(c_double))]
126 POINTER(POINTER(c_double)),
127 POINTER(POINTER(c_double)),
128 POINTER(POINTER(c_double)),
129 POINTER(POINTER(c_double)),
130 POINTER(POINTER(c_double)),
131 POINTER(POINTER(c_double)),
132 POINTER(POINTER(c_double)),
133 POINTER(POINTER(c_double)),
134 POINTER(POINTER(c_double)),
135 POINTER(POINTER(c_double)),
136 POINTER(POINTER(c_double)),
137 POINTER(POINTER(c_double)),
138 POINTER(POINTER(c_double)),
139 POINTER(POINTER(c_double)),
140 POINTER(POINTER(c_double)),
141 POINTER(POINTER(c_double)),
142 POINTER(POINTER(c_double)),
143 POINTER(POINTER(c_double)),
144 POINTER(POINTER(c_double)),
145 POINTER(POINTER(c_double)),
146 POINTER(POINTER(c_double)),
147 POINTER(POINTER(c_double)),
148 POINTER(POINTER(c_double)),
149 POINTER(POINTER(c_double)),
150 POINTER(POINTER(c_double)),
151 POINTER(POINTER(c_double)),
152 POINTER(POINTER(c_double)),
153 POINTER(POINTER(c_double)),
154 POINTER(POINTER(c_double)),
155 POINTER(POINTER(c_double)),
156 POINTER(POINTER(c_double))]
180 """ Defines a Neko mapping of the degrees of freedom """
189 """ Defines a Neko space. """
204 """ Defines a Neko field. """
211 """ Defines Neko coefficients. """
245 """ Initialise Neko. """
249 """ Finalize Neko. """
253 """ Initialise Neko device layer. """
257 """ Finalize Neko device lyaer. """
261 """ Display job information. """
265 """ Initialise a field registry. """
269 """ Destroy a field registry. """
272def case_init(case_json,
273 cb_initial_condition = initial_condition(0),
279 """Initialise a Neko case
281 A case is created based on a JSON file and a couple of (optional)
296 user_setup(case_descr, cb_initial_condition, cb_preprocess,
297 cb_compute, cb_dirichlet_condition, cb_material_properties,
304def case_free(case_descr):
305 """ Destroy a Neko case. """
309 """ Retrive the current time of a case. """
313def end_time(case_descr):
314 """ Retrive the end time of a case. """
318def tstep(case_descr):
319 """ Retrive the current time-step of a case. """
323def solve(case_descr):
324 """ Solve a Neko case. """
328 """ Compute a time-step for a Neko case. """
332 """ Retrive a Neko field as a `neko_field_t`. """
343def field_order(name):
344 """ Retrive the order of a Neko field. """
348def field_nelements(name):
349 """ Retrive the number of elements in a Neko field. """
354 """ Retrive the total number of degrees of freedom of a Neko field. """
358def field_dofmap(name):
359 """ Retrive a dofmap of a Neko field as a `neko_dofmap_t`. """
361 dof_ptr = POINTER(c_longlong)()
362 x_ptr = POINTER(c_double)()
363 y_ptr = POINTER(c_double)()
364 z_ptr = POINTER(c_double)()
366 byref(x_ptr), byref(y_ptr), byref(z_ptr))
368 dofmap =
wrap_dofmap(dof_ptr, x_ptr, y_ptr, z_ptr, size)
372def case_fluid_dofmap(case_descr):
373 """ Retrive a dofmap of a Neko case's fluid solver as a `neko_dofmap_t`. """
375 dof_ptr = POINTER(c_longlong)()
376 x_ptr = POINTER(c_double)()
377 y_ptr = POINTER(c_double)()
378 z_ptr = POINTER(c_double)()
380 byref(x_ptr), byref(y_ptr), byref(z_ptr),
401def field_space(name):
402 """ Retrive a space of a Neko field as a `neko_space_t`. """
404 zg = POINTER(c_double)()
405 dr_inv = POINTER(c_double)()
406 ds_inv = POINTER(c_double)()
407 dt_inv = POINTER(c_double)()
408 wx = POINTER(c_double)()
409 wy = POINTER(c_double)()
410 wz = POINTER(c_double)()
411 dx = POINTER(c_double)()
412 dy = POINTER(c_double)()
413 dz = POINTER(c_double)()
415 byref(dr_inv), byref(ds_inv), byref(dt_inv),
416 byref(wx), byref(wy), byref(wz),
417 byref(dx), byref(dy), byref(dz))
420 dr_inv, ds_inv, dt_inv,
421 wx, wy, wz, dx, dy, dz)
425def case_fluid_space(case_descr):
426 """ Retrive a space of a Neko case's fluid solver as a `neko_space_t`. """
428 zg = POINTER(c_double)()
429 dr_inv = POINTER(c_double)()
430 ds_inv = POINTER(c_double)()
431 dt_inv = POINTER(c_double)()
432 wx = POINTER(c_double)()
433 wy = POINTER(c_double)()
434 wz = POINTER(c_double)()
435 dx = POINTER(c_double)()
436 dy = POINTER(c_double)()
437 dz = POINTER(c_double)()
439 byref(dr_inv), byref(ds_inv), byref(dt_inv),
440 byref(wx), byref(wy), byref(wz),
441 byref(dx), byref(dy), byref(dz))
444 dr_inv, ds_inv, dt_inv,
445 wx, wy, wz, dx, dy, dz)
449def wrap_space(lx, zg, dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz):
476def case_fluid_coef(case_descr):
477 """ Retrive coefficients of a Neko case's fluid solver as a `neko_coef_t`. """
478 G11_ptr = POINTER(c_double)()
479 G22_ptr = POINTER(c_double)()
480 G33_ptr = POINTER(c_double)()
481 G12_ptr = POINTER(c_double)()
482 G13_ptr = POINTER(c_double)()
483 G23_ptr = POINTER(c_double)()
484 mult_ptr = POINTER(c_double)()
485 dxdr_ptr = POINTER(c_double)()
486 dydr_ptr = POINTER(c_double)()
487 dzdr_ptr = POINTER(c_double)()
488 dxds_ptr = POINTER(c_double)()
489 dyds_ptr = POINTER(c_double)()
490 dzds_ptr = POINTER(c_double)()
491 dxdt_ptr = POINTER(c_double)()
492 dydt_ptr = POINTER(c_double)()
493 dzdt_ptr = POINTER(c_double)()
494 drdx_ptr = POINTER(c_double)()
495 drdy_ptr = POINTER(c_double)()
496 drdz_ptr = POINTER(c_double)()
497 dsdx_ptr = POINTER(c_double)()
498 dsdy_ptr = POINTER(c_double)()
499 dsdz_ptr = POINTER(c_double)()
500 dtdx_ptr = POINTER(c_double)()
501 dtdy_ptr = POINTER(c_double)()
502 dtdz_ptr = POINTER(c_double)()
503 jac_ptr = POINTER(c_double)()
504 B_ptr = POINTER(c_double)()
505 area_ptr = POINTER(c_double)()
506 nx_ptr = POINTER(c_double)()
507 ny_ptr = POINTER(c_double)()
508 nz_ptr = POINTER(c_double)()
543 dm = case_fluid_dofmap(case_descr)
612def user_setup(case_descr, cb_initial_condition, cb_preprocess, cb_compute,
613 cb_dirichlet_condition, cb_material_properties, cb_source_term):
614 """ Setup user-provided callbacks. """
616 cb_initial_condition,
619 cb_dirichlet_condition,
620 cb_material_properties,
626def callback_field(name):
627 """ Retrive a callback's Neko field as a `neko_field_t`. """
638def callback_field_name(index, name):
639 """ Check the name of a field at a certain index in the callback's field list. """
640 field_index = c_int(index)
642 return same_field > 0
644def bc_mask(msk, msk_size):
654 return cast(create_string_buffer(
s.encode()),c_char_p)
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
user_setup(case_descr, cb_initial_condition, cb_preprocess, cb_compute, cb_dirichlet_condition, cb_material_properties, cb_source_term)
wrap_dofmap(dof_ptr, x_ptr, y_ptr, z_ptr, size)
wrap_space(lx, zg, dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz)
python_dict_to_fortran(d)
Implements the source_term_t type and a wrapper source_term_wrapper_t.