Skip on/off/rest
This post highlights three grok utility commands that are useful for building and debugging your grok file. These commands are particularly beneficial when you want to skip over certain sections of the code that aren’t necessary for execution during a specific run.
The three commands include skip on, skip off, and skip rest. The skip on and skip off commands should be used together to wrap around a block of code that you don’t want to execute. This can be helpful when skipping long grid generation procedures or debugging boundary conditions. On the other hand, skip rest instructs grok to ignore the rest of the file after a certain point, allowing you to focus on specific tasks, such as visualizing the mesh without running the entire simulation.
These commands are simple but effective tools for managing your grok file and ensuring that only the necessary parts of the model input file are executed.
There are six grok utility commands that can help you build and debug your grok file, each of which is introduced in Section 2.1.1 "File Process Control Options" of the HGS reference manual.
Three of these commands are particularly useful:
skip on
skip off
skip rest
skip on and skip off should be used together. The two commands wrap around a section of grok code that you do not want to execute. In the snippet below, my grid generation procedure takes too long to execute every time I run grok. So, I am "skipping" the grid generation and directly reading the prefixo.coordinates_pm and prefixo.elements_pm files (which grok had previously generated) directly with the command read 3d grid.
!Title Example model with a long grid generation procedure. END Title !===================================================================== ! Load the algomesh .ah2 mesh file. skip on read algomesh 2d grid my_algomesh_file.ah2 generate layers interactive include ..\grid_build.inc end grid generation skip off ! Read the coordinates_pm and elements_pm files directly read 3d grid end mesh to tecplot my_mesh.dat skip rest !-------------------------- General simulation parameters units: kilogram-metre-second transient flow unsaturated remove negative coefficients integrated finite difference for overland flow finite difference mode !... Rest of the grok file ...
Another good use for skip on and skip off is to toggle boundary conditions on and off, when you are debugging your model.
The command skip rest is similar, except that it instructs grok to ignore the remainder of the file. In the above grok snippet, I didn't actually want to run HGS just yet (I only wanted to visualize the mesh in tecplot). So I skipped the rest of the grok file after loading in the mesh and saving to tecplot format. Note that you can also use the comment character “!
“ to comment out blocks of code. It’s a matter of preference.
*Please also note that the HGS developers fixed a bug with the Skip commands in the February 2021 HGS release. Prior to this HGS release, grok would try to open any included files that belonged to a skip on/off block. Grok now fully skips these files.