butterfly.solution module

Butterfly Solution.

class butterfly.solution.Solution(case, recipe, decomposeParDict=None, solution_parameter=None, remove_extra_foam_files=False)[source]

Bases: object

Butterfly Solution.

This class creates a solution from a recipe which is ready to run and monitor.

Parameters:
  • case – A butterfly case.
  • recipe – A butterfly recipe.
  • decomposeParDict – decomposeParDict for parallel run (default: None).
  • solution_parameter – A SolutionParameter (default: None).
  • remove_extra_foam_files – set to True if you want butterfly to remove all the extra files in 0 folder once you update the recipe (default: False).
ToString()[source]

Overwrite .NET ToString method.

case

Case.

controlDict

Get controlDict.

decomposeParDict

DecomposeParDict.

duplicate()[source]

Return a copy of this object.

err_files

Get full path to error files.

info

Get timestep and residual values as a tuple.

is_running

Check if the solution is still running.

load_probe_values(field)[source]

Return OpenFOAM probes results for a given field (e.g. U).

load_probes(field)[source]

Return OpenFOAM probes location for a given field (e.g. U).

log

Get the log report.

log_files

Get full path to log files.

probes

Get probes if any.

project_dir

Get project directory.

project_name

Get porject name.

purge(remove_polyMesh_content=True, remove_snappyHexMesh_folders=True, remove_result_folders=False, remove_postProcessing_folder=False)[source]

Purge solution’s case folder.

recipe

Get recipe.

remove_extra_foam_files

If True, solution will remove extra files everytime recipe changes.

residualControl

Get residualControl values for this solution.

residual_fields

Get list of residuals to be watched during the run.

residual_file

Return address of the residual file.

residual_values

Get timestep and residual values as a tuple.

run(wait=False)[source]

Execute the solution.

sample(name, points, field, wait=True)[source]

Sample the results for a certain field.

Parameters:
  • name – A unique name for this sample.
  • points – List of points as (x, y, z).
  • fields – List of fields (e.g. U, p).
  • args – Command arguments.
  • wait – Wait until command execution ends.
Returns:

namedtuple(probes, values).

skipped_probes()[source]

Get list of probes that are skipped from the solution.

terminate()[source]

Cancel the solution.

timestep

Get latest timestep for this solution.

update_from_recipe(recipe)[source]

Update solution from recipe inputs.

This method creates a SolutionParameter from each recipe property, and uses updateSolutionParams to update the solution.

update_solution_params(sol_params, timestep=None)[source]

Update parameters.

sol_params

A list of solution parameters.

class butterfly.solution.SolutionParameter(of_filename, values, replace=False, time_range=None)[source]

Bases: object

A solution parameter that can be changed during the solution.

Add solution parameter to to solution settings.

filename

OpenFOAM filename that the values are belong to (e.g. blockMeshDict, fvSchemes).

values

New values as a python dictionary.

replace

Set to True if you want the original dictionary to be replaced by new values. Default is False which means the original dictionary will be only updated by new values.

time_range

Time range that this SolutioParameter is valid as a tuple (default: (0, 1.0e+100)).

ToString()[source]

Overwrite .NET ToString method.

duplicate()[source]

Return a copy of this object.

filename

Return OpenFOAM file name.

classmethod from_cpp_dictionary(of_filename, dictionary, replace=False, time_range=None, header=False)[source]

Create from an OpenFOAM dictionary in text format.

classmethod from_dictionary_file(of_filename, filepath, replace=False, time_range=None)[source]

Create from an OpenFOAM dictionary file.

isSolutionParameter

Return True.

is_time_in_range(time)[source]

Check if time is in this SolutionParameter time range.

time_range

Get time range.

values

Return OpenFOAM file name.