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)
76 POINTER(POINTER(c_longlong)),
77 POINTER(POINTER(c_double)),
78 POINTER(POINTER(c_double)),
79 POINTER(POINTER(c_double))]
83 POINTER(POINTER(c_longlong)),
84 POINTER(POINTER(c_double)),
85 POINTER(POINTER(c_double)),
86 POINTER(POINTER(c_double)),
92 POINTER(POINTER(c_double)),
93 POINTER(POINTER(c_double)),
94 POINTER(POINTER(c_double)),
95 POINTER(POINTER(c_double)),
96 POINTER(POINTER(c_double)),
97 POINTER(POINTER(c_double)),
98 POINTER(POINTER(c_double)),
99 POINTER(POINTER(c_double)),
100 POINTER(POINTER(c_double)),
101 POINTER(POINTER(c_double))]
106 POINTER(POINTER(c_double)),
107 POINTER(POINTER(c_double)),
108 POINTER(POINTER(c_double)),
109 POINTER(POINTER(c_double)),
110 POINTER(POINTER(c_double)),
111 POINTER(POINTER(c_double)),
112 POINTER(POINTER(c_double)),
113 POINTER(POINTER(c_double)),
114 POINTER(POINTER(c_double)),
115 POINTER(POINTER(c_double))]
119 POINTER(POINTER(c_double)),
120 POINTER(POINTER(c_double)),
121 POINTER(POINTER(c_double)),
122 POINTER(POINTER(c_double)),
123 POINTER(POINTER(c_double)),
124 POINTER(POINTER(c_double)),
125 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))]
173 """ Defines a Neko mapping of the degrees of freedom """
182 """ Defines a Neko space. """
197 """ Defines a Neko field. """
204 """ Defines Neko coefficients. """
238 """ Initialise Neko. """
242 """ Finalize Neko. """
246 """ Display job information. """
249def case_init(case_json,
250 cb_initial_condition = initial_condition(0),
256 """Initialise a Neko case
258 A case is created based on a JSON file and a couple of (optional)
273 user_setup(case_descr, cb_initial_condition, cb_preprocess,
274 cb_compute, cb_dirichlet_condition, cb_material_properties,
281def case_free(case_descr):
282 """ Destroy a Neko case. """
286 """ Retrive the current time of a case. """
290def end_time(case_descr):
291 """ Retrive the end time of a case. """
295def tstep(case_descr):
296 """ Retrive the current time-step of a case. """
300def solve(case_descr):
301 """ Solve a Neko case. """
305 """ Compute a time-step for a Neko case. """
309 """ Retrive a Neko field as a `neko_field_t`. """
320def field_order(name):
321 """ Retrive the order of a Neko field. """
325def field_nelements(name):
326 """ Retrive the number of elements in a Neko field. """
331 """ Retrive the total number of degrees of freedom of a Neko field. """
335def field_dofmap(name):
336 """ Retrive a dofmap of a Neko field as a `neko_dofmap_t`. """
338 dof_ptr = POINTER(c_longlong)()
339 x_ptr = POINTER(c_double)()
340 y_ptr = POINTER(c_double)()
341 z_ptr = POINTER(c_double)()
343 byref(x_ptr), byref(y_ptr), byref(z_ptr))
345 dofmap =
wrap_dofmap(dof_ptr, x_ptr, y_ptr, z_ptr, size)
349def case_fluid_dofmap(case_descr):
350 """ Retrive a dofmap of a Neko case's fluid solver as a `neko_dofmap_t`. """
352 dof_ptr = POINTER(c_longlong)()
353 x_ptr = POINTER(c_double)()
354 y_ptr = POINTER(c_double)()
355 z_ptr = POINTER(c_double)()
357 byref(x_ptr), byref(y_ptr), byref(z_ptr),
378def field_space(name):
379 """ Retrive a space of a Neko field as a `neko_space_t`. """
381 zg = POINTER(c_double)()
382 dr_inv = POINTER(c_double)()
383 ds_inv = POINTER(c_double)()
384 dt_inv = POINTER(c_double)()
385 wx = POINTER(c_double)()
386 wy = POINTER(c_double)()
387 wz = POINTER(c_double)()
388 dx = POINTER(c_double)()
389 dy = POINTER(c_double)()
390 dz = POINTER(c_double)()
392 byref(dr_inv), byref(ds_inv), byref(dt_inv),
393 byref(wx), byref(wy), byref(wz),
394 byref(dx), byref(dy), byref(dz))
397 dr_inv, ds_inv, dt_inv,
398 wx, wy, wz, dx, dy, dz)
402def case_fluid_space(case_descr):
403 """ Retrive a space of a Neko case's fluid solver as a `neko_space_t`. """
405 zg = POINTER(c_double)()
406 dr_inv = POINTER(c_double)()
407 ds_inv = POINTER(c_double)()
408 dt_inv = POINTER(c_double)()
409 wx = POINTER(c_double)()
410 wy = POINTER(c_double)()
411 wz = POINTER(c_double)()
412 dx = POINTER(c_double)()
413 dy = POINTER(c_double)()
414 dz = POINTER(c_double)()
416 byref(dr_inv), byref(ds_inv), byref(dt_inv),
417 byref(wx), byref(wy), byref(wz),
418 byref(dx), byref(dy), byref(dz))
421 dr_inv, ds_inv, dt_inv,
422 wx, wy, wz, dx, dy, dz)
426def wrap_space(lx, zg, dr_inv, ds_inv, dt_inv, wx, wy, wz, dx, dy, dz):
453def case_fluid_coef(case_descr):
454 """ Retrive coefficients of a Neko case's fluid solver as a `neko_coef_t`. """
455 G11_ptr = POINTER(c_double)()
456 G22_ptr = POINTER(c_double)()
457 G33_ptr = POINTER(c_double)()
458 G12_ptr = POINTER(c_double)()
459 G13_ptr = POINTER(c_double)()
460 G23_ptr = POINTER(c_double)()
461 mult_ptr = POINTER(c_double)()
462 dxdr_ptr = POINTER(c_double)()
463 dydr_ptr = POINTER(c_double)()
464 dzdr_ptr = POINTER(c_double)()
465 dxds_ptr = POINTER(c_double)()
466 dyds_ptr = POINTER(c_double)()
467 dzds_ptr = POINTER(c_double)()
468 dxdt_ptr = POINTER(c_double)()
469 dydt_ptr = POINTER(c_double)()
470 dzdt_ptr = POINTER(c_double)()
471 drdx_ptr = POINTER(c_double)()
472 drdy_ptr = POINTER(c_double)()
473 drdz_ptr = POINTER(c_double)()
474 dsdx_ptr = POINTER(c_double)()
475 dsdy_ptr = POINTER(c_double)()
476 dsdz_ptr = POINTER(c_double)()
477 dtdx_ptr = POINTER(c_double)()
478 dtdy_ptr = POINTER(c_double)()
479 dtdz_ptr = POINTER(c_double)()
480 jac_ptr = POINTER(c_double)()
481 B_ptr = POINTER(c_double)()
482 area_ptr = POINTER(c_double)()
483 nx_ptr = POINTER(c_double)()
484 ny_ptr = POINTER(c_double)()
485 nz_ptr = POINTER(c_double)()
520 dm = case_fluid_dofmap(case_descr)
589def user_setup(case_descr, cb_initial_condition, cb_preprocess, cb_compute,
590 cb_dirichlet_condition, cb_material_properties, cb_source_term):
591 """ Setup user-provided callbacks. """
593 cb_initial_condition,
596 cb_dirichlet_condition,
597 cb_material_properties,
603def callback_field(name):
604 """ Retrive a callback's Neko field as a `neko_field_t`. """
615def callback_field_name(index, name):
616 """ Check the name of a field at a certain index in the callback's field list. """
617 field_index = c_int(index)
619 return same_field > 0
621def bc_mask(msk, msk_size):
631 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.