Skip to content

Commit

Permalink
Merge branch 'trixi-framework:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ArseniyKholod authored May 9, 2023
2 parents 988d6b1 + 7dd4232 commit 16d93b9
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: Checkout Actions Repository
uses: actions/checkout@v3
- name: Check spelling
uses: crate-ci/[email protected].8
uses: crate-ci/[email protected].9
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Trixi"
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"]
version = "0.5.20-pre"
version = "0.5.23-pre"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
Expand All @@ -21,6 +21,7 @@ Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
P4est = "7d669430-f675-4ae7-b43e-fab78ec5a902"
Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down Expand Up @@ -58,6 +59,7 @@ Octavian = "0.3.5"
OffsetArrays = "1.3"
P4est = "0.4"
Polyester = "0.3.4, 0.5, 0.6, 0.7"
PrecompileTools = "1.1"
RecipesBase = "1.1"
Reexport = "1.0"
Requires = "1.1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ cd Trixi.jl
mkdir run
cd run
julia --project=. -e 'using Pkg; Pkg.develop(PackageSpec(path=".."))' # Install local Trixi.jl clone
julia -e 'using Pkg; Pkg.add(["OrdinaryDiffEq", "Trixi2Vtk", "Plots"])' # Install additional packages
julia --project=. -e 'using Pkg; Pkg.add(["OrdinaryDiffEq", "Trixi2Vtk", "Plots"])' # Install additional packages
```
Note that the postprocessing tools Trixi2Vtk.jl and Plots.jl are optional and
can be omitted.
Expand Down
92 changes: 51 additions & 41 deletions src/auxiliary/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
# Since these FMAs can increase the performance of many numerical algorithms,
# we need to opt-in explicitly.
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
@muladd begin


#=
The code contained in this file is inspired by an analysis performed
using SnoopCompile, although most of it is written manually.
Expand Down Expand Up @@ -347,7 +340,7 @@ function _precompile_manual_()
# end
@assert Base.precompile(Tuple{typeof(SummaryCallback)})
@assert Base.precompile(Tuple{DiscreteCallback{typeof(Trixi.summary_callback), typeof(Trixi.summary_callback), typeof(Trixi.initialize_summary_callback), typeof(SciMLBase.FINALIZE_DEFAULT)}})
@assert Base.precompile(Tuple{typeof(summary_box),typeof(stdout),String,Vector{Pair{String, Any}}})
@assert Base.precompile(Tuple{typeof(summary_box),Base.TTY,String,Vector{Pair{String, Any}}})
# TODO: AMRCallback, ControllerThreeLevel, indicators

# init_elements, interfaces, etc.
Expand All @@ -359,40 +352,44 @@ function _precompile_manual_()
# 1D, serial
@assert Base.precompile(Tuple{typeof(Trixi.init_boundaries),Array{Int,1},TreeMesh{1,Trixi.SerialTree{1}},Trixi.ElementContainer1D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_interfaces),Array{Int,1},TreeMesh{1,Trixi.SerialTree{1}},Trixi.ElementContainer1D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.save_mesh_file),TreeMesh{1,Trixi.SerialTree{1}},String})

# 2D, serial
@assert Base.precompile(Tuple{typeof(Trixi.init_boundaries),Array{Int,1},TreeMesh{2,Trixi.SerialTree{2}},Trixi.ElementContainer2D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_interfaces),Array{Int,1},TreeMesh{2,Trixi.SerialTree{2}},Trixi.ElementContainer2D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_mortars),Array{Int,1},TreeMesh{2,Trixi.SerialTree{2}},Trixi.ElementContainer2D{RealT,uEltype},mortar_type})
@assert Base.precompile(Tuple{typeof(Trixi.save_mesh_file),TreeMesh{2,Trixi.SerialTree{2}},String})

# 2D, parallel
@assert Base.precompile(Tuple{typeof(Trixi.init_boundaries),Array{Int,1},TreeMesh{2,Trixi.ParallelTree{2}},Trixi.ElementContainer2D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_interfaces),Array{Int,1},TreeMesh{2,Trixi.ParallelTree{2}},Trixi.ElementContainer2D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_mortars),Array{Int,1},TreeMesh{2,Trixi.ParallelTree{2}},Trixi.ElementContainer2D{RealT,uEltype},mortar_type})
@assert Base.precompile(Tuple{typeof(Trixi.init_mpi_interfaces),Array{Int,1},TreeMesh{2,Trixi.ParallelTree{2}},Trixi.ElementContainer2D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.save_mesh_file),TreeMesh{2,Trixi.ParallelTree{2}},String})

# 3D, serial
@assert Base.precompile(Tuple{typeof(Trixi.init_boundaries),Array{Int,1},TreeMesh{3,Trixi.SerialTree{3}},Trixi.ElementContainer3D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_interfaces),Array{Int,1},TreeMesh{3,Trixi.SerialTree{3}},Trixi.ElementContainer3D{RealT,uEltype}})
@assert Base.precompile(Tuple{typeof(Trixi.init_mortars),Array{Int,1},TreeMesh{3,Trixi.SerialTree{3}},Trixi.ElementContainer3D{RealT,uEltype},mortar_type})
@assert Base.precompile(Tuple{typeof(Trixi.save_mesh_file),TreeMesh{3,Trixi.SerialTree{3}},String})
end

# various `show` methods
for RealT in (Float64,)
# meshes
for NDIMS in 1:3
# serial
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),TreeMesh{NDIMS,Trixi.SerialTree{NDIMS}}})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",TreeMesh{NDIMS,Trixi.SerialTree{NDIMS}}})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,TreeMesh{NDIMS,Trixi.SerialTree{NDIMS}}})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",TreeMesh{NDIMS,Trixi.SerialTree{NDIMS}}})
# parallel
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),TreeMesh{NDIMS,Trixi.ParallelTree{NDIMS}}})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",TreeMesh{NDIMS,Trixi.ParallelTree{NDIMS}}})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,TreeMesh{NDIMS,Trixi.ParallelTree{NDIMS}}})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",TreeMesh{NDIMS,Trixi.ParallelTree{NDIMS}}})
end

# equations
for eq_type in equations_types(RealT)
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),eq_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",eq_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,eq_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",eq_type})
end

# mortars, analyzers, adaptors, DG
Expand All @@ -403,61 +400,61 @@ function _precompile_manual_()
analyzer_type = analyzer_type_dgsem(RealT, nnodes_)
adaptor_type = adaptor_type_dgsem(RealT, nnodes_)

@assert Base.precompile(Tuple{typeof(show),typeof(stdout),basis_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",basis_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,basis_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",basis_type})

@assert Base.precompile(Tuple{typeof(show),typeof(stdout),mortar_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",mortar_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,mortar_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",mortar_type})

@assert Base.precompile(Tuple{typeof(show),typeof(stdout),analyzer_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",analyzer_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,analyzer_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",analyzer_type})

@assert Base.precompile(Tuple{typeof(show),typeof(stdout),adaptor_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",adaptor_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,adaptor_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",adaptor_type})

# we could also use more numerical fluxes and volume integral types here
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),DG{basis_type,mortar_type,typeof(flux_lax_friedrichs),VolumeIntegralWeakForm}})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",DG{basis_type,mortar_type,typeof(flux_lax_friedrichs),VolumeIntegralWeakForm}})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,DG{basis_type,mortar_type,typeof(flux_lax_friedrichs),VolumeIntegralWeakForm}})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",DG{basis_type,mortar_type,typeof(flux_lax_friedrichs),VolumeIntegralWeakForm}})
end

# semidiscretizations
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",SemidiscretizationHyperbolic})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",SemidiscretizationHyperbolic})

# callbacks
summary_callback_type = DiscreteCallback{typeof(Trixi.summary_callback),typeof(Trixi.summary_callback),typeof(Trixi.initialize_summary_callback),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),summary_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",summary_callback_type})
@assert Base.precompile(Tuple{summary_callback_type,typeof(stdout)})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,summary_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",summary_callback_type})
@assert Base.precompile(Tuple{summary_callback_type,Base.TTY})

# TODO: SteadyStateCallback, AnalysisCallback

alive_callback_type = DiscreteCallback{AliveCallback,AliveCallback,typeof(Trixi.initialize!),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),alive_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",alive_callback_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,alive_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",alive_callback_type})

restart_callback_type = DiscreteCallback{SaveRestartCallback,SaveRestartCallback,typeof(Trixi.initialize!),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),restart_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",restart_callback_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,restart_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",restart_callback_type})

for solution_variables in (cons2cons, cons2prim)
save_solution_callback_type = DiscreteCallback{SaveSolutionCallback{typeof(solution_variables)},SaveSolutionCallback{typeof(solution_variables)},typeof(Trixi.initialize!),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),save_solution_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",save_solution_callback_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,save_solution_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",save_solution_callback_type})
end

# TODO: AMRCallback

stepsize_callback_type = DiscreteCallback{StepsizeCallback{RealT},StepsizeCallback{RealT},typeof(Trixi.initialize!),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),stepsize_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",stepsize_callback_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,stepsize_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",stepsize_callback_type})

glm_speed_callback_type = DiscreteCallback{GlmSpeedCallback{RealT},GlmSpeedCallback{RealT},typeof(Trixi.initialize!),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),glm_speed_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",glm_speed_callback_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,glm_speed_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",glm_speed_callback_type})

lbm_collision_callback_type = DiscreteCallback{typeof(Trixi.lbm_collision_callback),typeof(Trixi.lbm_collision_callback),typeof(Trixi.initialize!),typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show),typeof(stdout),lbm_collision_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{typeof(stdout)},MIME"text/plain",lbm_collision_callback_type})
@assert Base.precompile(Tuple{typeof(show),Base.TTY,lbm_collision_callback_type})
@assert Base.precompile(Tuple{typeof(show),IOContext{Base.TTY},MIME"text/plain",lbm_collision_callback_type})

# infrastructure, special elixirs
@assert Base.precompile(Tuple{typeof(trixi_include),String})
Expand All @@ -478,4 +475,17 @@ function _precompile_manual_()
end


end # @muladd
# Explicit precompilation running code only on Julia v1.9 and newer
using PrecompileTools: @setup_workload, @compile_workload

@static if VERSION >= v"1.9.0-beta4"
@setup_workload begin
# Setup code can go here

@compile_workload begin
# Everything inside this block will run at precompile time, saving the
# binary code to a cache in newer versions of Julia.
DGSEM(3)
end
end
end
23 changes: 1 addition & 22 deletions src/solvers/dgsem_p4est/dg_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,28 +444,6 @@ function init_neighbor_rank_connectivity_iter_face_inner(info, user_data)
return nothing
end

# Once the TreeMesh supports custom `uEltype`s, the following method could be used for both
# mesh types.
# See https://github.com/trixi-framework/Trixi.jl/pull/977#discussion_r793694635 for further
# discussion.
function init_mpi_data_structures(mpi_neighbor_interfaces, mpi_neighbor_mortars, n_dims, nvars, n_nodes, uEltype)
data_size = nvars * n_nodes^(n_dims - 1)
n_small_elements = 2^(n_dims-1)
mpi_send_buffers = Vector{Vector{uEltype}}(undef, length(mpi_neighbor_interfaces))
mpi_recv_buffers = Vector{Vector{uEltype}}(undef, length(mpi_neighbor_interfaces))
for index in 1:length(mpi_neighbor_interfaces)
mpi_send_buffers[index] = Vector{uEltype}(undef, length(mpi_neighbor_interfaces[index]) * data_size +
length(mpi_neighbor_mortars[index]) * n_small_elements * 2 * data_size)
mpi_recv_buffers[index] = Vector{uEltype}(undef, length(mpi_neighbor_interfaces[index]) * data_size +
length(mpi_neighbor_mortars[index]) * n_small_elements * 2 * data_size)
end

mpi_send_requests = Vector{MPI.Request}(undef, length(mpi_neighbor_interfaces))
mpi_recv_requests = Vector{MPI.Request}(undef, length(mpi_neighbor_interfaces))

return mpi_send_buffers, mpi_recv_buffers, mpi_send_requests, mpi_recv_requests
end


# Exchange normal directions of small elements of the MPI mortars. They are needed on all involved
# MPI ranks to calculate the mortar fluxes.
Expand Down Expand Up @@ -550,4 +528,5 @@ end
include("dg_2d_parallel.jl")
include("dg_3d_parallel.jl")


end # muladd
2 changes: 1 addition & 1 deletion src/solvers/dgsem_tree/containers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function reinitialize_containers!(mesh::TreeMesh, equations, dg::DGSEM, cache)
# re-initialize mpi cache
@unpack mpi_cache = cache
init_mpi_cache!(mpi_cache, mesh, elements, mpi_interfaces, mpi_mortars,
nvariables(equations), nnodes(dg))
nvariables(equations), nnodes(dg), eltype(elements))
end
end

Expand Down
3 changes: 3 additions & 0 deletions src/solvers/dgsem_tree/dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ include("indicators_3d.jl")
# Container data structures
include("containers.jl")

# Dimension-agnostic parallel setup
include("dg_parallel.jl")

# 1D DG implementation
include("dg_1d.jl")
include("dg_1d_parabolic.jl")
Expand Down
Loading

0 comments on commit 16d93b9

Please sign in to comment.