[yt-dev] Downgrading Grid Resolution in yt

Matthew Turk matthewturk at gmail.com
Fri Jun 1 11:59:23 PDT 2012

On Fri, Jun 1, 2012 at 12:26 PM, Cameron Hummels
<chummels at astro.columbia.edu> wrote:
> Hi Matt,
> Thanks for the quick responses!
>> pf.h.grids has an array of grids. This is definitely in the docs. You can
>> get their LeftEdge and RightEdge, and they also have the
>> get_global_startindex function which gives it to you in level-relative
>> integers.
> I'll look into this, thanks!
>> >
>> >
>> >> I also believe that if you ask for a covering grid at level 9, and it
>> >> covers grids at level 10, it will not use the level 10 grids when
>> >> calculating the constituent values.  There's this trick we do to
>> >> figure out if the child masking should be taken into account with
>> >> covering grids, and the criteria is: is this the final level we want
>> >> to sample to?
>> >
>> > That sounds great.  So all I want to do is simply ignore child masking
>> > data from levels on the highest level of refinement.  But again, is there
>> > any function which does this publicly, or is it all buried in covering_grid?
>> What I am getting at is that you could just use covering grid and specify
>> a lower level than the highest.
> Your suggestion will not universally downgrade the resolution by 1, it will
> only downgrade the resolution of items at the *top* level of refinement by
> 1, but grids on lower refinement levels will remain the same.  I'm looking
> for something that will downgrade refinement everywhere by 1, including
> regions at lower refinement.
> Any ideas on this, or is this just going to take an additional set of
> homemade functions inspecting each grid individually as per
> get_global_startindex() from above?

I think I am starting to understand.  You don't want to use the
(created-by-your-sim-code) lower-resolution, overlapped-with data
because you want the high resolution stuff downgraded a level.  I
believe this is what happens, by the way, in AMR codes.  But moving
beyond that, I guess what I see as being a possibility will require
understanding *how* you want to degrade the resolution (i.e., ensuring
your conservation equations are satisfied) and then applying something
like this:

# this simply averages
my_new_array = na.zeros( [i/2 for i in cg["Density"].shape], dtype="float64")
for i in range(2):
    for j in range(2):
        for k in range(2):
            my_new_array += cg["Density"][i::2,j::2,k::2]
my_new_array /= 8.0

There may be additional issues (and my code might be wrong, I am
wondering if I messed up the slicing there) but something like this
would certainly take the number of cells and combine octs into a
single cell.


> Thanks again for all of the help with this!
> Cameron
> _______________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org

More information about the yt-dev mailing list