lib/io/tseries.cc
/**
 ********************************************************************************************************************************************
 * \brief   Overloaded function to write the time-series data for scalar solver.
 *
 *          The function computes total energy, Nusselt number and divergence for scalar solver runs.
 *          Only the root rank (rank 0) writes the output.
 *          One line is written to the standard I/O, while another is written to the time series dat file.
 *
 * \param   T is a const reference to the temperature scalar field whose data is used to compute Nusselt number
 * \param   nu is a const reference to the real variable containing the value of kinematic viscosity
 * \param   kappa is a const reference to the real variable containing the value of thermal diffusion
 *
 ********************************************************************************************************************************************
 */
\brief   Overloaded function to write the time-series data for scalar solver.
The function computes total energy, Nusselt number and divergence for scalar solver runs.
Only the root rank (rank 0) writes the output.
One line is written to the standard I/O, while another is written to the time series dat file.

\param   T is a const reference to the temperature scalar field whose data is used to compute Nusselt number
\param   nu is a const reference to the real variable containing the value of kinematic viscosity
\param   kappa is a const reference to the real variable containing the value of thermal diffusion
\ brief Overloaded function to write the time - series data for scalar solver . The function computes total energy Nusselt number and divergence for scalar solver runs . Only the root rank ( rank 0 ) writes the output . One line is written to the standard I / O while another is written to the time series dat file . \ param T is a const reference to the temperature scalar field whose data is used to compute Nusselt number \ param nu is a const reference to the real variable containing the value of kinematic viscosity \ param kappa is a const reference to the real variable containing the value of thermal diffusion
void tseries::writeTSData(const sfield &T, const real nu, const real kappa) {
    V.divergence(divV, P);
    maxDivergence = divV.fxMax();
    if (maxDivergence > 1.0e5) {
        if (mesh.rankData.rank == 0) std::cout << std::endl << "ERROR: Divergence exceeds permissible limits. ABORTING" << std::endl << std::endl;
        MPI_Finalize();
        exit(0);
    }
    localEnergy = 0.0;
    totalEnergy = 0.0;
    localUzT = 0.0;
#ifdef PLANAR
    int iY = 0;
    for (int iX = xLow; iX <= xTop; iX++) {
        for (int iZ = zLow; iZ <= zTop; iZ++) {
            localEnergy += (pow((V.Vx.F(iX-1, iY, iZ) + V.Vx.F(iX, iY, iZ))/2.0, 2.0) +
                            pow((V.Vz.F(iX, iY, iZ-1) + V.Vz.F(iX, iY, iZ))/2.0, 2.0))*(mesh.dXi/mesh.xi_xColloc(iX))*(mesh.dZt/mesh.zt_zColloc(iZ));
            localUzT += ((V.Vz.F(iX, iY, iZ) + V.Vz.F(iX, iY, iZ-1))/2.0)*T.F.F(iX, iY, iZ)*(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++) {
                localEnergy += (pow((V.Vx.F(iX-1, iY, iZ) + V.Vx.F(iX, iY, iZ))/2.0, 2.0) +
                                pow((V.Vy.F(iX, iY-1, iZ) + V.Vy.F(iX, iY, iZ))/2.0, 2.0) +
                                pow((V.Vz.F(iX, iY, iZ-1) + V.Vz.F(iX, iY, iZ))/2.0, 2.0))*(mesh.dXi/mesh.xi_xColloc(iX))*(mesh.dEt/mesh.et_yColloc(iY))*(mesh.dZt/mesh.zt_zColloc(iZ));
                localUzT += ((V.Vz.F(iX, iY, iZ) + V.Vz.F(iX, iY, iZ-1))/2.0)*T.F.F(iX, iY, iZ)*(mesh.dXi/mesh.xi_xColloc(iX))*(mesh.dEt/mesh.et_yColloc(iY))*(mesh.dZt/mesh.zt_zColloc(iZ));
            }
        }
    }
#endif
    MPI_Allreduce(&localEnergy, &totalEnergy, 1, MPI_FP_REAL, MPI_SUM, MPI_COMM_WORLD);
    MPI_Allreduce(&localUzT, &totalUzT, 1, MPI_FP_REAL, MPI_SUM, MPI_COMM_WORLD);
    totalEnergy /= totalVol;
    NusseltNo = 1.0 + (totalUzT/totalVol)/kappa;
    if (mesh.rankData.rank == 0) {
        std::cout << std::fixed << std::setw(6)  << std::setprecision(4) << time << "\t" <<
                                    std::setw(16) << std::setprecision(8) << sqrt(totalEnergy)/nu << "\t" << NusseltNo << "\t" << maxDivergence << std::endl;
        ofFile << std::fixed << std::setw(6)  << std::setprecision(4) << time << "\t" <<
                                std::setw(16) << std::setprecision(8) << sqrt(totalEnergy)/nu << "\t" << NusseltNo << "\t" << maxDivergence << "\t" << tStp << std::endl;
    }
}
void tseries :: writeTSData ( const sfield & T , const real nu , const real kappa ) { V . divergence ( divV , P ) ; maxDivergence = divV . fxMax ( ) ; if ( maxDivergence > 1.0e5 ) { if ( mesh . rankData . rank == 0 ) std :: cout << std :: endl << " " << std :: endl << std :: endl ; MPI_Finalize ( ) ; exit ( 0 ) ; } localEnergy = 0.0 ; totalEnergy = 0.0 ; localUzT = 0.0 ; #ifdef PLANAR int iY = 0 ; for ( int iX = xLow ; iX <= xTop ; iX ++ ) { for ( int iZ = zLow ; iZ <= zTop ; iZ ++ ) { localEnergy += ( pow ( ( V . Vx . F ( iX - 1 , iY , iZ ) + V . Vx . F ( iX , iY , iZ ) ) / 2.0 , 2.0 ) + pow ( ( V . Vz . F ( iX , iY , iZ - 1 ) + V . Vz . F ( iX , iY , iZ ) ) / 2.0 , 2.0 ) ) * ( mesh . dXi / mesh . xi_xColloc ( iX ) ) * ( mesh . dZt / mesh . zt_zColloc ( iZ ) ) ; localUzT += ( ( V . Vz . F ( iX , iY , iZ ) + V . Vz . F ( iX , iY , iZ - 1 ) ) / 2.0 ) * T . F . F ( iX , iY , iZ ) * ( 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 ++ ) { localEnergy += ( pow ( ( V . Vx . F ( iX - 1 , iY , iZ ) + V . Vx . F ( iX , iY , iZ ) ) / 2.0 , 2.0 ) + pow ( ( V . Vy . F ( iX , iY - 1 , iZ ) + V . Vy . F ( iX , iY , iZ ) ) / 2.0 , 2.0 ) + pow ( ( V . Vz . F ( iX , iY , iZ - 1 ) + V . Vz . F ( iX , iY , iZ ) ) / 2.0 , 2.0 ) ) * ( mesh . dXi / mesh . xi_xColloc ( iX ) ) * ( mesh . dEt / mesh . et_yColloc ( iY ) ) * ( mesh . dZt / mesh . zt_zColloc ( iZ ) ) ; localUzT += ( ( V . Vz . F ( iX , iY , iZ ) + V . Vz . F ( iX , iY , iZ - 1 ) ) / 2.0 ) * T . F . F ( iX , iY , iZ ) * ( mesh . dXi / mesh . xi_xColloc ( iX ) ) * ( mesh . dEt / mesh . et_yColloc ( iY ) ) * ( mesh . dZt / mesh . zt_zColloc ( iZ ) ) ; } } } #endif MPI_Allreduce ( & localEnergy , & totalEnergy , 1 , MPI_FP_REAL , MPI_SUM , MPI_COMM_WORLD ) ; MPI_Allreduce ( & localUzT , & totalUzT , 1 , MPI_FP_REAL , MPI_SUM , MPI_COMM_WORLD ) ; totalEnergy /= totalVol ; NusseltNo = 1.0 + ( totalUzT / totalVol ) / kappa ; if ( mesh . rankData . rank == 0 ) { std :: cout << std :: fixed << std :: setw ( 6 ) << std :: setprecision ( 4 ) << time << " \t " << std :: setw ( 16 ) << std :: setprecision ( 8 ) << sqrt ( totalEnergy ) / nu << " \t " << NusseltNo << " \t " << maxDivergence << std :: endl ; ofFile << std :: fixed << std :: setw ( 6 ) << std :: setprecision ( 4 ) << time << " \t " << std :: setw ( 16 ) << std :: setprecision ( 8 ) << sqrt ( totalEnergy ) / nu << " \t " << NusseltNo << " \t " << maxDivergence << " \t " << tStp << std :: endl ; } }
\brief   Overloaded function to write the time-series data for scalar solver.
\ brief Overloaded function to write the time - series data for scalar solver .
// COMPUTE ENERGY AND DIVERGENCE FOR THE INITIAL CONDITION