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

Rework CellIterator by extracting out the caching part #546

Merged
merged 1 commit into from
Dec 19, 2022
Merged

Conversation

fredrikekre
Copy link
Member

This patch reworks the CellIterator by extracting out the caching parts to its own CellCache struct that can be used independently. Elements of a CellIterator are now CellCache instead of the CellIterator itself.

@fredrikekre fredrikekre added enhancement refactoring Code refactoring, no functional change. labels Dec 5, 2022
@lijas
Copy link
Collaborator

lijas commented Dec 5, 2022

Nice!

Copy link
Collaborator

@lijas lijas left a comment

Choose a reason for hiding this comment

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

Nice

src/Dofs/ConstraintHandler.jl Show resolved Hide resolved
throw(ArgumentError(msg))
end
# reinit! FEValues with CellCache
reinit!(cv::CellValues, cc::CellCache) = reinit!(cv, cc.coords)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally i never liked this method...I think it hides to much information to new users.
Using reinit!(cv, getcoordinates(cc)) is clearer i think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but could be in a cleanup PR, this is just replicating the functionality we already have :)

cellnodes!(cc.nodes, cc.grid, i)
end
if cc.flags.coords
cellcoords!(cc.coords, cc.grid, i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here you can change to getcoordinates, since dh isa DofHandler and has concrete cell type? And we will probably soon deprecate cellcoords!

Copy link
Member Author

Choose a reason for hiding this comment

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

There doesn't seem to be a method of getcoordinates that take a pre-allocated vector as input?

Copy link
Member

@termi-official termi-official Dec 6, 2022

Choose a reason for hiding this comment

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

Copy link
Member

@KnutAM KnutAM Dec 6, 2022

Choose a reason for hiding this comment

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

Edit: Beaten by @termi-official :)
getcoordinates!?

@assert cc.dh isa MixedDofHandler
cc.cellid[] = i
if cc.flags.nodes
resize!(cc.nodes, nnodes_per_cell(cc.dh, i))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is new behavior, since previously we would have gotten an error if we loop over a cellset with different cell types. Maybe this is better 🤔 @kimauth ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the error would just happen later in that case, e.g. when trying to reinit! FE values with the wrong size. The CellIterator(...) approach still checks that all elements have the same type too.

@KnutAM KnutAM mentioned this pull request Dec 15, 2022
3 tasks
This patch reworks the CellIterator by extracting out the caching parts
to its own CellCache struct that can be used independently. Elements of
a CellIterator are now CellCache instead of the CellIterator itself.
@codecov-commenter
Copy link

Codecov Report

Base: 93.02% // Head: 92.26% // Decreases project coverage by -0.76% ⚠️

Coverage data is based on head (1e28a29) compared to base (fcda121).
Patch coverage: 93.97% of modified lines in pull request are covered.

❗ Current head 1e28a29 differs from pull request most recent head b8b6dcf. Consider uploading reports for the commit b8b6dcf to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #546      +/-   ##
==========================================
- Coverage   93.02%   92.26%   -0.77%     
==========================================
  Files          23       22       -1     
  Lines        3973     3530     -443     
==========================================
- Hits         3696     3257     -439     
+ Misses        277      273       -4     
Impacted Files Coverage Δ
src/FEValues/common_values.jl 92.12% <ø> (-0.63%) ⬇️
src/iterators.jl 92.95% <92.64%> (-3.97%) ⬇️
src/Dofs/ConstraintHandler.jl 95.29% <100.00%> (-0.58%) ⬇️
src/Dofs/DofHandler.jl 89.36% <100.00%> (-1.68%) ⬇️
src/L2_projection.jl 100.00% <100.00%> (ø)
src/assembler.jl 98.24% <0.00%> (-1.08%) ⬇️
src/Grid/grid.jl 86.22% <0.00%> (-1.08%) ⬇️
src/Dofs/MixedDofHandler.jl 86.27% <0.00%> (-1.06%) ⬇️
src/PointEval/PointEvalHandler.jl 91.82% <0.00%> (-0.88%) ⬇️
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement refactoring Code refactoring, no functional change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants