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:
PlotMixinGridClass 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.gridcell_data with imported STL masks saved previously bysave_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 allstl_related variables (materials, colors, transforms).- Parameters
filename (str, optional) β Output filename for the HDF5 file. Default βgrid.h5β.