butterfly.grading module

Butterfly grading class for blockMeshDict.

class butterfly.grading.Grading(percentage_length=None, percentage_cells=None, expansion_ratio=1)[source]

Bases: object

OpenFOAM grading.

Use this class to create OpenFOAM grading with either a single expansion ration or (percentage_length, percentage_cells, expansion_ratio).

percentage_length

Percentage of length of the block.

percentage_cells

Percentage of cells to be included in this segment.

expansion_ratio

Expansion ration in this segment (default: 1).

ToString()[source]

Overwrite .NET ToString method.

duplicate()[source]

Return a copy of this object.

classmethod from_expansion_ratio(expansion_ratio=1)[source]

Create a grading with only expansion_ratio.

isGrading

Return True.

is_valid

Return True if grading is just an expansion_ratio.

class butterfly.grading.MultiGrading(gradings)[source]

Bases: object

MultiGrading.

Use this object to create MultiGrading like the example below.
(0.2 0.3 4) // 20% y-dir, 30% cells, expansion = 4 (0.6 0.4 1) // 60% y-dir, 40% cells, expansion = 1 (0.2 0.3 0.25) // 20% y-dir, 30% cells, expansion = 0.25 (1/4)

Read more at section 5.3.1.3: http://cfd.direct/openfoam/user-guide/blockmesh/

gradings

A list of minimum two OpenFOAM Gradings. All the gradings should have percentage_length and percentage_cells values.

ToString()[source]

Overwrite .NET ToString method.

duplicate()[source]

Return a copy of this object.

gradings

Get gradings in this MultiGrading.

isGrading

Return True.

isMultiGrading

Return True.

is_valid

Return True.

class butterfly.grading.SimpleGrading(x_grading=1, y_grading=1, z_grading=1)[source]

Bases: object

Block simpleGrading in blockMeshDict.

x_grading

Grading for X. The input can be a Grading or a MultiGrading (default: 1).

y_grading

Grading for Y. The input can be a Grading or a MultiGrading (default: 1).

z_grading

Grading for Z. The input can be a Grading or a MultiGrading (default: 1).

Usage:

x_grading = Grading.from_expansion_ratio(1) y_grading = Grading.from_expansion_ratio(1) z_grading = MultiGrading(

(Grading(0.2, 0.3, 4), Grading(0.6, 0.4, 1), Grading(0.2, 0.3, 0.25))

)

print(simpleGrading(x_grading, y_grading, z_grading))

>> simpleGrading (

1.0 1.0 (

(0.2 0.3 4.0) (0.6 0.4 1.0) (0.2 0.3 0.25)
ToString()[source]

Overwrite .NET ToString method.

duplicate()[source]

Return a copy of this object.

isSimpleGrading

Return True.

to_openfoam()[source]

Get blockMeshDict string.

Parameters:
  • vertices – list of vertices for all the geometries in the case.
  • tolerance – Distance tolerance between input vertices and blockMesh vertices.