[Users] Carpet: using baseextents?

Scott Hawley scott.hawley at belmont.edu
Thu Sep 12 19:57:03 CDT 2013


  Goal: I'm trying to determine if a given (fine) grid vertex coincides
with a coarser grid point.

Frank pointed me to baseextents, and I've come up with the following
snippet of code...
Just posting this for a sanity check: Am I on the right track?
Is there a more robust way one should do this?

My code relies on "baseextents" being the "full" extent of a given
refinement level, apart from any domain decomposition that occurs when
running with multiple MPI processors.   (Well, and it relies on the fact
that fine grid boundaries must lie along coarse grid points.)


 BEGIN_MAP_LOOP (cctkGH, CCTK_GF) {
         BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) {

            DECLARE_CCTK_ARGUMENTS;

            assert (maps == 1);
            int const m = 0;            // <--- Really?  m is never > 0?
            assert (mglevels == 1);
            int const rl = reflevel;

            ivect const ilo  = vhh.at(m)->baseextents.at(m).at(rl).lower();
            ivect const istr =
vhh.at(m)->baseextents.at(m).at(rl).stride();

            int ref_ratio = 2;         // <-- Do we support refinement
ratios > 2?
            ivect coarse_str = istr * ref_ratio;

            for (CCTK_INT k = 0 ; k < cctk_lsh[2] ; k=k+1) {
                for (CCTK_INT j = 0 ; j < cctk_lsh[1] ; j=j+1) {
                    for (CCTK_INT i = 0 ; i < cctk_lsh[0] ; i=i+1) {
   
                       // does this vertex coincide with a coarser grid
vertex?
                       if (  ( 0 ==  (i - ilo[0]) % coarse_str[0]) &&
                             ( 0 ==  (j - ilo[1]) % coarse_str[1]) &&
                             ( 0 ==  (k - ilo[2]) % coarse_str[2])) {

                               CCTK_VInfo(CCTK_THORNSTRING,"   We are over
a CG vertex!");
                       }
   
                    } // end loop over i
                 } // end loop over j
             } // end loop over k

   
         } END_LOCAL_COMPONENT_LOOP;
   } END_MAP_LOOP;


Thank you very m
uch,
Scott






More information about the Users mailing list