module myna.application.openfoam.mesh
Functions to create and manipulate OpenFOAM meshes
function update_parameter
update_parameter(foamdict_file, entry, value)
Updates the given parameter in an OpenFOAM dictionary
Args:
foamdict_file: (str) path to the OpenFOAM dictionary fileentry: (str) key for the entry, e.g., "geometry/refinementBox/min"value: (str or numeric) value to write. If the value contains spaces it must be enclosed in doublequotes, e.g.,value='"test string"'!
function run_command
run_command(args, app=None, parallel=None, **kwargs)
Runs the command, using app functions if they are present
Args:
args: (list) list of command arguments passed to Popenapp: (MynaApp instance) if provided, will use MynaApp job submissionparallel: (bool) if provided, will use parallel options for MynaApp job**kwargs: additional options passed to subprocess.Popen
function run_command_with_decompose_reconstruct
run_command_with_decompose_reconstruct(args, case_dir, app=None)
function preprocess_stl
preprocess_stl(case_dir, stl_path, convert_to_meters=1)
Preprocesses an STL for meshing:
- creates a copy of the stl file 2. converts stl to meters 3. cleans the copied stl file to the template directory
function extract_stl_features
extract_stl_features(case_dir, stl_path, refinement_level, origin)
extract features from the stl file and set parameters in files
function construct_bounding_box_dict
construct_bounding_box_dict(rve, rve_pad)
Construct a dictionary to define the bounding box properties
Args:
rve: (np.array(3,2))
function construct_mesh_bounding_box_dict
construct_mesh_bounding_box_dict(case_dir, tolerance=1e-08)
Construct a dictionary to define the bounding box properties based on the mesh of an existing OpenFOAM case
Args:
case_dir: (str) path to case directorytolerance: (float) tolerance used to pad the edge of the bounding box
function calc_n_cells
calc_n_cells(bb_dict, spacing)
Calculates the number of cells needed to span the bounding box
Args:
bb_dict: (dict) bounding box dictionary as defined byconstruct_bounding_box_dict()spacing: (float) mesh spacing, in meters
function create_cube_mesh
create_cube_mesh(case_dir, spacing, rve, rve_pad)
Create a cube mesh at the specified rve location
Args:
case_dir: (str) path to case directoryspacing: (float) mesh spacing for cube meshrve: (np.array(3,2)) cube bounds ((xmin, ymin, zmin, (xmax, ymax, zmax)))rve_pad: (np.array(3,)) padding to add to rve bounds (xpad, ypad, zpad)
function create_stl_cube_mesh
create_stl_cube_mesh(case_dir, working_stl_path, spacing, tolerance)
create a background mesh using blockMesh around the stl file
function create_part_mesh
create_part_mesh(case_dir, stl_path, bb_dict, app=None)
create the part mesh
function foam_to_adamantine
foam_to_adamantine(case_dir, precision=8)
convert OpenFOAM VTK format to adamantine VTK format
function slice_part_mesh
slice_part_mesh(case_dir, height)
slice the part mesh at a specified build height
function refine_mesh_in_box
refine_mesh_in_box(case_dir, bb, app=None, refinement_dict=None)
Refine the mesh for an OpenFOAM case within a bounding box using the specified refinement_dict settings
Args:
case_dir: (str) path to case directorybb: (np.array, shape (2,3)) bounding box ((xmin, ymin, zmin),(xmax, ymax, zmax))app: (MynaApp object) MynaApp object for parallel run settings, if None will run in serialrefinement_dict: (str) path to the snappyHexMesh refinement dictionary to use for refinement. If None, will default tosystem/refineMeshDict.
function refine_layer
refine_layer(case_dir, refinement_depth, refinement_level, app=None)
Refine the mesh for an OpenFOAM case for a region near the max-z surface
Args:
case_dir: (str) path to case directoryrefinement_depth: (float) depth of region from the max-z surface to refinerefinement_level: (int) number of refinement iterations, each iteration halves the mesh size
This file was automatically generated via lazydocs.