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

[ModelPart] support for range based loops #266

Merged
merged 5 commits into from
Aug 31, 2021
Merged

Conversation

philbucher
Copy link
Member

@philbucher philbucher commented Aug 25, 2021

I find it quite annoying that in order to loop the nodes one has to do:

for (auto node_it=model_part.NodesBegin(); node_it!=model_part.NodesEnd(); ++node_it) {
    (*node_it)->Id()
}

this PR adds support for range based loops:

for (auto& r_node : model_part.Nodes()) {
    r_node->Id()
    // r_node.Id() // this is done using boost::indirect_iterator in Kratos. 
    // We could implement our own iterator but not sure if it is worth it ...
}

lets discuss the implementation

@philbucher
Copy link
Member Author

we decided to adapt the dereferencing iterator (i.e. the same that boost::indirect_iterator does) from the PointerHashMapSet of Kratos

@philbucher philbucher merged commit cf03bff into master Aug 31, 2021
@philbucher philbucher deleted the model-part-range-loop branch August 31, 2021 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant