parthenon-hpc-lab / parthenon

Parthenon AMR infrastructure
https://parthenon-hpc-lab.github.io/parthenon/
Other
112 stars 34 forks source link

Refinement & Derefinement Criteria (Infinite Loop Bug) #762

Open tagardiner opened 2 years ago

tagardiner commented 2 years ago

From what I can tell, Parthenon has made the decision to have a refinement and derefinement tolerance. That is,

if on the current level error > refine_tolerance then refine and if on the current level error < derefine_tolerance then derefine.

I've tried this in the past and have run into the following challenge with this approach.

Iteration 1: On level L check the refine error metric, it's greater than refine_tolerance so refine to level L+1.

Iteration 2: On level L+1 check the refine error metric, it's less than derefine_tolerance so derefine to level L.

Iteration 3: Repeat the process in iteration 1 and enter an infinite loop.

This can be demonstrated with the advection example problem (I ran into this on Friday...) and the code enters an infinite loop during the initialization stage.

The way around this is to have ONLY a refine_tolerance and calculate the refinement error criterion on levels L-1 and L.

If both have an error < refine_tolerance, then derefine level L to L-1. If level L-1 has an error > refine_tolerance and level L has an error < refine_tolerance stay put. If level L has an error > refine_tolerance, refine level L to L+1 (or stay put if level L = maxlevel).

From what I understand, Parthenon has grid blocks and each block has a parent block so this strategy can be implemented with the current code design.

Yurlungur commented 2 years ago

Thanks for playing with this! Our solution to this refinement + derefinement loop is that we check for refinement every cycle, but derefinement only every, say, 10 cycles. The number of cycles to check is set in the input deck. That said, I like the strategy of checking 1 level up.

tagardiner commented 2 years ago

Does this apply on initialization as well?

Yurlungur commented 2 years ago

Oh! On initialization no it doesn't. I see your point. Yes, this is a bug. I'll look at the initialization loop... maybe it's an easy fix.

pgrete commented 2 years ago

My first thought here is to just disable derefinement during initialization because if a block has been refined in a previous pass then it should be refined (period)

Yurlungur commented 2 years ago

That seems reasonable.