graintrace.grid_resampling#

Offline resampling of a saved CPFE Exodus onto a regular grid via MOOSE.

When a CPFE run is done with grid_transfer="off" (or "final"), the per-step regular-grid field output is skipped to save the expensive MultiApp transfers. This module regenerates that gridded output afterward from the native-mesh Exodus (sim_output.e) using the same MOOSE shape-function-evaluation transfer: a no-solve sub-app (resample_source.i) loads the CPFE fields at a chosen Exodus timestep, and the main app (resample_grid.i) shape-evaluates them onto a GeneratedMesh grid and writes grid_out/out_element_centroid_<idx>.csv — the exact schema consumed by SimulationResults / IdentifyRareClusters / GraphSpatialCluster.

This is a cheap, smoothed approximation of the online per-step grid: the CPFE fields are order-FIRST MONOMIAL and MOOSE stores them in the Exodus as nodal projections, so grain-boundary extremes are compressed. For extreme-sensitive REI use the crisp online grid (grid_transfer="per_step") or run REI on the true mesh; a denser resample grid recovers spatial detail but not the extremes lost to the nodal projection.

class graintrace.grid_resampling.GridResampler(cpfe_exodus, save_dir, number_of_elements, bounding_box, moose_run_file, launcher='mpiexec', extra_ld_library_paths=None, ncore=1)[source]#

Bases: object

Resample a saved CPFE Exodus onto a regular grid, offline, via puma-opt.

Drives the resample_grid.i + resample_source.i templates once per requested Exodus timestep, emitting grid_out/out_element_centroid_<idx4>.csv under save_dir (indices 0-based, matching FieldFileNaming). See examples/demonstrate_postprocess.py and the /post-processing skill.

num_timesteps()[source]#

Number of time steps stored in the CPFE Exodus (via the netCDF reader).

resample(timesteps='all')[source]#

Resample the requested Exodus timesteps to regular-grid CSVs.

Runs the resample_grid.i + resample_source.i templates once per requested timestep, writing save_dir/grid_out/out_element_centroid_<idx4>.csv (0-based indices matching FieldFileNaming) with the schema consumed by SimulationResults / IdentifyRareClusters.

Parameters:

timesteps – “all” to resample every stored step, or a list of 1-based Exodus timestep indices (MOOSE initial_from_file_timestep convention). Default “all”.

Returns:

List of Path objects for the written grid CSVs, in output order.