Beispiel #1
0
/** Called once per time step, from mainFunc(). */
void
EBRestart::stepOnce(
  int                             a_step,
  RefCountedPtr<EBIndexSpace>&    a_ebIndexSpace,
  RefCountedPtr<EBIndexSpace>&    a_ebIndexSpace_old,
  Vector<LevelData<EBCellFAB>* >& a_ebvector,
  Vector<LevelData<EBCellFAB>* >& a_ebvector_old,
  Vector<DisjointBoxLayout>&      a_grids,
  int                             a_ghosts,
  GeomParams&                     a_geometry,
  const InputParams&              a_inputs,
  const EBRestart::CheckSumVect&  a_prevChecksums,
  EBRestart::CheckSumVect&        a_currChecksums
)
{
  int nlevs = a_inputs.nlevs;
  int refRatio = a_inputs.refratio;

  int eekflag = EBRestart::makeGeometry(*a_ebIndexSpace, a_geometry);
  if (eekflag != 0)
  {
    pout() << "Problem in EBRestart::makeGeometry(), eekflag = "
           << eekflag << endl;
  }

  if (a_step > 0)
  {
    // Same grids, new topology
    for ( int l=nlevs-1; l>=0; --l )
    {
      EBISLayout ebisl;
      EBRestart::makeEBISL(ebisl, a_grids[l],
                           coarsenPow(a_geometry.domain,refRatio,nlevs-1-l),
                           a_ebIndexSpace, a_ghosts );
      EBCellFactory factory(ebisl);
      a_ebvector[l]->define(a_grids[l], a_inputs.ncomps, IntVect::Unit*a_ghosts,
                          factory);
    }
    a_ebvector.swap( a_ebvector_old );
  }

  //
  // Regrid
  //
  EBRestart::initEBGrids( a_grids, a_ebvector, a_ebIndexSpace, a_ghosts,
                          a_inputs, a_geometry );

  if ( a_step == 0 )
  {
    EBRestart::fillData( a_ebvector, nlevs, a_inputs.ncomps, a_prevChecksums );
    EBRestart::updateChecksums( a_ebvector, nlevs, a_currChecksums );
  } else
  {
    // Perform second type of remap.  constant EBIndexSpace, but
    // different grids.
    //
    // Coarse grids in this case remain identical.
    a_ebvector_old[0]->copyTo(a_ebvector[0]->interval(),*a_ebvector[0],
                            a_ebvector_old[0]->interval());

    EBRestart::fillData( a_ebvector, nlevs, a_inputs.ncomps, a_prevChecksums );
    EBRestart::updateChecksums( a_ebvector, nlevs, a_currChecksums );
  }


#ifdef CH_USE_HDF5
  // Generate some component names.
  Vector<std::string> compNames(a_inputs.ncomps);
  ostringstream compName;
  for ( int c=0; c<a_inputs.ncomps; ++c )
  {
    compName << "velocity" << c; // Silly, but easy to spot.
    compNames[c] = compName.str();
    compName.str(""); // clears it
  }

  EBRestart::dumpHDF( filename(a_step),
                      compNames,
                      a_ghosts,
                      EBRestart::coarsenPow(a_geometry.domain, refRatio,
                                            nlevs-1),
                      a_ebIndexSpace,
                      a_ebvector,
                      a_grids,
                      nlevs,
                      a_inputs.ncomps,
                      a_geometry.dx,
                      refRatio );

  EBRestart::dumpOldStyle( std::string("oldstyle_") + filename(a_step),
                           compNames,
                           a_ghosts,
                           EBRestart::coarsenPow(a_geometry.domain, refRatio,
                                                 nlevs-1),
                           a_ebIndexSpace,
                           a_ebvector,
                           a_grids,
                           nlevs,
                           a_inputs.ncomps,
                           a_geometry.dx,
                           refRatio );
#endif

  //
  // Change the geometry -- for next step.
  //
  EBRestart::evolveGeomParams( a_geometry );
  a_ebIndexSpace_old.swap( a_ebIndexSpace );
  a_ebvector.swap( a_ebvector_old );
  if ( a_inputs.verbose )
  {
    pout() << "step " << a_step << std::endl;
  }
}