7cylinder_json = JSON.parsefile("cylinder.case")
9# Define initial conditions
10function initial_condition(scheme_name::Ptr{Cchar}, len::Cint)::Cvoid
12 # In this case the check is redudnant, but if both fluid and scalar
13 # initial conditions should be defined, `scheme_name` can be used
14 # to identifiy which solver has called the callback
15 if (unsafe_string(scheme_name) == "fluid")
16 # To retrive a Julia struct, with wrapped arrays of the data in a field
17 # from Neko's field registry use field()
19 nelm = Neko.field_nelements("u")
36# Define inflow conditions
37function inflow(msk::Ptr{Cint}, msk_size::Cint,
38 t::Cdouble, tstep::Cint)::Cvoid
40 bc_msk = Neko.bc_mask(msk, msk_size)
42 # In this case this check is redudant, but if different user provied
43 # boundary conditions share the same callback, one could use the content
44 # of the callbacks field list to identify which condition should be applied,
45 # for example a velocity condition passes the fields (u, v, w)
46 if (Neko.callback_field_name(1, "u"))
47 u = Neko.callback_field("u")
48 v = Neko.callback_field("v")
49 w = Neko.callback_field("w")
53 # Compute the (i,j,k,e) index given the linear index in bc_msk
54 idx = Neko.nonlinear_index(bc_msk[i], lx, lx, lx)
64# Create a Neko callback for the initial and inflow conditions
65const cb_initial = @Neko.initial_condition(initial_condition)
66const cb_inflow = @Neko.dirichlet_condition(inflow)
68# Create a Neko case from a JSON file and provied (optional) callbacks
69cylinder_case = Neko.case_init(cylinder_json,
70 cb_initial_condition = cb_initial,
71 cb_dirichlet_condition = cb_inflow)
73# To solve the entire case we can call solve()
74#Neko.solve(cylinder_case)
76# To manually step forward in time, call step()
77while Neko.time(cylinder_case) < Neko.end_time(cylinder_case)
78 Neko.step(cylinder_case)
82Neko.case_free(cylinder_case)