pmgbergen / porepy

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

Maintenance in porepy.ad #1166

Closed vlipovac closed 6 months ago

vlipovac commented 6 months ago

Proposed changes

  1. Introduction of intermediate Operator base classes handling arbitrary depth of previous iteration and time step.
  2. Re-work in forward evaluation: Removing double recursion by introducing parse for variables and replacing projection of global forward AdArray by slicing (less expensive than matrix multiplication)
  3. EquationSystem works internally now solely on Variable ID: Changes in some private data maps and fixing of global DOF order.
  4. Maintenance on Operator functions: Proper type setting and abstraction compatible with multiple inheritance including intermediate base classes from Change No 1.
  5. Adding tests to cover changes in prev iter and time step, as well as some basic tests of the operator function class.

Since the changes are a bit extensive, I am giving a walk-through in the form of a self-review.

EDIT:

Following the 1st round of reviews, the index convention for previous time steps is now unified with the convention for previous iterates:

Since current time (unknown value) is given by time_step_index = 0 and any iterate_index >= 0, it would be ambiguous to use the time step index. (and also unnecessary to store same data twice). Therefore time_step_index = 0 is now not supported anymore.

Types of changes

Checklist

keileg commented 6 months ago

@vlipovac: So you know, I am working my way through the PR, but I'm not done yet. To be continued.

IvarStefansson commented 6 months ago

@keileg, regarding your comment

  1. It seems there is a consensus to let the indexes of time steps and iterates both start at 0. I think it's wise to have a second look at all indexes and tags for iterates and time steps, including None and where we start counting (current time/iterate vs first previous time/iterate).
vlipovac commented 6 months ago

I pushed the easy/trivial suggestions and resolved respective conversations (including my self-review). Open discussions are what's left.

vlipovac commented 6 months ago

@keileg @IvarStefansson Regarding the discussion on unifying the time step indexation with the iterate indexation (time index 0 is current time): This requires to introduce a new convention. Since time index 0 is current time and we do not want to store same values twice, I propose making time_step_index=0 and iterate_index=0 equivalent throughout the framework. (By "current time" we always refer to the current iterate, since otherwise it would ambiguous). This convention must be implemented in pp.get_solution_values and pp.set_solutuon_values. Any comments regarding that?

Also, this will introduce minor changes in several files, where time_step_index=0 was used for previous time,

keileg commented 6 months ago

2. I think it's wise to have a second look at all indexes and tags for iterates and time steps, including None and where we start counting (current time/iterate vs first previous time/iterate).

I'll see if I can have a look at some code later today, and will get back to this (soon, I hope).

keileg commented 6 months ago

@vlipovac: I have gone through the changes and resolved conversations with a somewhat heavy hand. In addition to what looks like minor fixes, there are two remaining issues (both discussed in some details in the relevant conversations):

  1. Unifying the time_step_index and iterative_index in a way that leaves decent but not necessarily polished code (your time is better spent on the upcoming PRs)
  2. Reverting the change (or at least functionality) in EquationSystem.dofs_of().

Let me know if you have comments or questions.

review-notebook-app[bot] commented 6 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB