Skip to content

Commit

Permalink
isperiodic TreeMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Mar 6, 2024
1 parent 499af54 commit b0f3c88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 115 deletions.
3 changes: 3 additions & 0 deletions src/meshes/tree_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
130 changes: 15 additions & 115 deletions src/semidiscretization/semidiscretization_hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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() ||
Expand All @@ -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())
Expand All @@ -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() ||
Expand All @@ -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() ||
Expand All @@ -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() ||
Expand All @@ -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) &&
Expand Down

0 comments on commit b0f3c88

Please sign in to comment.