Erik,
How does one "nest" loops over grids at different levels? In my way of doing things, it was something like...
l = level;
gblm1 = mgh[l-1]; while (gblm1 != NULL) { Bbox coarse_bbox = gblm1->bbox;
gbl = mgh[l]; while (gbl != NULL) { Bbox fine_bbox = gbl->bbox;
// On the regions for which the finer grid overlaps the coarse grid, // do some operations...
gbl = gbl->next; }
gblm1 = gblm1->next; }
I have an idea of something to try, below, but I'm worried that I'm abusing the SWITCH_TO_LEVEL macro…
//reflevel = finer grid… SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) { BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
SWITCH_TO_LEVEL( cctkGH, reflevel ) { BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
// where fine grid bbox overlaps coarse bbox…. // do operations on coarse grid… SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) { // do operations…, e.g. call "L" operator } END_SWITCH_TO_LEVEL;
} END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP; } END_SWITCH_TO_LEVEL;
} END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP;
} END_SWITCH_TO_LEVEL;
Or?
On Sun, Apr 15, 2012 at 01:47:31PM -0700, Scott Hawley wrote:
// On the regions for which the finer grid overlaps the coarse grid, // do some operations...
You might be able to use the set operations on the regions first to find out what that region is without looping and then loop over whatever level you want and use the result from before to know where to do something.
Frank
SureŠ What are the set operations? I've found info in the User's Guide and Reference Manual to "Parameter Sets", various Reset operations, Setup routines, Table SetsŠ. ?
On 4/15/12 3:56 PM, "Frank Loeffler" knarf@cct.lsu.edu wrote:
On Sun, Apr 15, 2012 at 01:47:31PM -0700, Scott Hawley wrote:
// On the regions for which the finer grid overlaps the coarsegrid, // do some operations...
You might be able to use the set operations on the regions first to find out what that region is without looping and then loop over whatever level you want and use the result from before to know where to do something.
Frank
Maybe like...?
typedef bboxset <int, dim> ibboxset; ...
// list of all bboxes on finer level vector <ibboxset> fine_bboxset (reflevel);
SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) {
CCTK_INT coarse_icstride = pow(2,reflevel-1); // TODO: Better way of getting this info?
//Sync up on coarser grid CCTK_SyncGroup(cctkGH, "BruiserConstraints::temp");
BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
ibbox coarse_bbox; coarse_bbox.lower()[0] = cctk_bbox[0]; coarse_bbox.upper()[0] = cctk_bbox[1]; coarse_bbox.lower()[1] = cctk_bbox[2]; coarse_bbox.upper()[1] = cctk_bbox[3]; coarse_bbox.lower()[2] = cctk_bbox[4]; coarse_bbox.upper()[2] = cctk_bbox[5];
// loop over bboxes on finer level for (ibbox fine_bbox = fine_bboxset; fine_bbox != NULL; fine_bbox = fine_bbox.next() ) { // ???
// determine overlap region for fine & coarse ibbox iolap = coarse_bbox & fine_bbox; CCTK_INT overlap[6]; overlap[0] = iolap.lower()[0]; overlap[1] = iolap.upper()[0]; overlap[2] = iolap.lower()[1]; overlap[3] = iolap.upper()[1]; overlap[4] = iolap.lower()[2]; overlap[5] = iolap.upper()[2];
/* Call lop, but only operate on region covered by fine grid(s) */ //Call L operator (lop) using temp as input, placing result into tau CCTK_REAL hc = CCTK_DELTA_SPACE(0);
CCTK_FNAME(omplop)( tauphi, tauwx, tauwy, tauwz, t1, t2, t3, t4, gxx, gxy, gxz, gyy, gyz, gzz, kxx, kxy, kxz, kyy, kyz, kzz, x, y, z, bruiser_mask, overlap, overlap, &coarse_icstride, &(cctk_lsh[0]),&(cctk_lsh[1]),&(cctk_lsh[2]), &hc);
} // loop over fine bboxes } END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP;
CCTK_SyncGroup(cctkGH, "BruiserConstraints::tau");
} END_SWITCH_TO_LEVEL;
On 4/15/12 4:02 PM, "Scott Hawley" scott.hawley@belmont.edu wrote:
SureŠ What are the set operations? I've found info in the User's Guide and Reference Manual to "Parameter Sets", various Reset operations, Setup routines, Table SetsŠ. ?
On 4/15/12 3:56 PM, "Frank Loeffler" knarf@cct.lsu.edu wrote:
On Sun, Apr 15, 2012 at 01:47:31PM -0700, Scott Hawley wrote:
// On the regions for which the finer grid overlaps the coarsegrid, // do some operations...
You might be able to use the set operations on the regions first to find out what that region is without looping and then loop over whatever level you want and use the result from before to know where to do something.
Frank
Users mailing list Users@einsteintoolkit.org http://lists.einsteintoolkit.org/mailman/listinfo/users
Scott
In Carpet, fine boxes don't necessarily overlap a particular coarse box. Only the set of fine boxes overlaps (is contained in) the set of coarse boxes.
Also, the meaning of cctk_bbox and what Carpet calls a bbox are distinct. cctk_bbox contains booleans indicating whether the current regions contains a piece of the boundary (or whether it is in the interior of the grid), while Carpet's bboxes contain (integer) coordinates describing the rectangles (but in 3D) that make up the refined regions.
I don't quite understand what you are trying to do. Should we Skype tomorrow?
-erik
On Sun, Apr 15, 2012 at 4:47 PM, Scott Hawley scott.hawley@belmont.edu wrote:
Erik,
How does one "nest" loops over grids at different levels? In my way of doing things, it was something like...
l = level;
gblm1 = mgh[l-1]; while (gblm1 != NULL) { Bbox coarse_bbox = gblm1->bbox;
gbl = mgh[l]; while (gbl != NULL) { Bbox fine_bbox = gbl->bbox;
// On the regions for which the finer grid overlaps the coarse grid, // do some operations...
gbl = gbl->next; }
gblm1 = gblm1->next; }
I have an idea of something to try, below, but I'm worried that I'm abusing the SWITCH_TO_LEVEL macro…
//reflevel = finer grid… SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) { BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
SWITCH_TO_LEVEL( cctkGH, reflevel ) { BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
// where fine grid bbox overlaps coarse bbox…. // do operations on coarse grid… SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) { // do operations…, e.g. call "L" operator } END_SWITCH_TO_LEVEL;
} END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP; } END_SWITCH_TO_LEVEL;
} END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP;
} END_SWITCH_TO_LEVEL;
Or?
Ok. What I'm trying to do is compute the inter-grid truncation error at every point (where it's defined, on the coarse grid):
2h 2h 2h h 2h h h tau := L I u - I L u h h h
The first term on the right hand side is the one for which I need to find the intersection of bounding boxesŠ
Skyping tomorrow is fine.
On 4/15/12 5:54 PM, "Erik Schnetter" eschnetter@perimeterinstitute.ca wrote:
Scott
In Carpet, fine boxes don't necessarily overlap a particular coarse box. Only the set of fine boxes overlaps (is contained in) the set of coarse boxes.
Also, the meaning of cctk_bbox and what Carpet calls a bbox are distinct. cctk_bbox contains booleans indicating whether the current regions contains a piece of the boundary (or whether it is in the interior of the grid), while Carpet's bboxes contain (integer) coordinates describing the rectangles (but in 3D) that make up the refined regions.
I don't quite understand what you are trying to do. Should we Skype tomorrow?
-erik
On Sun, Apr 15, 2012 at 4:47 PM, Scott Hawley scott.hawley@belmont.edu wrote:
Erik,
How does one "nest" loops over grids at different levels? In my way of doing things, it was something like...
l = level;
gblm1 = mgh[l-1]; while (gblm1 != NULL) { Bbox coarse_bbox = gblm1->bbox;
gbl = mgh[l]; while (gbl != NULL) { Bbox fine_bbox = gbl->bbox; // On the regions for which the finer grid overlaps the coarsegrid, // do some operations...
gbl = gbl->next; }gblm1 = gblm1->next; }
I have an idea of something to try, below, but I'm worried that I'm abusing the SWITCH_TO_LEVEL macroŠ
//reflevel = finer gridŠ SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) { BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
SWITCH_TO_LEVEL( cctkGH, reflevel ) { BEGIN_MAP_LOOP (cctkGH, CCTK_GF) { BEGIN_LOCAL_COMPONENT_LOOP (cctkGH,CCTK_GF) { DECLARE_CCTK_ARGUMENTS;
// where fine grid bbox overlapscoarse bboxŠ. // do operations on coarse gridŠ SWITCH_TO_LEVEL( cctkGH, reflevel - 1 ) { // do operationsŠ, e.g. call "L" operator } END_SWITCH_TO_LEVEL;
} END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP; } END_SWITCH_TO_LEVEL; } END_LOCAL_COMPONENT_LOOP; } END_MAP_LOOP;} END_SWITCH_TO_LEVEL;
Or?
-- Erik Schnetter eschnetter@perimeterinstitute.ca http://www.perimeterinstitute.ca/personal/eschnetter/ AIM: eschnett247, Skype: eschnett, Google Talk: schnetter@gmail.com
users@lists.einsteintoolkit.org