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

Combine interpolating fields in one operation #6202

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gassmoeller
Copy link
Member

@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:

  • evaluate the solution at the support points of the current compositional field
  • evaluate the material model at the support points incl. prescribed outputs for all fields
  • only write the material model output for the current field into the solution vector

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:

  • the order in which we solve/interpolate compositional fields now changes if prescribed fields are mixed in between "normal" fields, but this doesnt matter much, because the current linearization point for all fields is only updated once all fields are solved (to avoid inconsistent time stepping / reactions between them). So the reordering of fields will only affect the screen and statistics output
  • the fields may have different finite elements. I solved this the same way we do in the function compute_reactions, by collecting all support points of all fields and creating a combined quadrature for all of them. I refactored the code from compute_reactions into its own function to avoid duplicating it.
  • if we interpolate several compositional fields at the same time we need to change the screen output, it now no longer prints the field name

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.

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

Successfully merging this pull request may close these issues.

1 participant