[GeoMechanicsApplication] Updating FindNeighboursOfInterfacesProcess#14487
Conversation
avdg81
left a comment
There was a problem hiding this comment.
Hi Gennady,
Thanks a lot for investigating and resolving this issue. I have two minor suggestions that you may want to consider. Please, let me know what you think of them.
| GlobalPointersVector<Element> KeepNeighboursWithHigherLocalDimension(const GlobalPointersVector<Element>& rNeighbourElements, | ||
| const std::size_t InterfaceElementLocalDimension) | ||
| { | ||
| GlobalPointersVector<Element> kept_neighbours; | ||
| for (auto it = rNeighbourElements.ptr_begin(); it != rNeighbourElements.ptr_end(); ++it) { | ||
| if ((**it).GetGeometry().LocalSpaceDimension() > InterfaceElementLocalDimension) { | ||
| kept_neighbours.push_back(*it); | ||
| } | ||
| } | ||
|
|
||
| return kept_neighbours; |
There was a problem hiding this comment.
This helper function is more general than its name suggests. It returns all elements that have a local space dimension that is higher than the given local space dimension. There is nothing specific for neighbors or interface elements here. Perhaps we can reflect that more general nature by renaming a few things? Also, I think we can use an STL algorithm here, e.g.:
| GlobalPointersVector<Element> KeepNeighboursWithHigherLocalDimension(const GlobalPointersVector<Element>& rNeighbourElements, | |
| const std::size_t InterfaceElementLocalDimension) | |
| { | |
| GlobalPointersVector<Element> kept_neighbours; | |
| for (auto it = rNeighbourElements.ptr_begin(); it != rNeighbourElements.ptr_end(); ++it) { | |
| if ((**it).GetGeometry().LocalSpaceDimension() > InterfaceElementLocalDimension) { | |
| kept_neighbours.push_back(*it); | |
| } | |
| } | |
| return kept_neighbours; | |
| GlobalPointersVector<Element> ExtractElementsWithHigherLocalDimension(const GlobalPointersVector<Element>& rElements, | |
| std::size_t LocalSpaceDimension) | |
| { | |
| GlobalPointersVector<Element> result; | |
| std::copy_if(rElements.ptr_begin(), rElements.ptr_end(), std::back_inserter(result), | |
| [LocalSpaceDimension](auto ElementPtr) { | |
| return ElementPtr->GetGeometry().LocalSpaceDimension() > LocalSpaceDimension; | |
| }); | |
| return result; |
What do you think?
There was a problem hiding this comment.
Thank you. You are absolutely right and perhaps, this function will move to utilities later. Used your suggestion.
| r_neighbour_elements = KeepNeighboursWithHigherLocalDimension( | ||
| r_neighbour_elements, interface_element_local_dimension); |
There was a problem hiding this comment.
Now that we no longer have the lambda expression that needed interface_element_local_dimension, we can perhaps move the function call to where we need the value:
| r_neighbour_elements = KeepNeighboursWithHigherLocalDimension( | |
| r_neighbour_elements, interface_element_local_dimension); | |
| r_neighbour_elements = KeepNeighboursWithHigherLocalDimension( | |
| r_neighbour_elements, r_interface_element.GetGeometry().LocalSpaceDimension()); |
There was a problem hiding this comment.
Indeed before it was used in the for loop. changed.
avdg81
left a comment
There was a problem hiding this comment.
Hi Gennady,
Thanks for processing the review suggestions. This PR is ready to go in my opinion. 👍
Please mark the PR with appropriate tags: