noether.data.datasets.cfd.drivaernet.preprocessing

This script converts the vtk files from the DrivAerNet++ dataset to torch tensors. It processes pressure and wall shear stress surface data, ensuring point order consistency, and saves the processed data in a structured format. Subsamples volume data for efficiency.

Functions

seed_from(*args)

hashes any arguments to create a unique seed. This is useful for reproducibility,

get_vtk_files(root)

load_data(file_path)

Loads position and field data from a VTK file into PyTorch tensors.

reorder_data_via_position_map(reference_data, ...[, ...])

Reorders tensors in 'data_to_reorder' to match the point order of 'reference_data'.

process_single_case(vtk_file, pressure_root, ...[, ...])

Loads, reorders, and saves data for a single simulation case.

main(unzipped_root, output_dir, subsample_factor_volume)

Main function to set up paths and process all files.

Module Contents

noether.data.datasets.cfd.drivaernet.preprocessing.seed_from(*args)

hashes any arguments to create a unique seed. This is useful for reproducibility, e.g. when generating same data for different models (which increment the seed differently). ————- Example usage: with local_seed(seed_from(“train”, 10)):

x = torch.randn(2) y = np.random.randn(2)

z = torch.randn(2) # here we have re-stored the “global” seed.

noether.data.datasets.cfd.drivaernet.preprocessing.get_vtk_files(root)
Parameters:

root (pathlib.Path)

Return type:

list[str]

noether.data.datasets.cfd.drivaernet.preprocessing.load_data(file_path)

Loads position and field data from a VTK file into PyTorch tensors.

Parameters:

file_path (pathlib.Path)

Return type:

dict[str, torch.Tensor]

noether.data.datasets.cfd.drivaernet.preprocessing.reorder_data_via_position_map(reference_data, data_to_reorder, rounding_precision=None)

Reorders tensors in ‘data_to_reorder’ to match the point order of ‘reference_data’.

This function assumes that both datasets contain the exact same set of points, just in a different order. The mapping is done using a dictionary lookup where point coordinates are the keys.

Parameters:
  • reference_data (dict[str, torch.Tensor]) – The dictionary with the target ordering (your pressure_data).

  • data_to_reorder (dict[str, torch.Tensor]) – The dictionary with the data to be reordered (your wallshear_data).

  • rounding_precision (int | None)

Returns:

A new dictionary containing the data from ‘data_to_reorder’ sorted according to the point order in ‘reference_data’.

Return type:

tuple[dict[str, torch.Tensor], int]

noether.data.datasets.cfd.drivaernet.preprocessing.process_single_case(vtk_file, pressure_root, wallshear_root, output_root, volume_root, subsample_factor_volume=10)

Loads, reorders, and saves data for a single simulation case.

Parameters:
  • vtk_file (str) – The relative path of the vtk file (e.g., ‘experiment/data.vtk’).

  • pressure_root (pathlib.Path) – The root directory for pressure data.

  • wallshear_root (pathlib.Path) – The root directory for wall shear stress data.

  • output_root (pathlib.Path) – The root directory to save the processed .pt files.

  • volume_root (pathlib.Path) – The root directory for volume data.

  • subsample_factor_volume (int)

noether.data.datasets.cfd.drivaernet.preprocessing.main(unzipped_root, output_dir, subsample_factor_volume)

Main function to set up paths and process all files.

Parameters: