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

Use GeometryMapping in BCValues #859

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Use GeometryMapping in BCValues #859

wants to merge 3 commits into from

Conversation

KnutAM
Copy link
Member

@KnutAM KnutAM commented Dec 11, 2023

Closes #849

Using GeometryMapping in BCValues slightly reduces code duplication and makes the similarity (and differences) between BCValues and FaceValues clearer. Not sure why faster on construction, but for update! it probably comes from the performance annotations used following the FaceValues setup with inbounds and inlines.

Updated benchmark after #860, values from run 2 below

Construction

  • PR: 18.499 ms (4266 allocations: 93.64 MiB)
  • master: 20.720 ms (4258 allocations: 93.64 MiB)

update!(ch, t)

  • PR: 333.900 μs (18 allocations: 1.47 KiB)
  • master: 373.200 μs (20 allocations: 1.53 KiB)
Benchmark script and results
using Ferrite, BenchmarkTools


grid = generate_grid(Quadrilateral, (1000, 1000))
function make_dh(grid)    
    dh = DofHandler(grid)
    ip = Lagrange{RefQuadrilateral,2}()
    add!(dh, :u, ip^2)
    add!(dh, :v, ip)
    close!(dh)
    return dh
end
dh = make_dh(grid)

function make_ch(dh, grid)
    ch = ConstraintHandler(dh)
    add!(ch, Dirichlet(:u, getfaceset(grid, "right"), Returns(zero(Vec{2}))))
    add!(ch, Dirichlet(:v, getfaceset(grid, "left"), Returns(0.0)))
    close!(ch)
    return ch
end

ch = make_ch(dh, grid)
@btime make_ch($dh, $grid)

update!(ch, 1.0)

@btime update!($ch, 2.0)

#= 
>>> PR
run 1
  18.414 ms (4266 allocations: 93.64 MiB)
  341.900 μs (18 allocations: 1.47 KiB)

run 2
  18.499 ms (4266 allocations: 93.64 MiB)
  333.900 μs (18 allocations: 1.47 KiB)

>>> master
run 1
    22.356 ms (4258 allocations: 93.64 MiB)
  367.800 μs (20 allocations: 1.53 KiB)

run 2
  20.720 ms (4258 allocations: 93.64 MiB)
  373.200 μs (20 allocations: 1.53 KiB)

=#

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cfe3863) 93.28% compared to head (8ac2946) 93.28%.
Report is 2 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #859   +/-   ##
=======================================
  Coverage   93.28%   93.28%           
=======================================
  Files          36       36           
  Lines        5224     5225    +1     
=======================================
+ Hits         4873     4874    +1     
  Misses        351      351           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks edge boundary conditions, right?

src/Dofs/ConstraintHandler.jl Outdated Show resolved Hide resolved
src/FEValues/FaceValues.jl Show resolved Hide resolved
src/FEValues/FaceValues.jl Show resolved Hide resolved
@KnutAM
Copy link
Member Author

KnutAM commented Dec 17, 2023

This breaks edge boundary conditions, right?

That should work fine because we use the appropriate "dof-locations" based on dirichlet_boundarydof_indices(boundary_type)(func_interpol). I didn't check this specifically, but I assume these cases are covered by the test suite.

Co-authored-by: Dennis Ogiermann <termi-official@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use GeometryMapping in BCValues
3 participants