VectorTools::interpolate: Make common case of vector problem faster #16843
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In several applications, I have observed that
VectorTools::interpolate
is quite slow, most recently when looking at ourtiming-step_68
benchmark case. The reason is that we ask aDoFHandler
'sFESystem
for the generalized support points and mix/match the local results insidedealii/include/deal.II/numerics/vector_tools_interpolate.templates.h
Lines 396 to 397 in c76154b
dealii/source/fe/fe_system.cc
Lines 2674 to 2693 in c76154b
This is quite expensive and involves a lot of memory allocations. While we can't change the underlying interfaces easily, we can at least detect when the
FiniteElement
consists of a single base element that has support points, in which case we can just pick up the values directly without the indirections.While there, also avoid some
dynamic_cast
to detect the case ofFESystem
recursively: We can usen_base_elements()
for that query.