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

WIP: Sc/p4est view #1761

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
bb07419
Added coupling converters.
SimonCan Jun 26, 2023
95892bf
Added generic converter_function for structured 2d meshes.
SimonCan Jun 29, 2023
e4f3a2b
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Aug 8, 2023
b2ffe2c
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Aug 10, 2023
53e38ad
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Aug 16, 2023
36380cd
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Sep 22, 2023
b754ea2
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Oct 4, 2023
d3453db
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Oct 19, 2023
e56b65e
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Oct 25, 2023
0470314
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Oct 25, 2023
21b72f6
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Oct 30, 2023
1859121
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Nov 9, 2023
7ec655b
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Nov 15, 2023
185b4fc
Merge branch 'main' of github.com:trixi-framework/Trixi.jl
SimonCan Nov 23, 2023
6fdc714
Added p4est-view.
SimonCan Nov 28, 2023
1a38c0c
Added p4estMeshView to various routines.
SimonCan Nov 28, 2023
ab26c8c
Merge branch 'main' into sc/p4est-view
SimonCan Nov 28, 2023
65a00ba
Added P4estMeshView in further functions.
SimonCan Nov 30, 2023
f1fe6b9
Merge branch 'sc/p4est-view' of github.com:trixi-framework/Trixi.jl i…
SimonCan Nov 30, 2023
a192873
Removed redundant toml files.
SimonCan Jun 27, 2024
40c4e0a
Removed redundant toml files.
SimonCan Jun 27, 2024
8f5216e
Removed redundant files.
SimonCan Jun 27, 2024
675e514
Removed elixir on p4est coupling.
SimonCan Jun 28, 2024
e130946
Removed default coupling converter functions.
SimonCan Jun 28, 2024
6b9783b
Fixed some merge errors.
SimonCan Jun 28, 2024
b8b2573
Fixed merging issues.
SimonCan Jul 1, 2024
bedfd55
Removed redundant p4est-view code.
SimonCan Jul 2, 2024
6503b7f
Merge branch 'main' into sc/p4est-view
SimonCan Jul 4, 2024
7b7900f
Added P4estMeshView.
SimonCan Jul 4, 2024
11190d6
Added P4estMeshView to a few more function as union with P4estMesh.
SimonCan Jul 8, 2024
ba965eb
Removed commented out code.
SimonCan Jul 9, 2024
422f3ee
Merge branch 'main' into sc/p4est-view
SimonCan Jul 9, 2024
7583e09
Spelling error.
SimonCan Jul 9, 2024
44d1b47
Merge branch 'sc/p4est-view' of https://github.com/trixi-framework/Tr…
SimonCan Jul 9, 2024
cf0d84c
Added test eleixir for 0th version of p4estview.
SimonCan Jul 9, 2024
05d2697
Added p4estview test in 2d.
SimonCan Jul 9, 2024
15ccd82
Applied autoformatter.
SimonCan Jul 9, 2024
836fcee
Moved calculation of node coordinates for P4estMeshView.
SimonCan Jul 11, 2024
7e6c25f
Added features to p4estMeshView.
SimonCan Jul 15, 2024
8825868
Added correct boundary names for p4estMeshViews.
SimonCan Jul 16, 2024
8974370
Reverted Project.toml from teststo an older version.
SimonCan Jul 17, 2024
b11698a
Cleaning up of p4estMeshViews.
SimonCan Jul 17, 2024
8f43553
Applied autoformatter.
SimonCan Jul 17, 2024
bd9c156
Merge branch 'main' into sc/p4est-view
SimonCan Jul 17, 2024
b8b992f
Changed mesh anem so that trixi2vtk can read it.
SimonCan Jul 18, 2024
252ba9d
Merge branch 'main' into sc/p4est-view
SimonCan Jul 19, 2024
09c8ee2
Removed redundant isperiodic checking function.
SimonCan Jul 22, 2024
a43e82d
Removed double occurence of function balance!(mesh::P4estMeshView{2}).
SimonCan Jul 22, 2024
e087369
Added optin for p4est write out in coupled simulations.
SimonCan Jul 24, 2024
455d53e
Added system to the mesh file neames for p4est mesh views.
SimonCan Jul 25, 2024
f058b57
Applied autoformatter.
SimonCan Jul 26, 2024
1cdfd88
Added indexed size function for p4est mesh views.
SimonCan Jul 26, 2024
4ee4a73
Changed the p4est mesh view example to two mesh views
SimonCan Jul 29, 2024
e5644bf
Merge branch 'main' into sc/p4est-view
SimonCan Jul 29, 2024
7ab4485
Applied autoformatter.
SimonCan Jul 29, 2024
593a213
Merge branch 'sc/p4est-view' of https://github.com/trixi-framework/Tr…
SimonCan Jul 29, 2024
7cca87a
Corrected trees_per_dimension in p4est mesh views.
SimonCan Aug 1, 2024
c57364d
Updated errors in p4est view test.
SimonCan Aug 1, 2024
7a74a7c
Merge branch 'main' into sc/p4est-view
SimonCan Aug 2, 2024
4ea94ce
Merge branch 'main' into sc/p4est-view
SimonCan Aug 14, 2024
2724abe
Commented constructor of P4estMeshView.
SimonCan Aug 15, 2024
9cd7528
Merge branch 'main' into sc/p4est-view
SimonCan Aug 20, 2024
f8c51cd
Merge branch 'main' into sc/p4est-view
SimonCan Aug 22, 2024
609b42b
Merge branch 'main' into sc/p4est-view
SimonCan Aug 23, 2024
55b3ee7
Removed unused code.
SimonCan Aug 23, 2024
a9c791d
Merge branch 'main' into sc/p4est-view
SimonCan Aug 23, 2024
b86cf32
Merge branch 'main' into sc/p4est-view
SimonCan Sep 2, 2024
841b36b
Merge branch 'main' into sc/p4est-view
SimonCan Sep 4, 2024
3800513
Merge branch 'main' into sc/p4est-view
SimonCan Sep 16, 2024
ad63556
Applied autoformatter.
SimonCan Sep 16, 2024
8937073
Changes to reflect NDIMS_AMBIENT in p4est.
SimonCan Sep 17, 2024
4a0d004
Merge branch 'main' into sc/p4est-view
SimonCan Sep 19, 2024
234f11f
Applied autoformatter.
SimonCan Sep 19, 2024
763220c
Merge branch 'sc/p4est-view' of https://github.com/trixi-framework/Tr…
SimonCan Sep 19, 2024
7f54554
Merge branch 'main' into sc/p4est-view
SimonCan Oct 8, 2024
81d836e
Applied autoformatter.
SimonCan Oct 8, 2024
820cf13
Removed the option of writing mesh files for different time steps.
SimonCan Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions examples/p4est_2d_dgsem/elixir_advection_p4estview.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# The same setup as tree_2d_dgsem/elixir_advection_basic.jl
# to verify the StructuredMesh implementation against TreeMesh

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the linear advection equation

advection_velocity = (0.2, -0.7)
equations = LinearScalarAdvectionEquation2D(advection_velocity)

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)

coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y))
coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y))

trees_per_dimension = (8, 8)

# Create P4estMesh with 8 x 8 trees and 16 x 16 elements and the mesh views
parent_mesh = P4estMesh(trees_per_dimension, polydeg = 3,
coordinates_min = coordinates_min,
coordinates_max = coordinates_max,
initial_refinement_level = 1, periodicity = (false, true))
mesh1 = P4estMeshView(parent_mesh; indices_min = (1, 1), indices_max = (4, 8),
coordinates_min = coordinates_min, coordinates_max = (0.0, 1.0),
periodicity = (false, true))
mesh2 = P4estMeshView(parent_mesh; indices_min = (5, 1), indices_max = (8, 8),
coordinates_min = (0.0, -1.0), coordinates_max = coordinates_max,
periodicity = (false, true))

boundary_conditions = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition_convergence_test),
:x_pos => BoundaryConditionDirichlet(initial_condition_convergence_test))

# A semidiscretization collects data structures and functions for the spatial discretization
semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_convergence_test,
solver, boundary_conditions = boundary_conditions)
semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_convergence_test,
solver, boundary_conditions = boundary_conditions)

# Create a semidiscretization that bundles semi1 and semi2
semi = SemidiscretizationCoupled(semi1, semi2)

###############################################################################
# ODE solvers, callbacks etc.

# Create ODE problem with time span from 0.0 to 1.0
ode = semidiscretize(semi, (0.0, 1.0));

# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
# and resets the timers
summary_callback = SummaryCallback()

# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_callback1 = AnalysisCallback(semi1, interval = 100)
analysis_callback2 = AnalysisCallback(semi2, interval = 100)
analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2)

# The SaveSolutionCallback allows to save the solution to a file in regular intervals
save_solution = SaveSolutionCallback(interval = 100,
solution_variables = cons2prim)

# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
stepsize_callback = StepsizeCallback(cfl = 1.6)

# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,
stepsize_callback)

###############################################################################
# run the simulation

# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);

# Print the timer summary
summary_callback()
2 changes: 1 addition & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export lake_at_rest_error
export ncomponents, eachcomponent

export TreeMesh, StructuredMesh, StructuredMeshView, UnstructuredMesh2D, P4estMesh,
T8codeMesh
P4estMeshView, T8codeMesh

export DG,
DGSEM, LobattoLegendreBasis,
Expand Down
19 changes: 12 additions & 7 deletions src/callbacks_step/analysis_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ end
function create_cache_analysis(analyzer,
mesh::Union{StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D,
P4estMesh{2}, T8codeMesh{2}},
P4estMesh{2}, P4estMeshView{2},
T8codeMesh{2}},
equations, dg::DG, cache,
RealT, uEltype)

Expand Down Expand Up @@ -109,7 +110,8 @@ end

function calc_error_norms(func, u, t, analyzer,
mesh::Union{StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D, P4estMesh{2}, T8codeMesh{2}},
UnstructuredMesh2D, P4estMesh{2},
P4estMeshView{2}, T8codeMesh{2}},
equations,
initial_condition, dg::DGSEM, cache, cache_analysis)
@unpack vandermonde, weights = analyzer
Expand Down Expand Up @@ -179,6 +181,7 @@ end
function integrate_via_indices(func::Func, u,
mesh::Union{StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D, P4estMesh{2},
P4estMeshView{2},
T8codeMesh{2}},
equations,
dg::DGSEM, cache, args...; normalize = true) where {Func}
Expand Down Expand Up @@ -208,7 +211,8 @@ end

function integrate(func::Func, u,
mesh::Union{TreeMesh{2}, StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D, P4estMesh{2}, T8codeMesh{2}},
UnstructuredMesh2D, P4estMesh{2}, P4estMeshView{2},
T8codeMesh{2}},
equations, dg::DG, cache; normalize = true) where {Func}
integrate_via_indices(u, mesh, equations, dg, cache;
normalize = normalize) do u, i, j, element, equations, dg
Expand All @@ -218,7 +222,7 @@ function integrate(func::Func, u,
end

function integrate(func::Func, u,
mesh::Union{TreeMesh{2}, P4estMesh{2}},
mesh::Union{TreeMesh{2}, P4estMesh{2}, P4estMeshView{2}},
equations, equations_parabolic,
dg::DGSEM,
cache, cache_parabolic; normalize = true) where {Func}
Expand All @@ -237,7 +241,8 @@ end

function analyze(::typeof(entropy_timederivative), du, u, t,
mesh::Union{TreeMesh{2}, StructuredMesh{2}, StructuredMeshView{2},
UnstructuredMesh2D, P4estMesh{2}, T8codeMesh{2}},
UnstructuredMesh2D, P4estMesh{2}, P4estMeshView{2},
T8codeMesh{2}},
equations, dg::DG, cache)
# Calculate ∫(∂S/∂u ⋅ ∂u/∂t)dΩ
integrate_via_indices(u, mesh, equations, dg, cache,
Expand Down Expand Up @@ -282,7 +287,7 @@ end

function analyze(::Val{:l2_divb}, du, u, t,
mesh::Union{StructuredMesh{2}, UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}},
P4estMeshView{2}, T8codeMesh{2}},
equations::IdealGlmMhdEquations2D, dg::DGSEM, cache)
@unpack contravariant_vectors = cache.elements
integrate_via_indices(u, mesh, equations, dg, cache, cache,
Expand Down Expand Up @@ -350,7 +355,7 @@ end

function analyze(::Val{:linf_divb}, du, u, t,
mesh::Union{StructuredMesh{2}, UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}},
P4estMeshView{2}, T8codeMesh{2}},
equations::IdealGlmMhdEquations2D, dg::DGSEM, cache)
@unpack derivative_matrix, weights = dg.basis
@unpack contravariant_vectors = cache.elements
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks_step/save_solution_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function save_solution_file(u, time, dt, timestep,
mesh::Union{SerialTreeMesh, StructuredMesh,
StructuredMeshView,
UnstructuredMesh2D, SerialP4estMesh,
SerialT8codeMesh},
P4estMeshView, SerialT8codeMesh},
equations, dg::DG, cache,
solution_callback,
element_variables = Dict{Symbol, Any}(),
Expand Down
4 changes: 2 additions & 2 deletions src/callbacks_step/stepsize_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ end

function max_dt(u, t,
mesh::Union{StructuredMesh{2}, UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}, StructuredMeshView{2}},
T8codeMesh{2}, StructuredMeshView{2}, P4estMeshView{2}},
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
Expand Down Expand Up @@ -113,7 +113,7 @@ end

function max_dt(u, t,
mesh::Union{StructuredMesh{2}, UnstructuredMesh2D, P4estMesh{2},
T8codeMesh{2}, StructuredMeshView{2}},
T8codeMesh{2}, StructuredMeshView{2}, P4estMeshView{2}},
constant_speed::True, equations, dg::DG, cache)
@unpack contravariant_vectors, inverse_jacobian = cache.elements

Expand Down
1 change: 1 addition & 0 deletions src/meshes/meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include("unstructured_mesh.jl")
include("face_interpolant.jl")
include("transfinite_mappings_3d.jl")
include("p4est_mesh.jl")
include("p4est_mesh_view.jl")
include("t8code_mesh.jl")
include("mesh_io.jl")
include("dgmulti_meshes.jl")
Expand Down
1 change: 1 addition & 0 deletions src/meshes/p4est_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ end

@inline Base.ndims(::P4estMesh{NDIMS}) where {NDIMS} = NDIMS
@inline Base.real(::P4estMesh{NDIMS, RealT}) where {NDIMS, RealT} = RealT
@inline Base.size(mesh::P4estMesh) = size(mesh.tree_node_coordinates)[end]

@inline function ntrees(mesh::P4estMesh)
return mesh.p4est.trees.elem_count[]
Expand Down
Loading
Loading