-
Notifications
You must be signed in to change notification settings - Fork 93
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
DofHandler with any <: AbstractGrid #379
Conversation
Codecov Report
@@ Coverage Diff @@
## master #379 +/- ##
=======================================
Coverage 91.50% 91.50%
=======================================
Files 22 22
Lines 3259 3259
=======================================
Hits 2982 2982
Misses 277 277
Continue to review full report at Codecov.
|
Comparing heat equation on master vs this branch on my laptop (subject to a plethora of fluctuations) in order to see if there is a significant performance drawback. Note this is not intended as performance benchmark but rather as a rough estimate if something was utterly needed w.r.t. type instability PR
Master
|
ping @fredrikekre |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase?
src/Dofs/DofHandler.jl
Outdated
|
||
function cellnodes!(global_nodes::Vector{Int}, grid::AbstractGrid{dim}, i::Int) where {dim} | ||
C = getcelltype(grid) | ||
@assert length(global_nodes) == nnodes(C) | ||
for j in 1:nnodes(C) | ||
global_nodes[j] = getcells(grid, i).nodes[j] ##TODO getnodes(::AbstractCell); only vertices(::AbstractCell) available | ||
end | ||
return global_nodes | ||
end | ||
|
||
function cellcoords!(global_coords::Vector{Vec{dim,T}}, grid::AbstractGrid{dim}, i::Int) where {dim,T} | ||
C = getcelltype(grid) | ||
@assert length(global_coords) == nnodes(C) | ||
global_coords .= getcoordinates(grid, i) | ||
return global_coords | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed after the change in https://github.com/Ferrite-FEM/Ferrite.jl/pull/425/files#diff-8db5ed06971ce1004169862f3e499f55666dd630868843be8a53d30ea385e505?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what we really need is:
Ferrite.jl/src/Dofs/DofHandler.jl
Lines 315 to 329 in 81440fa
# shared implementation for all grids | |
function cellcoords!(global_coords::Vector{Vec{dim,T}}, grid::AbstractGrid, cell::C) where {dim,C<:Ferrite.AbstractCell,T} | |
nodes = cell.nodes | |
N = length(nodes) | |
@assert length(global_coords) == N | |
for j in 1:N | |
global_coords[j] = grid.nodes[nodes[j]].x | |
end | |
return global_coords | |
end | |
function cellcoords!(global_coords::Vector{Vec{dim,T}}, grid::AbstractGrid, i) where {dim,T} | |
cell = getcells(grid, i) | |
cellcoords!(global_coords, grid, cell) | |
end |
It's supposed to handle the information for the reinit!
which needs the actual coords for any grid. The functionality can be recovered by using the already defined functions on AbstractGrid
, so getcoordinates
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can either delete the functions completely and wait for Kim's PR or we take the ones from Kim's PR with the slight improvement suggestion I made over there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We almost have this since #425 though (see Fredriks comment above). Why not just make the changes to that one? Allowing AbstractGrid
in the function signature and using getcells
+ getnodes
should literally have no impact on using the function with the regular Grid
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think I misunderstood the comment in the beginning. I changed in the latest commit the functions to work for any <: AbstractGrid
(I hope you meant this @kimauth, otherwise I'll revert it) I had to use the getcoordinates
dispatch for the Node
type as an abstraction in between, otherwise grids always need to use Node
as their node type. In the test example I only used a NTuple{dim}
, but we can also just assume that Node
is always used, if you prefer this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like what I meant.
I think assuming that a node always has a field x
for the coordinate is not too much of a stretch - but considering that we have getcoordinates(node)
it's good to use I guess.
8dec9b7
to
49ce28b
Compare
This PR is in the same spirit of #309 and not such a crowded catastrophe as #307
I added
cellnodes!
andcellcoords!
dispatches forAbstractGrid
that only call the interface function of<:AbstractGrid
. I noticed that this is needed when we did the first<:AbstractGrid
prototype. I'm not sure if these definitions should better live in grid.jl. They assume a concrete homogeneouscells
vector right now, since they are only called byDofHandler
.I'd like to do a follow up PR such that a
CellIterator
also can handle any <:AbstractGrid. Then, we would only need consistent usage of the interface functions and everything should work ootb for properly subtyped grids