snek5000.output.base#

Base class for sim.output.

Classes

MissingConfigFilter()

Output([sim, params])

Container and methods for getting paths of and copying case files.

class snek5000.output.base.MissingConfigFilter[source]#
filter(record)[source]#
class snek5000.output.base.Output(sim=None, params=None)[source]#

Container and methods for getting paths of and copying case files.

Some important methods:

and important attributes:

name_solver

Alias for solver short-name

Initialized from sim.info.solver.short_name used to discover source code files, such as usr, box, par files. The value of name_solver is also used to identify the entrypoint pointing to the solver module. Have a look at the packaging tutorial.

package#

Initialized using snek5000.solvers.get_solver_package() and name_solver, points to the path to the package to discover source code files.

path_run

Full path of the output directory for this specific simulation

Path to the generated simulation directory.

path_session#

Path to subdirectory under path_run which would contain the field files upon execution. This path would be written into the SESSION.NAME file.

Notes

Here, only the documention for params.output is displayed.

See also

Documentation for params.output

  • HAS_TO_SAVE: bool (default: True) If False, nothing new is saved in the directory of the simulation.

  • sub_directory: str (default: “”) A name of a sub-directory (relative to $FLUIDDYN_PATH_SCRATCH) wherein the directory of the simulation (path_run) is saved.

  • session_id: int (default: 0) Determines the sub-directory, path_session in which the field files would be generated during runtime. The session directory takes the form session_{session_id}.

Note

In short, the field files would be generated under $FLUIDDYN_PATH_SCRATCH/<path_run>/<path_session>

Documentation for params.output.phys_fields

Documentation for params.output.history_points

User parameter for history_points (subroutine hpts):

  • coords: list[tuple[float, float]] for 2D or list[tuple[float, float, float]] for 3D

    Coordinates of probes which gets written into the *.his file. Serves as input array for subroutine hpts() in Nek5000.

  • write_interval: int

    Interval to invoke hpts() subroutine. Gets recorded as user parameter number 10. This should be coupled within userchk() subroutine as follows:

    integer nit_hist
    
    nit_hist = abs(UPARAM(10))
    if (lhis.gt.1) then
        if (mod(ISTEP,nit_hist).eq.0) then
            call hpts()
        endif
    endif
    

Documentation for params.output.remaining_clock_time

property excludes#

Prefixes and suffixes of files which should be excluded from being copied.

property makefile_usr_sources#

Sources for inclusion to makefile_usr.inc Dict[directory] -> list of source files

property makefile_usr_obj#

Object files to be included in compilation. Should be exported as USR environment variable.

property fortran_inc_flags#
classmethod get_path_solver_package()[source]#

Get the path towards the solver package.

classmethod find_configfile(host=None) Path[source]#

Get path of the Snakemake configuration file for the current machine. All configuration files are stored under etc sub-package.

Parameters

host (str) – Override hostname detection and specify it instead

classmethod update_snakemake_config(config, name_solver, /, verbosity=0, env_sensitive=None, **kwargs)[source]#

Update snakemake config in-place with name of the solver / case, path to configfile and compiler flags

Parameters
  • config (dict) – Snakemake configuration

  • name_solver (str) – Short name of the solver, also known as case name

  • verbosity (int) – Set compiler verbosity level. See snek5000.util.smake.set_compiler_verbosity()

  • env_sensitive (bool (None)) – If False, the config dictionary is not modified (allows for reproducible runs). If True, the config dictionary is modified based on environment variables. If None (default), the value of env_sensitive is obtained with os.environ.get("SNEK_UPDATE_CONFIG_ENV_SENSITIVE", False).

  • deprecated: (..) – 0.8.0: The warnings parameter is deprecated! Use verbosity=0 (now default) to disable warnings. If you need warnings=True, similar behaviour can be obtained by verbosity=1 or verbosity=2.

sim#

The simulation class

name_solver#

Alias for solver short-name

oper#

An alias towards the Operators object

params#

The tree of parameters for output-related classes

get_paths()[source]#

Get a list of paths to all case files.

Returns

list

copy(new_dir, force=False)[source]#

Copy case files to a new directory. The directory does not have to be present.

Parameters
  • new_dir – A str or Path-like instance pointing to the new directory.

  • force – Force copy would overwrite if files already exist.

write_box(template)[source]#

Write <case name>.box file from box.j2 template.

See also

Genbox

write_size(template)[source]#

Write SIZE file from SIZE.j2 template.

See also

Nek5000 docs on SIZE

write_makefile_usr(template, fp=None, **template_vars)[source]#

Write the makefile_usr.inc file which gets included in the main makefile by the makenek tool.

Parameters
  • template (jinja2.environment.Template) – Template instance loaded from something like makefile_usr.inc.j2

  • fp (io.TextIOWrapper) – File handler to write to

  • comments (str) – Comments on top of the box file

  • template_vars (dict) – Keyword arguments passed while rendering the Jinja templates

write_snakemake_config(custom_env_vars=None, host=None)[source]#

Write the config file in the simulation directory

Parameters
  • custom_env_vars (dict (None)) – Environment variables used to update the configuration found by find_configfile().

  • host (str) – Override hostname detection and specify it instead

static build_nek5000(config)[source]#

Build Nek5000, if needed. This method is automatically invoked during post_init().

Examples

If compiler configuration is changed via a script after Simulation initialization, a rebuild can be manually triggered as follows:

>>> config = sim.output.write_snakemake_config(
...     custom_env_vars={"CFLAGS": "-O0 -g", FFLAGS": "-O0 -g"}
... )
>>> sim.output.build_nek5000(config)
static write_compile_sh(template, config, fp=None, path=None)[source]#

Write a standalone compile.sh shell script to compile the user code.

Parameters
get_field_file(prefix='', index=-1, t_approx=None)[source]#

Get a field file from path_session.

Parameters
  • prefix (str) – Prefix for special field files; for examples KTH statistics files use prefix sts.

  • index (int) – Index to match a specific field file. If index > 0, the file extension is matched as {prefix}case0.f{index:05d}. If index < 0, the file is indexed from the end of a list of files

  • t_approx (float) – Find a file from approximate simulation time

Returns

file

Return type

Path

post_init()[source]#

Logs info on instantiated classes and finally copy() all source code to simulation directory

SimReprMaker#

alias of SimReprMakerCore

post_init_create_additional_source_files()[source]#

Create the .box, SIZE and makefile_usr files from their template

path_run#

Full path of the output directory for this specific simulation