示例#1
0
void getResults(BlockStructure2D<T,DESCRIPTOR>& lattice,
                LBconverter<T>& converter, int iT) {

  const T lx   = 2.;
  const T ly   = 1.;

  const int saveIter = 2000;
  const int statIter = 200;

  const int imSize = 400;

  if (iT%statIter==0) {
    T middleU[2];
    lattice.get(converter.numNodes(lx)/2, converter.numNodes(ly)/2).computeU(middleU);
    OstreamManager cout(std::cout,"plotStatistics");
    T dx = converter.getDeltaX();
    T dt = converter.getDeltaT();
    cout << "iteration=" << setw(5) << iT;
    cout << "; t=" << setprecision(3) << setw(6)
         << iT*converter.getDeltaT();
    cout << "; E=" << setprecision(10) << setw(15)
         << lattice.getStatistics().getAverageEnergy()*dx*dx/dt/dt;
    cout << "; rho=" << setprecision(8) << setw(11)
         << lattice.getStatistics().getAverageRho();
    cout << "; uMax= " << setprecision(8) << setw(11)
         << middleU[0]*dx/dt;
    cout << endl;
    }

  if (iT%saveIter==0) {
    DataAnalysisBase2D<T,DESCRIPTOR> const& analysis = lattice.getDataAnalysis();

    ImageWriter<T> imageWriter("leeloo");
    imageWriter.writeScaledGif(createFileName("p", iT, 6),
                               analysis.getPressure(), imSize, imSize);
    imageWriter.writeScaledGif(createFileName("u", iT, 6),
                               analysis.getVelocityNorm(), imSize, imSize);
    ofstream *ofile = 0;
    if (singleton::mpi().isMainProcessor()) {
      ofile = new ofstream((singleton::directories().getLogOutDir()+"centerVel.dat").c_str());
    }
    for (int iY=0; iY<lattice.getNy(); ++iY) {
      T dx = converter.getDeltaX();
      T dt = converter.getDeltaT();
      T analytical = poiseuilleVelocity(iY, converter);
      T numerical[2];
      lattice.get(lattice.getNx()/2, iY).computeU(numerical);

      if (singleton::mpi().isMainProcessor()) {
        *ofile << iY*dx << " " << analytical*dx/dt
               << " " << numerical[0]*dx/dt << "\n";
      }
    }
    delete ofile;
  }
}
示例#2
0
void plotStatistics(int                              iT,
                    BlockStructure2D<T, DESCRIPTOR>& lattice,
                    LBunits<T>&                      converter,
                    T                                middleU)
{
    T dx = converter.getDeltaX();
    T dt = converter.getDeltaT();
    cout << "Iteration " << setw(5) << iT;
    cout << "; t=" << setprecision(3) << setw(6)
         << iT*converter.getDeltaT();
    cout << "; E=" << setprecision(10) << setw(15)
         << lattice.getStatistics().getAverageEnergy()*dx*dx/dt/dt;
    cout << "; rho=" << setprecision(8) << setw(11)
         << lattice.getStatistics().getAverageRho();
    cout << "; uMax= " << setprecision(8) << setw(11)
         << middleU*dx/dt;
    cout << endl;
}
示例#3
0
void getResults(BlockStructure2D<T,DESCRIPTOR>& lattice,
                LBconverter<T> const* converter, int iT, Timer<double>* timer,
                const T logT, const T imSave, const T vtkSave, const T maxT,
                std::string filenameGif, std::string filenameVtk,
                const bool timerPrintSum, const int timerPrintMode, const int timerTimeSteps) {

  const int imSize = 600;

  /// Get statistics
  if (iT%converter->numTimeSteps(logT)==0) {
    lattice.getStatistics().print(iT, converter->physTime(iT));
  }

  if (iT%timerTimeSteps==0) {
    timer->print(iT,timerPrintMode);
  }

  /// Writes the Gif files
  if (iT%converter->numTimeSteps(imSave)==0 && iT>0) {
    DataAnalysisBase2D<T,DESCRIPTOR> const& analysis = lattice.getDataAnalysis();

    ImageWriter<T> imageWriter("leeloo");
    imageWriter.writeScaledGif(createFileName(filenameGif, iT, 6),
                               analysis.getVelocityNorm(),
                               imSize, imSize );
  }

  /// Writes the VTK files
  if (iT%converter->numTimeSteps(vtkSave)==0 && iT>0) {
    DataAnalysisBase2D<T,DESCRIPTOR> const& analysis = lattice.getDataAnalysis();

    T dx = converter->getLatticeL();
    T dt = converter->physTime();
    VtkImageOutput2D<T> vtkOut(createFileName(filenameVtk, iT, 6), dx);
    vtkOut.writeData<double>(analysis.getVorticity(), "vorticity", (T)1/dt);
    vtkOut.writeData<2,double>(analysis.getVelocity(), "velocity", dx/dt);
  }

  if (iT == converter->numTimeSteps(maxT)-1 ){
  timer->stop();
  if (timerPrintSum==true)
    timer->printSummary();
  }


}