Structured AMR Interoperability Effort




Data Aliasing



Client Component functions


void AMR_Create(int MPI_communicator,
                int components,
                int dimension,
                int centering,
                int datatype,
                int ordering,
                int* levelhandle);

void AMR_addPatchFloat( int levelhandle,
                        int* loRange, int* hiRange,
                        int* loValid, int* hiValid,
                        float* dataPtr);

void AMR_Close(int levelhandle);

void AMR_Delete(int levelhandle);



Server Component functions


void AMR_GetInfo(int levelhandle,
                 int* MPI_communicator,
                 int* nComponents,
                 int* dimension,
                 int* centering,
                 int* datatype,
                 int* ordering,
                 int* localcount);

void AMR_GetPatchInfo(   int levelhandle, 
                         int** loRange, int** hiRange,
                         int** loValid, int** hiValid);
void AMR_GetPatchFloat(  int levelhandle, float**  dataPtr);
void AMR_NextPatchInfo(   int levelhandle, 
                          int** loRange, int** hiRange,
                          int** loValid, int** hiValid);
void AMR_NextPatchFloat(  int levelhandle, float**  dataPtr);


Example: Writing a Server Component


extern "C" {
  int helm3_(  double dx, double helmsoeff, double scale, 
               double tolerance, int maxIter, int minIter,
               int* domain_lo, int* domain_hi, int phi,  int rhs  ) 
{
  int p_comps, p_dimension,p_centering,p_type,p_ordering,p_count;
  AMR_GetInfo(phi,&p_comps, &p_dimension,&p_centering, 
                  &p_type,&p_ordering,&p_count);
//---perform checks on input data here.... return codes, etc. omitted---
  AliasDataFactory phiFactory(phi);   
  AliasDataFactory rhsFactory(rhs);
  levelData<FArrayBox> p(phiFactory); 
  levelData<FArrayBox> r(rhsFactory);
  
  ProblemDomain pd(Box(domain_lo, domain_hi));
  HelmHoltzOp hop;                
  LevelSolver solver;  
  hop.setHelmCoeff(helmcoeff);    
  hop.scaleHelmCoeff(scale);  
  solver.setTolerace(tolerance);  
  solver.setMaxIter(maxIter);
  solver.define(p.getBoxes(), NULL, pd, dx, 1, &hop, p_comps);
  solver.levelSolveH(p, r);
  return 0;
  }
}



Example: C++ Client Using a Server Component


void ChomboHelmHoltz3(XArray3<Grid3<double> >& phi,
            XArray3<Grid3<double> >& rhs,
            double dx, double helmcoeff, double scale, 
            double tolerance, int maxIter, int minIter,
            const Region& domain)
{
  int p, r, i;
  AMR_Create( 1, 3, 1, 3, 0, &p);  
  AMR_Create( 1, 3, 1, 3, 0, &r);

  for (nodeIterator ni(phi); ni; ++ni) 
  {
    i = ni();   
    double *p_ptr(phi.ptr(i)),  *r_ptr(rhs.ptr(i));
    Region reg = phi.floorplan(i);  
    Region valid(reg);  
    valid.grow(-1);
    AMR_addPatchDouble(p, reg.lower()(), reg.upper()()
             valid.lower()(), valid.upper()(), p_ptr);
    AMR_addPatchDouble(r, reg.lower()(), reg.upper()()
             valid.lower()(), valid.upper()(), r_ptr); 
  }  
  AMR_close(p);  
  AMR_close(r); 
  helm3_(dx, helmcoeff,scale, tolerance, maxIter, 
        minIter,domain.lower()(), domain.upper()(), p, r);
  
  AMR_Delete(p);
  AMR_Delete(r);
}



Example: Fortran Client Using a Server Component


This example is an atem
  subroutine CHhelm3(dx, helmcoeff, scale, tolerance, maxIter, minIter)
    integer maxIter, minIter, phi_handle, rhs_handle, offset, lo(3), hi(3)
    real*8 dx(3),  helmcoeff, scale, tolerance)
    DBASEMODULE()
    call amrcreate( 1, 3, 1, 3, 0, phi_handle)
    call amrcreate( 1, 3, 1, 3, 0, rhs_handle)

    do this_block = 1, level_blocks
      call dBaseGetIntCoords( "phi", this_block, lo, hi)
      call dBaseGetDataOffset("phi", this_block, offset)
      call amraddpatchdouble(phi_handle, lo, hi, lo, hi, DATA(offset))        
      call dBaseGetDataOffset("rhs", this_block, offset)
      call amraddpatchdouble(rhs_handle, lo, hi, lo, hi, DATA(offset))
    end do
    call amrclose(phi_handle)
    call amrclose(rhs_handle)
    call helm3(dx, helmcoeff,scale, tolerance, maxIter, 
  &     minIter,dl, dh , phi_handle, rhs_handle)
    return
    end


Pros and Cons




AMR-HDF5 Interface




Do I have to learn HDF5 ?




Current Status