pumapy.io
pumapy.io.export_texgen_weave
- pumapy.io.export_texgen_weave.export_weave_vtu(filename, weave, domain, max_dim_nvox, round_vox_up=True, export_orientation=True)[source]
Exporting weave to vtu, to be read by pumapy
- Parameters
filename (string) – filepath and name
weave (CTextile or child class of CTextile) – weave object, as defined in TexGen
domain (CDomainPlanes) – domain size object, as defined in TexGen
max_dim_nvox (int) – number of voxels to add in the largest domain dimension
round_vox_up (bool) – for the shorter dimensions, round number of voxels up (for +/-1 vox)
export_orientation (bool) – specify whether to export orientation
- Returns
filename of weave exported (input filename + dimensions)
- Return type
string
pumapy.io.input
- pumapy.io.input.import_3Dtiff(filename, voxel_length=1e-06, import_ws=True)[source]
Function to io 3D tiff
- Parameters
filename (string) – filepath and name
voxel_length (float) – size of a voxel side
import_ws (bool) – if True returns a puma.Workspace, otherwise a ndarray
- Returns
domain
- Return type
pumapy.Workspace or np.ndarray
- Example
>>> import pumapy as puma >>> ws_tiff = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"), 1.3e-6, import_ws=True) Importing ... >>> ws_tiff.get_shape() (50, 50, 50)
- pumapy.io.input.import_bin(filename)[source]
Import a pumapy.Workspace to binary (.pumapy extension)
- Parameters
filename (string) – filepath and name
- Returns
domain
- Return type
pumapy.Workspace
- Example
>>> import pumapy as puma >>> ws_binary = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy")) Importing ...
- pumapy.io.input.import_scalar_field_from_chfem(filename, domain_shape, rotate_domain=True)[source]
Import scalar field (e.g. temperature, pressure) output from CHFEM_GPU CUDA kernels (https://gitlab.com/cortezpedro/chfem_gpu)
- Parameters
filename (string) – file path and name of .bin file
domain_shape ((int, int, int)) – shape of domain for which the scalar field was generated
rotate_domain (bool) – rotate the domain to be in the same format as export
- Returns
scalar field (x,y,z)
- Return type
np.ndarray
- pumapy.io.input.import_sparta_implicit_surfaces(filename, dimension=3, voxel_length=1e-06, import_ws=True, extend_to_boundary=True)[source]
Function to io sparta implicit surfaces
- Parameters
filename (string) – filepath and name
dimension (int) – dimensionality of imported sparta structure
voxel_length (float) – size of a voxel side
import_ws (bool) – if True returns a puma.Workspace, otherwise a ndarray
extend_to_boundary (bool) – if True recreates nonzero boundary values as extension of inner structure, otherwise all boundary values equal zero
- Returns
domain
- Return type
pumapy.Workspace or np.ndarray
- Example
>>> import pumapy as puma >>> ws = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy")) Importing ... >>> puma.experimental.export_sparta_implicit_surfaces("surfaces", ws) Exporting ... >>> surf = puma.experimental.import_sparta_implicit_surfaces("surfaces.pumapy.isurf", dimension=3, voxel_length=1.0e-6, import_ws=False) Importing ...
- pumapy.io.input.import_stress_field_from_chfem(filename, domain_shape, rotate_domain=True)[source]
Import stress fields output from CHFEM_GPU CUDA kernels (https://gitlab.com/cortezpedro/chfem_gpu)
- Parameters
filename (string) – file path and name of .bin file
domain_shape ((int, int, int)) – shape of domain for which the scalar field was generated
rotate_domain (bool) – rotate the domain to be in the same format as export
- Returns
direct stresses (x,y,z,3) and shear stresses (x,y,z,3)
- Return type
(np.ndarray, np.ndarray)
- pumapy.io.input.import_vector_field_from_chfem(filename, domain_shape, rotate_domain=True, correct_direction=None)[source]
Import vector field (e.g. heat flux, displacement, velocity) output from CHFEM_GPU CUDA kernels (https://gitlab.com/cortezpedro/chfem_gpu)
- Parameters
filename (string) – file path and name of .bin file
domain_shape ((int, int, int)) – shape of domain for which the scalar field was generated
rotate_domain (bool) – rotate the domain to be in the same format as export
correct_direction (str) – correct orientation field according to simulation direction, expects ‘x’, ‘y’, or ‘z’
- Returns
vector field (x,y,z,3)
- Return type
np.ndarray
- pumapy.io.input.import_vti(filename, voxel_length=None, import_ws=True)[source]
Function to import either legacy VTK file (.vtk) or vtkImageData (.vti)
- Parameters
filename (string) – filepath and name
voxel_length (float) – voxel_length. If None, voxel_length from the vtk file is used
import_ws (bool) – True returns a puma.Workspace, otherwise a list of ndarrays
- Returns
if import_ws is True, then it returns a Workspace. if import_ws is False, it returns a dictionary of ndarrays as {“name1”: data1, “name2”: data2 …}
- Return type
pumapy.Workspace or {str: np.ndarray}
- Example
>>> import pumapy as puma >>> ws_vtk = puma.import_vti(puma.path_to_example_file("fibers_with_orientation.vti")) Importing ...
- pumapy.io.input.import_weave_vtu(filename, from_texgen_gui=False)[source]
Import TexGen vtu weave in a Workspace
- Parameters
filename (string) – file path and name
from_texgen_gui (bool) – voxel grid exported from the TexGen GUI (Windows) or from TexGen inside PuMA
- Returns
voxelized weave from TexGen
- Return type
pumapy.Workspace
pumapy.io.output
- pumapy.io.output.export_3Dtiff(filename, ws_or_nparray, to8bit=True)[source]
Export either a puma.Workspace or numpy array to 3Dtiff
- Parameters
filename (string) – filepath and name
ws_or_nparray (Workspace or ndarray) – to be exported
to8bit (bool) – if True, it converts the image to 8bit, otherwise 16bit is exported
- Example
>>> import pumapy as puma >>> ws_tiff = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"), 1.3e-6, import_ws=True) Importing ... >>> puma.export_3Dtiff("50_artfibers.tif", ws_tiff) Exporting ...
- pumapy.io.output.export_bin(filename, ws)[source]
Export a puma.Workspace to binary (.pumapy extension)
- Parameters
filename (string) – filepath and name
ws – to be exported
- Type
pumapy.Workspace
- Example
>>> import pumapy as puma >>> ws_binary = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy")) Importing ... >>> puma.export_bin("fibers_with_orientation.vti", ws_binary) Exporting ...
- pumapy.io.output.export_for_chfem(filename, ws, analysis, solver=0, export_nf=True, export_json=True, tol=1e-06, max_iter=10000)[source]
Export a puma.Workspace to run an analysis in CHFEM_GPU CUDA kernels (https://gitlab.com/cortezpedro/chfem_gpu) or CHPACK Julia package (https://gitlab.com/lcc-uff/Chpack.jl)
- Parameters
filename (string) – filepath and name
ws (pumapy.Workspace) – to be exported
type_of_analysis (int) – 0 = conductivity, 1 = elasticity, 2 = permeability
type_of_solver (int) – 0 = pcg (default), 1 = cg, 2 = minres
export_nf (bool) – export .nf file with simulations inputs for CHFEM_GPU
export_json (bool) – export .json file with simulations inputs for CHFPACK
tol (float) – solver tolerance for simulation
max_iter (int) – maximum number of iterations
- Example
>>> import pumapy as puma >>> ws = puma.import_3Dtiff(puma.path_to_example_file("200_fiberform.tif"), 1.3e-6) Importing ... >>> puma.export_for_chfem('200_fiberform', ws, 2, tol=1e-6, max_iter=100000)
- pumapy.io.output.export_sparta_implicit_surfaces(filename, ws)[source]
Export a puma.Workspace to binary (.pumapy extension)
- Parameters
filename (string) – filepath and name
ws (pumapy.Workspace) – to be exported
- Example
>>> import pumapy as puma >>> ws = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy")) Importing ... >>> puma.experimental.export_sparta_implicit_surfaces("surfaces", ws) Exporting ...
- pumapy.io.output.export_stl(filename, ws, cutoff, flag_closed_edges=True, flag_gaussian=False, binary=True)[source]
Export a puma.Workspace to STL
- Parameters
filename (string) – filepath and name
ws (pumapy.Workspace) – to be exported
cutoff ((int, int)) – specify cutoff to binarize material
flag_closed_edges (bool) – close the surface edges on the boundaries
flag_gaussian (bool) – apply Gaussian filter before creating surface
- Example
>>> import pumapy as puma >>> ws_imported = puma.import_3Dtiff(puma.path_to_example_file("200_fiberform.tif"), 1.3e-6) Importing ... >>> puma.export_stl('200_fiberform', ws_imported, cutoff=(100, 255), flag_closed_edges=True) Exporting ...
- pumapy.io.output.export_vti(filename, dict_data, voxel_length=None)[source]
Export either a puma.Workspace or numpy array to vti
- Parameters
filename (string) – filepath and name
dict_data (dict or Workspace or np.ndarray) – dictionary setup as {“name1”: data1, “name2”: data2 …} containing either Workspaces or ndarrays
voxel_length (float) – with voxel length to give to Numpy arrays (if any)
- Example
>>> import pumapy as puma >>> ws_vtk = puma.import_vti(puma.path_to_example_file("fibers_with_orientation.vti")) Importing ... >>> puma.export_vti("fibers_with_orientation.vti", ws_vtk) Exporting ...