butterfly.parser module

OpenFOAM/c++ dictionary parser.

class butterfly.parser.CppDictParser(text)[source]

Bases: object

Parse OpenFOAM dictionary to Python dictionary.

Use values property to get the dictionary.

text

OpenFOAM dictionary as a single multiline string.

ToString()[source]

Overwrite ToString method.

classmethod from_file(filepath)[source]

Create a parser from an OpenFOAM file.

static remove_comments(code)[source]

Remove comments from c++ codes.

values

Get OpenFOAM dictionary values as a python dictionary.

class butterfly.parser.ResidualParser(filepath, parse=True)[source]

Bases: object

Paeser for residual values from a log file.

filepath

Full file path to .log file.

parser

If ture Parser will start parsing the values once initiated.

get_residuals(quantity, time_range)[source]

Get residuals for a quantity.

get_times()[source]

Get time steps.

parse()[source]

Parse the log file.

residuals

Get residuals as a dictionary.

time_range

Get time range as a tuple.