lib/io/tseries.cc
/**
 ********************************************************************************************************************************************
 * \brief   Constructor of the tseries class
 *
 *          The constructor initializes the variables and parameters for writing time-series data
 *          The header for the time-series data file is also written here.
 *          Depending on whether the run is for a scalar solver or hydro solver, the appropriate header is written.
 *
 * \param   mesh is a const reference to the global data contained in the grid class
 * \param   solverV is a reference to the velocity vector field whose data is used in calculating global quantities
 * \param   solverP is a const reference to the pressure scalar field whose dimensions are used to set array limits
 * \param   solverTime is a const reference to the real variable holding the value of current solver time
 * \param   timeStep is a const reference to the real variable holding the value of current time-step
 *
 ********************************************************************************************************************************************
 */
\brief   Constructor of the tseries class
The constructor initializes the variables and parameters for writing time-series data
The header for the time-series data file is also written here.
Depending on whether the run is for a scalar solver or hydro solver, the appropriate header is written.


\ brief Constructor of the tseries class The constructor initializes the variables and parameters for writing time - series data The header for the time - series data file is also written here . Depending on whether the run is for a scalar solver or hydro solver the appropriate header is written .
tseries::tseries(const grid &mesh, vfield &solverV, const sfield &solverP, const real &solverTime, const real &timeStep):
                 time(solverTime), tStp(timeStep), mesh(mesh), P(solverP), V(solverV), divV(mesh, P) {
    if (mesh.inputParams.restartFlag) {
        ofFile.open("output/TimeSeries.dat", std::fstream::out | std::fstream::app);
    } else {
        ofFile.open("output/TimeSeries.dat", std::fstream::out);
    }
    xLow = P.F.fCore.lbound(0);        xTop = P.F.fCore.ubound(0);
#ifndef PLANAR
    yLow = P.F.fCore.lbound(1);        yTop = P.F.fCore.ubound(1);
#endif
    zLow = P.F.fCore.lbound(2);        zTop = P.F.fCore.ubound(2);
    if (mesh.rankData.xRank > 0) {
        xLow += 1;
    }
#ifndef PLANAR
    if (mesh.rankData.yRank > 0) {
        yLow += 1;
    }
#endif
    real localVol = 0.0;
    totalVol = 0.0;
#ifdef PLANAR
    for (int iX = xLow; iX <= xTop; iX++) {
        for (int iZ = zLow; iZ <= zTop; iZ++) {
            localVol += (mesh.dXi/mesh.xi_xColloc(iX))*(mesh.dZt/mesh.zt_zColloc(iZ));
        }
    }
#else
    for (int iX = xLow; iX <= xTop; iX++) {
        for (int iY = yLow; iY <= yTop; iY++) {
            for (int iZ = zLow; iZ <= zTop; iZ++) {
                localVol += (mesh.dXi/mesh.xi_xColloc(iX))*(mesh.dEt/mesh.et_yColloc(iY))*(mesh.dZt/mesh.zt_zColloc(iZ));
            }
        }
    }
#endif
    MPI_Allreduce(&localVol, &totalVol, 1, MPI_FP_REAL, MPI_SUM, MPI_COMM_WORLD);
    if (mesh.rankData.rank == 0) {
        if (mesh.inputParams.probType <= 4) {
            std::cout << std::fixed << std::setw(6)  << "Time" << "\t" <<
                                    std::setw(16) << "Total energy" << "\t" << "Divergence" << std::endl;
            ofFile << "#VARIABLES = Time, Energy, Divergence, dt\n";
        } else {
            std::cout << std::fixed << std::setw(6)  << "Time" << "\t" <<
                                    std::setw(16) << "Re (Urms)" << "\t" << "Nusselt No" << "\t" << "Divergence" << std::endl;
            ofFile << "#VARIABLES = Time, Energy, NusseltNo, Divergence, dt\n";
        }
    }
}
tseries :: tseries ( const grid & mesh , vfield & solverV , const sfield & solverP , const real & solverTime , const real & timeStep ) : time ( solverTime ) , tStp ( timeStep ) , mesh ( mesh ) , P ( solverP ) , V ( solverV ) , divV ( mesh , P ) { if ( mesh . inputParams . restartFlag ) { ofFile . open ( " " , std :: fstream :: out | std :: fstream :: app ) ; } else { ofFile . open ( " " , std :: fstream :: out ) ; } xLow = P . F . fCore . lbound ( 0 ) ; xTop = P . F . fCore . ubound ( 0 ) ; #ifndef PLANAR yLow = P . F . fCore . lbound ( 1 ) ; yTop = P . F . fCore . ubound ( 1 ) ; #endif zLow = P . F . fCore . lbound ( 2 ) ; zTop = P . F . fCore . ubound ( 2 ) ; if ( mesh . rankData . xRank > 0 ) { xLow += 1 ; } #ifndef PLANAR if ( mesh . rankData . yRank > 0 ) { yLow += 1 ; } #endif real localVol = 0.0 ; totalVol = 0.0 ; #ifdef PLANAR for ( int iX = xLow ; iX <= xTop ; iX ++ ) { for ( int iZ = zLow ; iZ <= zTop ; iZ ++ ) { localVol += ( mesh . dXi / mesh . xi_xColloc ( iX ) ) * ( mesh . dZt / mesh . zt_zColloc ( iZ ) ) ; } } #else for ( int iX = xLow ; iX <= xTop ; iX ++ ) { for ( int iY = yLow ; iY <= yTop ; iY ++ ) { for ( int iZ = zLow ; iZ <= zTop ; iZ ++ ) { localVol += ( mesh . dXi / mesh . xi_xColloc ( iX ) ) * ( mesh . dEt / mesh . et_yColloc ( iY ) ) * ( mesh . dZt / mesh . zt_zColloc ( iZ ) ) ; } } } #endif MPI_Allreduce ( & localVol , & totalVol , 1 , MPI_FP_REAL , MPI_SUM , MPI_COMM_WORLD ) ; if ( mesh . rankData . rank == 0 ) { if ( mesh . inputParams . probType <= 4 ) { std :: cout << std :: fixed << std :: setw ( 6 ) << " " << " \t " << std :: setw ( 16 ) << " " << " \t " << " " << std :: endl ; ofFile << " \n " ; } else { std :: cout << std :: fixed << std :: setw ( 6 ) << " " << " \t " << std :: setw ( 16 ) << " " << " \t " << " " << " \t " << " " << std :: endl ; ofFile << " \n " ; } } }
\brief   Constructor of the tseries class
          The constructor initializes the variables and parameters for writing time-series data
          The header for the time-series data file is also written here.
\ brief Constructor of the tseries class The constructor initializes the variables and parameters for writing time - series data The header for the time - series data file is also written here .
// Open TimeSeries file // UPPER AND LOWER LIMITS WHEN COMPUTING ENERGY IN STAGGERED GRID // STAGGERED GRIDS HAVE SHARED POINT ACROSS MPI-SUBDOMAINS - ACCORDINGLY DECREASE LIMITS // TOTAL VOLUME FOR AVERAGING THE RESULT OF VOLUMETRIC INTEGRATION // WRITE THE HEADERS FOR BOTH STANDARD I/O AS WELL AS THE OUTPUT TIME-SERIES FILE