Skip to content
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

Check BCs for periodicity for periodic Tree & Structured meshes #1860

Merged
94 changes: 94 additions & 0 deletions src/semidiscretization/semidiscretization_hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
ranocha marked this conversation as resolved.
Show resolved Hide resolved

SemidiscretizationHyperbolic{typeof(mesh), typeof(equations),
typeof(initial_condition),
typeof(_boundary_conditions), typeof(source_terms),
Expand Down Expand Up @@ -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.
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved
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
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved

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
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved

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
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved

function Base.show(io::IO, semi::SemidiscretizationHyperbolic)
@nospecialize semi # reduce precompilation time

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
ranocha marked this conversation as resolved.
Show resolved Hide resolved

cache_parabolic = (;
create_cache_parabolic(mesh, equations, equations_parabolic,
solver, solver_parabolic, RealT,
Expand Down
Loading