Skip to content

[forms][bugfix] Avoid reference to temporary when localizing operators

Carsten Gräser requested to merge bugfix/fix-localized-operators into master

When creating a localized linear or bilinear operator using localOp = localOperator(op) in the local assemblers, this was based on the global operator passed to integrate(...) before. This is dagerous because it may happen that the local operator internally refers to the global one or some of its internal state. If the argument passed to integrate(...) is a temporary we have a dangling reference inside of the local operator.

To avoid this the local operator is now created from the stored copy of the global one.

Notice that the described problem is hard to trigger with the existing operators, because the local one in general does not share state with the global one. However, this may happen when wrapping a temporary GridFunction into a Forms::Coefficient or when implementing a custom global operator.

Merge request reports

Loading