butterfly.geometry module

BF geometry library.

class butterfly.geometry.BFBlockGeometry(name, vertices, face_indices, border_vertices, boundary_condition=None)[source]

Bases: butterfly.geometry.BFGeometry

Butterfly block geometry.

Use this geometry to create geometries for blockMeshDict.

name

Name as a string (A-Z a-z 0-9 _).

vertices

A flatten list of (x, y, z) for vertices.

face_indices

A flatten list of (a, b, c) for indices for each face.

boundary_condition

Boundary condition for this geometry.

border_vertices

List of lists of (x, y, z) values for each quad face of the geometry.

border_vertices

Return list of border vertices.

isBFBlockGeometry

Return True for Butterfly block geometries.

class butterfly.geometry.BFGeometry(name, vertices, face_indices, normals=None, boundary_condition=None, refinementLevels=None, nSurfaceLayers=None)[source]

Bases: butterfly.geometry._BFMesh

Butterfly geometry.

name

Name as a string (A-Z a-z 0-9 _).

vertices

A flatten list of (x, y, z) for vertices.

face_indices

A flatten list of (a, b, c) for indices for each face.

normals

A flatten list of (x, y, z) for face normals.

boundary_condition

Boundary condition for this geometry.

Usage:

vertices = ((0, 0, 0), (10, 0, 0), (10, 10, 0), (0, 10, 0))

geo = BFGeometry(name=’square’, vertices=vertices,
face_indices=((0, 1, 2), (0, 2, 3)), normals=((0, 0, 1), (0, 0, 1)))

print(geo.to_stl(convertToMeters=1))

boundary_condition

Boundary condition.

isBFGeometry

Return True for Butterfly geometries.

nSurfaceLayers

Number of surface layers for snappyHexMeshDict addLayers.

refinementLevels

refinementLevels for snappyHexMeshDict as (min, max).

butterfly.geometry.bf_geometry_from_stl_block(stl_block, convert_from_meters=1)[source]

Create BFGeometry from an stl block as a string.

butterfly.geometry.bf_geometry_from_stl_file(filepath, convert_from_meters=1)[source]

Return a tuple of BFGeometry from an stl file.

butterfly.geometry.calculate_min_max(geometry, angle)[source]

Calculate maximum and minimum x, y, z for input geometry.

angle: Anticlockwise rotation angle of the new coordinates system.

butterfly.geometry.calculate_min_max_from_bf_geometries(geometries, x_axis=None)[source]

Calculate maximum and minimum x, y, z for this geometry.

Returns:(min_pt, max_pt)
butterfly.geometry.dimensions_from_min_max(min_pt, max_pt, x_axis=None)[source]

Calculate width, length and height for input x_axis.