|
|
from read_node import read_dat_file, read_result_file
|
|
|
import os
|
|
|
|
|
|
import numpy as np
|
|
|
import pyvista as pv
|
|
|
folder_path = r"D:\AnK\FatigueNet\Fatigue_Life\datasets\Raw data\shaft_high\life_D15_d5_r1"
|
|
|
folder_base_name = os.path.basename(folder_path).replace("_data", "")
|
|
|
dat_file_path = os.path.join(folder_path, f"{folder_base_name}.dat")
|
|
|
fatigue_life_path = os.path.join(folder_path, f"{folder_base_name}.txt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
positions,cells = read_dat_file(dat_file_path)
|
|
|
fatigue_life = read_result_file(fatigue_life_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log_fatigue_life = np.log10(fatigue_life)
|
|
|
|
|
|
|
|
|
point_cloud = pv.PolyData(positions)
|
|
|
point_cloud["Fatigue Life (log10)"] = log_fatigue_life
|
|
|
|
|
|
|
|
|
|
|
|
sphere_source = pv.Sphere(radius=0.15)
|
|
|
glyphs = point_cloud.glyph(geom=sphere_source, scale=False)
|
|
|
|
|
|
|
|
|
plotter = pv.Plotter()
|
|
|
|
|
|
|
|
|
plotter.add_mesh(
|
|
|
glyphs,
|
|
|
scalars="Fatigue Life (log10)",
|
|
|
cmap="viridis",
|
|
|
opacity=1.0,
|
|
|
show_edges=False
|
|
|
)
|
|
|
|
|
|
|
|
|
plotter.add_scalar_bar(
|
|
|
title="log₁₀(Fatigue Life)",
|
|
|
n_labels=6,
|
|
|
fmt="%.1f"
|
|
|
)
|
|
|
|
|
|
|
|
|
plotter.set_background('white')
|
|
|
|
|
|
|
|
|
plotter.camera_position = 'iso'
|
|
|
|
|
|
|
|
|
plotter.add_axes()
|
|
|
|
|
|
|
|
|
plotter.show()
|
|
|
|
|
|
|
|
|
print(f"Created {len(positions)} spheres")
|
|
|
print(f"Fatigue life range: {fatigue_life.min():.0e} to {fatigue_life.max():.0e}")
|
|
|
print(f"Log fatigue life range: {log_fatigue_life.min():.2f} to {log_fatigue_life.max():.2f}") |