-
Notifications
You must be signed in to change notification settings - Fork 92
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
Refactor to use grid and dofhandler interface internally #655
Conversation
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #655 +/- ##
==========================================
- Coverage 92.27% 92.25% -0.02%
==========================================
Files 30 30
Lines 4594 4598 +4
==========================================
+ Hits 4239 4242 +3
- Misses 355 356 +1
☔ View full report in Codecov by Sentry. |
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.
LGTM
(But I think it would make sense to use getcelltype
in a few places)
Co-authored-by: Knut Andreas Meyer <knutam@gmail.com>
Seems like I forgot some lines. Your suggestion pointed me to them. Thanks! |
src/iterators.jl
Outdated
@@ -113,7 +113,7 @@ cellid(cc::CellCache) = cc.cellid[] | |||
celldofs!(v::Vector, cc::CellCache) = copyto!(v, cc.dofs) # celldofs!(v, cc.dh, cc.cellid[]) | |||
|
|||
# TODO: These should really be replaced with something better... | |||
nfaces(cc::CellCache) = nfaces(eltype(cc.grid.cells)) | |||
nfaces(cc::CellCache) = nfaces(getcelltype(cc.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.
This fails for non-concrete grids, but unrelated to this pr...
But should be relevant for merging of dofhandlers, cc: @kimauth
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.
But should be easy to fix.
nfaces(cc::CellCache) = nfaces(getcelltype(cc.grid)) | |
nfaces(cc::CellCache) = nfaces(getcelltype(cc.grid, cc.cellid.x)) |
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.
Yes, I'm aware of this. Not an issue for merging, as this will still work as long as the grid is concrete (so it works for people who are using DofHandler
now.
Should benchmark that solution, it has the usual problem of extracting an unconcrete cell, which might or might not be an issue.
I think nfaces(fv::FaceValues)
should be used instead in most cases.
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.
Exactly, so I suggest not changing that in this pr!
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 cannot find any remaining dh.grid
in src/
I have to say that I find
much more readable than
. Methods that are typed with |
I disagree with this, you can assemble and solve the heat equation by subtyping |
Actually I do not think that this is a question of readability here (because readability of a user often comes from what he is used to read and write). However, I agree that some methods are specific on our |
Yes, but you are not hitting any of the code paths that (currently) uses
With this I mean that for example Ferrite.jl/src/Dofs/MixedDofHandler.jl Line 82 in b019eea
::MixedDofHandler and not ::AbstractDofHandler -- the interface should be to define ndofs(::MyDofHandler) not to have this specific field: Ferrite.jl/src/Dofs/MixedDofHandler.jl Line 54 in b019eea
|
I think it's the other way around. We are hitting code paths that used to use For |
But you are hitting code paths that uses |
I agree which is why I suggested depreciating xj = get_node_coordinate(grid, nodes[j]) But that should be left for a separate PR. 👍 for this:
For larger functions, I think it makes sense to use the accessor functions even if direct field access can be used, making it easier to generalize if required later. Of course, ideally this should happen at once with a |
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.
LGTM but see the comment about exporting the new names (and various other things).
if interpolation !== default_interpolation(typeof(ch.dh.grid.cells[first(cellset)])) | ||
function _add!(ch::ConstraintHandler, dbc::Dirichlet, bcnodes::Set{Int}, interpolation::Interpolation, field_dim::Int, offset::Int, bcvalue::BCValues, cellset::Set{Int}=Set{Int}(1:getncells(getgrid(ch.dh)))) | ||
grid = getgrid(ch.dh) | ||
if interpolation !== default_interpolation(getcelltype(grid, first(cellset))) |
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.
getcelltype(grid, i)
should probably be typeof(getcell(grid, i)). Although,
getcelltype` can be optimized for homogeneous grids, but not sure that matters.
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 added it because I thought it is a nice convenience which is clearer in the intent.
Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com>
I'll hold #664 until this one is merged (I think that should be the least amount of work regarding conflict resolution) |
First cherry-pick from #486 . Basically uses the interface for the types instead of accessing members of them directly. This is used to allow local views of distributed grids and distributed dof handlers to be used (non-overlapping case!).