From 1712f1fd4345aba8994d89f7ef9553d272687365 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 14:52:37 +0100 Subject: [PATCH 01/12] Check BCs for periodicity for periodic meshes --- .../semidiscretization_hyperbolic.jl | 94 +++++++++++++++++++ ...semidiscretization_hyperbolic_parabolic.jl | 4 + 2 files changed, 98 insertions(+) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 7ebd758de37..c9e00a1ccd4 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -72,6 +72,10 @@ function SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver _boundary_conditions = digest_boundary_conditions(boundary_conditions, mesh, solver, cache) + if mesh isa TreeMesh || mesh isa StructuredMesh + check_periodicity_mesh_boundary_conditions(mesh, _boundary_conditions) + end + SemidiscretizationHyperbolic{typeof(mesh), typeof(equations), typeof(initial_condition), typeof(_boundary_conditions), typeof(source_terms), @@ -210,6 +214,96 @@ function digest_boundary_conditions(boundary_conditions::AbstractArray, mesh, so throw(ArgumentError("Please use a (named) tuple instead of an (abstract) array to supply multiple boundary conditions (to improve performance).")) end +function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, + boundary_conditions) + @unpack x_neg, x_pos = boundary_conditions + if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || + x_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + +function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, + boundary_conditions) + @unpack x_neg, x_pos = boundary_conditions + if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || + x_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + +function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, + boundary_conditions) + @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions + if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || + x_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh.tree, 2) && (y_neg != BoundaryConditionPeriodic() || + y_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + +function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, + boundary_conditions) + @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions + if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || + x_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh, 2) && (y_neg != BoundaryConditionPeriodic() || + y_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + +function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, + boundary_conditions) + @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions + if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || + x_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh.tree, 2) && (y_neg != BoundaryConditionPeriodic() || + y_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh.tree, 3) && (z_neg != BoundaryConditionPeriodic() || + z_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + +function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, + boundary_conditions) + @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions + if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || + x_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh, 2) && (y_neg != BoundaryConditionPeriodic() || + y_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh, 3) && (z_neg != BoundaryConditionPeriodic() || + z_pos != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function Base.show(io::IO, semi::SemidiscretizationHyperbolic) @nospecialize semi # reduce precompilation time diff --git a/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl b/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl index 0f44941390a..5fb18428b59 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl @@ -136,6 +136,10 @@ function SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabo _boundary_conditions_parabolic = digest_boundary_conditions(boundary_conditions_parabolic, mesh, solver, cache) + if mesh isa TreeMesh || mesh isa StructuredMesh + check_periodicity_mesh_boundary_conditions(mesh, _boundary_conditions) + end + cache_parabolic = (; create_cache_parabolic(mesh, equations, equations_parabolic, solver, solver_parabolic, RealT, From 5e87108e0a6d4158504f6074529af6ff77599234 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:07:25 +0100 Subject: [PATCH 02/12] default case for periodic bcs --- src/semidiscretization/semidiscretization_hyperbolic.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index c9e00a1ccd4..f983ddc7465 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -214,6 +214,10 @@ function digest_boundary_conditions(boundary_conditions::AbstractArray, mesh, so throw(ArgumentError("Please use a (named) tuple instead of an (abstract) array to supply multiple boundary conditions (to improve performance).")) end +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, StructuredMesh}, + boundary_conditions::BoundaryConditionPeriodic) +end + function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, boundary_conditions) @unpack x_neg, x_pos = boundary_conditions @@ -249,6 +253,8 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, end end + + function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, boundary_conditions) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions From 3a9cf88cbd66ad18ea4c2ba5c1ccb53ce86c076e Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:07:41 +0100 Subject: [PATCH 03/12] fmt --- src/semidiscretization/semidiscretization_hyperbolic.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index f983ddc7465..47925ed0eca 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -214,7 +214,8 @@ function digest_boundary_conditions(boundary_conditions::AbstractArray, mesh, so throw(ArgumentError("Please use a (named) tuple instead of an (abstract) array to supply multiple boundary conditions (to improve performance).")) end -function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, StructuredMesh}, +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, + StructuredMesh}, boundary_conditions::BoundaryConditionPeriodic) end @@ -253,8 +254,6 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, end end - - function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, boundary_conditions) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions From 90258512e5d1c7e6119c47c227c3c351bcc9b538 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:18:14 +0100 Subject: [PATCH 04/12] specialize --- .../semidiscretization_hyperbolic.jl | 110 +++++++++++++++++- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 47925ed0eca..3975142a095 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -220,7 +220,8 @@ function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, end function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, - boundary_conditions) + boundary_conditions::NamedTuple{Keys, + ValueTypes}) @unpack x_neg, x_pos = boundary_conditions if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) @@ -229,8 +230,19 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, end end +function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, + boundary_conditions::NTuple{2, Any}) + if isperiodic(mesh.tree, 1) && + (boundary_conditions[1] != BoundaryConditionPeriodic() || + boundary_conditions[2] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, - boundary_conditions) + boundary_conditions::NamedTuple{Keys, + ValueTypes}) @unpack x_neg, x_pos = boundary_conditions if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) @@ -239,8 +251,19 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, end end +function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, + boundary_conditions::NTuple{2, Any}) + @unpack x_neg, x_pos = boundary_conditions + if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || + boundary_conditions[2] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, - boundary_conditions) + boundary_conditions::NamedTuple{Keys, + ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) @@ -254,8 +277,25 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, end end +function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, + boundary_conditions::NTuple{4, Any}) + if isperiodic(mesh.tree, 1) && + (boundary_conditions[1] != BoundaryConditionPeriodic() || + boundary_conditions[2] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh.tree, 2) && + (boundary_conditions[3] != BoundaryConditionPeriodic() || + boundary_conditions[4] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, - boundary_conditions) + boundary_conditions::NamedTuple{Keys, + ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) @@ -269,8 +309,23 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, end end +function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, + boundary_conditions::NTuple{4, Any}) + if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || + boundary_conditions[2] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh, 2) && (boundary_conditions[3] != BoundaryConditionPeriodic() || + boundary_conditions[4] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, - boundary_conditions) + boundary_conditions::NamedTuple{Keys, + ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) @@ -289,8 +344,31 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, end end +function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, + boundary_conditions::NTuple{6, Any}) + if isperiodic(mesh.tree, 1) && + (boundary_conditions[1] != BoundaryConditionPeriodic() || + boundary_conditions[2] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh.tree, 2) && + (boundary_conditions[3] != BoundaryConditionPeriodic() || + boundary_conditions[4] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh.tree, 3) && + (boundary_conditions[5] != BoundaryConditionPeriodic() || + boundary_conditions[6] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, - boundary_conditions) + boundary_conditions::NamedTuple{Keys, + ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) @@ -309,6 +387,26 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, end end +function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, + boundary_conditions::NTuple{6, Any}) + @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions + if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || + boundary_conditions[2] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh, 2) && (boundary_conditions[3] != BoundaryConditionPeriodic() || + boundary_conditions[4] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end + if isperiodic(mesh, 3) && (boundary_conditions[5] != BoundaryConditionPeriodic() || + boundary_conditions[6] != BoundaryConditionPeriodic()) + @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + The boundary conditions will be ignored and periodic boundary conditions are used." + end +end + function Base.show(io::IO, semi::SemidiscretizationHyperbolic) @nospecialize semi # reduce precompilation time From 499af543609e17c46ac0e1a9e8cb7a8be3f88267 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:20:53 +0100 Subject: [PATCH 05/12] error ant fmt --- .../semidiscretization_hyperbolic.jl | 102 ++++++++++-------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 3975142a095..3dc874b426b 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -223,9 +223,10 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, boundary_conditions::NamedTuple{Keys, ValueTypes}) @unpack x_neg, x_pos = boundary_conditions - if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh.tree, 1) && + (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions are supplied. + @error "For periodic mesh non-periodic boundary conditions are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -235,7 +236,7 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, if isperiodic(mesh.tree, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions are supplied. + @error "For periodic mesh non-periodic boundary conditions are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -244,9 +245,10 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, boundary_conditions::NamedTuple{Keys, ValueTypes}) @unpack x_neg, x_pos = boundary_conditions - if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh, 1) && + (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions are supplied. + @error "For periodic mesh non-periodic boundary conditions are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -254,9 +256,10 @@ end function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, boundary_conditions::NTuple{2, Any}) @unpack x_neg, x_pos = boundary_conditions - if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || + if isperiodic(mesh, 1) && + (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions are supplied. + @error "For periodic mesh non-periodic boundary conditions are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -265,14 +268,16 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, boundary_conditions::NamedTuple{Keys, ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions - if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh.tree, 1) && + (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh.tree, 2) && (y_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh.tree, 2) && + (y_neg != BoundaryConditionPeriodic() || y_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -282,13 +287,13 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, if isperiodic(mesh.tree, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end if isperiodic(mesh.tree, 2) && (boundary_conditions[3] != BoundaryConditionPeriodic() || boundary_conditions[4] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -297,28 +302,32 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, boundary_conditions::NamedTuple{Keys, ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions - if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh, 1) && + (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh, 2) && (y_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh, 2) && + (y_neg != BoundaryConditionPeriodic() || y_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, boundary_conditions::NTuple{4, Any}) - if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || + if isperiodic(mesh, 1) && + (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh, 2) && (boundary_conditions[3] != BoundaryConditionPeriodic() || + if isperiodic(mesh, 2) && + (boundary_conditions[3] != BoundaryConditionPeriodic() || boundary_conditions[4] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -327,19 +336,22 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, boundary_conditions::NamedTuple{Keys, ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - if isperiodic(mesh.tree, 1) && (x_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh.tree, 1) && + (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh.tree, 2) && (y_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh.tree, 2) && + (y_neg != BoundaryConditionPeriodic() || y_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh.tree, 3) && (z_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh.tree, 3) && + (z_neg != BoundaryConditionPeriodic() || z_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -349,19 +361,19 @@ function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, if isperiodic(mesh.tree, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end if isperiodic(mesh.tree, 2) && (boundary_conditions[3] != BoundaryConditionPeriodic() || boundary_conditions[4] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end if isperiodic(mesh.tree, 3) && (boundary_conditions[5] != BoundaryConditionPeriodic() || boundary_conditions[6] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -370,19 +382,22 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, boundary_conditions::NamedTuple{Keys, ValueTypes}) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh, 1) && + (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh, 2) && (y_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh, 2) && + (y_neg != BoundaryConditionPeriodic() || y_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh, 3) && (z_neg != BoundaryConditionPeriodic() || + if isperiodic(mesh, 3) && + (z_neg != BoundaryConditionPeriodic() || z_pos != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end @@ -390,19 +405,22 @@ end function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, boundary_conditions::NTuple{6, Any}) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || + if isperiodic(mesh, 1) && + (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in x-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh, 2) && (boundary_conditions[3] != BoundaryConditionPeriodic() || + if isperiodic(mesh, 2) && + (boundary_conditions[3] != BoundaryConditionPeriodic() || boundary_conditions[4] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in y-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end - if isperiodic(mesh, 3) && (boundary_conditions[5] != BoundaryConditionPeriodic() || + if isperiodic(mesh, 3) && + (boundary_conditions[5] != BoundaryConditionPeriodic() || boundary_conditions[6] != BoundaryConditionPeriodic()) - @warn "For periodic mesh non-periodic boundary conditions in z-direction are supplied. + @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. The boundary conditions will be ignored and periodic boundary conditions are used." end end From b0f3c887c67bc8958c32be7e4b6061c8d0a9b157 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:31:37 +0100 Subject: [PATCH 06/12] isperiodic TreeMesh --- src/meshes/tree_mesh.jl | 3 + .../semidiscretization_hyperbolic.jl | 130 ++---------------- 2 files changed, 18 insertions(+), 115 deletions(-) diff --git a/src/meshes/tree_mesh.jl b/src/meshes/tree_mesh.jl index 05699d17d16..1092fc54cc1 100644 --- a/src/meshes/tree_mesh.jl +++ b/src/meshes/tree_mesh.jl @@ -228,5 +228,8 @@ function total_volume(mesh::TreeMesh) return mesh.tree.length_level_0^ndims(mesh) end +isperiodic(mesh::TreeMesh) = isperiodic(mesh.tree) +isperiodic(mesh::TreeMesh, dimension) = isperiodic(mesh.tree, dimension) + include("parallel_tree_mesh.jl") end # @muladd diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 3dc874b426b..ad1ba0175f3 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -219,31 +219,9 @@ function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, boundary_conditions::BoundaryConditionPeriodic) end -function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, - boundary_conditions::NamedTuple{Keys, - ValueTypes}) - @unpack x_neg, x_pos = boundary_conditions - if isperiodic(mesh.tree, 1) && - (x_neg != BoundaryConditionPeriodic() || - x_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end -end - -function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{1}, - boundary_conditions::NTuple{2, Any}) - if isperiodic(mesh.tree, 1) && - (boundary_conditions[1] != BoundaryConditionPeriodic() || - boundary_conditions[2] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end -end - -function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, - boundary_conditions::NamedTuple{Keys, - ValueTypes}) +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, + StructuredMesh{1}}, + boundary_conditions::NamedTuple) @unpack x_neg, x_pos = boundary_conditions if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || @@ -253,9 +231,9 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, end end -function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, + StructuredMesh{1}}, boundary_conditions::NTuple{2, Any}) - @unpack x_neg, x_pos = boundary_conditions if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || boundary_conditions[2] != BoundaryConditionPeriodic()) @@ -264,43 +242,9 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{1}, end end -function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, - boundary_conditions::NamedTuple{Keys, - ValueTypes}) - @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions - if isperiodic(mesh.tree, 1) && - (x_neg != BoundaryConditionPeriodic() || - x_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh.tree, 2) && - (y_neg != BoundaryConditionPeriodic() || - y_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end -end - -function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{2}, - boundary_conditions::NTuple{4, Any}) - if isperiodic(mesh.tree, 1) && - (boundary_conditions[1] != BoundaryConditionPeriodic() || - boundary_conditions[2] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh.tree, 2) && - (boundary_conditions[3] != BoundaryConditionPeriodic() || - boundary_conditions[4] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end -end - -function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, - boundary_conditions::NamedTuple{Keys, - ValueTypes}) +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, + StructuredMesh{2}}, + boundary_conditions::NamedTuple) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || @@ -316,7 +260,8 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, end end -function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, + StructuredMesh{2}}, boundary_conditions::NTuple{4, Any}) if isperiodic(mesh, 1) && (boundary_conditions[1] != BoundaryConditionPeriodic() || @@ -332,55 +277,9 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{2}, end end -function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, - boundary_conditions::NamedTuple{Keys, - ValueTypes}) - @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - if isperiodic(mesh.tree, 1) && - (x_neg != BoundaryConditionPeriodic() || - x_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh.tree, 2) && - (y_neg != BoundaryConditionPeriodic() || - y_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh.tree, 3) && - (z_neg != BoundaryConditionPeriodic() || - z_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end -end - -function check_periodicity_mesh_boundary_conditions(mesh::TreeMesh{3}, - boundary_conditions::NTuple{6, Any}) - if isperiodic(mesh.tree, 1) && - (boundary_conditions[1] != BoundaryConditionPeriodic() || - boundary_conditions[2] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh.tree, 2) && - (boundary_conditions[3] != BoundaryConditionPeriodic() || - boundary_conditions[4] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh.tree, 3) && - (boundary_conditions[5] != BoundaryConditionPeriodic() || - boundary_conditions[6] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end -end - -function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, - boundary_conditions::NamedTuple{Keys, - ValueTypes}) +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, + StructuredMesh{3}}, + boundary_conditions::NamedTuple) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || @@ -402,7 +301,8 @@ function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, end end -function check_periodicity_mesh_boundary_conditions(mesh::StructuredMesh{3}, +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, + StructuredMesh{3}}, boundary_conditions::NTuple{6, Any}) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions if isperiodic(mesh, 1) && From ace6b6732c165e36cbbc02674cfc07f218a6464b Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:40:15 +0100 Subject: [PATCH 07/12] avoid if --- .../semidiscretization_hyperbolic.jl | 13 ++++++++++--- .../semidiscretization_hyperbolic_parabolic.jl | 4 +--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index ad1ba0175f3..3f47308ba5b 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -72,9 +72,7 @@ function SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver _boundary_conditions = digest_boundary_conditions(boundary_conditions, mesh, solver, cache) - if mesh isa TreeMesh || mesh isa StructuredMesh - check_periodicity_mesh_boundary_conditions(mesh, _boundary_conditions) - end + check_periodicity_mesh_boundary_conditions(mesh, _boundary_conditions) SemidiscretizationHyperbolic{typeof(mesh), typeof(equations), typeof(initial_condition), @@ -214,6 +212,15 @@ function digest_boundary_conditions(boundary_conditions::AbstractArray, mesh, so throw(ArgumentError("Please use a (named) tuple instead of an (abstract) array to supply multiple boundary conditions (to improve performance).")) end +# No checks for these meshes yet available +function check_periodicity_mesh_boundary_conditions(mesh::Union{P4estMesh, + UnstructuredMesh2D, + T8CodeMesh, + DGMultiMesh}, + boundary_conditions) +end + +# No actions needed for periodic boundary conditions function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, StructuredMesh}, boundary_conditions::BoundaryConditionPeriodic) diff --git a/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl b/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl index 5fb18428b59..57724374acb 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl @@ -136,9 +136,7 @@ function SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabo _boundary_conditions_parabolic = digest_boundary_conditions(boundary_conditions_parabolic, mesh, solver, cache) - if mesh isa TreeMesh || mesh isa StructuredMesh - check_periodicity_mesh_boundary_conditions(mesh, _boundary_conditions) - end + check_periodicity_mesh_boundary_conditions(mesh, _boundary_conditions) cache_parabolic = (; create_cache_parabolic(mesh, equations, equations_parabolic, From 34f274aa0dd2ab928caf89994cc7aa913be67001 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:47:12 +0100 Subject: [PATCH 08/12] shorten --- .../semidiscretization_hyperbolic.jl | 117 +++++++----------- 1 file changed, 43 insertions(+), 74 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 3f47308ba5b..64eb752aea5 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -215,7 +215,7 @@ end # No checks for these meshes yet available function check_periodicity_mesh_boundary_conditions(mesh::Union{P4estMesh, UnstructuredMesh2D, - T8CodeMesh, + T8codeMesh, DGMultiMesh}, boundary_conditions) end @@ -226,110 +226,79 @@ function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh, boundary_conditions::BoundaryConditionPeriodic) end -function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, - StructuredMesh{1}}, - boundary_conditions::NamedTuple) - @unpack x_neg, x_pos = boundary_conditions +function check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) if isperiodic(mesh, 1) && (x_neg != BoundaryConditionPeriodic() || x_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." + @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied." + end +end + +function check_periodicity_mesh_boundary_conditions_y(mesh, y_neg, y_pos) + if isperiodic(mesh, 2) && + (y_neg != BoundaryConditionPeriodic() || + y_pos != BoundaryConditionPeriodic()) + @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied." + end +end + +function check_periodicity_mesh_boundary_conditions_z(mesh, z_neg, z_pos) + if isperiodic(mesh, 3) && + (z_neg != BoundaryConditionPeriodic() || + z_pos != BoundaryConditionPeriodic()) + @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied." end end +function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, + StructuredMesh{1}}, + boundary_conditions::NamedTuple) + @unpack x_neg, x_pos = boundary_conditions + check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) +end + function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, StructuredMesh{1}}, boundary_conditions::NTuple{2, Any}) - if isperiodic(mesh, 1) && - (boundary_conditions[1] != BoundaryConditionPeriodic() || - boundary_conditions[2] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end + check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], + boundary_conditions[2]) end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, StructuredMesh{2}}, boundary_conditions::NamedTuple) @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions - if isperiodic(mesh, 1) && - (x_neg != BoundaryConditionPeriodic() || - x_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh, 2) && - (y_neg != BoundaryConditionPeriodic() || - y_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end + check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) + check_periodicity_mesh_boundary_conditions_y(mesh, y_neg, y_pos) end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, StructuredMesh{2}}, boundary_conditions::NTuple{4, Any}) - if isperiodic(mesh, 1) && - (boundary_conditions[1] != BoundaryConditionPeriodic() || - boundary_conditions[2] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh, 2) && - (boundary_conditions[3] != BoundaryConditionPeriodic() || - boundary_conditions[4] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end + check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], + boundary_conditions[2]) + check_periodicity_mesh_boundary_conditions_y(mesh, boundary_conditions[3], + boundary_conditions[4]) end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, StructuredMesh{3}}, boundary_conditions::NamedTuple) @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - if isperiodic(mesh, 1) && - (x_neg != BoundaryConditionPeriodic() || - x_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh, 2) && - (y_neg != BoundaryConditionPeriodic() || - y_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh, 3) && - (z_neg != BoundaryConditionPeriodic() || - z_pos != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end + check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) + check_periodicity_mesh_boundary_conditions_y(mesh, y_neg, y_pos) + check_periodicity_mesh_boundary_conditions_z(mesh, z_neg, z_pos) end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, StructuredMesh{3}}, boundary_conditions::NTuple{6, Any}) - @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - if isperiodic(mesh, 1) && - (boundary_conditions[1] != BoundaryConditionPeriodic() || - boundary_conditions[2] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in x-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh, 2) && - (boundary_conditions[3] != BoundaryConditionPeriodic() || - boundary_conditions[4] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in y-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end - if isperiodic(mesh, 3) && - (boundary_conditions[5] != BoundaryConditionPeriodic() || - boundary_conditions[6] != BoundaryConditionPeriodic()) - @error "For periodic mesh non-periodic boundary conditions in z-direction are supplied. - The boundary conditions will be ignored and periodic boundary conditions are used." - end + check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], + boundary_conditions[2]) + check_periodicity_mesh_boundary_conditions_y(mesh, boundary_conditions[3], + boundary_conditions[4]) + check_periodicity_mesh_boundary_conditions_z(mesh, boundary_conditions[5], + boundary_conditions[6]) end function Base.show(io::IO, semi::SemidiscretizationHyperbolic) From 4ac44f0a47d26442bfa4173648814c7bb726b03f Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 15:59:51 +0100 Subject: [PATCH 09/12] shorten --- .../semidiscretization_hyperbolic.jl | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 64eb752aea5..72770d7f9bd 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -252,29 +252,18 @@ end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, StructuredMesh{1}}, - boundary_conditions::NamedTuple) - @unpack x_neg, x_pos = boundary_conditions - check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) -end - -function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, - StructuredMesh{1}}, - boundary_conditions::NTuple{2, Any}) + boundary_conditions::Union{NamedTuple, + NTuple{2, + Any}}) check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], boundary_conditions[2]) end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, StructuredMesh{2}}, - boundary_conditions::NamedTuple) - @unpack x_neg, x_pos, y_neg, y_pos = boundary_conditions - check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) - check_periodicity_mesh_boundary_conditions_y(mesh, y_neg, y_pos) -end - -function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, - StructuredMesh{2}}, - boundary_conditions::NTuple{4, Any}) + boundary_conditions::Union{NamedTuple, + NTuple{4, + Any}}) check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], boundary_conditions[2]) check_periodicity_mesh_boundary_conditions_y(mesh, boundary_conditions[3], @@ -283,16 +272,9 @@ end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, StructuredMesh{3}}, - boundary_conditions::NamedTuple) - @unpack x_neg, x_pos, y_neg, y_pos, z_neg, z_pos = boundary_conditions - check_periodicity_mesh_boundary_conditions_x(mesh, x_neg, x_pos) - check_periodicity_mesh_boundary_conditions_y(mesh, y_neg, y_pos) - check_periodicity_mesh_boundary_conditions_z(mesh, z_neg, z_pos) -end - -function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, - StructuredMesh{3}}, - boundary_conditions::NTuple{6, Any}) + boundary_conditions::Union{NamedTuple, + NTuple{6, + Any}}) check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], boundary_conditions[2]) check_periodicity_mesh_boundary_conditions_y(mesh, boundary_conditions[3], From 90e0bba2bb47d620684ea445a23a8a75f66fda0a Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 16:34:29 +0100 Subject: [PATCH 10/12] Make meshes non-periodic --- .../structured_2d_dgsem/elixir_advection_coupled.jl | 12 ++++++++---- .../structured_2d_dgsem/elixir_euler_warm_bubble.jl | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_advection_coupled.jl b/examples/structured_2d_dgsem/elixir_advection_coupled.jl index 43b68f21b03..0002bb8d374 100644 --- a/examples/structured_2d_dgsem/elixir_advection_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_advection_coupled.jl @@ -53,7 +53,8 @@ cells_per_dimension = (8, 8) coordinates_min1 = (-1.0, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y)) -mesh1 = StructuredMesh(cells_per_dimension, coordinates_min1, coordinates_max1) +mesh1 = StructuredMesh(cells_per_dimension, coordinates_min1, coordinates_max1, + periodicity = false) # Define the coupling functions coupling_function12 = (x, u, equations_other, equations_own) -> u @@ -84,7 +85,8 @@ semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_converg coordinates_min2 = (0.0, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max2 = (1.0, 1.0) # maximum coordinates (max(x), max(y)) -mesh2 = StructuredMesh(cells_per_dimension, coordinates_min2, coordinates_max2) +mesh2 = StructuredMesh(cells_per_dimension, coordinates_min2, coordinates_max2, + periodicity = false) # Define the coupling functions coupling_function21 = (x, u, equations_other, equations_own) -> u @@ -115,7 +117,8 @@ semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_converg coordinates_min3 = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) coordinates_max3 = (0.0, 0.0) # maximum coordinates (max(x), max(y)) -mesh3 = StructuredMesh(cells_per_dimension, coordinates_min3, coordinates_max3) +mesh3 = StructuredMesh(cells_per_dimension, coordinates_min3, coordinates_max3, + periodicity = false) # Define the coupling functions coupling_function34 = (x, u, equations_other, equations_own) -> u @@ -146,7 +149,8 @@ semi3 = SemidiscretizationHyperbolic(mesh3, equations, initial_condition_converg coordinates_min4 = (0.0, -1.0) # minimum coordinates (min(x), min(y)) coordinates_max4 = (1.0, 0.0) # maximum coordinates (max(x), max(y)) -mesh4 = StructuredMesh(cells_per_dimension, coordinates_min4, coordinates_max4) +mesh4 = StructuredMesh(cells_per_dimension, coordinates_min4, coordinates_max4, + periodicity = false) # Define the coupling functions coupling_function43 = (x, u, equations_other, equations_own) -> u diff --git a/examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl b/examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl index 05c09d57530..38b9386e94e 100644 --- a/examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl +++ b/examples/structured_2d_dgsem/elixir_euler_warm_bubble.jl @@ -100,7 +100,8 @@ coordinates_min = (0.0, 0.0) coordinates_max = (20_000.0, 10_000.0) cells_per_dimension = (64, 32) -mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) +mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, + periodicity = (true, false)) semi = SemidiscretizationHyperbolic(mesh, equations, warm_bubble_setup, solver, source_terms = warm_bubble_setup, From 6c35218ad55e969b0c752aaacdf620217ffae1c3 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 6 Mar 2024 17:07:43 +0100 Subject: [PATCH 11/12] fix rti --- .../elixir_euler_rayleigh_taylor_instability.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl index 6c254e8bd8b..dd0cc339b20 100644 --- a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl @@ -69,7 +69,7 @@ mapping(xi, eta) = SVector(0.25 * 0.5 * (1.0 + xi), 0.5 * (1.0 + eta)) num_elements_per_dimension = 32 cells_per_dimension = (num_elements_per_dimension, num_elements_per_dimension * 4) -mesh = StructuredMesh(cells_per_dimension, mapping) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = false) initial_condition = initial_condition_rayleigh_taylor_instability boundary_conditions = (x_neg = boundary_condition_slip_wall, From 2b475779229d19cdb23a55a6518c7e41e67102af Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Thu, 7 Mar 2024 08:34:48 +0100 Subject: [PATCH 12/12] shorten dispatch --- src/semidiscretization/semidiscretization_hyperbolic.jl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/semidiscretization/semidiscretization_hyperbolic.jl b/src/semidiscretization/semidiscretization_hyperbolic.jl index 72770d7f9bd..f61378a7dca 100644 --- a/src/semidiscretization/semidiscretization_hyperbolic.jl +++ b/src/semidiscretization/semidiscretization_hyperbolic.jl @@ -253,8 +253,7 @@ end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{1}, StructuredMesh{1}}, boundary_conditions::Union{NamedTuple, - NTuple{2, - Any}}) + Tuple}) check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], boundary_conditions[2]) end @@ -262,8 +261,7 @@ end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{2}, StructuredMesh{2}}, boundary_conditions::Union{NamedTuple, - NTuple{4, - Any}}) + Tuple}) check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], boundary_conditions[2]) check_periodicity_mesh_boundary_conditions_y(mesh, boundary_conditions[3], @@ -273,8 +271,7 @@ end function check_periodicity_mesh_boundary_conditions(mesh::Union{TreeMesh{3}, StructuredMesh{3}}, boundary_conditions::Union{NamedTuple, - NTuple{6, - Any}}) + Tuple}) check_periodicity_mesh_boundary_conditions_x(mesh, boundary_conditions[1], boundary_conditions[2]) check_periodicity_mesh_boundary_conditions_y(mesh, boundary_conditions[3],