class CSVConverter[source]

CSVConverter(csv_dir_path:str, dtype:dtype=torch.float32, verbose:bool=True, pde_solver:pd4to.pde.PDESolver=None, solve_pde_for_trivial_solution:bool=False, solve_pde_for_gt_solution:bool=False)

The purpose of the CSVConverter class is to convert csv files into TO problems. For each problem there should be two csv files: one that contains all voxel-wise information (forces, design space, Dirichlet conditions and ground truth densities) and one "_info" file that contains all scalar information (Young's modulus E, Poisson's ratio ν, yield stress σ_ys and voxel size h). The names of the files should start with 0 and increase, so the files for the first sample are "0.csv" and "0_info.csv", the files for the second sample are "1.csv" and "1_info.csv" and so one. For more information on the exact formating we refer to the SELTO datasets [1].

Type Default Details
csv_dir_path str The path to the directory that contains files named as "i.pt" and "i_info.pt" where i is an integer, starting at i=0 for the first sample.
dtype dtype torch.float32 The datatype into which the values from the csv files are converted.
verbose bool True Whether to give the user feedback on the progress.
pde_solver pd4to.pde.PDESolver None The pde solver that is used to solve the PDE for linear elasticity. Only has an effect if either solve_pde_for_trivial_solution=True or solve_pde_for_gt_solution=True.
solve_pde_for_trivial_solution bool False Whether to solve the PDE for each trivial solution and save the displacements in the solution object. These can later be accessed via problem.trivial_solution.u. This is useful if PDE preprocessing is used. Requires a pde solver.
solve_pde_for_gt_solution bool False Whether to solve the PDE for each ground truth and save the displacements in the solution object. These can later be accessed via gt_solution.u. Requires a pde solver.

Methods

CSVConverter.__len__[source]

CSVConverter.__len__()

Returns the number of file pairs (i.csv, i_info.csv) that are contained in self.csv_dir_path.

CSVConverter.__getitem__[source]

CSVConverter.__getitem__(idx:int)

Returns the tuple (problem, gt_solution) for index idx.

Type Default Details
idx int The index for which (problem, gt_solution) should be returned.

CSVConverter.__call__[source]

CSVConverter.__call__(pt_dir_path:str=None)

Converts all (i.csv, i_info.csv) pairs in csv_dir_path and saves them as .pt files in the directory pt_dir_path.

Type Default Details
pt_dir_path str None The path where the .pt files should be saved.

References

[1] Dittmer, Sören, Erzmann, David, Harms, Henrik, Falck, Rielson, & Gosch, Marco. (2023). SELTO Dataset [Data set]. Zenodo. https://doi.org/10.5281/zenodo.7781392