clawpack / visclaw

Clawpack visualization tools
http://www.clawpack.org
BSD 3-Clause "New" or "Revised" License
29 stars 47 forks source link

Compute global quantities from AMR grid patches of solution #207

Open rjleveque opened 7 years ago

rjleveque commented 7 years ago

A user requested a post-processing tool to help compute a global quantity (e.g. the total mass) from each frame of AMR output.

Not sure if this would go in visclaw, amrclaw, or pyclaw?

One way to do this might be:

ketch commented 7 years ago

We have a hook for this functionality in Pyclaw; see http://www.clawpack.org/pyclaw/output.html#outputting-functionals (although the example code there doesn't make sense). A working example is in pyclaw/examples/psystem_2d/psystem_2d.py; see the function total energy. Of course, that is coded for a single patch which makes things very simple.

mjberger commented 7 years ago

this is done at every time step in the routine conck.f, for mass conservation. Since we do conservative updates, it is only necessary to do it on the coarsest level. So I must not be understanding what you are looking for?

— Marsha

On Feb 21, 2017, at 12:32 AM, Randall J. LeVeque notifications@github.com wrote:

A user requested a post-processing tool to help compute a global quantity (e.g. the total mass) from each frame of AMR output.

Not sure if this would go in visclaw, amrclaw, or pyclaw?

One way to do this might be:

For each grid patch define a boolean array finest of the same size, initialized to True everywhere. Loop over patches from coarsest to finest. If a patch at level L covers some rectangular region of a patch at level L-1 then set finest = False in that portion of the level L-1 patch. Loop over all patches a second time, accumulating the desired value, e.g. adding in rho(i,j)dxdy for each grid cell (i,j) for which finest = True. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

rjleveque commented 7 years ago

@mjberger: Sorry, I was using mass computation as a simple example but the actual problem is to compute e.g. potential energy of a tsunami, which requires summing eta**2 * dx*dy over all wet cells, where eta = h + B. Since this is a nonlinear function of the solution, computing it on the coarse level is not sufficient. It has to be done using the finest patch available at each point.

rjleveque commented 5 years ago

This could be incorporated in the gridtools.py module I am working on to deal with AMR data.