pmgbergen / porepy

Python Simulation Tool for Fractured and Deformable Porous Media
GNU General Public License v3.0
248 stars 88 forks source link

Make `DenseArray` and `SparseArray` immutable #1214

Open Yuriyzabegaev opened 2 months ago

Yuriyzabegaev commented 2 months ago

During the discussion with @keileg, the idea was considered to make the array and matrix AD operators immutable. Effectively, this can be achieved by setting the certain flag for the underlying numpy arrays, see this. Right now, these objects are not meant to be modified, however, there is no strict rule about it. The changeable during the simulation quantities are supported with TimeDependentDenseArray.

The motivation of the change is that the immutability will be assumed and utilized for hashing #1179, and this will be a safeguard against violating this assumption.

IvarStefansson commented 2 months ago

Have you considered fracture propagation?

Yuriyzabegaev commented 2 months ago

@IvarStefansson no, we need to discuss this

keileg commented 2 months ago

Have you considered fracture propagation?

Fair point. I think it is implicit that if the geometry is updated, more or less all parameters and discretizations must be updated. However, now is maybe a good time to make such assumptions explicit, or find out how to avoid making them.

jwboth commented 1 day ago

Clarifying question. In the discussion above, the presented issue is described as necessary step for #1179. At the same time #1179 is completed. Is this issue now obsolete, already taken care of, or still an issue?

Yuriyzabegaev commented 1 day ago

@jwboth the current hashing implementation silently assumes that the values of DenseArrays and SparseArrays are not touched by a user after the ad tree is once built. If someone modifies them, which is unlikely, because they are meant to be constant in contrary to TimeDependentDenseArrays, cashing will produce invalid result and no error will be thrown.