Skip to content
Snippets Groups Projects
Verified Commit 890e6e59 authored by Lambert Theisen's avatar Lambert Theisen
Browse files

update postprocessing

parent 4c469262
No related branches found
No related tags found
No related merge requests found
Pipeline #1519741 failed
Showing
with 14172 additions and 23 deletions
from paraview.simple import *
kn_array = [0.05, 0.1, 0.2, 0.4]
for kn in kn_array:
filename = 'thermal-flow-between-cylinders' + str(kn) + '/u_0.xdmf'
u_0xdmf = paraview.simple.Xdmf3ReaderS(
registrationName='u_0.xdmf', FileName=[filename])
plotOverLine1 = paraview.simple.PlotOverLine(
registrationName='PlotOverLine1', Input=u_0xdmf)
plotOverLine1.Point1 = [0.0, 0.0, 0.0]
plotOverLine1.Point2 = [2.0, 2.0, 0.0]
spreadSheetView1 = FindViewOrCreate(
'SpreadSheetView1', viewtype='SpreadSheetView')
spreadSheetView1.Update()
u_0xdmfDisplay_1 = Show(u_0xdmf, spreadSheetView1,
'SpreadSheetRepresentation')
plotOverLine1Display_2 = Show(
plotOverLine1, spreadSheetView1, 'SpreadSheetRepresentation')
outputname = 'u_0_' + str(kn) + '.csv'
ExportView(outputname, view=spreadSheetView1)
using CairoMakie
using CSV
using DataFrames
# Function to load data for a given Kn value
function load_data(Kn)
return [CSV.File("u_$(Kn)_$i.csv") |> DataFrame for i in 0:3]
end
# Load the data for Kn = 0.05, 0.1, 0.2, 0.4
data_kn_values = Dict(
0.05 => load_data(0.05),
0.1 => load_data(0.1),
0.2 => load_data(0.2),
0.4 => load_data(0.4)
)
# Colors and line styles for different datasets
line_styles = reverse([:solid, :dash, :dot, :dashdot])
dataset_colors = [:blue, :green, :red, :purple]
# Create a figure with a grid layout: 2 rows x 2 columns
f = Figure(resolution = (800, 600))
# Kn values and their positions in the grid
kn_list = [0.05, 0.1, 0.2, 0.4]
positions = [(1, 1), (1, 2), (2, 1), (2, 2)]
# Iterate over Kn values and their subplot positions
for (Kn_value, pos) in zip(kn_list, positions)
# Create an axis for each Kn value
ax = Axis(f[pos...], title = "Kn = $(Kn_value)")
data_list = data_kn_values[Kn_value]
# Plot datasets for i = 0:3
for (i, d) in enumerate(data_list)
lines!(
ax,
d[!, "Points_0"],
d[!, "u_Magnitude"],
label = "Mesh $i",
color = dataset_colors[i],
linestyle = line_styles[i],
linewidth = 2
)
if i == length(data_dict)
Legend(f[i, 2], ax)
end
end
# Add legend to the subplot
# Legend(f[pos[1], pos[2] + 1], ax, title = "Datasets", tellwidth = false)
# Adjust the subplot layout if needed
colsize!(f.layout, pos[2], Fixed(300))
rowsize!(f.layout, pos[1], Fixed(150))
end
save("fig1.png", f)
# Display the figure
f
using CairoMakie
using CSV
using DataFrames
# Function to load data for a given Kn value
function load_data(Kn)
return [CSV.File("u_$(Kn)_$i.csv") |> DataFrame for i in 0:3]
end
# Load the data for Kn = 0.05, 0.1, 0.2, 0.4
data_0_05 = load_data(0.05)
data_0_1 = load_data(0.1)
data_0_2 = load_data(0.2)
data_0_4 = load_data(0.4)
# Create a figure
f = Figure()
# Create an axis
ax1 = Axis(f[1, 1], title = "Velocity Magnitude vs. Position w.r.t. mesh sizes", aspect = 1)
# Colors for different Kn values
kn_colors = Dict(
0.05 => :blue,
0.1 => :green,
0.2 => :red,
0.4 => :purple
)
# Plotting function
function plot_data(ax, data_list, Kn_value, color)
for (i, d) in enumerate(data_list)
lines!(
ax,
d[!, "Points_0"],
d[!, "u_Magnitude"],
label = "Kn = $(Kn_value), Mesh $i",
color = color,
linestyle = [:solid, :dash, :dot, :dashdot][i]
)
end
end
# Plot data for each Kn value
plot_data(ax1, data_0_05, 0.05, kn_colors[0.05])
plot_data(ax1, data_0_1, 0.1, kn_colors[0.1])
plot_data(ax1, data_0_2, 0.2, kn_colors[0.2])
plot_data(ax1, data_0_4, 0.4, kn_colors[0.4])
# Create a legend
legend = Legend(f[1, 2], ax1)
# Adjust the layout
colsize!(f.layout, 1, Fixed(300)) # Adjust as needed
save("fig2.png", f)
# Display the figure
f
examples/thermal-flow-between-cylinders/postprocessing/fig1.png

137 KiB

examples/thermal-flow-between-cylinders/postprocessing/fig2.png

119 KiB

from paraview.simple import *
for kn in [0.05, 0.1, 0.2, 0.4]:
for i in range(0,4):
filename = '../thermal-flow-between-cylinders' + str(kn) + '/u_' + str(i) + '.xdmf'
uxdmf = paraview.simple.Xdmf3ReaderS(
registrationName='u.xdmf', FileName=[filename])
plotOverLine1 = paraview.simple.PlotOverLine(
registrationName='PlotOverLine1', Input=uxdmf)
plotOverLine1.Point1 = [0.0, 0.0, 0.0]
plotOverLine1.Point2 = [2.0, 2.0, 0.0]
spreadSheetView1 = FindViewOrCreate(
'SpreadSheetView1', viewtype='SpreadSheetView')
spreadSheetView1.Update()
uxdmfDisplay_1 = Show(uxdmf, spreadSheetView1,
'SpreadSheetRepresentation')
plotOverLine1Display_2 = Show(
plotOverLine1, spreadSheetView1, 'SpreadSheetRepresentation')
outputname = 'u_' + str(kn) +'_' + str(i) + '.csv'
ExportView(outputname, view=spreadSheetView1)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment