Skip to content

Commit

Permalink
Clip paraview figure to remove boundary effect and plot points of p f…
Browse files Browse the repository at this point in the history
…or standard load
  • Loading branch information
finsberg committed Feb 26, 2024
1 parent 939240a commit 38530db
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 7 deletions.
84 changes: 83 additions & 1 deletion code/create_paraview_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,88 @@ def main(filename, min_value, max_value, name, label, blocknr, figure_folder):
# update the view to ensure updated data information
renderView1.Update()

# create a new 'Clip'
clip3 = Clip(registrationName="Clip3", Input=clip2)
clip3.ClipType = "Plane"
clip3.HyperTreeGridClipper = "Plane"
clip3.Scalars = ["POINTS", name]
clip3.Value = 2.0714892148971558

# init the 'Plane' selected for 'ClipType'
clip3.ClipType.Origin = [0.0, -150.0, 0.0]

# init the 'Plane' selected for 'HyperTreeGridClipper'
clip3.HyperTreeGridClipper.Origin = [0.0, -150.0, 0.0]

# Properties modified on clip3.ClipType
clip3.ClipType.Origin = [1500.0, -150.0, 0.0]

# show data in view
clip3Display = Show(clip3, renderView1, "UnstructuredGridRepresentation")

# trace defaults for the display properties.
clip3Display.Representation = "Surface"
clip3Display.ColorArrayName = ["POINTS", name]
clip3Display.LookupTable = sigma_xxLUT
clip3Display.SelectTCoordArray = "None"
clip3Display.SelectNormalArray = "None"
clip3Display.SelectTangentArray = "None"
clip3Display.OSPRayScaleArray = name
clip3Display.OSPRayScaleFunction = "PiecewiseFunction"
clip3Display.SelectOrientationVectors = "None"
clip3Display.ScaleFactor = 378.05637207031253
clip3Display.SelectScaleArray = name
clip3Display.GlyphType = "Arrow"
clip3Display.GlyphTableIndexArray = name
clip3Display.GaussianRadius = 18.902818603515627
clip3Display.SetScaleArray = ["POINTS", name]
clip3Display.ScaleTransferFunction = "PiecewiseFunction"
clip3Display.OpacityArray = ["POINTS", name]
clip3Display.OpacityTransferFunction = "PiecewiseFunction"
clip3Display.DataAxesGrid = "GridAxesRepresentation"
clip3Display.PolarAxes = "PolarAxesRepresentation"
clip3Display.ScalarOpacityFunction = sigma_xxPWF
clip3Display.ScalarOpacityUnitDistance = 140.15433787367883
clip3Display.OpacityArrayName = ["POINTS", name]
clip3Display.SelectInputVectors = [None, ""]
clip3Display.WriteLog = ""

# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
clip3Display.ScaleTransferFunction.Points = [
-2.363538980484009,
0.0,
0.5,
0.0,
6.50651741027832,
1.0,
0.5,
0.0,
]

# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
clip3Display.OpacityTransferFunction.Points = [
-2.363538980484009,
0.0,
0.5,
0.0,
6.50651741027832,
1.0,
0.5,
0.0,
]

# hide data in view
Hide(clip2, renderView1)

# show color bar/color legend
clip3Display.SetScalarBarVisibility(renderView1, True)

# update the view to ensure updated data information
renderView1.Update()

# toggle interactive widget visibility (only when running from the GUI)
HideInteractiveWidgets(proxy=clip3.ClipType)

# get color legend/bar for sigma_xxLUT in view renderView1
sigma_xxLUTColorBar = GetScalarBar(sigma_xxLUT, renderView1)

Expand All @@ -294,7 +376,7 @@ def main(filename, min_value, max_value, name, label, blocknr, figure_folder):
sigma_xxTF2D.RescaleTransferFunction(min_value, max_value, 0.0, 1.0)

# toggle interactive widget visibility (only when running from the GUI)
HideInteractiveWidgets(proxy=clip2.ClipType)
HideInteractiveWidgets(proxy=clip3.ClipType)

# get layout
layout1 = GetLayout()
Expand Down
26 changes: 26 additions & 0 deletions code/postprocess_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,32 @@ def plot_points_in_slice(data_file, figdir):
fig.savefig(figdir / "p_points.png")
fig.savefig(figdir / "p_points.svg")

df_p_std = df_plot[df_plot["key"] == 3000.0]
fig = plt.figure()
ax = sns.barplot(
data=df_p_std,
x="point",
y="value",
hue="point",
alpha=0.7,
errorbar="ci",
palette="viridis",
legend=False,
)

N = 5
xticks = np.linspace(0, len(df_p_std["point"].unique()), N)
xticklabels = np.linspace(0, df_p_std["point_end"].max(), N)
ax.set_xticks(xticks)
ax.set_xticklabels([f"{x:.2f}" for x in xticklabels])
ax.set_xlabel("Radius")

ax.grid()
ax.set_ylabel("$p$ [kPa]")
fig.tight_layout()
fig.savefig(figdir / "p_points_std_load.png")
fig.savefig(figdir / "p_points_std_load.svg")


def plot_stress(data_file, figdir):
print("Plotting stress")
Expand Down
10 changes: 4 additions & 6 deletions code/run_create_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@


results_folder_tmp = (
"/Users/finsberg/local/src/ciucci-2024/code/results/cylinder_{varying_str}/spring3000.0"
)
figure_folder_tmp = (
"/Users/finsberg/local/src/ciucci-2024/figures/cylinder_{varying_str}/spring3000.0"
"/Users/finsberg/local/src/ciucci-2024/code/results/cylinder{varying_str}/spring3000"
)
figure_folder_tmp = "/Users/finsberg/local/src/ciucci-2024/figures/cylinder{varying_str}/spring3000"


def create_uniform_gamma_figures():
Expand Down Expand Up @@ -70,7 +68,7 @@ def create_varing_gamma_figures():
(-0.3, 0.0, "E_xx", "$E_{xx}$", 7),
(0.0, 0.2, "E_r", "$E_{r}$", 8),
(0.0, 0.2, "E_c", "$E_{c}$", 9),
(-2.0, 1.0, "hydrostatic", "$p$", 10),
(-1.5, 1.0, "hydrostatic", "$p$", 10),
]:
print(name)

Expand All @@ -97,7 +95,7 @@ def create_varing_gamma_figures():


def main():
# create_uniform_gamma_figures()
create_uniform_gamma_figures()
create_varing_gamma_figures()


Expand Down

0 comments on commit 38530db

Please sign in to comment.