-
Notifications
You must be signed in to change notification settings - Fork 15
Fix the validation setup based on Marrone2011 #858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 14 commits
0f7d337
70b364e
8502ed9
27bc611
205ac2a
0428af1
5a6778e
bf91ec4
5d83c47
8396ee7
f56386c
c2e559b
9255600
e88b6f1
3cea45e
cfdf06b
5aa69f7
47e57d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function max_x_coord(system, data, t) | ||
return maximum(j -> data.coordinates[1, j], axes(data.coordinates, 2)) | ||
end | ||
|
||
function interpolated_pressure(coord_top, coord_bottom, v_ode, u_ode, t, system, semi) end | ||
|
||
function interpolated_pressure(coord_top, coord_bottom, v_ode, u_ode, t, | ||
system::TrixiParticles.FluidSystem, semi) | ||
# use at least 5 interpolation points for low resolution simulations | ||
# otherwise use at least the number of particles present | ||
n_interpolation_points = min(5, Int(ceil(sensor_size / particle_spacing))) | ||
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? I think 10 should be enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can change that in your PR all the files are generated with this setting. |
||
interpolated_values = interpolate_line(coord_top, coord_bottom, | ||
n_interpolation_points, semi, system, v_ode, | ||
u_ode, | ||
smoothing_length=2.0 * | ||
TrixiParticles.initial_smoothing_length(system), | ||
clip_negative_pressure=true) | ||
return sum(map(x -> isnan(x) ? 0.0 : x, interpolated_values.pressure)) / | ||
n_interpolation_points | ||
end | ||
|
||
function pressure_probe(coord_top, coord_bottom, v_ode, u_ode, t, system, semi) end | ||
|
||
function pressure_probe(coord_top, coord_bottom, v_ode, u_ode, t, | ||
system::TrixiParticles.BoundarySystem, semi) | ||
# The sensor is at the right wall, so its x-coordinate is the same for top and bottom. | ||
x_sensor = coord_top[1] | ||
|
||
# Use the initial particle spacing as a reference for the thickness of the averaging region. | ||
# A thickness of one or two particle spacings is usually a good choice. | ||
region_thickness = 2.0 * particle_spacing | ||
|
||
# Define the rectangular region for averaging | ||
x_min = x_sensor - region_thickness | ||
x_max = x_sensor + region_thickness | ||
y_min = coord_bottom[2] | ||
y_max = coord_top[2] | ||
|
||
sum_of_pressures = 0.0 | ||
num_particles_in_region = 0 | ||
|
||
v = TrixiParticles.wrap_v(v_ode, system, semi) | ||
u = TrixiParticles.wrap_u(u_ode, system, semi) | ||
|
||
# Iterate over each particle in the specified fluid system | ||
for particle_idx in TrixiParticles.eachparticle(system) | ||
pc = TrixiParticles.current_coords(u, system, particle_idx) | ||
|
||
# Get coordinates for the current particle from the 1D vector | ||
px = pc[1] # x-coordinate | ||
py = pc[2] # y-coordinate | ||
|
||
# Check if the particle is inside the sensor's rectangular region | ||
if (x_min <= px <= x_max) && (y_min <= py <= y_max) | ||
# Add its pressure to the sum and increment the count | ||
sum_of_pressures += TrixiParticles.current_pressure(v, system, particle_idx) | ||
num_particles_in_region += 1 | ||
end | ||
end | ||
|
||
# If no particles are in the region (e.g., before the water hits the wall), | ||
# the pressure is zero. | ||
if num_particles_in_region == 0 | ||
return 0.0 | ||
end | ||
|
||
# Return the calculated average pressure | ||
return sum_of_pressures / num_particles_in_region | ||
end | ||
Comment on lines
+22
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it makes any sense to include this particle-averaged pressure computation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Than remove it in your PR. I have it in all the reference files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I can also remove it manually |
Uh oh!
There was an error while loading. Please reload this page.