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

Unify DGMultiMesh constructor signature, update overview.md #1386

Merged
merged 12 commits into from
Apr 10, 2023
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ for human readability.
- The macro `@unpack` (re-exported originally from UnPack.jl) is deprecated and
will be removed. Consider using Julia's standard destructuring syntax
`(; a, b) = stuff` instead of `@unpack a, b = stuff`.
- The constructor `DGMultiMesh(dg; cells_per_dimension, kwargs...)` is deprecated
and will be removed. The new constructor `DGMultiMesh(dg, cells_per_dimension; kwargs...)`
does not have `cells_per_dimesion` as a keyword argument.

#### Removed

Expand Down
9 changes: 6 additions & 3 deletions docs/literate/src/files/DGMulti_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ dg = DGMulti(polydeg = 3,
surface_flux = flux_lax_friedrichs,
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))

cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg,
cells_per_dimension=(32, 32), # initial_refinement_level = 5
cells_per_dimension, # initial_refinement_level = 5
coordinates_min=(-2.0, -2.0),
coordinates_max=( 2.0, 2.0),
periodicity=true)
Expand Down Expand Up @@ -75,8 +76,9 @@ dg = DGMulti(polydeg = 3,
surface_flux = flux_lax_friedrichs,
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))

cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg,
cells_per_dimension=(32, 32), # initial_refinement_level = 5
cells_per_dimension, # initial_refinement_level = 5
coordinates_min=(-2.0, -2.0),
coordinates_max=( 2.0, 2.0),
periodicity=true)
Expand Down Expand Up @@ -114,8 +116,9 @@ dg = DGMulti(polydeg = 3,
surface_flux = flux_lax_friedrichs,
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))

cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg,
cells_per_dimension=(32, 32), # initial_refinement_level = 5
cells_per_dimension, # initial_refinement_level = 5
coordinates_min=(-2.0, -2.0),
coordinates_max=( 2.0, 2.0),
periodicity=true)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ different features on different mesh types.
| Feature | [`TreeMesh`](@ref) | [`StructuredMesh`](@ref) | [`UnstructuredMesh2D`](@ref) | [`P4estMesh`](@ref) | [`DGMultiMesh`](@ref) | Further reading
|:-------------------------------------------------------------|:------------------:|:------------------------:|:----------------------------:|:-------------------:|:--------------------------:|:-----------------------------------------
| Spatial dimension | 1D, 2D, 3D | 1D, 2D, 3D | 2D | 2D, 3D | 1D, 2D, 3D |
| Coordinates | Cartesian | curvilinear | curvilinear | curvilinear | affine |
| Coordinates | Cartesian | curvilinear | curvilinear | curvilinear | curvilinear |
| Connectivity | *h*-nonconforming | conforming | conforming | *h*-nonconforming | conforming |
| Element type | line, square, cube | line, quadᵃ, hexᵃ | quadᵃ | quadᵃ, hexᵃ | simplex, quadᵃ, hexᵃ |
| Adaptive mesh refinement | ✅ | ❌ | ❌ | ✅ | ❌ | [`AMRCallback`](@ref)
Expand Down
7 changes: 3 additions & 4 deletions examples/dgmulti_1d/elixir_advection_gauss_sbp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ dg = DGMulti(polydeg = 3,
###############################################################################
# setup the 1D mesh

mesh = DGMultiMesh(dg,
cells_per_dimension=(8,),
coordinates_min=(-1.0,),
coordinates_max=(1.0,),
cells_per_dimension = (8,)
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(-1.0,), coordinates_max=(1.0,),
periodicity=true)

###############################################################################
Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_1d/elixir_euler_flux_diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ equations = CompressibleEulerEquations1D(1.4)
initial_condition = initial_condition_convergence_test
source_terms = source_terms_convergence_test

mesh = DGMultiMesh(dg, cells_per_dimension=(8,),
cells_per_dimension = (8,)
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(-1.0,), coordinates_max=(1.0,), periodicity=true)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg;
source_terms=source_terms)
Expand Down
4 changes: 3 additions & 1 deletion examples/dgmulti_2d/elixir_advection_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ right(x, tol=50*eps()) = abs(x[1] - 1) < tol
bottom(x, tol=50*eps()) = abs(x[2] + 1) < tol
top(x, tol=50*eps()) = abs(x[2] - 1) < tol
is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom)
mesh = DGMultiMesh(dg, cells_per_dimension=(16, 16); is_on_boundary)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary)

# BC types
boundary_condition_left = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.1 * x[2]))
Expand Down
8 changes: 6 additions & 2 deletions examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ top(x, tol=50*eps()) = abs(x[2] - 0.5) < tol
entire_boundary(x, tol=50*eps()) = true
is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom,
:entire_boundary => entire_boundary)
mesh = DGMultiMesh(dg; coordinates_min=(-1.0, -0.5), coordinates_max=(0.0, 0.5),
cells_per_dimension=(16, 16), is_on_boundary)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension;
coordinates_min=(-1.0, -0.5),
coordinates_max=(0.0, 0.5),
is_on_boundary)

# BC types
boundary_condition = BoundaryConditionDirichlet(initial_condition)
Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function initial_condition_sharp_gaussian(x, t, equations::LinearScalarAdvection
end
initial_condition = initial_condition_sharp_gaussian

mesh = DGMultiMesh(dg, cells_per_dimension = (16, 16), periodicity=true)
cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true)
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, dg)

Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function initial_condition_BM_vortex(x, t, equations::CompressibleEulerEquations
end
initial_condition = initial_condition_BM_vortex

mesh = DGMultiMesh(dg, cells_per_dimension=(16, 16),
cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(-0.5, -0.5), coordinates_max=(0.5, 0.5),
periodicity=true)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function initial_condition_kelvin_helmholtz_instability(x, t, equations::Compres
end
initial_condition = initial_condition_kelvin_helmholtz_instability

mesh = DGMultiMesh(dg, cells_per_dimension=(32, 32), periodicity=true)
cells_per_dimension = (32, 32)
mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg)

tspan = (0.0, 1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha))

num_elements = 16
mesh = DGMultiMesh(dg, cells_per_dimension=(num_elements, 4 * num_elements),
cells_per_dimension = (num_elements, 4 * num_elements)
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(0.0, 0.0), coordinates_max=(0.25, 1.0),
periodicity=(true, false))

Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_2d/elixir_euler_weakform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ top_boundary(x, tol=50*eps()) = abs(x[2]-1)<tol
rest_of_boundary(x, tol=50*eps()) = !top_boundary(x, tol)
is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary)

mesh = DGMultiMesh(dg, cells_per_dimension=(8, 8), is_on_boundary=is_on_boundary)
cells_per_dimension = (8, 8)
mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary=is_on_boundary)

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :top => boundary_condition_convergence_test,
Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_2d/elixir_euler_weakform_periodic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ equations = CompressibleEulerEquations2D(1.4)
initial_condition = initial_condition_convergence_test
source_terms = source_terms_convergence_test

mesh = DGMultiMesh(dg, cells_per_dimension = (4, 4), periodicity=true)
cells_per_dimension = (4, 4)
mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms)

Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = Polynomial()
surface_integral = SurfaceIntegralWeakForm(surface_flux),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

mesh = DGMultiMesh(dg, cells_per_dimension=(16, 16),
cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(-2.0, -2.0), coordinates_max=(2.0, 2.0),
periodicity=true)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg)
Expand Down
2 changes: 1 addition & 1 deletion examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = SBP(),
surface_integral = SurfaceIntegralWeakForm(surface_flux),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

mesh = DGMultiMesh(dg, cells_per_dimension=cells_per_dimension,
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(-2.0, -2.0), coordinates_max=(2.0, 2.0),
periodicity=true)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg)
Expand Down
4 changes: 3 additions & 1 deletion examples/dgmulti_2d/elixir_navierstokes_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(

top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol
is_on_boundary = Dict(:top_bottom => top_bottom)
mesh = DGMultiMesh(dg, cells_per_dimension=(16, 16); periodicity=(true, false), is_on_boundary)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=(true, false), is_on_boundary)

# Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion2D`
# since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion2D`)
Expand Down
4 changes: 3 additions & 1 deletion examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = GaussSBP()
top(x, tol=50*eps()) = abs(x[2] - 1) < tol
rest_of_boundary(x, tol=50*eps()) = !top(x, tol)
is_on_boundary = Dict(:top => top, :rest_of_boundary => rest_of_boundary)
mesh = DGMultiMesh(dg, cells_per_dimension=(16, 16); is_on_boundary)

cells_per_dimension = (16, 16)
mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary)

function initial_condition_cavity(x, t, equations::CompressibleEulerEquations2D)
Ma = 0.1
Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_2d/elixir_shallowwater_source_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = SBP(),
surface_integral = SurfaceIntegralWeakForm(surface_flux),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

mesh = DGMultiMesh(dg, cells_per_dimension=(8, 8),
cells_per_dimension = (8, 8)
mesh = DGMultiMesh(dg, cells_per_dimension,
coordinates_min=(0.0, 0.0), coordinates_max=(sqrt(2), sqrt(2)),
periodicity=true)

Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ solver = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynom
surface_integral= SurfaceIntegralWeakForm(surface_flux),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

mesh = DGMultiMesh(solver, cells_per_dimension=(8, 8, 8),
cells_per_dimension = (8, 8, 8)
mesh = DGMultiMesh(solver, cells_per_dimension,
coordinates_min=(-pi, -pi, -pi), coordinates_max=(pi, pi, pi),
periodicity=true)

Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_3d/elixir_euler_weakform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ top_boundary(x, tol=50*eps()) = abs(x[2] - 1) < tol
rest_of_boundary(x, tol=50*eps()) = !top_boundary(x, tol)
is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary)

mesh = DGMultiMesh(dg, cells_per_dimension=(4, 4, 4), is_on_boundary=is_on_boundary)
cells_per_dimension = (4, 4, 4)
mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary=is_on_boundary)

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :top => boundary_condition_convergence_test,
Expand Down
3 changes: 2 additions & 1 deletion examples/dgmulti_3d/elixir_euler_weakform_periodic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ equations = CompressibleEulerEquations3D(1.4)
initial_condition = initial_condition_convergence_test
source_terms = source_terms_convergence_test

mesh = DGMultiMesh(dg, cells_per_dimension=(4, 4, 4), periodicity=true)
cells_per_dimension = (4, 4, 4)
mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg,
source_terms = source_terms)
Expand Down
4 changes: 3 additions & 1 deletion examples/dgmulti_3d/elixir_navierstokes_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(

top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol
is_on_boundary = Dict(:top_bottom => top_bottom)
mesh = DGMultiMesh(dg, cells_per_dimension=(8, 8, 8); periodicity=(true, false, true), is_on_boundary)

cells_per_dimension = (8, 8, 8)
mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=(true, false, true), is_on_boundary)

# Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion3D`
# since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion3D`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = GaussSBP(),

coordinates_min = (-1.0, -1.0, -1.0) .* pi
coordinates_max = ( 1.0, 1.0, 1.0) .* pi
mesh = DGMultiMesh(dg; coordinates_min, coordinates_max,
cells_per_dimension=(8, 8, 8),
periodicity=(true, true, true))
cells_per_dimension = (8, 8, 8)
mesh = DGMultiMesh(dg, cells_per_dimension;
coordinates_min, coordinates_max,
periodicity=(true, true, true))

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, dg)
Expand Down
13 changes: 7 additions & 6 deletions src/solvers/dgmulti/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ function DGMultiMesh(dg::DGMulti{2, Tri}, triangulateIO, boundary_dict::Dict{Sym
return DGMultiMesh(dg, GeometricTermsType(TriangulateIO(), dg), md, boundary_faces)
end

# TODO: DGMulti. Make `cells_per_dimension` a non-keyword argument for easier dispatch.
"""
DGMultiMesh(dg::DGMulti; cells_per_dimension,
DGMultiMesh(dg::DGMulti, cells_per_dimension;
coordinates_min=(-1.0, -1.0), coordinates_max=(1.0, 1.0),
is_on_boundary=nothing,
periodicity=ntuple(_ -> false, NDIMS))
Expand All @@ -166,7 +165,7 @@ the tensor product of the intervals `[coordinates_min[i], coordinates_max[i]]`.
- `is_on_boundary` specifies boundary using a `Dict{Symbol, <:Function}`
- `periodicity` is a tuple of `Bool`s specifying periodicity = `true`/`false` in the (x,y,z) direction.
"""
function DGMultiMesh(dg::DGMulti{NDIMS}; cells_per_dimension,
function DGMultiMesh(dg::DGMulti{NDIMS}, cells_per_dimension;
coordinates_min=ntuple(_ -> -one(real(dg)), NDIMS),
coordinates_max=ntuple(_ -> one(real(dg)), NDIMS),
is_on_boundary=nothing,
Expand Down Expand Up @@ -233,7 +232,7 @@ end
- `filename` is a path specifying a `.mesh` file generated by
[HOHQMesh](https://github.com/trixi-framework/HOHQMesh).
"""
function DGMultiMesh(dg::DGMulti{NDIMS}, filename;
function DGMultiMesh(dg::DGMulti{NDIMS}, filename::String;
periodicity=ntuple(_ -> false, NDIMS)) where {NDIMS}

hohqmesh_data = StartUpDG.read_HOHQMesh(filename)
Expand All @@ -243,8 +242,6 @@ function DGMultiMesh(dg::DGMulti{NDIMS}, filename;
return DGMultiMesh(dg, GeometricTermsType(Curved(), dg), md, boundary_faces)
end

# Todo: DGMulti. Add traits for dispatch on affine/curved meshes here.

# Matrix type for lazy construction of physical differentiation matrices
# Constructs a lazy linear combination of B = ∑_i coeffs[i] * A[i]
struct LazyMatrixLinearCombo{Tcoeffs, N, Tv, TA <: AbstractMatrix{Tv}} <: AbstractMatrix{Tv}
Expand Down Expand Up @@ -364,6 +361,10 @@ end

end # @muladd

# TODO: deprecations introduced in Trixi.jl v0.6
@deprecate DGMultiMesh(dg::DGMulti{NDIMS}; cells_per_dimension, kwargs...) where {NDIMS} DGMultiMesh(dg, cells_per_dimension; kwargs...)

# TODO: deprecations introduced in Trixi.jl v0.5
@deprecate DGMultiMesh(vertex_coordinates, EToV, dg::DGMulti{NDIMS}; kwargs...) where {NDIMS} DGMultiMesh(dg, vertex_coordinates, EToV; kwargs...)
@deprecate DGMultiMesh(triangulateIO, dg::DGMulti{2, Tri}, boundary_dict::Dict{Symbol, Int}; kwargs...) DGMultiMesh(dg, triangulateIO, boundary_dict; kwargs...)