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

Consolidate mesh infrastructure after adding structured and unstructured ones #542

Closed
22 of 23 tasks
ranocha opened this issue Apr 15, 2021 · 1 comment · Fixed by #742
Closed
22 of 23 tasks

Consolidate mesh infrastructure after adding structured and unstructured ones #542

ranocha opened this issue Apr 15, 2021 · 1 comment · Fixed by #742
Labels
documentation Improvements or additions to documentation enhancement New feature or request performance We are greedy visualization

Comments

@ranocha
Copy link
Member

ranocha commented Apr 15, 2021

  • Consistent naming scheme: TreeMesh, StructuredMesh, UnstructuredMesh, P4estMesh... (rename mesh types #676)
  • ... with appropriate type hierarchy (Enrich mesh supertype infrastructure #536)
  • Make a decision on Maybe switch to mappings that accept vectors/tuples for CurvedMesh/P4estMesh #602: Update the signature of mappings (see the issue)
  • Remove the experimental status, add the new meshes to NEWS.md and README.md, including the feature matrix, cf. add feature matrix #703 (new meshes/solvers are stable #742)
  • eachelement, nelements etc. should use the signature eachelement(mesh, dg, cache) (allow passing the mesh to nelements #706)
  • Take care of # TODO: Clean-up meshes
  • Remove type parameters NVARS, POLYDEG from unstructured containers (remove parameters NVARS, POLYDEG from unstructured containers #702)
  • Move stuff to appropriate files (definition of DG to dg_common.jl etc.) (reorganize DG implementations for different meshes #700)
  • Unify the argument order and types of init_elements etc. (When implementing FD methods, I hit the init stuff of the unstructured mesh instead of getting a method error...)
  • Consistent order of arguments: mesh, equations, solver, cache (Trixi on unstructured mesh of 2d curved quads #500 (comment)), in accordance with the style guide. Pass the mesh to lower-level functions called inside rhs!, also for the TreeMesh
  • Consolidate flux functions (Add the type constraint orientation::Integer to every flux function #506) and unify rotation stuff (Trixi on unstructured mesh of 2d curved quads #500 (comment))
  • Choose rules for dispatch on dimension: u, mesh, equations? See Implement dimension dispatch in max_dt on mesh/equations dimensions #515
  • Benchmark performance (runtime, latency) and compare different approaches
  • Proper boundary conditions for the UnstructuredMesh (Unstructured mesh improvements #570)
  • Clean up printing of the BCs for hyperbolic semidiscretizations, cf. Unstructured mesh improvements #570 (comment)
  • Fix all TODO: Meshes
  • Improve visualization (Improve the visualization for curved meshes with Plots.jl #518)
  • Improved performance of boundary conditions for the UnstructuredMesh (unstructured BCs #573, Sort unstructured boundary conditions #583)
    • Right now, the boundary handling is type unstable in general and problematic. A possible solution might be to sort the boundaries by boundary condition to get type stability.
    • Alternatively, we could use function pointers, e.g.
      julia> using BenchmarkTools, StaticArrays
      
      julia> function demo!(output, input, functions, names)
                @inbounds for i in eachindex(output)
                    output[i] = functions[names[i]](input[i])
                end
            end
      demo! (generic function with 1 method)
      
      julia> foo(x) = 2 * x
      foo (generic function with 1 method)
      
      julia> bar(x) = x .^ 2
      bar (generic function with 1 method)
      
      julia> foobar(x) = 2 * x.^2
      foobar (generic function with 1 method)
      
      julia> n = 1000; output = zeros(SVector{3, Float64}, n); input = [@SVector randn(3) for _ in 1:n]; functions = Dict("foo" => foo, "bar" => bar, "foobar" => foobar); names = rand(["foo", "bar", "foobar"], n);
      
      julia> @benchmark demo!($output, $input, $functions, $names)
      BenchmarkTools.Trial:
        memory estimate:  70.14 KiB
        allocs estimate:  2489
        --------------
        minimum time:     53.610 μs (0.00% GC)
        median time:      56.399 μs (0.00% GC)
        mean time:        61.755 μs (2.15% GC)
        maximum time:     1.231 ms (94.52% GC)
        --------------
        samples:          10000
        evals/sample:     1
      
      julia> function_pointers = Dict("foo" => @cfunction(foo, eltype(output), (eltype(input),)), "bar" => @cfunction(bar, eltype(output), (eltype(input),)), "foobar" => @cfunction(foobar, eltype(output), (eltype(input),)))
      Dict{String, Ptr{Nothing}} with 3 entries:
        "bar"    => Ptr{Nothing} @0x00007f8ba6f1dea0
        "foobar" => Ptr{Nothing} @0x00007f8ba6f1e070
        "foo"    => Ptr{Nothing} @0x00007f8ba6f1dcd0
      
      julia> function demo!(output, input, functions::Dict{<:Any, Ptr{Nothing}}, names)
                @inbounds for i in eachindex(output)
                    output[i] = ccall(functions[names[i]], SVector{3,Float64}, (SVector{3,Float64},), input[i])
                end
            end
      demo! (generic function with 2 methods)
      
      julia> @benchmark demo!($output, $input, $function_pointers, $names)
      BenchmarkTools.Trial:
        memory estimate:  0 bytes
        allocs estimate:  0
        --------------
        minimum time:     23.530 μs (0.00% GC)
        median time:      24.439 μs (0.00% GC)
        mean time:        25.886 μs (0.00% GC)
        maximum time:     129.502 μs (0.00% GC)
        --------------
        samples:          10000
        evals/sample:     1
      Note that using Strings as keys comes also with some performance overhead that can be reduced by using Symbols instead.
      julia> functions = Dict(:foo => foo, :bar => bar, :foobar => foobar); names = rand([:foo, :bar, :foobar], n); function_pointers = Dict(:foo => @cfunction(foo, eltype(output), (eltype(input),)), :bar => @cfunction(bar, eltype(output), (eltype(input),)), :foobar => @cfunction(foobar, eltype(output), (eltype(input),)));
      
      julia> @benchmark demo!($output, $input, $functions, $names)
        memory estimate:  70.14 KiB
        allocs estimate:  2489
        --------------
        minimum time:     44.858 μs (0.00% GC)
        median time:      46.790 μs (0.00% GC)
        mean time:        49.364 μs (2.64% GC)
        maximum time:     1.083 ms (95.18% GC)
        --------------
        samples:          10000
        evals/sample:     1
      
      julia> @benchmark demo!($output, $input, $function_pointers, $names)
      BenchmarkTools.Trial:
        memory estimate:  0 bytes
        allocs estimate:  0
        --------------
        minimum time:     15.210 μs (0.00% GC)
        median time:      15.429 μs (0.00% GC)
        mean time:        15.497 μs (0.00% GC)
        maximum time:     32.738 μs (0.00% GC)
        --------------
        samples:          10000
        evals/sample:     1
@ranocha ranocha added documentation Improvements or additions to documentation enhancement New feature or request performance We are greedy visualization labels Apr 15, 2021
@sloede
Copy link
Member

sloede commented Apr 15, 2021

Thanks for creating this overview, this will be very helpful!

@andrewwinters5000 andrewwinters5000 pinned this issue Jun 29, 2021
@ranocha ranocha unpinned this issue Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request performance We are greedy visualization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants