How to Jinja templates#
Three files needed for Nek5000 are produced by Snek5000 through Jinja templates:
<case name>.box
, SIZE
and makefile_usr.inc
. As a Nek5000 user, you might want to
understand how these important files are produced, so let us explain by diving into the
code:
These files are produced by the methods:
These methods are called in a method
snek5000.output.base.Output.post_init_create_additional_source_files()
which uses the class attributestemplate_box
,template_size
andtemplate_makefile_usr
. These attributes are defined in the solvers, for example forsnek5000-tgv
in the filesnek5000_tgv.output
:from snek5000.output.base import Output as OutputBase from snek5000.resources import get_base_templates box, makefile_usr, size = get_base_templates() class OutputTGV(OutputBase): template_box = box template_makefile_usr = makefile_usr template_size = size @property def makefile_usr_sources(self): """ Sources for inclusion to makefile_usr.inc Dict[directory] -> list of source files """ return {} @classmethod def _set_info_solver_classes(cls, classes): """Set the classes for info_solver.classes.Output""" super()._set_info_solver_classes(classes) classes._set_child( "SpatialMeans", dict( module_name="snek5000.output.spatial_means", class_name="SpatialMeans", ), ) Output = OutputTGV
Note
With this mechanism, the template files can be obtained from a simulation object with
sim.output.template_box.filename
.Some base template files are in the subpackage
snek5000.resources
. These files are general enough so that they can be used directly by most solvers (for example we saw thatsnek5000-tgv
usessnek5000.resources.get_base_templates()
). However, it is also possible to use other templates. For example, insnek5000-cbox
, Jinja inheritance is used to extend the template for theSIZE
file.