Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
e541ce8
add interpolation
svchb Nov 29, 2023
d09e779
basic working
svchb Nov 30, 2023
fd3c98b
support periodic
svchb Nov 30, 2023
118585b
allow to define different smoothing_length
svchb Nov 30, 2023
a4e306d
more precisely identify system regions
svchb Nov 30, 2023
d0d4e85
to improve accuracy calc shepard
svchb Dec 1, 2023
7f11ce6
add support for multiple points
svchb Dec 1, 2023
2d7334c
add line interpolation
svchb Dec 1, 2023
0a5a580
add doc
svchb Dec 1, 2023
2c10d6c
format
svchb Dec 1, 2023
69e8ddf
add test
svchb Dec 1, 2023
567e1fb
Merge branch 'main' into add_interpolation
svchb Dec 1, 2023
27065cc
small change to doc
svchb Dec 1, 2023
238671e
revert accidental change
svchb Dec 1, 2023
1512816
fix
svchb Dec 1, 2023
959e36e
another fix
svchb Dec 1, 2023
a0c9694
format
svchb Dec 1, 2023
b0a22e4
format
svchb Dec 1, 2023
9f3b68b
also interpolate pressure and velocity
svchb Dec 1, 2023
c83061e
lower tolerance
svchb Dec 1, 2023
f9b8bef
add example plot
svchb Dec 1, 2023
54ffa68
missing dependency
svchb Dec 1, 2023
9d2b15e
format
svchb Dec 1, 2023
51567d6
add func
svchb Dec 1, 2023
a7786fd
add doc
svchb Dec 1, 2023
4278910
add test
svchb Dec 1, 2023
fcfb065
add another test
svchb Dec 1, 2023
9106912
comment out example
svchb Dec 1, 2023
363bfcb
remove pyplot again
svchb Dec 1, 2023
5a89022
fix
svchb Dec 1, 2023
589f7b3
format
svchb Dec 1, 2023
3351d74
small update improve accuracy
svchb Dec 12, 2023
a995d03
Merge branch 'main' into plane_interpolation
svchb Dec 12, 2023
6044f55
Merge branch 'plane_interpolation' of github.com:svchb/TrixiParticles…
svchb Dec 12, 2023
cd8ddc5
update
svchb Dec 12, 2023
f6b3829
up
svchb Dec 12, 2023
7a5c42e
fix
svchb Dec 13, 2023
c6165f0
format
svchb Dec 13, 2023
8c58ff6
add JSON library
svchb Dec 18, 2023
e5dd805
postprocess_callback
svchb Dec 19, 2023
23dca83
add rect_3d example
svchb Dec 20, 2023
235f72a
fix
svchb Dec 21, 2023
66af558
format
svchb Dec 21, 2023
a9c99bb
Merge branch 'main' into sensor_cb
svchb Dec 21, 2023
46c9ae7
Merge branch 'more_fixes_for_risc' into sensor_cb
svchb Dec 23, 2023
bf4997d
impl
svchb Jan 5, 2024
4e17772
Merge branch 'main' into sensor_cb
svchb Jan 5, 2024
d9e854e
fixes
svchb Jan 5, 2024
22d8789
fix setting the interval
svchb Jan 5, 2024
e5d2bef
impl other functions
svchb Jan 5, 2024
9226364
Merge branch 'main' into plane_interpolation
svchb Jan 16, 2024
6136f7d
fix plots
svchb Jan 16, 2024
8cddffa
fix plots.jl plot
svchb Jan 16, 2024
f4c2204
cleanup
svchb Jan 16, 2024
fb16b70
fix tests
svchb Jan 16, 2024
1b450dd
cleanup
svchb Jan 16, 2024
babdde0
cleanup
svchb Jan 16, 2024
3025102
fix docs
svchb Jan 16, 2024
bb57d18
fix doc
svchb Jan 16, 2024
a865c41
remove unused func
svchb Jan 16, 2024
073558c
remove unused code
svchb Jan 16, 2024
6b9bb14
fix
svchb Jan 16, 2024
a99f4ee
write missing values
svchb Jan 18, 2024
3d8a6d3
replace incorrect nomenclature
svchb Jan 18, 2024
e9ced79
calc von mises stress
svchb Jan 18, 2024
e0af8eb
rm comment
svchb Jan 18, 2024
743cdad
format
svchb Jan 18, 2024
043a90e
change docs to F
svchb Jan 18, 2024
4e01f48
add test
svchb Jan 18, 2024
2795bb3
format
svchb Jan 18, 2024
22c2acb
Merge branch 'main' into sensor_cb
svchb Jan 19, 2024
d73dbe7
fix merge
svchb Jan 19, 2024
3671952
move files
svchb Jan 19, 2024
ff6bf1b
include exclude bnd
svchb Jan 19, 2024
5891e7f
add version info to meta data
svchb Jan 19, 2024
974859e
fix
svchb Jan 19, 2024
9afa33b
add filename and overwrite
svchb Jan 19, 2024
c69650a
write initial values
svchb Jan 19, 2024
e91d529
format
svchb Jan 19, 2024
d81e4f9
add helper function to obtain latest file
svchb Jan 19, 2024
10f0658
improve func
svchb Jan 19, 2024
b41ad2c
format
svchb Jan 19, 2024
8e85162
fix plots
svchb Jan 19, 2024
95a1e48
rename
svchb Jan 19, 2024
d603ebf
add doc
svchb Jan 19, 2024
10b70fd
add exports
svchb Jan 19, 2024
69043c5
cleanup
svchb Jan 19, 2024
ad313fe
cleanup
svchb Jan 19, 2024
3863ccc
format
svchb Jan 19, 2024
81d9e2b
Merge branch 'plane_interpolation' into sensor_cb3
svchb Jan 19, 2024
93e3310
working example
svchb Jan 19, 2024
aa25735
add plot
svchb Jan 19, 2024
6e1d805
also save the cauchy stress components
svchb Jan 22, 2024
46661b4
format
svchb Jan 22, 2024
769ca47
fix dt
svchb Jan 22, 2024
a9fbf6d
fix
svchb Jan 22, 2024
1893ae9
fix
svchb Jan 22, 2024
497bcd4
fix viscosity
svchb Jan 22, 2024
9486a04
working 3d example for plane interpolation
svchb Jan 23, 2024
586f639
add 2d plot as well for 3d case
svchb Jan 23, 2024
8659c44
add docs
svchb Jan 23, 2024
e2f991d
fix tests
svchb Jan 23, 2024
cf5558f
fix
svchb Jan 23, 2024
e62453c
fix plot
svchb Jan 23, 2024
699beaa
fix comments
svchb Jan 23, 2024
3e7ad09
fix comment
svchb Jan 23, 2024
971be6f
update
svchb Jan 23, 2024
db52b69
format
svchb Jan 23, 2024
e47ae70
add Plots
svchb Jan 23, 2024
86837d1
fix
svchb Jan 23, 2024
12ff4ef
adjust plot
svchb Jan 23, 2024
010ddb9
reduce time
svchb Jan 23, 2024
def6be7
Merge remote-tracking branch 'refs/remotes/origin/plane_interpolation'
svchb Jan 24, 2024
9389659
Merge remote-tracking branch 'origin/sensor_cb' into sensor_cb3
svchb Jan 24, 2024
3967441
Merge branch 'save_TLSPH' into sensor_cb3
svchb Jan 24, 2024
90cbdaa
add reference
svchb Jan 24, 2024
04e62b9
add better digitized curves and error calc
svchb Jan 24, 2024
3df6e54
performance optimization and some slight adjustment to improve error
svchb Jan 25, 2024
95bf29e
Merge branch 'main' into sensor_cb
svchb Jan 25, 2024
b246c78
Merge branch 'main'
svchb Jan 26, 2024
21ec719
format
svchb Jan 26, 2024
8da0acd
update
svchb Feb 1, 2024
550e032
Merge branch 'main' into sensor_cb
svchb Feb 1, 2024
c88bb7f
format
svchb Feb 1, 2024
895925b
Merge branch 'sensor_cb' of github.com:svchb/TrixiParticles.jl into s…
svchb Feb 1, 2024
8a7da40
Merge branch 'main' into sensor_cb3
svchb Feb 1, 2024
0515b84
add reference files
svchb Feb 2, 2024
a648f57
Merge branch 'main' into sensor_cb
svchb Feb 2, 2024
8108bd7
add CSV
svchb Feb 2, 2024
22d71b4
add csv output
svchb Feb 2, 2024
8175205
Merge branch 'sensor_cb' of github.com:svchb/TrixiParticles.jl into s…
svchb Feb 2, 2024
c0a1794
Merge branch 'main' into sensor_cb
svchb Feb 2, 2024
94a4fa1
format
svchb Feb 2, 2024
3755d4f
Merge branch 'sensor_cb' of github.com:svchb/TrixiParticles.jl into s…
svchb Feb 2, 2024
65c3b0b
Merge branch 'main' into sensor_cb
svchb Feb 6, 2024
f835aa5
up
svchb Feb 7, 2024
f9693fc
Merge branch 'main' into sensor_cb
svchb Feb 7, 2024
0cc4e08
fixes
svchb Feb 7, 2024
82f8d5e
update
svchb Feb 7, 2024
7975a7b
Merge branch 'sensor_cb' of github.com:svchb/TrixiParticles.jl into s…
svchb Feb 7, 2024
07017b3
fix paths
svchb Feb 8, 2024
b1cd1fd
fixes
svchb Feb 8, 2024
58691fa
review
svchb Feb 8, 2024
1ac5e2d
review
svchb Feb 8, 2024
b1ca149
change git
svchb Feb 8, 2024
cd2f7ca
change type
svchb Feb 8, 2024
ceacf7e
remove mutable
svchb Feb 8, 2024
b12a122
add new example
svchb Feb 8, 2024
92a88fa
change to plots.jl
svchb Feb 8, 2024
b22bccb
increase the resolution
svchb Feb 8, 2024
4e156d2
include into CI
svchb Feb 8, 2024
20b0c75
move condition
svchb Feb 8, 2024
6e3a999
add more output to summary box
svchb Feb 9, 2024
5f27c34
update
svchb Feb 9, 2024
d7cd92c
remove DataEntry
svchb Feb 12, 2024
dc6905c
Merge branch 'sensor_cb' into sensor_cb3
svchb Feb 13, 2024
70490c8
update file structure
svchb Feb 13, 2024
bc84f81
fix setup
svchb Feb 13, 2024
3e34bce
fix plot
svchb Feb 13, 2024
44b6551
Merge branch 'main' into sensor_cb
svchb Feb 13, 2024
8975bf3
update
svchb Feb 14, 2024
13189a5
Merge branch 'main' into sensor_cb
svchb Feb 14, 2024
1e9f532
fix
svchb Feb 14, 2024
c696664
update
svchb Feb 14, 2024
e38972d
format
svchb Feb 14, 2024
6bf1d93
review update
svchb Feb 14, 2024
439845f
fix test
svchb Feb 14, 2024
aebd697
nvalue->n_values
svchb Feb 14, 2024
b2c9d2d
fix
svchb Feb 14, 2024
f1a073d
fixfix
svchb Feb 14, 2024
8ef914e
add check for anonymous functions
svchb Feb 14, 2024
08bf3f3
fix test
svchb Feb 14, 2024
61271d1
remove unused 'using'
svchb Feb 14, 2024
71d2efa
add simple test
svchb Feb 14, 2024
5a35aa0
fix using statements
svchb Feb 14, 2024
03b4b81
ignore
svchb Feb 15, 2024
4fc8d5c
format
svchb Feb 15, 2024
5533585
fix ignore string
svchb Feb 15, 2024
481bc79
fix json reading in example
svchb Feb 15, 2024
338b8d1
update
svchb Feb 15, 2024
aae9f22
update based on review comments
svchb Feb 16, 2024
521b42e
format
svchb Feb 16, 2024
f327cd0
change funcs to keyword args
svchb Feb 16, 2024
fd98f91
fix docs
svchb Feb 16, 2024
0008c52
format
svchb Feb 16, 2024
3c6e9c5
review comments
svchb Feb 16, 2024
0c7a049
format
svchb Feb 16, 2024
2611e73
Merge branch 'main' into sensor_cb
svchb Feb 16, 2024
128ce2e
fix tests
svchb Feb 16, 2024
153d0e0
fix test
svchb Feb 16, 2024
0e4a6ab
format
svchb Feb 16, 2024
3eb44a8
review
svchb Feb 16, 2024
7852782
format
svchb Feb 16, 2024
b11ad70
fix plot
svchb Feb 16, 2024
ba39f94
fix test
svchb Feb 16, 2024
c43fcf2
remove include
svchb Feb 16, 2024
db38d89
Merge branch 'main' into sensor_cb
efaulhaber Feb 16, 2024
93932c5
fix test
svchb Feb 16, 2024
be5a9be
Merge branch 'sensor_cb' of github.com:svchb/TrixiParticles.jl into s…
svchb Feb 16, 2024
25509d6
Merge branch 'sensor_cb' into sensor_cb3
svchb Feb 20, 2024
40e8a6f
Merge branch 'main' into sensor_cb3
svchb Feb 20, 2024
283e5f3
rm
svchb Feb 20, 2024
acd15a5
move
svchb Feb 20, 2024
bc6d75a
add reference curves
svchb Feb 20, 2024
5ba46e0
fix plot
svchb Feb 20, 2024
c6184f4
fix
svchb Feb 20, 2024
7f99b36
add files
svchb Feb 21, 2024
8a5c9ea
update
svchb Feb 21, 2024
217f9c3
cleanup
svchb Feb 21, 2024
8293d8e
format
svchb Feb 21, 2024
7437abc
update
svchb Feb 21, 2024
ecbdb3b
cleanup plot
svchb Feb 21, 2024
97d0e6c
simplify plot
svchb Feb 21, 2024
6ea4bea
switch to makie
svchb Feb 21, 2024
b0ad145
implement check
svchb Feb 21, 2024
3e7ee92
format
svchb Feb 21, 2024
21c7bcd
update to new reference
svchb Feb 22, 2024
b7c0911
update
svchb Feb 22, 2024
95eecd4
format
svchb Feb 27, 2024
178e68b
rename
svchb Feb 27, 2024
4714431
remove the dependencies
svchb Feb 27, 2024
cbeee99
remove dependencies
svchb Feb 28, 2024
30b7e5f
add 5 resolution back
svchb Feb 28, 2024
b4112b4
format
svchb Feb 28, 2024
caca014
Merge branch 'main' into sensor_cb3
svchb Feb 28, 2024
ca0efab
use include
svchb Feb 28, 2024
fcf2da1
format
svchb Feb 28, 2024
2f2740a
renaming
svchb Feb 28, 2024
b1f1d58
fix readme
svchb Feb 28, 2024
4d46ef0
fix test [skip ci]
svchb Feb 28, 2024
222b8b0
[skip ci] remove save for compare
svchb Feb 28, 2024
552c0af
[skip ci] add tspan back
svchb Feb 28, 2024
9998b53
review comments
svchb Feb 28, 2024
0bf9b85
small fixes [skip ci]
svchb Feb 28, 2024
162540a
update [skip ci]
svchb Feb 29, 2024
ccdf42c
rename [skip ci]
svchb Feb 29, 2024
b2d66b9
update [skip ci]
svchb Feb 29, 2024
dbc0a7f
fix
svchb Mar 1, 2024
ea2684c
exchange interpolation function
svchb Mar 1, 2024
9ae2ba2
rename
svchb Mar 1, 2024
f836223
exchange common time range find code
svchb Mar 1, 2024
d92399e
update reference file
svchb Mar 1, 2024
8324939
update [skip ci]
svchb Mar 1, 2024
2f26a18
format [skip ci]
svchb Mar 1, 2024
d2ba9c8
update
svchb Mar 1, 2024
071d527
Merge branch 'main' into sensor_cb3
svchb Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/fsi/falling_water_column_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ boundary_model = BoundaryModelMonaghanKajtar(k, spacing_ratio, particle_spacing,

solid_system = TotalLagrangianSPHSystem(solid,
smoothing_kernel, smoothing_length,
E, nu, boundary_model=boundary_model,
material.E, material.nu,
boundary_model=boundary_model,
n_fixed_particles=nparticles(fixed_particles),
acceleration=(0.0, -gravity))

Expand Down
4 changes: 2 additions & 2 deletions examples/postprocessing/postprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ function hello(v, u, t, system)
# Value stored for output in the postprocessing output file
return 2 * t
end
example_cb = PostprocessCallback(; interval=10, hello)
example_cb = PostprocessCallback(; interval=10, hello, write_file_interval=0)

trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"),
extra_callback=example_cb, tspan=(0.0, 0.1));

# Lets write the average pressure and kinetic energy every 0.01s
pp = PostprocessCallback(; dt=0.005, filename="example_pressure_ekin", avg_pressure,
kinetic_energy)
kinetic_energy, write_file_interval=0)

trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"),
Expand Down
49 changes: 21 additions & 28 deletions examples/solid/oscillating_beam_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,32 @@ n_particles_y = 5
gravity = 2.0
tspan = (0.0, 5.0)

length_beam = 0.35
thickness = 0.02
elastic_beam = (length=0.35, thickness=0.02)
material = (density=1000.0, E=1.4e6, nu=0.4)
clamp_radius = 0.05
material_density = 1000.0

# Young's modulus and Poisson ratio
E = 1.4e6
nu = 0.4

# The structure starts at the position of the first particle and ends
# at the position of the last particle.
particle_spacing = thickness / (n_particles_y - 1)
particle_spacing = elastic_beam.thickness / (n_particles_y - 1)

# Add particle_spacing/2 to the clamp_radius to ensure that particles are also placed on the radius
fixed_particles = SphereShape(particle_spacing, clamp_radius + particle_spacing / 2,
(0.0, thickness / 2), material_density,
cutout_min=(0.0, 0.0), cutout_max=(clamp_radius, thickness),
(0.0, elastic_beam.thickness / 2), material.density,
cutout_min=(0.0, 0.0),
cutout_max=(clamp_radius, elastic_beam.thickness),
tlsph=true)

n_particles_clamp_x = round(Int, clamp_radius / particle_spacing)

# Beam and clamped particles
n_particles_per_dimension = (round(Int, length_beam / particle_spacing) +
n_particles_per_dimension = (round(Int, elastic_beam.length / particle_spacing) +
n_particles_clamp_x + 1, n_particles_y)

# Note that the `RectangularShape` puts the first particle half a particle spacing away
# from the boundary, which is correct for fluids, but not for solids.
# We therefore need to pass `tlsph=true`.
beam = RectangularShape(particle_spacing, n_particles_per_dimension,
(0.0, 0.0), density=material_density, tlsph=true)
(0.0, 0.0), density=material.density, tlsph=true)

solid = union(beam, fixed_particles)

Expand All @@ -51,9 +47,10 @@ smoothing_length = 2 * sqrt(2) * particle_spacing
smoothing_kernel = WendlandC2Kernel{2}()

solid_system = TotalLagrangianSPHSystem(solid, smoothing_kernel, smoothing_length,
E, nu,
material.E, material.nu,
n_fixed_particles=nparticles(fixed_particles),
acceleration=(0.0, -gravity))
acceleration=(0.0, -gravity),
penalty_force=nothing)

# ==========================================================================================
# ==== Simulation
Expand All @@ -63,26 +60,22 @@ ode = semidiscretize(semi, tspan)
info_callback = InfoCallback(interval=100)

# Track the position of the particle in the middle of the tip of the beam.
particle_id = Int(n_particles_per_dimension[1] * (n_particles_per_dimension[2] + 1) / 2)

shift_x = beam.coordinates[1, particle_id]
shift_y = beam.coordinates[2, particle_id]
middle_particle_id = Int(n_particles_per_dimension[1] * (n_particles_per_dimension[2] + 1) /
2)
startposition_x = beam.coordinates[1, middle_particle_id]
startposition_y = beam.coordinates[2, middle_particle_id]

function x_deflection(v, u, t, system)
particle_position = TrixiParticles.current_coords(u, system, particle_id)

return particle_position[1] - shift_x
function deflection_x(v, u, t, system)
return system.current_coordinates[1, middle_particle_id] - startposition_x
end

function y_deflection(v, u, t, system)
particle_position = TrixiParticles.current_coords(u, system, particle_id)

return particle_position[2] - shift_y
function deflection_y(v, u, t, system)
return system.current_coordinates[2, middle_particle_id] - startposition_y
end

saving_callback = SolutionSavingCallback(dt=0.02, prefix="",
x_deflection=x_deflection,
y_deflection=y_deflection)
deflection_x=deflection_x,
deflection_y=deflection_y)

callbacks = CallbackSet(info_callback, saving_callback)

Expand Down
2 changes: 1 addition & 1 deletion src/TrixiParticles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export BoundaryModelMonaghanKajtar, BoundaryModelDummyParticles, AdamiPressureEx
PressureMirroring, PressureZeroing
export BoundaryMovement
export GridNeighborhoodSearch, TrivialNeighborhoodSearch
export examples_dir, trixi_include
export examples_dir, validation_dir, trixi_include
export trixi2vtk
export RectangularTank, RectangularShape, SphereShape
export VoxelSphere, RoundSphere, reset_wall!
Expand Down
12 changes: 6 additions & 6 deletions src/schemes/solid/total_lagrangian_sph/penalty_force.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ struct PenaltyForceGanzenmueller{ELTYPE}
end

@inline function calc_penalty_force!(dv, particle, neighbor, initial_pos_diff,
initial_distance, system,
initial_distance, system, m_a, m_b, rho_a, rho_b,
penalty_force::PenaltyForceGanzenmueller)
(; mass, material_density, young_modulus) = system
(; young_modulus) = system

current_pos_diff = current_coords(system, particle) -
current_coords(system, neighbor)
current_distance = norm(current_pos_diff)

volume_particle = mass[particle] / material_density[particle]
volume_neighbor = mass[neighbor] / material_density[neighbor]
volume_particle = m_a / rho_a
volume_neighbor = m_b / rho_b

kernel_weight = smoothing_kernel(system, initial_distance)

Expand All @@ -76,9 +76,9 @@ end
kernel_weight / initial_distance^2 * young_modulus * delta_sum *
current_pos_diff / current_distance

for i in 1:ndims(system)
@inbounds for i in 1:ndims(system)
# Divide force by mass to obtain acceleration
dv[i, particle] += f[i] / mass[particle]
dv[i, particle] += f[i] / m_a
end

return dv
Expand Down
6 changes: 4 additions & 2 deletions src/schemes/solid/total_lagrangian_sph/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ end
grad_kernel = smoothing_kernel_grad(particle_system, initial_pos_diff,
initial_distance)

m_a = particle_system.mass[particle]
m_b = neighbor_system.mass[neighbor]

dv_particle = m_b *
(pk1_corrected(particle_system, particle) / rho_a^2 +
pk1_corrected(neighbor_system, neighbor) / rho_b^2) *
grad_kernel

for i in 1:ndims(particle_system)
@inbounds for i in 1:ndims(particle_system)
dv[i, particle] += dv_particle[i]
end

calc_penalty_force!(dv, particle, neighbor, initial_pos_diff,
initial_distance, particle_system, penalty_force)
initial_distance, particle_system, m_a, m_b, rho_a, rho_b,
penalty_force)

# TODO continuity equation?
end
Expand Down
3 changes: 2 additions & 1 deletion src/schemes/solid/total_lagrangian_sph/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ end
end

@inline function calc_penalty_force!(dv, particle, neighbor, initial_pos_diff,
initial_distance, system, ::Nothing)
initial_distance, system, m_a, m_b, rho_a, rho_b,
::Nothing)
return dv
end

Expand Down
16 changes: 16 additions & 0 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ readdir(examples_dir())
"""
examples_dir() = pkgdir(TrixiParticles, "examples")

"""
validation_dir()

Return the directory where the validation files provided with TrixiParticles.jl are located. If TrixiParticles is
installed as a regular package (with `]add TrixiParticles`), these files are read-only and should *not* be
modified. To find out which files are available, use, e.g., `readdir`.

Copied from [Trixi.jl](https://github.com/trixi-framework/Trixi.jl).

# Examples
```@example
readdir(validation_dir())
```
"""
validation_dir() = pkgdir(TrixiParticles, "validation")

"""
@autoinfiltrate
@autoinfiltrate condition::Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ using DataFrames
using Printf

pp_cb = PostprocessCallback(; ekin=kinetic_energy, max_pressure, avg_density, dt=0.025,
filename="relaxation", write_csv=false)
filename="relaxation", write_csv=false, write_file_interval=0)

pp_damped_cb = PostprocessCallback(; ekin=kinetic_energy, max_pressure, avg_density,
dt=0.025,
filename="relaxation_damped", write_csv=false)
filename="relaxation_damped", write_csv=false,
write_file_interval=0)

trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid", "hydrostatic_water_column_2d.jl"),
Expand Down
9 changes: 9 additions & 0 deletions validation/oscillating_beam_2d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The following files are provided here:

1) Validation simulation: validation_oscillating_beam_2d.jl
2) Comparison with reference: compare_reference_oscillating_beam_results.jl
3) Comparison with TrixiParticles.jl and literature reference: plot_oscillating_beam_results.jl
4) TrixiParticles.jl reference files: validation_reference_[5, 9, 21, 35].j (5 is the default CI resolution, note that resolution 21 takes about 30-50 minutes while 35 takes about 4-6 hours)
5) Reference file reference_turek.csv extracted from the file csm3_l4_t0p005.point here:
https://wwwold.mathematik.tu-dortmund.de/~featflow/en/benchmarks/cfdbenchmarking/fsi_benchmark/fsi_tests/fsi_csm_tests.html

80 changes: 80 additions & 0 deletions validation/oscillating_beam_2d/plot_oscillating_beam_results.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
include("../validation_util.jl")

# Activate for interactive plot
# using GLMakie
using CairoMakie
using CSV
using DataFrames
using JSON
using Glob
using Printf
using TrixiParticles

elastic_plate = (length=0.35, thickness=0.02)

# Load the reference simulation data
ref = CSV.read(joinpath(validation_dir(), "oscillating_beam_2d/reference_turek.csv"),
DataFrame)

# Get the list of JSON files
reference_files = glob("validation_reference_*.json",
joinpath(validation_dir(), "oscillating_beam_2d"))
simulation_files = glob("validation_run_oscillating_beam_2d_*.json",
joinpath(pkgdir(TrixiParticles), "out"))
merged_files = vcat(reference_files, simulation_files)
input_files = sort(merged_files, by=extract_number)

# Regular expressions for matching keys
key_pattern_x = r"deflection_x_solid_\d+"
key_pattern_y = r"deflection_y_solid_\d+"

# Setup for Makie plotting
fig = Figure(size=(1200, 800))
ax1 = Axis(fig, title="X-Axis Displacement", xlabel="Time [s]", ylabel="X Displacement")
ax2 = Axis(fig, title="Y-Axis Displacement", xlabel="Time [s]", ylabel="Y Displacement")
fig[1, 1] = ax1
fig[2, 1] = ax2

for file_name in input_files
println("Loading the input file: $file_name")
json_data = JSON.parsefile(file_name)

resolution = parse(Int, split(split(file_name, "_")[end], ".")[1])
particle_spacing = elastic_plate.thickness / (resolution - 1)

matching_keys_x = sort(collect(filter(key -> occursin(key_pattern_x, key),
keys(json_data))))
matching_keys_y = sort(collect(filter(key -> occursin(key_pattern_y, key),
keys(json_data))))

if isempty(matching_keys_x)
error("No matching keys found in: $file_name")
end

label_prefix = occursin("reference", file_name) ? "Reference" : ""

for (matching_keys, ax) in ((matching_keys_x, ax1), (matching_keys_y, ax2))
for key in matching_keys
data = json_data[key]
times = Float64.(data["time"])
displacements = Float64.(data["values"])

mse_results = occursin(key_pattern_x, key) ?
interpolated_mse(ref.time, ref.Ux, data["time"], displacements) :
interpolated_mse(ref.time, ref.Uy, data["time"], displacements)

label = "$label_prefix dp = $(@sprintf("%.8f", particle_spacing)) mse=$(@sprintf("%.8f", mse_results))"
lines!(ax, times, displacements, label=label)
end
end
end

# Plot reference data
lines!(ax1, ref.time, ref.Ux, color=:black, linestyle=:dash,
label="Turek and Hron 2006")
lines!(ax2, ref.time, ref.Uy, color=:black, linestyle=:dash,
label="Turek and Hron 2006")

legend_ax1 = Legend(fig[1, 2], ax1)
legend_ax2 = Legend(fig[2, 2], ax2)
fig
Loading