These are builtin Macros which you can execute with the $ operator. Some of these, like plot_history and simulate , are intended for you to use directly. Others, like iterate , are internal macros that are typically called by other builtin macros, but you can still call them yourself or edit them to change the builtin behavior if you desire.
compute_heating
Implementation
{
integrand_surface = heat_flux_expr
integrate_surface
heating_rate = integral_surface_heat_flux
}
Compute the total heat flux into the surface.
iterate
Implementation
{
update
compute_residuals
case0 = {}
case1 = {
$compute_force
$compute_heating
}
$$({case} + has_geometry)
{compute initial residual for normalization}
case0 = {}
case1 = {
init_residual_momentum = residual_momentum
init_residual_density = residual_density
init_residual_energy = residual_energy
}
$$({case} + ((iteration == (steady | !implicit))))
case0 = {}
case1 = {
init_unsteady_residual_momentum = unsteady_residual_momentum
init_unsteady_residual_density = unsteady_residual_density
init_unsteady_residual_energy = unsteady_residual_energy
case0 = {}
case1 = {
init_init_unsteady_residual_momentum = unsteady_residual_momentum
init_init_unsteady_residual_density = unsteady_residual_density
init_init_unsteady_residual_energy = unsteady_residual_energy
}
$$({case} + (iteration == 0))
}
$$({case} + (pseudotime_iteration == 1 & !steady & implicit))
$normalized_residual_expr
println report
hexed_prev_except = except
except = {println exception}
$(read(working_dir + {runtime_cmd.hil}))
except = hexed_prev_except
shell({echo > } + working_dir + {runtime_cmd.hil})
hexed_done = (($done) != 0) | hexed_failed
case0 = {}
case1 = {
hexed_time_step_done = ($time_step_done) != 0
hexed_done = hexed_done & hexed_time_step_done & time_stage == n_time_stages - 1
}
$$({case} + (!steady & implicit))
case0 = {}
case1 = {
case0 = {}
case1 = {
case0 = {}
case1 = {
print {Updating surface roughness... }
update_roughness
println {done}
}
$$({case} + (update_roughness_freq > 0 & iteration%update_roughness_freq == 0 & hexed_time_step_done & turbulence_model == {k-omega}))
$adapt_iter
$write_iter
$vis_iter
}
$$({case} + (time_stage == n_time_stages - 1))
case0 = {}
case1 = {
next_time_stage
}
$$({case} + (!steady & implicit))
}
$$({case} + (hexed_time_step_done & !hexed_done))
}
Executes one iteration (called by
solve). Behavior is roughly the following:
- calls update
- computes residuals
- prints history variables
- may writes mesh and state files, depending on write_freq
- may write visualization files, depending on vis_freq
- executes any commands in runtime_cmd.hil and empties the file
If you wish for the solver to perform extra actions on every iteration, you can accomplish this by modifying
iterate. For example, if you wanted to compute and print the total mass in the flowfield at every iteration, you could do:
iterate = iterate + {
integrand_field = {density = density;}
integrate_field
}
print_vars = print_vars + {total_mass = integral_field_density;}
plot_history
Implementation
{
shell({python3 -c "from hexedpy.utils import History_plot;History_plot('} + working_dir + {')" &})
}
Shows a real-time plot of the convergence history in a separate window with
Matplotlib. Obviously, you should not do this if you are in a remote session with ssh.
print_force
Implementation
{
$compute_force
println({drag: } + drag + { N})
println({lift: } + lift + { N})
println({side force: } + side_force + { N})
println({drag coefficient: } + drag_coef)
println({lift coefficient: } + lift_coef)
println({side force coefficient: } + side_force_coef)
}
Print a report on the aerodynamic forces.
read_restart
Implementation
{
println {reading restart data...}
$read(input_data + {.status.hil})
$setup_io
create_solver
read_mesh
hexed_mesh_init = true
read_state
read_status
println {done}
println({ Monitor window: } + monitor_window)
}
Reads all restart data from a previous simulation (but does not automatically resume execution). This restart data includes the mesh, flow state, and the value of all user- and solver-defined
HIL variables. The variables
input_data and
working_dir are not read from the file—they will retain their current values. Before executing
$read_restart you will most likely want to set
input_data. After executing
$read_restart, you will most likely want to modify some parameters and then either call
$solve to resume execution or
visualize.
restart
Reads all restart data from a previous simulation and resumes execution. Usually it is advisable to set
input_data and
working_dir before calling
$read_restart, (Otherwise it will stay the same as in the simulation you are restarting.) If you want to modify any other simulation parameters before resuming execution, you will need to use
read_restart instead. An example input file for restarting a simulation might look like this:
input_data = {hexed_out/latest}
working_dir = {hexed_out_restart}
$restart
simulate
Implementation
{
$start
mesh
init_state
$solve
}
Runs the simulation. If you call this after defining your input parameters, you don't need to call any other macros. You may wish to call
plot_history before calling
simulate, but this is optional.
solve
Implementation
{
compute_residuals
case0 = {}
case1 = {
$compute_force
$compute_heating
}
$$({case} + has_geometry)
init_monitors
$write_init
$vis_init
$print_init
shell({echo > } + working_dir + {runtime_cmd.hil})
adapt_changed = true
hexed_time_step_done = true
hexed_done = false
while = {!hexed_done}
do = {$iterate}
$loop
$print_final
$write_final
$vis_final
}
Runs the solver. Assumes that the mesh has already been generated and the flow state initialized. If you want those steps to be done automatically as well, use
simulate instead.
start
Implementation
{
$setup_io
case1 = {
case1 = {surface_bc = {nonpenetration}}
case0 = {surface_bc = {no_slip}}
$$({case} + (viscosity_model == {}))
}
$$({case} + (surface_bc == {auto}))
case0 = {}
case1 = {domain_size = domain_size_ratio*reference_length}
$$({case} + (domain_size <= 0.))
case0 = {}
case1 = {
i_dim = 0
while = {i_dim < n_dim}
do = {
$({flood_fill_start} + i_dim) = $({domain_center} + i_dim) + (mesh_extreme_eps - .5)*domain_size
i_dim = i_dim + 1
}
$loop
}
$$({case} + (flood_fill_start0 == huge))
case0 = {}
case1 = {$set_shock; $set_ramping}
$$({case} + capture_shocks)
compute_freestream
create_solver
init_residual_momentum = 0.
init_residual_density = 0.
init_residual_energy = 0.
init_init_unsteady_residual_momentum = 0.
init_init_unsteady_residual_density = 0.
init_init_unsteady_residual_energy = 0.
prev_residual = 0.
hexed_next_flow_time = 0.
last_refine_iter = 0
allow_refinement = false
pseudotime_iteration = 0
rms_flux = 0.
n_diffusion_limited = 0
n_source_limited = 0
total_iteration = 0
case0 = {}
case1 = {
iteration_expr = iteration_expr + unsteady_iteration_expr
print_vars = print_vars + unsteady_residual_expr
}
$$({case} + (!steady & implicit))
case1 = {iteration_expr = iteration_expr + {flow_time = flow_time; time_step = time_step;}}
$$({case} + !steady)
println({ Monitor window: } + monitor_window)
}
Performs basic initialization that has to happen before you can do anything with the solver (but after you've defined your parameters). Behavior is roughly the following:
- creates working directory if it does not already exist
- copies the input file to the working directory for the user's future reference
- initializes automatically-determined parameters
- calls create_solver
terminate
Implementation
{
print_emph = true
print_type = {error}
println {User commanded termination.}
hexed_failed = true
}
Call this macro (usually from
runtime_cmd.hil) to gracefully terminate the simulation.
time_step_done
Default: {((unsteady_residual_momentum + unsteady_residual_density + unsteady_residual_energy)/3 < .1*(init_unsteady_residual_momentum + init_unsteady_residual_density + init_unsteady_residual_energy)/3)}
Termination condition for the pseudotime iteration. This should be a macro that evaluates to an integer. It will be evaluated at each pseudotime iteration and iff it evaluates to
true, the simulation it will move on to the next real-time step. As should be clear from the default value, you
must set this variable yourself if
steady =
false and
implicit =
true.
- Todo
- Document options based on history monitors and determine a reasonable default value.