parthenon-hpc-lab/parthenon

`pmb->loc` broken?

Opened this issue · 3 comments

@lroberts36 I'm trying to calculate the effective offsets for each block for writing outputs.

Within a block like (on a mesh with 64x96 and blocks of 32x32)

    for (auto &pmb : pm->block_list) {
...
              std::cout << "Block " << pmb->gid << " writes chunk of [" << chunk_extent[0]
                        << " " << chunk_extent[1] << " "
                        << "] with offset [" << chunk_offset[0] << " " << chunk_offset[1]
                        << "] and logical locs [" << pmb->loc.lx2() << " "
                        << pmb->loc.lx1() << "]\n";
...

I get the following output:

Block 0 writes chunk of [32 32 ] with offset [0 0] and logical locs [0 0]
Block 1 writes chunk of [32 32 ] with offset [0 0] and logical locs [0 0]
Block 2 writes chunk of [32 32 ] with offset [0 0] and logical locs [0 0]
Block 3 writes chunk of [32 32 ] with offset [0 0] and logical locs [0 0]
Block 4 writes chunk of [32 32 ] with offset [0 0] and logical locs [0 0]
Block 5 writes chunk of [32 32 ] with offset [0 0] and logical locs [0 0]


Am I missing sth? IIRC previously `loc.lx#` returned the effective logical location in a global mesh at a given level.
This is with all changes from current `develop`.

No, this is the expected behavior as the grid you are using results in a forest of six trees. Each block has a logical location relative to the tree it is in, but 'LogicalLocation' now also contains the index of the tree in which it is contained accessible via 'LogicalLocation::tree()'. Getting on a plane now (and writing this from my phone), I will look at how to extract the offsets you want tomorrow morning. They are probably already contained in the neighbor block information.

For now, you could use Forest::GetLegacyTreeLocation using the locations stored in the MeshBlocks to get the old global logical location, but this will not work with general forests.

Perfect, that did the job! Thanks for the quick reply.
Now I also understand why this showed up in downstream testing (as I previously used a mesh that was part of a single tree in Parthenon).
One more reminder to add downstream testing of more complex mesh structures.