gridFIT3D module

class wakis.gridFIT3D.GridFIT3D(xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, Nx=None, Ny=None, Nz=None, x=None, y=None, z=None, use_mpi=False, use_mesh_refinement=False, refinement_method='insert', refinement_tol=1e-8, snap_points=None, snap_tol=1e-5, snap_solids=None, stl_solids=None, stl_materials=None, stl_rotate=[0.0, 0.0, 0.0], stl_translate=[0.0, 0.0, 0.0], stl_scale=1.0, stl_colors=None, stl_tol=1e-3, stl_method='legacy', subpixel_smoothing=False, subpixel_smoothing_factor=4, subpixel_smoothing_threshold=0.3, subpixel_smoothing_bool=True, load_from_h5=None, verbose=2)[source]

Bases: PlotMixinGrid

Class holding the grid information and stl importing handling using PyVista

check_stl_masks_overlap()[source]

Check for overlapping STL masks in the grid and print warnings if overlaps are found.

This method computes the sum of all STL masks and identifies cells that are marked as inside more than one solid.

load_from_h5(filename)[source]

Load grid axis arrays and STL metadata from an HDF5 file.

The function restores axis arrays, recomputes grid metrics and fills self.grid cell_data with imported STL masks saved previously by save_to_h5.

Parameters

filename (str) – HDF5 filename to read. The β€˜.h5’ suffix is appended if missing.

mpi_gather_asGrid()[source]

Gather the global grid from all MPI subdomains and return a new GridFIT3D.

Returns

_grid – The global grid object (only on rank 0).

Return type

GridFIT3D or None

plot_snap_points(snap_solids=None, snap_tol=1e-8)[source]

Plot snap points extracted from STL feature edges for mesh refinement.

Parameters
  • snap_solids (list or None, optional) – STL solids to use for snap point extraction. Default is all.

  • snap_tol (float, optional) – Tolerance for snap point detection.

read_stl(key)[source]

Read and transform an STL solid by key.

Parameters

key (str) – Key of the STL solid to read.

Returns

surf – The transformed STL surface.

Return type

pyvista.PolyData

refine_axis(xmin, xmax, Nx, x_snaps, method='insert', tol=1e-12)[source]

Refine a grid axis using snap points and a chosen method.

Parameters
  • xmin (float) – Axis bounds.

  • xmax (float) – Axis bounds.

  • Nx (int) – Number of grid points.

  • x_snaps (array_like) – Snap points to include in the axis.

  • method (str, optional) – Refinement algorithm (β€˜insert’, β€˜neighbor’, β€˜subdivision’).

  • tol (float, optional) – Convergence tolerance for optimization.

Returns

x – Refined axis array.

Return type

ndarray

save_to_h5(filename='grid.h5')[source]

Save the generated grid and STL metadata to an HDF5 file.

The file contains axis arrays, STL masks suitable for grid.cell_data, and all stl_ related variables (materials, colors, transforms).

Parameters

filename (str, optional) – Output filename for the HDF5 file. Default β€˜grid.h5’.

update_logger(attrs)[source]

Copy selected Grid attributes into the internal Logger.

Parameters

attrs (iterable of str) – Names of attributes to copy into self.logger.grid.