Skip to content

achodankar

Forum Replies Created

Viewing 7 posts - 61 through 67 (of 67 total)
  • Author
    Posts
  • in reply to: Storing velocity data in csv file #5776
    achodankar
    Participant

    The code snippet is called in the main function while timestepping:

    for (std::size_t iT = 0; iT < converter.getLatticeTime(maxPhysT)+10; ++iT) {
    particle.simulateTimestep(“verlet”);
    getResults(sLattice, converter, iT, superGeometry, timer, circle1, circle2);
    sLattice.collideAndStream();
    superExt1.communicate();
    superExt2.communicate();
    superExt3.communicate();

    }

    in reply to: Storing velocity data in csv file #5775
    achodankar
    Participant

    I am running the dkt2d example. The simulation results are correct when I view it in Paraview and usin ppm images. here is the code snippet:

    void getResults(SuperLattice2D<T, DESCRIPTOR>& sLattice,
    UnitConverter<T,DESCRIPTOR> const& converter, int iT,
    SuperGeometry2D<T>& superGeometry, Timer<double>& timer, SmoothIndicatorF2D<T,T,true> &particle1, SmoothIndicatorF2D<T,T,true> &particle2)
    {
    OstreamManager clout(std::cout, “getResults”);

    #ifdef WriteVTK
    SuperVTMwriter2D<T> vtkWriter(“sedimentation”);
    SuperLatticePhysVelocity2D<T, DESCRIPTOR> velocity(sLattice, converter);
    SuperLatticePhysPressure2D<T, DESCRIPTOR> pressure(sLattice, converter);
    SuperLatticePhysExternalPorosity2D<T, DESCRIPTOR> externalPor(sLattice, converter);
    vtkWriter.addFunctor(velocity);
    vtkWriter.addFunctor(pressure);
    vtkWriter.addFunctor(externalPor);

    if (iT == 0) {
    converter.write(“dkt”);
    SuperLatticeGeometry2D<T, DESCRIPTOR> geometry(sLattice, superGeometry);
    SuperLatticeCuboid2D<T, DESCRIPTOR> cuboid(sLattice);
    SuperLatticeRank2D<T, DESCRIPTOR> rank(sLattice);
    vtkWriter.write(geometry);
    vtkWriter.write(cuboid);
    vtkWriter.write(rank);
    vtkWriter.createMasterFile();

    }

    if (iT % converter.getLatticeTime(iTwrite) == 0) {
    vtkWriter.write(iT);
    }

    // Writes the vtk files
    const int vtkIter = converter.getLatticeTime( .3 );
    if ( iT%vtkIter == 0 && iT > 0 ) {
    vtkWriter.write( iT );

    {
    SuperEuklidNorm2D<T, DESCRIPTOR> normVel( velocity );
    BlockReduction2D2D<T> planeReduction( normVel, 600, BlockDataSyncMode::ReduceOnly );
    // write output as JPEG
    heatmap::write(planeReduction, iT);

    }

    //plot a gif of the simulation
    {
    SuperEuklidNorm2D<T,DESCRIPTOR> normVel( velocity );
    BlockReduction2D2D<T> planeReduction( normVel );
    //BlockReduction2D2D<T> planeReduction(normVel, sLattice);
    BlockGifWriter<T> gifWriter;
    //gifWriter.write(planeReduction, 0, 0.7, iT, “vel”); //static scale
    gifWriter.write( planeReduction, iT, ” vel ” ); // scaled
    //SuperEuklidNorm2D<T,DESCRIPTOR> press( pressure );
    //BlockReduction2D2D<T> planeReduction( press );
    //gifWriter.write( planeReduction, iT, ” press ” ); // scaled
    }
    {

    BlockGifWriter<T> gifWriter;
    SuperEuklidNorm2D<T,DESCRIPTOR> press( pressure );
    BlockReduction2D2D<T> planeReduction( press );
    gifWriter.write( planeReduction, iT, ” press ” ); // scaled
    }

    {
    SuperLatticePhysVelocity2D<T,DESCRIPTOR> velocityF(sLattice, converter);
    BlockReduction2D2D<T> velocityPlane(velocityF, 600, BlockDataSyncMode::ReduceOnly);
    ofstream myfile1;
    myfile1.open(“velocity_”+ std::to_string(iT) + “.csv”);
    myfile1 << “i,” << “j,” << “Ux,” <<“Uy”<< std::endl;
    int latticeR[2] { };
    T vel[2] { };
    velocityPlane(vel, latticeR);
    for (latticeR[0]=0; latticeR[0] < velocityPlane.getBlockStructure().getNx(); ++latticeR[0])
    {
    for (latticeR[1]=0; latticeR[1] < velocityPlane.getBlockStructure().getNy(); ++latticeR[1])
    {
    //cout<<“Enter-“<<std::endl;
    myfile1 << latticeR[0] << “,” << latticeR[1] << “,”<< vel[0] << “,”<< vel[1] << std::endl;
    }
    }
    myfile1.close();

    }

    }
    #endif

    #ifdef WriteGnuPlot
    if (iT % converter.getLatticeTime(iTwrite) == 0) {
    if (singleton::mpi().getRank() == 0) {

    ofstream myfile;
    myfile.open (gnuplotFilename.c_str(), ios::app);
    myfile
    << converter.getPhysTime(iT) << ” ”
    << std::setprecision(9)
    << particle2.getPos()[1] << ” ”
    << particle1.getPos()[1] << ” ”
    << particle2.getPos()[0] << ” ”
    << particle1.getPos()[0] << endl;
    myfile.close();
    }
    }
    #endif

    /// Writes output on the console
    if (iT % converter.getLatticeTime(iTwrite) == 0) {
    timer.update(iT);
    timer.printStep();
    sLattice.getStatistics().print(iT, converter.getPhysTime(iT));
    }

    return;
    }

    in reply to: Storing velocity data in csv file #5773
    achodankar
    Participant

    Hello Adrian,
    Thank you. This fixes the problem. I missed on that bug. The velocity values are showing up to be zero for all time steps in the csv files. Is the above way the right way to extract the velocity values?

    Thank you.

    Yours sincerely,

    Abhijeet

    in reply to: Set periodic BCs @ inlet and outlet (cylinder2d example) #5764
    achodankar
    Participant

    Hello Nicolas,
    Thank you for your prompt response.

    Yours sincerely,

    Abhijeet

    in reply to: Set periodic BCs @ inlet and outlet (cylinder2d example) #5751
    achodankar
    Participant

    Hello Developers,
    I was able to set the periodic boundary conditions using
    cuboidGeometry.setPeriodicity(true,false ); in the dkt2d example in the x direction. However, the particles gets absorbed in the exit and won’t re-enter the simulation from the inlet. Am I doing anything wrong in the implementation process?

    Thank you.

    Yours sincerely,

    Abhijeet

    in reply to: Error in GNUplot & image data #5735
    achodankar
    Participant

    Hello Adrian,
    Thank you very much for your prompt reply. The proposed solution fixed the issue.

    Thank you.

    Yours sincerely,

    Abhijeet

    in reply to: Error in GNUplot & image data #5733
    achodankar
    Participant

    Hello,
    I was able to run the .p scripts using gnuplot-x11 and get the corresponding images and pdfs. However, I had to do all of it manually. How should I modify OpenLB code to use gnuplot-x11? I have uninstalled the gnuplot version, so I just have the gnuplot-x11 version presently.

Viewing 7 posts - 61 through 67 (of 67 total)