carputils
Doxygen code documentation for the python framework controlling openCARP
Classes | Functions | Variables
carputils.tools Namespace Reference

Classes

class  MaxNPAction
 Class to check that the maximum number of processes is not exceeded. More...
 
class  PrintAction
 Class to print a unformatted message like '–help' and exit. More...
 

Functions

def basic_parser (showdefault=True, overwrite_behaviour=OVERWRITE_BEHAVIOUR[0], formatter_cls=None)
 
def standard_parser (showdefault=True)
 Generate a standard argument parser for collection of common options. More...
 
def basic_job_id (args)
 Generate default job ID. More...
 
def basicexample (parser=basic_parser, job_id=basic_job_id, summary=True, temp=False)
 Generate a decorator for openCARP example run function. More...
 
def carp_job_id (args)
 Generate default job ID. More...
 
def carpexample (parser=standard_parser, job_id=carp_job_id, meshdir=None, clean_pattern='^(\d{4}-\d{2}-\d{2})|(mesh)', simple=False, summary=True, temp=False, mkdir=True)
 Generate a decorator for openCARP example run function. More...
 
def carp_cmd (parfile=None, mech_symmetric=False)
 Construct the basic openCARP command line. More...
 
def list_to_string (pl)
 
def gen_physics_opts (ExtraTags=None, IntraTags=None, EikonalTags=None, MechTags=None, FluidTags=None)
 
def simfile_path (path, mesh=False)
 This function should encapsulate the paths of the external files required for the experiment. More...
 
def resolve_simfilepath (path, mesh)
 Generates the string representing the parameter that has to be given to the simfile_path function in the protocol script contained in the bundle, to replace 'path'. More...
 

Variables

 OVERWRITE_BEHAVIOUR = tuple(clean.OVERWRITE_MODES.keys())
 
 maxnp = None
 

Function Documentation

◆ basic_job_id()

def carputils.tools.basic_job_id (   args)

Generate default job ID.

◆ basic_parser()

def carputils.tools.basic_parser (   showdefault = True,
  overwrite_behaviour = OVERWRITE_BEHAVIOUR[0],
  formatter_cls = None 
)

◆ basicexample()

def carputils.tools.basicexample (   parser = basic_parser,
  job_id = basic_job_id,
  summary = True,
  temp = False 
)

Generate a decorator for openCARP example run function.

The decorator sets up sensible defaults for argv and sequence for an openCARP example's run function, and executes the command sequence on exit, where required.

◆ carp_cmd()

def carputils.tools.carp_cmd (   parfile = None,
  mech_symmetric = False 
)

Construct the basic openCARP command line.

Constructs a list of command line arguments. This will automatically include the loading of the correct options for the specified solvers.

Parameters
parfilestr, optional The openCARP parameter file to be used, if any.
Returns
list of str The initial openCARP command line.

◆ carp_job_id()

def carputils.tools.carp_job_id (   args)

Generate default job ID.

◆ carpexample()

def carputils.tools.carpexample (   parser = standard_parser,
  job_id = carp_job_id,
  meshdir = None,
  clean_pattern = '^(\d{4}-\d{2}-\d{2})|(mesh)',
  simple = False,
  summary = True,
  temp = False,
  mkdir = True 
)

Generate a decorator for openCARP example run function.

The decorator sets up sensible defaults for argv and sequence for a openCARP example's run function, and executes the command sequence on exit, where required.

◆ gen_physics_opts()

def carputils.tools.gen_physics_opts (   ExtraTags = None,
  IntraTags = None,
  EikonalTags = None,
  MechTags = None,
  FluidTags = None 
)

◆ list_to_string()

def carputils.tools.list_to_string (   pl)

◆ resolve_simfilepath()

def carputils.tools.resolve_simfilepath (   path,
  mesh 
)

Generates the string representing the parameter that has to be given to the simfile_path function in the protocol script contained in the bundle, to replace 'path'.

If the path is an existing file path, this file is copied in the bundle. Note that the filename can be given without its extension.

Parameters
pathpath to a file
meshset to true if the path is leading to a mesh file
Returns
string representing the parameter to give to the simfile_path function in the bundle.

◆ simfile_path()

def carputils.tools.simfile_path (   path,
  mesh = False 
)

This function should encapsulate the paths of the external files required for the experiment.

The function is passive if –bundle command line option is not set: it simply returns the 'path' parameter. Otherwise it changes the path into a relative path in the self-contained bundle, and consequently modifies the protocol script that will be written in the bundle. It also copies the file targeted by path in the bundle folder if it exists. The mesh option tells if the file given by the path is a mesh file or not.

Warning
for now, this function can't be called on multiple lines.
Parameters
pathPath to a file
meshif True, the file is considered as a mesh file
Returns
the path parameter without any modification

◆ standard_parser()

def carputils.tools.standard_parser (   showdefault = True)

Generate a standard argument parser for collection of common options.

Returns ArgumentParser The parser object from the python standard library argparse module. See the online documentation <https://docs.python.org/2.7/library/argparse.html>_ for information on adding additional options to this parser in a run script. To actually parse the command line, use the parse_args method of the returned parser object.

Variable Documentation

◆ maxnp

carputils.tools.maxnp = None

◆ OVERWRITE_BEHAVIOUR

carputils.tools.OVERWRITE_BEHAVIOUR = tuple(clean.OVERWRITE_MODES.keys())