Flux reconstruction does not deep-copy the local operator
During flux reconstruction (see model/richards/richards.hh#L560
), the local operator is copied, but that does not involve copies of its dependent structures FlowBoundary
, FlowSource
, and, most importantly, FlowParameters
.
Summary
Like when retrieving water content or regular flux states from a model, these retrieved states should be independent of any later changes to the models. These changes might include a change in state by propagating the model, or an alteration of the parameters through data assimilation. The decoupling is ensured by copying the required structures before assembling the respective grid functions.
For flux reconstruction, the entire local operator is required and hence copied. However, copying the operator alone only copies its member pointers. The objects they point to are not copied (no deep-copy). This makes the flux reconstruction grid function affected by changes to the parameters after retrieving it.
What is the current bug behaviour?
Parameters, BCs, and source data structures are not copied when creating a reconstructed flux grid function.
What is the expected correct behaviour?
get_water_flux_reconstructed
performs a deep-copy of all structures attached to the local operator.
Reconstructed flux grid function is independent of subsequent changes to parameters.
Ideas how to fix this?
Create a public method clone
in all local operators which creates a deep-copy of the structures attached to the current object and returns a shared pointer to a new instance referencing these copies. Use this function to retrieve a local operator copy when reconstructing a flux.