Parallel Mesh Generation

A class build to handle generation of a blockMeshDict in parallel using the
mergeMeshes and stitchMesh OpenFoam utilities.
Written By: Matthew Stadelman
Date Written: 2016/08/09
Last Modifed: 2016/08/15
class apmapflow.openfoam.parallel_mesh_gen.BlockMeshRegion(region, avg_fact, x_shift, z_shift, mesh_params, offset_reg)[source]

Used to handle a sub-set of field point data for parallel mesh generation

__init__(region, avg_fact, x_shift, z_shift, mesh_params, offset_reg)[source]

Takes a field object and a set of mesh params to set the properties of the blockMeshDict. The x_shift and z_shift values are multipled by avg_fact.

data_region : DataFieldRegion object avg_fact : float, number of voxels along the X and Z axes. x_shift : int, number of voxels shifted from orgin z_shift : int, number of voxels shifted from origin mesh_params : dict, a dictionary containing parameters to offsets : DataFieldRegion object use instead of the defaults

_create_blocks(cell_mask=None)[source]

Generates blocks and verticies the same as the parent class and then applies the x and z shift

run_block_mesh(mesh_type, path, system_dir, t_name, overwrite)[source]

Writes the blockMeshDict and runs blockMesh on a region

class apmapflow.openfoam.parallel_mesh_gen.DataFieldRegion(data, point_data)[source]

Used to manipulate a specfic data region of a DataField. In order to maintain data integrity point data is not able to be recalculated here.

class apmapflow.openfoam.parallel_mesh_gen.MergeGroup(region_id, external_patches, path)[source]

Handles merging of meshes and stitching any patches that become internal

__init__(region_id, external_patches, path)[source]

Sets up the initial merge group as a single region. External patches is a dictionary with an entry for each side, {side: ‘patch_name’}. The attribute ‘external_patches’ has the same format except its entries for each side are lists.

__weakref__

list of weak references to the object (if defined)

static _clean_polymesh(path)[source]

Removes files left over from merging and stitching meshes together

merge_regions(region_in, direction, t_name)[source]

Merges two regions updating the external_patches dict and stitching and patches that become internal. It is assumed the region_in will be a higher ‘id’ than this region.

stitch_patches(internal_patches, t_name)[source]

Stitches all internal patches in the region together

class apmapflow.openfoam.parallel_mesh_gen.ParallelMeshGen(field, system_dir, nprocs=4, **kwargs)[source]

Handles creation of a large mesh in parallel utilizing the OpenFoam utilties mergeMesh and stitchMesh.

__weakref__

list of weak references to the object (if defined)

static _create_merge_queue(grid, direction)[source]

Determines the region merge queue based on the grid supplied

_create_regions_thread(region_queue, t_name, kwargs)[source]

Handles processing of the queue in it’s own thread

_create_subregion_meshes(ndivs, **kwargs)[source]

Divides the data map into smaller regions and creates a BlockMeshRegion object for each one.

_merge_submeshes(grid)[source]

Handles merging and stitching of meshes based on alternating rounds of horizontal pairing and then vertical pairing.

static _remove_leftover_patches(path)[source]

Removes all left over merge patches from theboundary file

_setup_region(region_id, z_slice, x_slice, **kwargs)[source]

sets up an individual mesh region

generate_mesh(mesh_type='simple', path='.', ndivs=8, **kwargs)[source]

Generates multiple mesh types and outputs them to a specific path. Valid mesh_types are: simple, threshold and symmetry. Additional kwargs need to be supplied for the given mesh type if it needs additional keywords.