Skip to content

Commit

Permalink
Remove initial_condition from rhs; fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Oct 15, 2024
1 parent 1ff7b1d commit 8d02b1e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
11 changes: 6 additions & 5 deletions examples/t8code_2d_fv/elixir_advection_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ mapping_coordinates = Trixi.coordinates2mapping(coordinates_min, coordinates_max
# f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s))

# [0,8]^2
f1(s) = SVector(0.0, 4*(s+1))
f2(s) = SVector(8.0, 4*(s+1))
f3(s) = SVector(4*(s+1), 0.0)
f4(s) = SVector(4*(s+1), 8.0)
f1(s) = SVector(0.0, 4 * (s + 1))
f2(s) = SVector(8.0, 4 * (s + 1))
f3(s) = SVector(4 * (s + 1), 0.0)
f4(s) = SVector(4 * (s + 1), 8.0)
faces = (f1, f2, f3, f4)
Trixi.validate_faces(faces)
mapping_faces = Trixi.transfinite_mapping(faces)
Expand All @@ -57,7 +57,8 @@ end
# directly within this elixir (e.g. mapping = trixi_t8_mapping_c(mapping)), we get the SegFault error.
# - Is the function called with the correct parameters? Memory location correct? It seems so, yes.
# - Life time issue for the GC tracked Julia object used in C? **Yes, see gc deactivation in elixir.**
function trixi_t8_mapping(cmesh, gtreeid, ref_coords, num_coords, out_coords, tree_data, user_data)
function trixi_t8_mapping(cmesh, gtreeid, ref_coords, num_coords, out_coords,
tree_data, user_data)
ltreeid = t8_cmesh_get_local_id(cmesh, gtreeid)
eclass = t8_cmesh_get_tree_class(cmesh, ltreeid)
T8code.t8_geom_compute_linear_geometry(eclass, tree_data,
Expand Down
3 changes: 2 additions & 1 deletion examples/t8code_3d_fv/elixir_advection_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function mapping(xi, eta, zeta)
return SVector(x, y, z)
end

function trixi_t8_mapping(cmesh, gtreeid, ref_coords, num_coords, out_coords, tree_data, user_data)
function trixi_t8_mapping(cmesh, gtreeid, ref_coords, num_coords, out_coords,
tree_data, user_data)
ltreeid = t8_cmesh_get_local_id(cmesh, gtreeid)
eclass = t8_cmesh_get_tree_class(cmesh, ltreeid)
T8code.t8_geom_compute_linear_geometry(eclass, tree_data,
Expand Down
15 changes: 10 additions & 5 deletions src/meshes/t8code_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function T8codeMesh(trees_per_dimension, eclass;
cmesh = cmesh_ref[]

@assert(allequal(trees_per_dimension),
"Different trees per dimensions are not supported for quad mesh. `trees_per_dimension`: $trees_per_dimension")
"Different trees per dimensions are not supported for quad mesh. `trees_per_dimension`: $trees_per_dimension")
num_trees = prod(trees_per_dimension) * 1 # 1 = number of trees for single hypercube with quads

vertices_per_tree = 2^NDIMS # number of vertices (=corners) in one tree
Expand Down Expand Up @@ -425,8 +425,11 @@ function T8codeMesh(trees_per_dimension, eclass;
coordinates_tree_y = range(-1.0, 1.0, length = trees_per_dimension[2] + 1)
coordinates_tree_z = range(-1.0, 1.0, length = trees_per_dimension[3] + 1)

for itree_z in 1:trees_per_dimension[3], itree_y in 1:trees_per_dimension[2], itree_x in 1:trees_per_dimension[1]
index = trees_per_dimension[1] * trees_per_dimension[2] * 3 * vertices_per_tree * (itree_z - 1) +
for itree_z in 1:trees_per_dimension[3], itree_y in 1:trees_per_dimension[2],
itree_x in 1:trees_per_dimension[1]

index = trees_per_dimension[1] * trees_per_dimension[2] * 3 *
vertices_per_tree * (itree_z - 1) +
trees_per_dimension[1] * 3 * vertices_per_tree * (itree_y - 1) +
3 * vertices_per_tree * (itree_x - 1) + 1

Expand Down Expand Up @@ -494,7 +497,8 @@ function T8codeMesh(trees_per_dimension, eclass;
offset_vertices = 3 * vertices_per_tree * (itree - 1)
t8_cmesh_set_tree_class(cmesh, itree - 1, eclass)
t8_cmesh_set_tree_vertices(cmesh, itree - 1,
@views(vertices[(1 + offset_vertices):end]), vertices_per_tree)
@views(vertices[(1 + offset_vertices):end]),
vertices_per_tree)
end

if NDIMS == 2
Expand Down Expand Up @@ -1808,7 +1812,8 @@ function cmesh_new_quad(; trees_per_dimension = (1, 1),
end

function cmesh_new_quad_3d(; trees_per_dimension = (1, 1, 1),
coordinates_min = (-1.0, -1.0, -1.0), coordinates_max = (1.0, 1.0, 1.0),
coordinates_min = (-1.0, -1.0, -1.0),
coordinates_max = (1.0, 1.0, 1.0),
periodicity = (true, true, true))::t8_cmesh_t
# This is how the cmesh looks like. The numbers are the tree numbers:
# +---+
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/fv_t8code/fv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function create_cache(mesh::T8codeMesh, equations::AbstractEquations, solver::FV
end

function rhs!(du, u, t, mesh::T8codeMesh, equations,
initial_condition, boundary_conditions, source_terms::Source,
boundary_conditions, source_terms::Source,
solver::FV, cache) where {Source}
# Reset du
@trixi_timeit timer() "reset ∂u/∂t" du.=zero(eltype(du))
Expand Down
11 changes: 7 additions & 4 deletions test/test_mpi_t8code_fv_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_fv")

# Run basic tests
@testset "Examples 3D" begin
# NOTE: Since I use 2x2x2 tree instead of 8x8x8, I need to increase the resolution 2 times by the factor of 2 -> +2
@trixi_testset "elixir_advection_basic.jl" begin
@trixi_testset "first-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
order=1,
initial_refinement_level=2+2,
initial_refinement_level=2 + 2,
l2=[0.2848617953369851],
linf=[0.3721898718954475])
# Ensure that we do not have excessive memory allocations
Expand All @@ -30,7 +31,7 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_fv")
end
@trixi_testset "second-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
initial_refinement_level=2+2,
initial_refinement_level=2 + 2,
l2=[0.10381089565603231],
linf=[0.13787405651527007])
# Ensure that we do not have excessive memory allocations
Expand All @@ -48,7 +49,8 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_fv")

@trixi_testset "elixir_advection_basic_hybrid.jl" begin
@trixi_testset "first-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_hybrid.jl"),
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_basic_hybrid.jl"),
order=1,
l2=[0.20282363730327146],
linf=[0.28132446651281295])
Expand All @@ -62,7 +64,8 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "t8code_3d_fv")
end
end
@trixi_testset "second-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_hybrid.jl"),
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_basic_hybrid.jl"),
l2=[0.02153993127089835],
linf=[0.039109618097251886])
# Ensure that we do not have excessive memory allocations
Expand Down
18 changes: 9 additions & 9 deletions test/test_t8code_fv_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mkdir(outdir)
@trixi_testset "first-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
order=1,
initial_refinement_level=2+2,
initial_refinement_level=2 + 2,
l2=[0.2848617953369851],
linf=[0.3721898718954475])
# Ensure that we do not have excessive memory allocations
Expand All @@ -63,7 +63,7 @@ mkdir(outdir)
end
@trixi_testset "second-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
initial_refinement_level=2+2,
initial_refinement_level=2 + 2,
l2=[0.10381089565603231],
linf=[0.13787405651527007])
# Ensure that we do not have excessive memory allocations
Expand All @@ -77,7 +77,7 @@ mkdir(outdir)
end
@trixi_testset "second-order FV, extended reconstruction stencil" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
initial_refinement_level=1+2,
initial_refinement_level=1 + 2,
extended_reconstruction_stencil=true,
l2=[0.3282177575292713],
linf=[0.39002345444858333])
Expand Down Expand Up @@ -177,14 +177,14 @@ end
0.0351299673616484,
0.0351299673616484,
0.03512996736164839,
0.1601847269543808,
0.1601847269543808
],
linf=[
0.07175521415072939,
0.04648499338897771,
0.04648499338897816,
0.04648499338897816,
0.2235470564880404,
0.2235470564880404
])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -203,14 +203,14 @@ end
0.010791416898840429,
0.010791416898840464,
0.010791416898840377,
0.036995680347196136,
0.036995680347196136
],
linf=[
0.01982294164697862,
0.01840725612418126,
0.01840725612418148,
0.01840725612418148,
0.05736595182767079,
0.05736595182767079
])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand All @@ -230,14 +230,14 @@ end
0.03596196296013507,
0.03616867188152877,
0.03616867188152873,
0.14939041550302212,
0.14939041550302212
],
linf=[
0.07943789383956079,
0.06389365911606859,
0.06469291944863809,
0.0646929194486372,
0.23507781748792533,
0.23507781748792533
])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
Expand Down

0 comments on commit 8d02b1e

Please sign in to comment.