Block Mesh Dict

A class build to handle generation of a blockMeshDict from an aperture map.
Written By: Matthew Stadelman
Date Written: 2016/08/08
Last Modifed: 2016/08/08
class apmapflow.openfoam.block_mesh_dict.BlockMeshDict(field, avg_fact=1.0, mesh_params=None, offset_field=None)[source]

This is a special subclass of OpenFoamFile used to generate and output a blockMeshDict for OpenFoam

__init__(field, avg_fact=1.0, mesh_params=None, offset_field=None)[source]

Takes a field object and a set of mesh params to set the properties of the blockMeshDict

field : DataField, field that is storing the aperture map data avg_fact : float, optional, number of voxels along the X and Z axes. mesh_params : dict, optional, a dictionary containing parameters to use instead of the defaults offset_field : DataField, field object that stores the offset data for an aperture map

_create_blocks(cell_mask)[source]

Sets up the vertices and blocks.

  • cell_mask is a boolean array in the shape of the data_map

telling the function what blocks to include.

vert_map stores the 4 vertex indices that make up the back surface and the front surface is ‘+ 1’ the index of the corresponding lower point. In terms of the very first block vert_map[i,j,0] is at the orgin (0,0), bottom left corner vert_map[i,j,1] is bottom right corner (1,0) vert_map[i,j,2] is the top right corner (1,1) vert_map[i,j,3] is the top left corner (0,1)

_generate_masked_mesh(cell_mask=None)[source]

Generates the mesh based on the cell mask provided

generate_mesh_file()[source]

Populates keys on itself based on geometry data to output a mesh file

generate_simple_mesh()[source]

Generates a simple mesh including all cells in the data map

generate_threshold_mesh(min_value=0.0, max_value=1000000000.0)[source]

Generates a mesh excluding all blocks below the min_value arg. Regions that are isolated by the thresholding are also automatically removed.

set_boundary_patches(boundary_blocks, reset=False)[source]

Sets up boundary patches based on the dictionary passed in. Overlapping declarations are overwritten by the last patch to use that face. The boundary blocks dictionary contains a dictionary entry for each patch name.

  • boundary_blocks dictionary has the format of:
    {patch_name: {

    <side>: [ block-list ], <side>: [ block-list ], ...

    } where <side> is left, right, bottom, top, front or back and block list is a list of blocks to add that patch to the side of.

  • reset - boolean : if True then the face labels dictionary

    and _faces array are re-initialized to default values

write_foam_file(path='.', create_dirs=True, overwrite=False)[source]

Writes a full blockMeshDict file based on stored geometry data

write_mesh_file(path='.', create_dirs=True, overwrite=False)[source]

Passes args off to write_foam_file

write_symmetry_plane(path='.', create_dirs=True, overwrite=False)[source]

Exports the +Y half of the mesh flattening out everything below 0 on the Y axis