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

Feature t8code: Extending to 3D #1535

Merged
merged 169 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 158 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
db1ea6b
Initial commit for the new feature using t8code as meshing backend.
May 5, 2023
2cac6c9
Delete t8code_2d_dgsem
jmark May 5, 2023
1bb2061
Added new examples and tests. Testing updates for T8code.jl.
May 17, 2023
ba920cd
Merge branch 'feature-t8code' of github.com:trixi-framework/Trixi.jl …
May 17, 2023
1cab250
Worked in the comments.
May 22, 2023
edf6a91
Merge branch 'main' into feature-t8code
jmark May 23, 2023
cdced17
Fixed spelling.
May 23, 2023
d02d32e
Update src/auxiliary/auxiliary.jl
jmark May 24, 2023
7c01df0
Added whitespace in Unions.
May 24, 2023
e6cd1ab
Adapted commented out code block reporting the no. of elements per le…
May 24, 2023
0abdcd9
Added dummy save mesh support for .
May 24, 2023
10ac87d
Added test .
May 24, 2023
349136a
Added to method signature.
May 24, 2023
3e47616
Deleted unnecessary comments.
May 24, 2023
fe6d874
Removed commented out tests.
May 24, 2023
d5d6298
Fixed Morton ordering bug in 2D at mortar interfaces.
May 25, 2023
9c0db6f
Disabled `save_solution` callbacks and added more tests.
May 25, 2023
1440f90
Added more tests.
May 26, 2023
85a34df
Merge branch 'main' into feature-t8code
jmark May 26, 2023
068558f
Updated code according to the review.
May 30, 2023
1fab9b9
Merge branch 'main' into feature-t8code
jmark May 30, 2023
6dcca7b
Merge branch 'main' into feature-t8code
jmark May 31, 2023
497f957
Update src/auxiliary/t8code.jl
jmark Jun 1, 2023
4a958c4
Update src/auxiliary/t8code.jl
jmark Jun 1, 2023
3d869b0
Update src/auxiliary/t8code.jl
jmark Jun 1, 2023
c04b0f0
Update src/auxiliary/t8code.jl
jmark Jun 1, 2023
5396b87
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
095fdbc
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
3222693
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
db52949
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
62cc2b6
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
3ec60f2
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
13169bf
Update src/solvers/dgsem_t8code/containers_2d.jl
jmark Jun 1, 2023
1eb3d4c
Update src/meshes/t8code_mesh.jl
jmark Jun 1, 2023
c3e3869
Code cleanup.
Jun 12, 2023
504b637
Merging.
Jun 12, 2023
25265e3
Updated to [email protected]
Jun 12, 2023
86b6fed
Fixing minor issues.
Jun 12, 2023
12dc4fe
Fixed typo.
Jun 12, 2023
8e118dc
Code cleanup.
Jun 12, 2023
eb3af26
Enabled `set_ghost` in examples.
Jun 13, 2023
0dd6725
Generalized type info in function signature.
Jun 13, 2023
7218b05
Added namespace qualifier.
Jun 13, 2023
aad6321
Updated comments.
Jun 13, 2023
3dea7a1
Refactored code and deleted lots of it.
Jun 13, 2023
518669b
Merge branch 'main' into feature-t8code
Jun 13, 2023
f6f67ad
Removed a copy operation.
Jun 13, 2023
e2069b4
Initial commit.
Jun 13, 2023
12b792c
Fxinig minor bugs.
Jun 14, 2023
ca3797e
Fixed minor typo.
Jun 14, 2023
bc7e219
Added first 3d example and fixed segfault.
Jun 14, 2023
9ee3c21
Added many 3D examples and tests.
Jun 15, 2023
2639fab
Backup.
Jun 19, 2023
dc74b89
Resolving merge conflicts.
Jun 19, 2023
0638d18
Resolving merge conflicts.
Jun 19, 2023
8df37d1
Fixed merging issues.
Jun 19, 2023
6d67075
Adding more tests.
Jun 20, 2023
c9f431d
Fixed some merging issues and formatting.
Jun 20, 2023
7c1357f
Merge branch 'main' into feature-t8code
Jun 20, 2023
27ecb8a
Merge branch 'main' into feature-t8code
jmark Jun 20, 2023
ced89df
Fixed spelling.
Jun 20, 2023
32b6711
Fixed spelling and changed assert macro.
Jun 20, 2023
c450680
Applied automatic formatting.
Jun 20, 2023
5853034
Applied automatic formatting.
Jun 20, 2023
ea65411
Merged with feature-t8code and added more tests, fixed formatting.
Jun 20, 2023
40df56f
Merge branch 'main' into feature-t8code
ranocha Jun 29, 2023
39cb7cc
Merge branch 'main' into feature-t8code
jmark Jul 11, 2023
d238db7
Backup.
Jul 11, 2023
6ac73cf
Removed superfluous outer constructor for T8codeMesh.
Jul 11, 2023
c40b650
Merge branch 'feature-t8code' of github.com:trixi-framework/Trixi.jl …
Jul 11, 2023
1e0fa0c
Added return statement for consistency.
Jul 11, 2023
0adfbe1
Fixed wrong indentation by autoformatter.
Jul 11, 2023
e42f36e
Added comments.
Jul 11, 2023
aedea64
Made sure an exception is thrown.
Jul 14, 2023
27da77e
Merge branch 'main' into feature-t8code
Jul 14, 2023
1456f1f
Changed flags for sc_init for t8code initialization.
Jul 19, 2023
3857cc3
Updated formatting.
Jul 19, 2023
83a5b81
Merge branch 'main' into feature-t8code
jmark Jul 19, 2023
df94655
Workaround for error about calling MPI routines after MPI has been fi…
Jul 20, 2023
a54377b
Merge branch 'feature-t8code' of github.com:trixi-framework/Trixi.jl …
Jul 20, 2023
40d45c9
Upped to T8code v0.4.1.
Jul 21, 2023
4fa4374
Merge branch 'main' into feature-t8code
ranocha Jul 22, 2023
6074e87
Added mpi_finailize_hook for proper memory cleanup.
Jul 24, 2023
766abc9
Added t8code to test_threaded.jl
Jul 24, 2023
99b1282
Merge branch 'feature-t8code' of github.com:trixi-framework/Trixi.jl …
Jul 24, 2023
2891e6f
Merge branch 'main' into feature-t8code
Jul 24, 2023
0d3af2a
Merge branch 'main' of github.com:trixi-framework/Trixi.jl into featu…
Jul 25, 2023
032f69e
Added a `save_mesh_file` call in order to satisfy code coverage.
Jul 25, 2023
104df24
Merge branch 'main' into feature-t8code
Jul 25, 2023
dde2802
Improved finalizer logic for T8coeMesh.
Jul 25, 2023
c9c1c64
Refined code.
Jul 25, 2023
33fced5
Restructured to do blocks.
Jul 25, 2023
b2d97a4
Moved save_mesh_file call to test file.
Jul 25, 2023
19950c8
Fixed spelling error.
Jul 25, 2023
3047e66
Merge branch 'main' into feature-t8code
ranocha Jul 26, 2023
9435b34
Merge branch 'main' into feature-t8code
ranocha Jul 26, 2023
12a20e5
Made sc_finalize optional.
Jul 26, 2023
7f9b0e2
Fixed spelling.
Jul 26, 2023
b8980b3
Merging with feature-t8code.
Jul 26, 2023
7cb972d
Cleaned up examples.
Jul 26, 2023
2c0861f
Updated and cleaned t8code solver codes.
Jul 26, 2023
0e49cb5
Updated tests for t8code 3D code.
Jul 26, 2023
a36001d
Fixed spelling.
Jul 26, 2023
e2599f0
Update elixir_euler_source_terms_nonconforming_unstructured_curved.jl
jmark Jul 26, 2023
a8d5de7
Update elixir_euler_source_terms_nonconforming_unstructured_curved.jl
jmark Jul 26, 2023
090f7d1
Fixed merge conflicts.
Jul 26, 2023
f30a61b
Fixed indentation.
Jul 26, 2023
c6ed4d8
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Jul 26, 2023
f3a68bc
Merge branch 'main' into feature-t8code-3d
ranocha Jul 28, 2023
3acecd9
Merge branch 'main' into feature-t8code-3d
Aug 31, 2023
79ab0cb
Update src/solvers/dgsem_structured/dg_3d.jl
jmark Aug 31, 2023
1453ad5
Update src/solvers/dgsem_t8code/containers_3d.jl
jmark Aug 31, 2023
54655e3
Update src/callbacks_step/amr_dg3d.jl
jmark Aug 31, 2023
0372153
Update examples/t8code_3d_dgsem/elixir_euler_ec.jl
jmark Aug 31, 2023
7a7ccb1
Update examples/t8code_3d_dgsem/elixir_advection_unstructured_curved.jl
jmark Aug 31, 2023
70bf2d3
Update examples/t8code_3d_dgsem/elixir_advection_amr_unstructured_cur…
jmark Aug 31, 2023
5de7c73
Update src/solvers/dgsem_structured/dg_3d.jl
jmark Aug 31, 2023
2246f83
Update src/meshes/t8code_mesh.jl
jmark Aug 31, 2023
7b0baf7
Update src/callbacks_step/analysis_dg3d.jl
jmark Aug 31, 2023
ccdd90e
Update examples/t8code_3d_dgsem/elixir_euler_free_stream.jl
jmark Aug 31, 2023
ed47329
Removed NDIMS from T8codeMesh construction in case of p4est/p8est con…
Aug 31, 2023
ccb2d5e
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Aug 31, 2023
30d8105
Aligned T8codeMesh constructur with other mesh constructors.
Aug 31, 2023
7e932bc
Update examples/t8code_3d_dgsem/elixir_euler_sedov.jl
jmark Aug 31, 2023
641765a
Update examples/t8code_3d_dgsem/elixir_euler_sedov.jl
jmark Aug 31, 2023
7562f7f
Cleanup up.
Aug 31, 2023
488ee97
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Aug 31, 2023
80fe0e6
Added @allocated test.
Aug 31, 2023
1421434
Fixed formatting.
Aug 31, 2023
af06ee9
Merge branch 'main' into feature-t8code-3d
jmark Dec 18, 2023
0026a72
Applied formatter.
Dec 18, 2023
69de363
Merge branch 'main' into feature-t8code-3d
jmark Dec 19, 2023
67381e7
Merge branch 'main' into feature-t8code-3d
Jan 11, 2024
ff56688
Code cleanup.
Jan 11, 2024
ec8c801
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Jan 11, 2024
d3b6746
Merge branch 'main' into feature-t8code-3d
Jan 12, 2024
0bfc644
Removed unused member variable.
Jan 15, 2024
f66d284
Apply suggestions from code review
benegee Jan 15, 2024
edb0fba
suggestions from review
benegee Jan 15, 2024
2374fe5
fix format (strange?)
benegee Jan 15, 2024
a2a1de8
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Jan 15, 2024
8f8d2ad
Added comments to help interpreting the source code.
Jan 15, 2024
c9aad1b
Update src/callbacks_step/amr_dg3d.jl
jmark Jan 15, 2024
20fd85f
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Jan 15, 2024
61160d9
Adhered to unified mesh constructor calling scheme.
Jan 15, 2024
36e41a6
Applied formatter.
Jan 15, 2024
deb02bc
Switched to Float64 instead of Cdouble.
Jan 15, 2024
7ba7b9e
Update src/meshes/t8code_mesh.jl
benegee Jan 15, 2024
d7bf2ef
Refactored negative volume check.
Jan 16, 2024
fbbc7e0
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Jan 16, 2024
7cb90b8
Applied formatter.
Jan 16, 2024
ba442ff
Fixed typo resp. bug.
Jan 16, 2024
40624af
Apply suggestions from code review
benegee Jan 17, 2024
5c7cfbc
add missing allocation checks
benegee Jan 17, 2024
30c6e29
Some refactoring.
Jan 18, 2024
cd7acc5
Deleted msh file.
Jan 18, 2024
52f917e
Fixed a bug.
Jan 18, 2024
c67800a
Code cleanup.
Jan 18, 2024
d7afb24
Ignore gmsh files.
Jan 19, 2024
8f80b76
Removed adapt! from global namespace.
Jan 19, 2024
c6204f1
Added documentation.
Jan 19, 2024
8100cd8
Added @test_warn to test.
Jan 19, 2024
65c4424
Applied formatter.
Jan 19, 2024
28b1244
Apply suggestions from code review
benegee Jan 19, 2024
cae1cbb
Turned @warn to @info.
Jan 19, 2024
e055f5a
Code cleanup and added @deprecated routines in order to avoid breakin…
Jan 19, 2024
38aa10b
Merge branch 'feature-t8code-3d' of github.com:trixi-framework/Trixi.…
Jan 19, 2024
4a1b775
Applied formatter.
Jan 19, 2024
6e79e6a
Added formatter pragmas to avoid ugly formatting.
Jan 19, 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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- p4est_part1
- p4est_part2
- t8code_part1
- t8code_part2
- unstructured_dgmulti
- parabolic
- paper_self_gravitating_gas_dynamics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)
coordinates_min = (-5.0, -5.0)
coordinates_max = (5.0, 5.0)

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

trees_per_dimension = (1, 1)

mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 1)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ isfile(mesh_file) ||
# we can create a t8code mesh.
conn = Trixi.read_inp_p4est(mesh_file, Val(2))

mesh = T8codeMesh{2}(conn, polydeg = 3,
mapping = mapping_flag,
initial_refinement_level = 1)
mesh = T8codeMesh(conn, polydeg = 3,
mapping = mapping_flag,
initial_refinement_level = 1)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)
Expand Down
4 changes: 1 addition & 3 deletions examples/t8code_2d_dgsem/elixir_advection_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ 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))

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

trees_per_dimension = (8, 8)

mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 1)

# A semidiscretization collects data structures and functions for the spatial discretization
Expand Down
52 changes: 15 additions & 37 deletions examples/t8code_2d_dgsem/elixir_advection_nonconforming_flag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,28 @@ f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s))
faces = (f1, f2, f3, f4)
mapping = Trixi.transfinite_mapping(faces)

# Create P4estMesh with 3 x 2 trees and 6 x 4 elements,
# Create T8codeMesh with 3 x 2 trees and 6 x 4 elements,
# approximate the geometry with a smaller polydeg for testing.
trees_per_dimension = (3, 2)
mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
mapping = mapping,
initial_refinement_level = 1)

function adapt_callback(forest,
forest_from,
which_tree,
lelement_id,
ts,
is_family,
num_elements,
elements_ptr)::Cint
vertex = Vector{Cdouble}(undef, 3)

elements = unsafe_wrap(Array, elements_ptr, num_elements)

Trixi.t8_element_vertex_reference_coords(ts, elements[1], 0, pointer(vertex))
# Note: This is actually a `p4est_quadrant_t` which is much bigger than the
# following struct. But we only need the first three fields for our purpose.
struct t8_dquad_t
x::Int32
y::Int32
level::Int8
# [...] # See `p4est.h` in `p4est` for more info.
end

level = Trixi.t8_element_level(ts, elements[1])
# Refine quadrants of each tree at lower left edge to level 4.
function adapt_callback(forest, ltreeid, eclass_scheme, lelemntid, elements, is_family,
user_data)
el = unsafe_load(Ptr{t8_dquad_t}(elements[1]))

# TODO: Make this condition more general.
if vertex[1] < 1e-8 && vertex[2] < 1e-8 && level < 4
if el.x == 0 && el.y == 0 && el.level < 4
# return true (refine)
return 1
else
Expand All @@ -53,26 +50,7 @@ function adapt_callback(forest,
end
end

Trixi.@T8_ASSERT(Trixi.t8_forest_is_committed(mesh.forest)!=0);

# Init new forest.
new_forest_ref = Ref{Trixi.t8_forest_t}()
Trixi.t8_forest_init(new_forest_ref);
new_forest = new_forest_ref[]

# Check out `examples/t8_step4_partition_balance_ghost.jl` in
# https://github.com/DLR-AMR/T8code.jl for detailed explanations.
let set_from = C_NULL, recursive = 1, set_for_coarsening = 0, no_repartition = 0
Trixi.t8_forest_set_user_data(new_forest, C_NULL)
Trixi.t8_forest_set_adapt(new_forest, mesh.forest,
Trixi.@t8_adapt_callback(adapt_callback), recursive)
Trixi.t8_forest_set_balance(new_forest, set_from, no_repartition)
Trixi.t8_forest_set_partition(new_forest, set_from, set_for_coarsening)
Trixi.t8_forest_set_ghost(new_forest, 1, Trixi.T8_GHOST_FACES)
Trixi.t8_forest_commit(new_forest)
end

mesh.forest = new_forest
adapt!(mesh, adapt_callback)

# A semidiscretization collects data structures and functions for the spatial discretization
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ isfile(mesh_file) ||
# we can create a t8code mesh.
conn = Trixi.read_inp_p4est(mesh_file, Val(2))

mesh = T8codeMesh{2}(conn, polydeg = 3,
mapping = mapping_flag,
initial_refinement_level = 2)
mesh = T8codeMesh(conn, polydeg = 3,
mapping = mapping_flag,
initial_refinement_level = 2)

# A semidiscretization collects data structures and functions for the spatial discretization.
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
Expand Down
45 changes: 9 additions & 36 deletions examples/t8code_2d_dgsem/elixir_euler_free_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,17 @@ isfile(mesh_file) ||
# we can create a t8code mesh.
conn = Trixi.read_inp_p4est(mesh_file, Val(2))

mesh = T8codeMesh{2}(conn, polydeg = 3,
mapping = mapping,
initial_refinement_level = 1)

function adapt_callback(forest,
forest_from,
which_tree,
lelement_id,
ts,
is_family,
num_elements,
elements_ptr)::Cint
vertex = Vector{Cdouble}(undef, 3)
mesh = T8codeMesh(conn, polydeg = 3,
mapping = mapping,
initial_refinement_level = 1)

elements = unsafe_wrap(Array, elements_ptr, num_elements)
function adapt_callback(forest, ltreeid, eclass_scheme, lelemntid, elements, is_family,
user_data)
vertex = Vector{Cdouble}(undef, 3)

Trixi.t8_element_vertex_reference_coords(ts, elements[1], 0, pointer(vertex))
Trixi.t8_element_vertex_reference_coords(eclass_scheme, elements[1], 0, vertex)

level = Trixi.t8_element_level(ts, elements[1])
level = Trixi.t8_element_level(eclass_scheme, elements[1])

# TODO: Make this condition more general.
if vertex[1] < 1e-8 && vertex[2] < 1e-8 && level < 3
Expand All @@ -70,26 +62,7 @@ function adapt_callback(forest,
end
end

Trixi.@T8_ASSERT(Trixi.t8_forest_is_committed(mesh.forest)!=0);

# Init new forest.
new_forest_ref = Ref{Trixi.t8_forest_t}()
Trixi.t8_forest_init(new_forest_ref);
new_forest = new_forest_ref[]

# Check out `examples/t8_step4_partition_balance_ghost.jl` in
# https://github.com/DLR-AMR/T8code.jl for detailed explanations.
let set_from = C_NULL, recursive = 1, set_for_coarsening = 0, no_repartition = 0
Trixi.t8_forest_set_user_data(new_forest, C_NULL)
Trixi.t8_forest_set_adapt(new_forest, mesh.forest,
Trixi.@t8_adapt_callback(adapt_callback), recursive)
Trixi.t8_forest_set_balance(new_forest, set_from, no_repartition)
Trixi.t8_forest_set_partition(new_forest, set_from, set_for_coarsening)
Trixi.t8_forest_set_ghost(new_forest, 1, Trixi.T8_GHOST_FACES)
Trixi.t8_forest_commit(new_forest)
end

mesh.forest = new_forest
adapt!(mesh, adapt_callback)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition)))
Expand Down
4 changes: 1 addition & 3 deletions examples/t8code_2d_dgsem/elixir_euler_sedov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

trees_per_dimension = (4, 4)

mesh = T8codeMesh(trees_per_dimension, polydeg = 4,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 2, periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
4 changes: 1 addition & 3 deletions examples/t8code_2d_dgsem/elixir_euler_shockcapturing_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux,
coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

trees_per_dimension = (4, 4)

mesh = T8codeMesh(trees_per_dimension, polydeg = 4,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 2, periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,17 @@ isfile(mesh_file) ||
# we can create a t8code mesh.
conn = Trixi.read_inp_p4est(mesh_file, Val(2))

mesh = T8codeMesh{2}(conn, polydeg = 3,
mapping = mapping_flag,
initial_refinement_level = 1)

function adapt_callback(forest,
forest_from,
which_tree,
lelement_id,
ts,
is_family,
num_elements,
elements_ptr)::Cint
vertex = Vector{Cdouble}(undef, 3)
mesh = T8codeMesh(conn, polydeg = 3,
mapping = mapping_flag,
initial_refinement_level = 1)

elements = unsafe_wrap(Array, elements_ptr, num_elements)
function adapt_callback(forest, ltreeid, eclass_scheme, lelemntid, elements, is_family,
user_data)
vertex = Vector{Cdouble}(undef, 3)

Trixi.t8_element_vertex_reference_coords(ts, elements[1], 0, pointer(vertex))
Trixi.t8_element_vertex_reference_coords(eclass_scheme, elements[1], 0, pointer(vertex))

level = Trixi.t8_element_level(ts, elements[1])
level = Trixi.t8_element_level(eclass_scheme, elements[1])

# TODO: Make this condition more general.
if vertex[1] < 1e-8 && vertex[2] < 1e-8 && level < 2
Expand All @@ -70,26 +62,7 @@ function adapt_callback(forest,
end
end

@assert(Trixi.t8_forest_is_committed(mesh.forest)!=0);

# Init new forest.
new_forest_ref = Ref{Trixi.t8_forest_t}()
Trixi.t8_forest_init(new_forest_ref);
new_forest = new_forest_ref[]

# Check out `examples/t8_step4_partition_balance_ghost.jl` in
# https://github.com/DLR-AMR/T8code.jl for detailed explanations.
let set_from = C_NULL, recursive = 1, set_for_coarsening = 0, no_repartition = 0
Trixi.t8_forest_set_user_data(new_forest, C_NULL)
Trixi.t8_forest_set_adapt(new_forest, mesh.forest,
Trixi.@t8_adapt_callback(adapt_callback), recursive)
Trixi.t8_forest_set_balance(new_forest, set_from, no_repartition)
Trixi.t8_forest_set_partition(new_forest, set_from, set_for_coarsening)
Trixi.t8_forest_set_ghost(new_forest, 1, Trixi.T8_GHOST_FACES)
Trixi.t8_forest_commit(new_forest)
end

mesh.forest = new_forest
adapt!(mesh, adapt_callback)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms,
Expand Down
4 changes: 1 addition & 3 deletions examples/t8code_2d_dgsem/elixir_eulergravity_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ coordinates_max = (2.0, 2.0)

trees_per_dimension = (1, 1)

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

mesh = T8codeMesh(trees_per_dimension, polydeg = 1,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 2)

semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition,
Expand Down
5 changes: 2 additions & 3 deletions examples/t8code_2d_dgsem/elixir_mhd_alfven_wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ initial_condition = initial_condition_convergence_test

# Get the DG approximation space
volume_flux = (flux_central, flux_nonconservative_powell)

solver = DGSEM(polydeg = 4, surface_flux = (flux_hlle, flux_nonconservative_powell),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (0.0, 0.0)
coordinates_max = (sqrt(2.0), sqrt(2.0))

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

trees_per_dimension = (8, 8)

mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 0, periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
6 changes: 3 additions & 3 deletions examples/t8code_2d_dgsem/elixir_mhd_rotor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ isfile(mesh_file) ||
# we can create a t8code mesh.
conn = Trixi.read_inp_p4est(mesh_file, Val(2))

mesh = T8codeMesh{2}(conn, polydeg = 4,
mapping = mapping_twist,
initial_refinement_level = 1)
mesh = T8codeMesh(conn, polydeg = 4,
mapping = mapping_twist,
initial_refinement_level = 1)

boundary_condition = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = Dict(:all => boundary_condition)
Expand Down
4 changes: 1 addition & 3 deletions examples/t8code_2d_dgsem/elixir_shallowwater_source_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ solver = DGSEM(polydeg = 3,
coordinates_min = (0.0, 0.0) # minimum coordinates (min(x), min(y))
coordinates_max = (sqrt(2.0), sqrt(2.0)) # maximum coordinates (max(x), max(y))

mapping = Trixi.coordinates2mapping(coordinates_min, coordinates_max)

trees_per_dimension = (8, 8)

mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
mapping = mapping,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
initial_refinement_level = 1)

# A semidiscretization collects data structures and functions for the spatial discretization
Expand Down
Loading
Loading