Combine interpolating fields in one operation #6202
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.
@Wang-yijun and @KiralyAgi showed me a model with 36 prescribed compositional fields (a lot of components of a larger tensor), in which the interpolation from material model output into compositional fields took >50% of the total model runtime. This made me look into the algorithm and search for optimization potential. When we prescribe compositional fields from the material model output we currently do the following steps consecutively for each compositional field:
All steps of this operation could be combined for all compositional fields that need to be interpolated, which would save significant time for models with many prescribed fields and expensive material models. This PR implements this change by copying the approach we already take for particles. We essentially collect all fields that are prescribed while looping through the compositional fields and then interpolate all of them together after all other fields have been solved.
Some intricacies:
compute_reactions
, by collecting all support points of all fields and creating a combined quadrature for all of them. I refactored the code fromcompute_reactions
into its own function to avoid duplicating it.First tests by @Wang-yijun (and I could reproduce this) showed that this change reduces the time spent in this algorithm from >50% to <5% of the total model time for her model.