When are materials evaluated? #16710
-
Hello, I am trying to figuring out how and when materials are evaluated during a transient simulation using the classical NEWTON scheme. Assume that I have a simple linear stress-strain material for the tensor mechanics module. Within Considering a single element with a single quadrature point, a simple print statement gives me following output:
So, within each time step, the material is evaluated 4 times (!), which seems a lot for a linear simulation.
My questions are:
Thank you in advance ! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
@rwcarlsen might be able to help on this as I think he's looking into this now |
Beta Was this translation helpful? Give feedback.
-
Evaluations 2 and 3 (residual and jac) are indeed a (known) underoptimization in the framework with AD (automatic differentiation) at least. But it looks like you are using material objects that manually calculate a jacobian contribution along with every residual evaluation. In that case - the material object just needs to be smarter. Materials can ask the framework what operation (residual/jac) is triggering a given material evaluation - those materials could be updated to query that state and omit unnecessary calcs accordingly. With respect to the redundant work when using AD - there are some subtleties about how the residual and jacobian calcs are integrated between MOOSE and PETSc that make it not quite as straight forward for us to combine them into one evaluation so instead we compute the residual during residual evaluation and then compute the residual and jacobian together during the jacobian evaluation (even though we don't need the residual again). I honestly can't remember what the detail is around the 1st evaluation. Probably @lindsayad or @fdkong could clarify that one. |
Beta Was this translation helpful? Give feedback.
-
We knew this. It could be optimized out in the future for some cases
Jacobian and Residual evaluations are involved from PETSc side via two different call-back functions. The Jacobian evaluation needs to compute material again because we do not store the materials from the earlier residual computation. Materials are expensive to store. That being said, storing materials might use a lot of memory when considering the values at each quadrature point are needed. |
Beta Was this translation helpful? Give feedback.
-
Thank you all for the elaborate answers! However, despite the expensive nature of those material models, I am currently surprised that for large scale simulations the overhead of the multiple material evaluation only has negligible influence (In my case: An accumulated Residual/Jacobian percentage of 25% compared to ~75% taken by the linear solve). So I agree that there is not very much potential for optimization. |
Beta Was this translation helpful? Give feedback.
Evaluations 2 and 3 (residual and jac) are indeed a (known) underoptimization in the framework with AD (automatic differentiation) at least. But it looks like you are using material objects that manually calculate a jacobian contribution along with every residual evaluation. In that case - the material object just needs to be smarter. Materials can ask the framework what operation (residual/jac) is triggering a given material evaluation - those materials could be updated to query that state and omit unnecessary calcs accordingly.
With respect to the redundant work when using AD - there are some subtleties about how the residual and jacobian calcs are integrated between MOOSE and PETSc tha…