lib/test/EBAMRTools/restart.cpp
/** The "checksum" is a function of all the field data at a given step.
 *  That field data, in turn, is a function of the checksum at the previous
 *  step.  That way I can be pretty sure that when this restart thing
 *  produces the expected hdf5 files, it's not just fooling me.
*/
The "checksum" is a function of all the field data at a given step.
That field data, in turn, is a function of the checksum at the previous
step.  That way I can be pretty sure that when this restart thing
produces the expected hdf5 files, it's not just fooling me.
The " checksum " is a function of all the field data at a given step . That field data in turn is a function of the checksum at the previous step . That way I can be pretty sure that when this restart thing produces the expected hdf5 files it ' s not just fooling me .
void
EBRestart::updateChecksums( Vector<LevelData<EBCellFAB>*>&  a_ebvector,
                            int                             a_nlevs,
                            EBRestart::CheckSumVect&        a_checksums )
{
  for ( int lev=0; lev<a_nlevs; ++lev )
  {
    LevelData<EBCellFAB>& field( *a_ebvector[lev] );
    DataIterator dit = field.dataIterator();
    for (dit.begin(); dit.ok(); ++dit)
    {
      EBCellFAB& ebcf((*a_ebvector[lev])[dit]);
      BaseFab<Real>& fab(ebcf.getSingleValuedFAB());
      a_checksums[lev].len_reg += fab.box().numPts();
      a_checksums[lev].len_irreg +=
        ebcf.getEBISBox().getEBGraph().getIrregCells(fab.box()).numPts();
      for ( int i=0; i<fab.box().numPts(); ++i )
      {
        long x = long(fab.dataPtr()[i]);
        a_checksums[lev].sum += x*x;
      }
    }
     MPI-reduce the various members of a_checksums[lev].
#ifdef CH_MPI
    Real all_proc_sum;
    Real proc_sum( a_checksums[lev].sum );
    if ( MPI_SUCCESS !=
        MPI_Allreduce(&proc_sum, &all_proc_sum, 1, MPI_CH_REAL,
                      MPI_SUM, Chombo_MPI::comm) )
    {
      MayDay::Error("Failure in MPI_Allreduce().");
    }
    a_checksums[lev].sum = long(all_proc_sum);
     There's no MPI_CH_LONG.  Maybe I should make .sum Real then.
     Reduce a_checksums[lev].len_reg
    Real all_proc_len_reg;
    Real proc_len_reg( a_checksums[lev].len_reg );
    if ( MPI_SUCCESS !=
        MPI_Allreduce(&proc_len_reg, &all_proc_len_reg, 1, MPI_CH_REAL,
                      MPI_SUM, Chombo_MPI::comm) )
    {
      MayDay::Error("Failure in MPI_Allreduce().");
    }
    a_checksums[lev].len_reg = long(all_proc_len_reg);
     Reduce a_checksums[lev].len_irreg
    Real all_proc_len_irreg;
    Real proc_len_irreg( a_checksums[lev].len_irreg );
    if ( MPI_SUCCESS !=
        MPI_Allreduce(&proc_len_irreg, &all_proc_len_irreg, 1, MPI_CH_REAL,
                      MPI_SUM, Chombo_MPI::comm) )
    {
      MayDay::Error("Failure in MPI_Allreduce().");
    }
    a_checksums[lev].len_irreg = long(all_proc_len_irreg);
#endif
  }
}
void EBRestart :: updateChecksums ( Vector < LevelData < EBCellFAB > * > & a_ebvector , int a_nlevs , EBRestart :: CheckSumVect & a_checksums ) { for ( int lev = 0 ; lev < a_nlevs ; ++ lev ) { LevelData < EBCellFAB > & field ( * a_ebvector [ lev ] ) ; DataIterator dit = field . dataIterator ( ) ; for ( dit . begin ( ) ; dit . ok ( ) ; ++ dit ) { EBCellFAB & ebcf ( ( * a_ebvector [ lev ] ) [ dit ] ) ; BaseFab < Real > & fab ( ebcf . getSingleValuedFAB ( ) ) ; a_checksums [ lev ] . len_reg += fab . box ( ) . numPts ( ) ; a_checksums [ lev ] . len_irreg += ebcf . getEBISBox ( ) . getEBGraph ( ) . getIrregCells ( fab . box ( ) ) . numPts ( ) ; for ( int i = 0 ; i < fab . box ( ) . numPts ( ) ; ++ i ) { long x = long ( fab . dataPtr ( ) [ i ] ) ; a_checksums [ lev ] . sum += x * x ; } } #ifdef CH_MPI Real all_proc_sum ; Real proc_sum ( a_checksums [ lev ] . sum ) ; if ( MPI_SUCCESS != MPI_Allreduce ( & proc_sum , & all_proc_sum , 1 , MPI_CH_REAL , MPI_SUM , Chombo_MPI :: comm ) ) { MayDay :: Error ( " " ) ; } a_checksums [ lev ] . sum = long ( all_proc_sum ) ; Real all_proc_len_reg ; Real proc_len_reg ( a_checksums [ lev ] . len_reg ) ; if ( MPI_SUCCESS != MPI_Allreduce ( & proc_len_reg , & all_proc_len_reg , 1 , MPI_CH_REAL , MPI_SUM , Chombo_MPI :: comm ) ) { MayDay :: Error ( " " ) ; } a_checksums [ lev ] . len_reg = long ( all_proc_len_reg ) ; Real all_proc_len_irreg ; Real proc_len_irreg ( a_checksums [ lev ] . len_irreg ) ; if ( MPI_SUCCESS != MPI_Allreduce ( & proc_len_irreg , & all_proc_len_irreg , 1 , MPI_CH_REAL , MPI_SUM , Chombo_MPI :: comm ) ) { MayDay :: Error ( " " ) ; } a_checksums [ lev ] . len_irreg = long ( all_proc_len_irreg ) ; #endif } }
The "checksum" is a function of all the field data at a given step.
The " checksum " is a function of all the field data at a given step .
// // MPI-reduce the various members of a_checksums[lev]. // // There's no MPI_CH_LONG.  Maybe I should make .sum Real then. // // Reduce a_checksums[lev].len_reg // // // Reduce a_checksums[lev].len_irreg //