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

A Loop over a CellIterator returns an Object of type CellCache #775

Closed
Firimo opened this issue Jul 28, 2023 · 4 comments
Closed

A Loop over a CellIterator returns an Object of type CellCache #775

Firimo opened this issue Jul 28, 2023 · 4 comments

Comments

@Firimo
Copy link

Firimo commented Jul 28, 2023

Hello,

The Minimal working example looks as follows

using Ferrite

grid = generate_grid(Quadrilateral, (5,5))

for cell in CellIterator(grid)
    @show typeof(cell)
    break
end

where cell is of the typeCellCache. However, I would expect cell to be of the type CellIterator and this used (v0.3.10) to be the standard behavior.

What I am trying to say is, that the real issue is, that v0.3.11 should have been called v0.4.11, since it introduced a breaking change.

Consequently there are two pathways, either the behavior of the CellIterator constructor is changed, or all Ferrite.jl versions dating back to v0.3.11 are renamed v0.4.xx.

Kind regards

P.S.: I believe this issue arises from a function called Base.iterate() found in the file iterators.jl

@fredrikekre
Copy link
Member

Hi and thanks for the report!

I am sorry that you ran into this issue. This was an intentional change (#546) that I didn't imagine would be breaking. For example, as you can see in the PR, it didn't break any of the Ferrite documentation examples which is usually quite similar to "user code". Can you elaborate how it breaks your code? Perhaps you define methods like f(::CellIterator) or something? In that case, fortunately the fix is pretty easy.

Since this is not a very recent change I don't think we can or will revert the releases at this point. If you don't have time to upgrade right now I suggest you pin Ferrite to version 0.3.10 and use that.

@Firimo
Copy link
Author

Firimo commented Jul 28, 2023

Hi @fredrikekre ,

indeed I have read #546 and indeed I use f(::CellIterator). Independent of my personal struggle with version maintenance, it does nonetheless seem rather counter-intuitive from a user perspective to construct a CellIterator and get a CellCache object.

Thanks for your (very) quick answer

@fredrikekre
Copy link
Member

it does nonetheless seem rather counter-intuitive from a user perspective to construct a CellIterator and get a CellCache object.

I disagree. One of the reasons for #546 was actually that the previous behavior was counter-intuitive for many people. For example, if you loop over a vector, the iterates are not the vector itself, but the elements of the vector. Similarly, after #546, the elements of the CellIterator are the CellCaches.

(Also, since you are a Ferrite user I haven't seen before: Welcome! We are hosting a user and developer day on October 6 in Bochum, Germany, and everyone curious about Ferrite is welcome to join, see https://ferrite-fem.github.io/FerriteCon/ for more details.)

@Firimo
Copy link
Author

Firimo commented Jul 28, 2023

Hi @fredrikekre ,

That is, I have to say, a logic I cannot argue against and thanks for the welcoming words, they are receipted gratefully.

Greetings

@Firimo Firimo closed this as completed Jul 28, 2023
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

No branches or pull requests

2 participants