|
WARPXM v1.10.0
|
This document describes the basic structure of WARPy, relevant for developers looking to modify WARPy itself. It also discusses some advanced flags for power users which generally don't need to be modified. You should be familiar with how to use WARPy already.
WARPy's source code is entirely located in tools/warpy. The general directory organization for WARPy are:
apps contains all applications which can be added to a spatial solver or variable adjuster.clusters contains support for queuing a WARPXM job on clusters. It contains capabilities for running WARPXM on clusters using the PBS or Schlurm schedulers. There are default configs for these schedulers, but additional configurations may be required for certain clusters (ex.: loading modules, location of the scratch folder, etc.). These can be added by sub-classing the cluster_info class, then adding the class to clusters_map in clusters/__init__.py. The key is the name of the login node, and the value is the specific instance of a cluster_info object. Note that many clusters have multiple login nodes, and these must individually be enumerated.dt_calc contains all dt controllersfunctions contains all the initial condition functions, as well as the initial condition applicator.host_actions contains all host actions. This includes syncing, temporal solvers, etc.hyperapps contains old applications for the HOFVM method. These no longer work in WARPXM and should not be used.spatial_solvers contains all spatial solvers. Currently the only one of interest is ndg which implements Nodal DG.variable_adjusters contains all variable adjusters. Variable adjusters are patch processes which apply a functional transform \(q = f(u)\), where \(q\) and \(u\) are distributed variables. These include boundary conditions, calculating gradients, limiters, etc.xdmf contains the XDMF generator.tools/warpy/generator.py contains the basic input file output code. It takes Python representations of input parameters and writes out the appropriate .inp format read in by WARPXM.
This is contained in the block class. It roughly represents an XML-like block in the .inp file. Note that at this level there is very little logic associated with actual logical blocks; it knows nothing about what attributes or sub blocks belong where. It's primary concern is properly formatting numbers, strings, lists, and child blocks.
The main class of interest is the warpy_obj class. This is the starting point for all higher level logic blocks. It is able to represent attributes as key-value pairs, and supports both required attributes, as well as optional attributes. An optional attribute is only written to the .inp file if it is not None.
It contains a root block which represents the warpy object itself, and child blocks can either be generated in the __init__ function, or during export by overriding the generate function. Note that if overriding the generate function this function should not modify its internal state; instead, copies should be made of anything to be modified. It is rare that a developer should have to override the generate function; most functionality can be achieved by a combination of passing in appropriate parameters to the base class constructor, or overriding the attrs member function.
The base simulation block is found in tools/warpy/simulation.py. This block represents the highest level entry in the .inp file, and the class also allows users to export the full .inp file and/or run the simulation locally or on a cluster. Configuring the simulation run parameters happens at 3 different levels:
warpy_config.in.py.$HOME/.config/warpy_user_config.py. In theory all the config settings found in warpy_config.in.py can be overridden in this file, though many of the default values should not need to be modified by the user.simulation.run.The configuration files are loaded in the above order. Any configs which are specified in later config files override earlier set values.
In addition to these configs, there are cluster configs found in tools/warpy/clusters. These are used for determining how to generate job files and various parameters specific to certain clusters such as the location of the scratch folder, what scheduler to use, etc. Currently WARPy supports the SLURM and PBS/Torque schedulers.
The applications_container class the base class for all applications, spatial solvers, and variable adjusters. It's purpose is to simplify the process of generating blocks for internal applications.
There are a few key features hidden inside applications_container:
ion.rho might map to component index 5. The mapping is generated by the parent, and must be unique.generate function is called, the blocks associated with these contained applications are automatically added as children.internal_components and internal_const_components. internal_components are variable components which are expected to be read in and written out to. An example is the fluid components for an Euler flux application. internal_const_components are variable components which are only expected to be read in. An example is the electric and magnetic fields for computing the Lorenz body force contribution to a multi-fluid model.warpy_obj class; this includes classifying attributes as required or optional. \end{itemize}The constructor of the applications_container class is able to receive extra components and const components which are not part of any contained applications. This is useful for example if you're implementing a variable adjuster that directly operate without any applications (computing gradients, limiters, etc.).
To implement a custom variable adjuster:
variable_adjusters folder (or one of its subdirectories)variable_adjuster class (which subclasses the applications_container class). Most variable adjusters should only need to call the base class constructor with appropriate parameters, and override the attrs function to add special fields for reading/writing internal components.WARPY_FILES in the CMakeLists.txt file for that folder. This will ensure that the python file will be symbolically linked into the build directory. You should never run WARPy from inside the git directory! This will result in polluting the git repository.__init__.py file for that directory.In order to allow recursive nesting of applications, the application class inherits from applications_container. In addition to the concept of internal components/internal const components, the application also has the concept of components and const components. These two contain all internal components/internal const components respectively, but also contain any components which are directly used by the application.
Process for adding a new application to WARPy:
apps folder (or one of its subdirectories)application. Most applications should only need to define the constructor, and pass appropriate parameters to the base class constructor.WARPY_FILES in the CMakeLists.txt file for that folder. This will ensure that the python file will be symbolically linked into the build directory. You should never run WARPy from inside the git directory! This will result in polluting the git repository.__init__.py file for that directory.There are additional subtle points when dealing with nested applications. The components variable map given to nested applications is currently the "global" one. It is the responsability of the parent application to properly match the requested variables by the child application with the list they are given.
In order to do this, the parent application should request as inputs all variables it needs as well as any variables it's children apps need as inputs. Similarly, it should output all variables it needs as well as any it's children apps need.
For implementing a new initial condition you only need to implement the function. The general applicator provided in WARPXM and WARPy should be sufficient. To implement the function:
functions folder (or one of its subdirectories)warpy_obj class. Most initial condition functions should only need to call the base class constructor with appropriate parameters. Note that the Type attribute should be function.WARPY_FILES in the CMakeLists.txt file for that folder. This will ensure that the python file will be symbolically linked into the build directory. You should never run WARPy from inside the git directory! This will result in polluting the git repository.__init__.py file for that directory.TODO
TODO
TODO