Skip to content

Conversation

@SimonCan
Copy link
Contributor

Add the ability to couple systems that use more than one variable and p4est meshes.

SimonCan and others added 30 commits May 1, 2025 00:24
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Removed redundant code from structured mesh coupled semidiscretization.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SimonCan and others added 23 commits October 9, 2025 10:24
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines +113 to 129
@trixi_testset "elixir_advection_coupled.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"),
l2=[0., 0.],
linf=[0., 0.])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
# @test_allocations(Trixi.rhs!, semi, sol, 1000)

# Ensure we cover the calculation of the node coordinates
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
ntuple(_ -> length(parent_mesh.nodes),
2)...,
length(mesh.cell_ids))
result = Trixi.calc_node_coordinates!(node_coordinates, mesh, parent_mesh.nodes)
@test parent_mesh.tree_node_coordinates == result

length(mesh1.cell_ids))
# Load the mesh file for code coverage.
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"); n_cells_max = 0,
loaded_mesh = Trixi.load_mesh_serial(joinpath(EXAMPLES_DIR, "out", "mesh_1.h5"); n_cells_max = 0,
RealT = typeof(parent_mesh).parameters[3])
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@trixi_testset "elixir_advection_coupled.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"),
l2=[0., 0.],
linf=[0., 0.])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
# @test_allocations(Trixi.rhs!, semi, sol, 1000)
# Ensure we cover the calculation of the node coordinates
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
ntuple(_ -> length(parent_mesh.nodes),
2)...,
length(mesh.cell_ids))
result = Trixi.calc_node_coordinates!(node_coordinates, mesh, parent_mesh.nodes)
@test parent_mesh.tree_node_coordinates == result
length(mesh1.cell_ids))
# Load the mesh file for code coverage.
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"); n_cells_max = 0,
loaded_mesh = Trixi.load_mesh_serial(joinpath(EXAMPLES_DIR, "out", "mesh_1.h5"); n_cells_max = 0,
RealT = typeof(parent_mesh).parameters[3])
end
@trixi_testset "elixir_advection_coupled.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"),
l2=[0.0, 0.0],
linf=[0.0, 0.0])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
# @test_allocations(Trixi.rhs!, semi, sol, 1000)
# Ensure we cover the calculation of the node coordinates
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
ntuple(_ -> length(parent_mesh.nodes),
2)...,
length(mesh1.cell_ids))
# Load the mesh file for code coverage.
loaded_mesh = Trixi.load_mesh_serial(joinpath(EXAMPLES_DIR, "out", "mesh_1.h5");
n_cells_max = 0,
RealT = typeof(parent_mesh).parameters[3])
end

du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end

Comment on lines +582 to 616
@trixi_testset "elixir_euler_mhd_coupled.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_mhd_coupled.jl"),
l2=[0.009862595305604965,
0.011874205535856063,
5.0185914245237475e-6,
0.0,
0.024657539839658474,
0.0,
0.0,
0.0,
0.0,
0.0098589277826056,
0.011870558900297097,
6.882386285170543e-6,
0.024648257743835045
],
linf=[0.013719847889148373,
0.01678917375613853,
2.933466212909218e-5,
0.0,
0.03429795097747568,
0.0,
0.0,
0.0,
0.0,
0.01368217970493435,
0.016790901855796785,
3.091328454846926e-5,
0.034236712653821444])
# Ensure we cover the calculation of the node coordinates
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
ntuple(_ -> length(parent_mesh.nodes),
2)...,
length(mesh1.cell_ids))
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@trixi_testset "elixir_euler_mhd_coupled.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_mhd_coupled.jl"),
l2=[0.009862595305604965,
0.011874205535856063,
5.0185914245237475e-6,
0.0,
0.024657539839658474,
0.0,
0.0,
0.0,
0.0,
0.0098589277826056,
0.011870558900297097,
6.882386285170543e-6,
0.024648257743835045
],
linf=[0.013719847889148373,
0.01678917375613853,
2.933466212909218e-5,
0.0,
0.03429795097747568,
0.0,
0.0,
0.0,
0.0,
0.01368217970493435,
0.016790901855796785,
3.091328454846926e-5,
0.034236712653821444])
# Ensure we cover the calculation of the node coordinates
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
ntuple(_ -> length(parent_mesh.nodes),
2)...,
length(mesh1.cell_ids))
end
@trixi_testset "elixir_euler_mhd_coupled.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_mhd_coupled.jl"),
l2=[0.009862595305604965,
0.011874205535856063,
5.0185914245237475e-6,
0.0,
0.024657539839658474,
0.0,
0.0,
0.0,
0.0,
0.0098589277826056,
0.011870558900297097,
6.882386285170543e-6,
0.024648257743835045
],
linf=[0.013719847889148373,
0.01678917375613853,
2.933466212909218e-5,
0.0,
0.03429795097747568,
0.0,
0.0,
0.0,
0.0,
0.01368217970493435,
0.016790901855796785,
3.091328454846926e-5,
0.034236712653821444])
# Ensure we cover the calculation of the node coordinates
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
ntuple(_ -> length(parent_mesh.nodes),
2)...,
length(mesh1.cell_ids))
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

@trixi_testset "elixir_advection_basic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
# Expected errors are exactly the same as with TreeMesh!
l2=[8.311947673061856e-6],
linf=[6.627000273229378e-5])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
semi32 = Trixi.trixi_adapt(Array, Float32, semi)
@test real(semi32.solver) == Float32
@test real(semi32.solver.basis) == Float32
@test real(semi32.solver.mortar) == Float32
# TODO: remake ignores the mesh itself as well
@test real(semi32.mesh) == Float64
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

@trixi_testset "elixir_advection_restart_amr.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart_amr.jl"),
l2=[2.869137983727866e-6],
linf=[3.8353423270964804e-5])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

@trixi_testset "elixir_mhd_alfven_wave.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
l2=[1.0513414461545583e-5, 1.0517900957166411e-6,
1.0517900957304043e-6, 1.511816606372376e-6,
1.0443997728645063e-6, 7.879639064990798e-7,
7.879639065049896e-7, 1.0628631669056271e-6,
4.3382328912336153e-7],
linf=[4.255466285174592e-5, 1.0029706745823264e-5,
1.0029706747467781e-5, 1.2122265939010224e-5,
5.4791097160444835e-6, 5.18922042269665e-6,
5.189220422141538e-6, 9.552667261422676e-6,
1.4237578427628152e-6])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

@trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_mhd_alfven_wave_nonconforming.jl"),
l2=[
0.0322570437144848,
0.03598284801272945,
0.03562228071357411,
0.05288641880143085,
0.040752873778199326,
0.04207276835260492,
0.04171391252403866,
0.05289242879893149,
0.0016038935411812223
],
linf=[
0.175984910510666,
0.13999726708245439,
0.13336032728399658,
0.21248359539637798,
0.133294808938885,
0.17934684696413217,
0.1831567822932948,
0.21575881133569155,
0.01967917976620703
],
tspan=(0.0, 0.25))
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
@test_allocations(Trixi.rhs!, semi, sol, 1000)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants