From 4c4c296d62f70073f384c5c27c09e322adfcb94a Mon Sep 17 00:00:00 2001 From: Francisco Palacios Date: Sun, 17 Apr 2016 16:51:33 -0700 Subject: [PATCH 1/2] Updated IO --- SU2_CFD/include/solver_structure.hpp | 10 +- SU2_CFD/include/solver_structure.inl | 4 +- SU2_CFD/src/output_structure.cpp | 229 ++++++++++++++++++++------- SU2_CFD/src/output_tecplot.cpp | 24 ++- SU2_CFD/src/solver_direct_mean.cpp | 35 ++-- 5 files changed, 222 insertions(+), 80 deletions(-) diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 653790d3cb3..63a0eed4392 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -2081,8 +2081,8 @@ class CSolver { * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. * \return Value of the skin friction coefficient. */ - virtual su2double GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex); - + virtual su2double GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim); + /*! * \brief A virtual member. * \param[in] val_marker - Surface marker where the coefficient is computed. @@ -4654,7 +4654,7 @@ class CNSSolver : public CEulerSolver { *CQ_Visc, /*!< \brief Torque coefficient (viscous contribution) for each boundary. */ *Heat_Visc, /*!< \brief Heat load (viscous contribution) for each boundary. */ *MaxHeatFlux_Visc, /*!< \brief Maximum heat flux (viscous contribution) for each boundary. */ - **CSkinFriction; /*!< \brief Skin friction coefficient for each boundary and vertex. */ + ***CSkinFriction; /*!< \brief Skin friction coefficient for each boundary and vertex. */ su2double *ForceViscous, /*!< \brief Viscous force for each boundary. */ *MomentViscous; /*!< \brief Inviscid moment for each boundary. */ su2double AllBound_CDrag_Visc, /*!< \brief Drag coefficient (viscous contribution) for all the boundaries. */ @@ -4830,8 +4830,8 @@ class CNSSolver : public CEulerSolver { * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. * \return Value of the skin friction coefficient. */ - su2double GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex); - + su2double GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim); + /*! * \brief Get the skin friction coefficient. * \param[in] val_marker - Surface marker where the coefficient is computed. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index ae1f7f7925a..d3786e4e31b 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -324,7 +324,7 @@ inline void CSolver::SetHeatFluxTarget(unsigned short val_marker, unsigned long inline su2double *CSolver::GetCharacPrimVar(unsigned short val_marker, unsigned long val_vertex) { return 0; } -inline su2double CSolver::GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex) { return 0; } +inline su2double CSolver::GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim) { return 0; } inline su2double CSolver::GetHeatFlux(unsigned short val_marker, unsigned long val_vertex) { return 0; } @@ -1055,7 +1055,7 @@ inline su2double CNSSolver::GetAllBound_CSideForce_Visc() { return AllBound_CSid inline su2double CNSSolver::GetAllBound_CDrag_Visc() { return AllBound_CDrag_Visc; } -inline su2double CNSSolver::GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex) { return CSkinFriction[val_marker][val_vertex]; } +inline su2double CNSSolver::GetCSkinFriction(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim) { return CSkinFriction[val_marker][val_vertex][val_dim]; } inline su2double CNSSolver::GetHeatFlux(unsigned short val_marker, unsigned long val_vertex) { return HeatFlux[val_marker][val_vertex]; } diff --git a/SU2_CFD/src/output_structure.cpp b/SU2_CFD/src/output_structure.cpp index 12cb1581a8b..6c9f6f5d899 100644 --- a/SU2_CFD/src/output_structure.cpp +++ b/SU2_CFD/src/output_structure.cpp @@ -50,11 +50,12 @@ COutput::COutput(void) { nGlobal_BoundQuad = 0; /*--- Initialize pointers to NULL ---*/ - Coords=NULL; - Conn_Line=NULL; Conn_BoundTria=NULL; Conn_BoundQuad=NULL; - Conn_Tria=NULL; Conn_Quad=NULL; Conn_Tetr=NULL; - Conn_Hexa=NULL; Conn_Pris=NULL; Conn_Pyra=NULL; - Data=NULL; + + Coords = NULL; + Conn_Line = NULL; Conn_BoundTria = NULL; Conn_BoundQuad = NULL; + Conn_Tria = NULL; Conn_Quad = NULL; Conn_Tetr = NULL; + Conn_Hexa = NULL; Conn_Pris = NULL; Conn_Pyra = NULL; + Data = NULL; /*--- Initialize CGNS write flag ---*/ @@ -90,9 +91,9 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, CSolver *FlowSolver, unsigned long iExtIter, unsigned short val_iZone) { - unsigned short iMarker; + unsigned short iMarker, iDim; unsigned long iPoint, iVertex, Global_Index; - su2double PressCoeff = 0.0, SkinFrictionCoeff; + su2double PressCoeff = 0.0, SkinFrictionCoeff[3]; su2double xCoord = 0.0, yCoord = 0.0, zCoord = 0.0, Mach, Pressure; char cstr[200]; @@ -131,11 +132,14 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, SurfFlow_file << "\"Global_Index\", \"x_coord\", \"y_coord\", "; if (nDim == 3) SurfFlow_file << "\"z_coord\", "; - SurfFlow_file << "\"Pressure\", \"Pressure_Coefficient\", "; + SurfFlow_file << "\"Pressure\", \"Cp\", "; switch (solver) { - case EULER : SurfFlow_file << "\"Mach_Number\"" << endl; break; - case NAVIER_STOKES: case RANS: SurfFlow_file << "\"Skin_Friction_Coefficient\", \"Heat_Flux\"" << endl; break; + case EULER : SurfFlow_file << "\"Mach\"" << endl; break; + case NAVIER_STOKES: case RANS: + if (nDim == 2) SurfFlow_file << "\"Cf_x\", \"Cf_y\", \"h\"" << endl; + if (nDim == 3) SurfFlow_file << "\"Cf_x\", \"Cf_y\", \"Cf_z\", \"h\"" << endl; + break; } for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -164,10 +168,15 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, Mach = sqrt(FlowSolver->node[iPoint]->GetVelocity2()) / FlowSolver->node[iPoint]->GetSoundSpeed(); SurfFlow_file << scientific << Mach << endl; break; - case NAVIER_STOKES: case RANS: - SkinFrictionCoeff = FlowSolver->GetCSkinFriction(iMarker, iVertex); + case RANS: + + for (iDim = 0; iDim < nDim; iDim++) + SkinFrictionCoeff[iDim] = FlowSolver->GetCSkinFriction(iMarker, iVertex, iDim); HeatFlux = FlowSolver->GetHeatFlux(iMarker, iVertex); - SurfFlow_file << scientific << SkinFrictionCoeff << ", " << HeatFlux << endl; + + if (nDim == 2) SurfFlow_file << scientific << SkinFrictionCoeff[0] << ", " << SkinFrictionCoeff[1] << ", " << HeatFlux << endl; + if (nDim == 3) SurfFlow_file << scientific << SkinFrictionCoeff[0] << ", " << SkinFrictionCoeff[1] << ", " << SkinFrictionCoeff[2] << ", " << HeatFlux << endl; + break; } } @@ -227,8 +236,14 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, su2double *Buffer_Send_Mach = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_Mach = NULL; - su2double *Buffer_Send_SkinFriction = new su2double [MaxLocalVertex_Surface]; - su2double *Buffer_Recv_SkinFriction = NULL; + su2double *Buffer_Send_SkinFriction_x = new su2double [MaxLocalVertex_Surface]; + su2double *Buffer_Recv_SkinFriction_x = NULL; + + su2double *Buffer_Send_SkinFriction_y = new su2double [MaxLocalVertex_Surface]; + su2double *Buffer_Recv_SkinFriction_y = NULL; + + su2double *Buffer_Send_SkinFriction_z = new su2double [MaxLocalVertex_Surface]; + su2double *Buffer_Recv_SkinFriction_z = NULL; su2double *Buffer_Send_HeatTransfer = new su2double [MaxLocalVertex_Surface]; su2double *Buffer_Recv_HeatTransfer = NULL; @@ -245,7 +260,9 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, Buffer_Recv_Press = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_CPress = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_Mach = new su2double [nProcessor*MaxLocalVertex_Surface]; - Buffer_Recv_SkinFriction = new su2double [nProcessor*MaxLocalVertex_Surface]; + Buffer_Recv_SkinFriction_x = new su2double [nProcessor*MaxLocalVertex_Surface]; + Buffer_Recv_SkinFriction_y = new su2double [nProcessor*MaxLocalVertex_Surface]; + if (nDim == 3) Buffer_Recv_SkinFriction_z = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_HeatTransfer = new su2double [nProcessor*MaxLocalVertex_Surface]; Buffer_Recv_GlobalIndex = new unsigned long [nProcessor*MaxLocalVertex_Surface]; } @@ -278,8 +295,11 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, if (solver == EULER) Buffer_Send_Mach[nVertex_Surface] = sqrt(FlowSolver->node[iPoint]->GetVelocity2()) / FlowSolver->node[iPoint]->GetSoundSpeed(); - if ((solver == NAVIER_STOKES) || (solver == RANS)) - Buffer_Send_SkinFriction[nVertex_Surface] = FlowSolver->GetCSkinFriction(iMarker, iVertex); + if ((solver == NAVIER_STOKES) || (solver == RANS)) { + Buffer_Send_SkinFriction_x[nVertex_Surface] = FlowSolver->GetCSkinFriction(iMarker, iVertex, 0); + Buffer_Send_SkinFriction_y[nVertex_Surface] = FlowSolver->GetCSkinFriction(iMarker, iVertex, 1); + if (nDim == 3) Buffer_Send_SkinFriction_z[nVertex_Surface] = FlowSolver->GetCSkinFriction(iMarker, iVertex, 2); + } nVertex_Surface++; } } @@ -292,7 +312,11 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, SU2_MPI::Gather(Buffer_Send_Press, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Press, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_CPress, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_CPress, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); if (solver == EULER) SU2_MPI::Gather(Buffer_Send_Mach, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_Mach, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - if ((solver == NAVIER_STOKES) || (solver == RANS)) SU2_MPI::Gather(Buffer_Send_SkinFriction, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_SkinFriction, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + if ((solver == NAVIER_STOKES) || (solver == RANS)) { + SU2_MPI::Gather(Buffer_Send_SkinFriction_x, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_SkinFriction_x, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Gather(Buffer_Send_SkinFriction_y, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_SkinFriction_y, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + if (nDim == 3) SU2_MPI::Gather(Buffer_Send_SkinFriction_z, MaxLocalVertex_Surface, MPI_DOUBLE, Buffer_Recv_SkinFriction_z, MaxLocalVertex_Surface, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + } SU2_MPI::Gather(Buffer_Send_GlobalIndex, MaxLocalVertex_Surface, MPI_UNSIGNED_LONG, Buffer_Recv_GlobalIndex, MaxLocalVertex_Surface, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); /*--- The master node unpacks the data and writes the surface CSV file ---*/ @@ -329,11 +353,14 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, SurfFlow_file << "\"Global_Index\", \"x_coord\", \"y_coord\", "; if (nDim == 3) SurfFlow_file << "\"z_coord\", "; - SurfFlow_file << "\"Pressure\", \"Pressure_Coefficient\", "; + SurfFlow_file << "\"Pressure\", \"Cp\", "; switch (solver) { - case EULER : SurfFlow_file << "\"Mach_Number\"" << endl; break; - case NAVIER_STOKES: case RANS: SurfFlow_file << "\"Skin_Friction_Coefficient\"" << endl; break; + case EULER : SurfFlow_file << "\"Mach\"" << endl; break; + case NAVIER_STOKES: case RANS: + if (nDim == 2) SurfFlow_file << "\"Cf_x\", \"Cf_y\"" << endl; + if (nDim == 3) SurfFlow_file << "\"Cf_x\", \"Cf_y\", \"Cf_z\"" << endl; + break; } /*--- Loop through all of the collected data and write each node's values ---*/ @@ -365,8 +392,11 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, SurfFlow_file << scientific << Mach << endl; break; case NAVIER_STOKES: case RANS: - SkinFrictionCoeff = Buffer_Recv_SkinFriction[Total_Index]; - SurfFlow_file << scientific << SkinFrictionCoeff << endl; + SkinFrictionCoeff[0] = Buffer_Recv_SkinFriction_x[Total_Index]; + SkinFrictionCoeff[1] = Buffer_Recv_SkinFriction_y[Total_Index]; + if (nDim == 3) SkinFrictionCoeff[2] = Buffer_Recv_SkinFriction_z[Total_Index]; + if (nDim == 2) SurfFlow_file << scientific << SkinFrictionCoeff[0] << ", " << SkinFrictionCoeff[1] << endl; + if (nDim == 3) SurfFlow_file << scientific << SkinFrictionCoeff[0] << ", " << SkinFrictionCoeff[1] << ", " << SkinFrictionCoeff[2] << endl; break; } } @@ -383,7 +413,9 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, delete [] Buffer_Recv_Press; delete [] Buffer_Recv_CPress; delete [] Buffer_Recv_Mach; - delete [] Buffer_Recv_SkinFriction; + delete [] Buffer_Recv_SkinFriction_x; + delete [] Buffer_Recv_SkinFriction_y; + if (nDim == 3) delete [] Buffer_Recv_SkinFriction_z; delete [] Buffer_Recv_HeatTransfer; delete [] Buffer_Recv_GlobalIndex; @@ -399,7 +431,9 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, delete [] Buffer_Send_Press; delete [] Buffer_Send_CPress; delete [] Buffer_Send_Mach; - delete [] Buffer_Send_SkinFriction; + delete [] Buffer_Send_SkinFriction_x; + delete [] Buffer_Send_SkinFriction_y; + delete [] Buffer_Send_SkinFriction_z; delete [] Buffer_Send_HeatTransfer; delete [] Buffer_Send_GlobalIndex; @@ -1853,13 +1887,13 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv unsigned short iVar = 0, jVar = 0, FirstIndex = NONE, SecondIndex = NONE, ThirdIndex = NONE; unsigned short nVar_First = 0, nVar_Second = 0, nVar_Third = 0; unsigned short iVar_GridVel = 0, iVar_PressCp = 0, iVar_Density = 0, iVar_Lam = 0, iVar_MachMean = 0, - iVar_ViscCoeffs = 0, iVar_Sens = 0, iVar_Extra = 0, iVar_Eddy = 0, iVar_Sharp = 0, + iVar_ViscCoeffs = 0, iVar_HeatCoeffs = 0, iVar_Sens = 0, iVar_Extra = 0, iVar_Eddy = 0, iVar_Sharp = 0, iVar_FEA_Vel = 0, iVar_FEA_Accel = 0, iVar_FEA_Stress = 0, iVar_FEA_Stress_3D = 0, iVar_FEA_Extra = 0, iVar_SensDim = 0; unsigned long iPoint = 0, jPoint = 0, iVertex = 0, iMarker = 0; su2double Gas_Constant, Mach2Vel, Mach_Motion, RefDensity, RefPressure = 0.0, factor = 0.0; - su2double *Aux_Frict = NULL, *Aux_Heat = NULL, *Aux_yPlus = NULL, *Aux_Sens = NULL; + su2double *Aux_Frict_x = NULL, *Aux_Frict_y = NULL, *Aux_Frict_z = NULL, *Aux_Heat = NULL, *Aux_yPlus = NULL, *Aux_Sens = NULL; unsigned short CurrentIndex; int *Local_Halo; @@ -1972,8 +2006,13 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv /*--- Add Laminar Viscosity, Skin Friction, Heat Flux, & yPlus to the restart file ---*/ if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - iVar_Lam = nVar_Total; nVar_Total += 1; - iVar_ViscCoeffs = nVar_Total; nVar_Total += 3; + iVar_Lam = nVar_Total; + nVar_Total += 1; + iVar_ViscCoeffs = nVar_Total; + if (geometry->GetnDim() == 2) nVar_Total += 2; + else if (geometry->GetnDim() == 3) nVar_Total += 3; + iVar_HeatCoeffs = nVar_Total; + nVar_Total += 2; } /*--- Add Eddy Viscosity to the restart file ---*/ @@ -2097,7 +2136,9 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv /*--- Auxiliary vectors for surface coefficients ---*/ if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - Aux_Frict = new su2double[geometry->GetnPoint()]; + Aux_Frict_x = new su2double[geometry->GetnPoint()]; + Aux_Frict_y = new su2double[geometry->GetnPoint()]; + Aux_Frict_z = new su2double[geometry->GetnPoint()]; Aux_Heat = new su2double[geometry->GetnPoint()]; Aux_yPlus = new su2double[geometry->GetnPoint()]; } @@ -2554,7 +2595,91 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv } } - /*--- Communicate skin friction, heat transfer, y+ ---*/ + /*--- Communicate skin friction ---*/ + + /*--- First, loop through the mesh in order to find and store the + value of the viscous coefficients at any surface nodes. They + will be placed in an auxiliary vector and then communicated like + all other volumetric variables. ---*/ + + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + Aux_Frict_x[iPoint] = 0.0; + Aux_Frict_y[iPoint] = 0.0; + Aux_Frict_z[iPoint] = 0.0; + } + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) + if (config->GetMarker_All_Plotting(iMarker) == YES) { + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + Aux_Frict_x[iPoint] = solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, 0); + Aux_Frict_y[iPoint] = solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, 1); + if (geometry->GetnDim() == 3) Aux_Frict_z[iPoint] = solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, 2); + } + } + + /*--- Loop over this partition to collect the current variable ---*/ + + jPoint = 0; + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + + /*--- Check for halos & write only if requested ---*/ + + if (!Local_Halo[iPoint] || Wrt_Halo) { + + /*--- Load buffers with the three grid velocity components. ---*/ + + Buffer_Send_Var[jPoint] = Aux_Frict_x[iPoint]; + Buffer_Send_Res[jPoint] = Aux_Frict_y[iPoint]; + if (geometry->GetnDim() == 3) + Buffer_Send_Vol[jPoint] = Aux_Frict_z[iPoint]; + jPoint++; + } + } + + /*--- Gather the data on the master node. ---*/ + +#ifdef HAVE_MPI + SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + if (geometry->GetnDim() == 3) { + SU2_MPI::Gather(Buffer_Send_Vol, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Vol, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + } +#else + for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) + Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; + for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) + Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; + if (geometry->GetnDim() == 3) { + for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) + Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; + } +#endif + + /*--- The master node unpacks and sorts this variable by global index ---*/ + + if (rank == MASTER_NODE) { + jPoint = 0; + iVar = iVar_ViscCoeffs; + for (iProcessor = 0; iProcessor < size; iProcessor++) { + for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { + + /*--- Get global index, then loop over each variable and store ---*/ + + iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; + Data[iVar][iGlobal_Index] = Buffer_Recv_Var[jPoint]; + Data[iVar + 1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; + if (geometry->GetnDim() == 3) + Data[iVar + 2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; + jPoint++; + } + + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ + + jPoint = (iProcessor + 1) * nBuffer_Scalar; + } + } + + /*--- Communicate heat transfer, y+ ---*/ /*--- First, loop through the mesh in order to find and store the value of the viscous coefficients at any surface nodes. They @@ -2562,16 +2687,14 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv all other volumetric variables. ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - Aux_Frict[iPoint] = 0.0; - Aux_Heat[iPoint] = 0.0; + Aux_Heat[iPoint] = 0.0; Aux_yPlus[iPoint] = 0.0; } for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) if (config->GetMarker_All_Plotting(iMarker) == YES) { for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Aux_Frict[iPoint] = solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex); - Aux_Heat[iPoint] = solver[FLOW_SOL]->GetHeatFlux(iMarker, iVertex); + Aux_Heat[iPoint] = solver[FLOW_SOL]->GetHeatFlux(iMarker, iVertex); Aux_yPlus[iPoint] = solver[FLOW_SOL]->GetYPlus(iMarker, iVertex); } } @@ -2583,18 +2706,15 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv /*--- Check for halos & write only if requested ---*/ - if (!Local_Halo[iPoint] || Wrt_Halo) { /*--- Load buffers with the skin friction, heat transfer, y+ variables. ---*/ if (compressible) { - Buffer_Send_Var[jPoint] = Aux_Frict[iPoint]; Buffer_Send_Res[jPoint] = Aux_Heat[iPoint]; Buffer_Send_Vol[jPoint] = Aux_yPlus[iPoint]; } if (incompressible || freesurface) { - Buffer_Send_Var[jPoint] = Aux_Frict[iPoint]; Buffer_Send_Res[jPoint] = Aux_Heat[iPoint]; Buffer_Send_Vol[jPoint] = Aux_yPlus[iPoint]; } @@ -2605,39 +2725,40 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv /*--- Gather the data on the master node. ---*/ #ifdef HAVE_MPI - SU2_MPI::Gather(Buffer_Send_Var, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Var, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Res, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Res, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(Buffer_Send_Vol, nBuffer_Scalar, MPI_DOUBLE, Buffer_Recv_Vol, nBuffer_Scalar, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); #else - for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Var[iPoint] = Buffer_Send_Var[iPoint]; - for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; - for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; + for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) + Buffer_Recv_Res[iPoint] = Buffer_Send_Res[iPoint]; + for (iPoint = 0; iPoint < nBuffer_Scalar; iPoint++) + Buffer_Recv_Vol[iPoint] = Buffer_Send_Vol[iPoint]; #endif /*--- The master node unpacks and sorts this variable by global index ---*/ if (rank == MASTER_NODE) { - jPoint = 0; iVar = iVar_ViscCoeffs; - + jPoint = 0; + iVar = iVar_HeatCoeffs; + for (iProcessor = 0; iProcessor < size; iProcessor++) { for (iPoint = 0; iPoint < Buffer_Recv_nPoint[iProcessor]; iPoint++) { /*--- Get global index, then loop over each variable and store ---*/ iGlobal_Index = Buffer_Recv_GlobalIndex[jPoint]; - Data[iVar+0][iGlobal_Index] = Buffer_Recv_Var[jPoint]; - Data[iVar+1][iGlobal_Index] = Buffer_Recv_Res[jPoint]; - Data[iVar+2][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; + Data[iVar + 0][iGlobal_Index] = Buffer_Recv_Res[jPoint]; + Data[iVar + 1][iGlobal_Index] = Buffer_Recv_Vol[jPoint]; jPoint++; } /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - jPoint = (iProcessor+1)*nBuffer_Scalar; + jPoint = (iProcessor + 1) * nBuffer_Scalar; } } } + /*--- Communicate the Eddy Viscosity ---*/ if (Kind_Solver == RANS) { @@ -3259,7 +3380,8 @@ void COutput::MergeSolution(CConfig *config, CGeometry *geometry, CSolver **solv delete [] Local_Halo; if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - delete [] Aux_Frict; delete [] Aux_Heat; delete [] Aux_yPlus; + delete[] Aux_Frict_x; delete[] Aux_Frict_y; delete[] Aux_Frict_z; + delete [] Aux_Heat; delete [] Aux_yPlus; } if (( Kind_Solver == ADJ_EULER ) || ( Kind_Solver == ADJ_NAVIER_STOKES ) || @@ -3587,15 +3709,16 @@ void COutput::SetRestart(CConfig *config, CGeometry *geometry, CSolver **solver, } if ((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - restart_file << "\t\"Pressure\"\t\"Temperature\"\t\"Pressure_Coefficient\"\t\"Mach\""; + restart_file << "\t\"Pressure\"\t\"Temperature\"\t\"Cp\"\t\"Mach\""; } if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - restart_file << "\t\"Laminar_Viscosity\"\t\"Skin_Friction_Coefficient\"\t\"Heat_Flux\"\t\"Y_Plus\""; + if (nDim == 2) restart_file << "\t\"m\"\t\"Cf_x\"\t\"Cf_y\"\t\"h\"\t\"y+\""; + if (nDim == 3) restart_file << "\t\"m\"\t\"Cf_x\"\t\"Cf_y\"\t\"Cf_z\"\t\"h\"\t\"y+\""; } if (Kind_Solver == RANS) { - restart_file << "\t\"Eddy_Viscosity\""; + restart_file << "\t\"mt\""; } if (config->GetWrt_SharpEdges()) { diff --git a/SU2_CFD/src/output_tecplot.cpp b/SU2_CFD/src/output_tecplot.cpp index 77813e82054..e9540370b9f 100644 --- a/SU2_CFD/src/output_tecplot.cpp +++ b/SU2_CFD/src/output_tecplot.cpp @@ -175,15 +175,16 @@ void COutput::SetTecplotASCII(CConfig *config, CGeometry *geometry, CSolver **so } if ((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - Tecplot_File << ",\"Pressure\",\"Temperature\",\"Pressure_Coefficient\",\"Mach\""; + Tecplot_File << ",\"Pressure\",\"Temperature\",\"Cp\",\"Mach\""; } if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - Tecplot_File << ",\"Laminar_Viscosity\", \"Skin_Friction_Coefficient\", \"Heat_Flux\", \"Y_Plus\""; + if (nDim == 2) Tecplot_File << ", \"m\", \"Cf_x\", \"Cf_y\", \"h\", \"y+\""; + else Tecplot_File << ", \"m\", \"Cf_x\", \"Cf_y\", \"Cf_z\", \"h\", \"y+\""; } if (Kind_Solver == RANS) { - Tecplot_File << ", \"Eddy_Viscosity\""; + Tecplot_File << ", \"mt\""; } if (config->GetWrt_SharpEdges()) { @@ -492,10 +493,11 @@ void COutput::SetTecplotASCII_LowMemory(CConfig *config, CGeometry *geometry, CS } if ((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - Tecplot_File << ",\"Pressure\",\"Temperature\",\"Pressure_Coefficient\",\"Mach\""; + Tecplot_File << ", \"Pressure\",\"Temperature\",\"Cp\",\"Mach\""; if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - Tecplot_File << ",\"Laminar_Viscosity\", \"Skin_Friction_Coefficient\", \"Heat_Flux\", \"Y_Plus\""; - if (Kind_Solver == RANS) { Tecplot_File << ", \"Eddy_Viscosity\""; } + if (geometry->GetnDim() == 2) Tecplot_File << ", \"m\", \"Cf_x\", \"Cf_y\", \"h\", \"y+\""; + else Tecplot_File << ", \"m\", \"Cf_x\", \"Cf_y\", \"Cf_z\", \"h\", \"y+\""; + if (Kind_Solver == RANS) { Tecplot_File << ", \"mt\""; } } if (config->GetWrt_SharpEdges()) { Tecplot_File << ", \"Sharp_Edge_Dist\""; } } @@ -2624,8 +2626,14 @@ string COutput::AssembleVariableNames(CGeometry *geometry, CConfig *config, unsi } if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - variables << "Laminar_Viscosity Skin_Friction_Coefficient Heat_Flux Y_Plus "; - *NVar += 4; + if (nDim == 2) { + variables << "Laminar_Viscosity Skin_Friction_Coefficient_x Skin_Friction_Coefficient_y Heat_Flux Y_Plus "; + *NVar += 5; + } + else { + variables << "Laminar_Viscosity Skin_Friction_Coefficient_x Skin_Friction_Coefficient_y Skin_Friction_Coefficient_z Heat_Flux Y_Plus "; + *NVar += 6; + } } if (Kind_Solver == RANS) { diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 7f49bcd855c..814adbb43c2 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -12217,11 +12217,14 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Skin friction in all the markers ---*/ - CSkinFriction = new su2double* [nMarker]; + CSkinFriction = new su2double** [nMarker]; for (iMarker = 0; iMarker < nMarker; iMarker++) { - CSkinFriction[iMarker] = new su2double [geometry->nVertex[iMarker]]; + CSkinFriction[iMarker] = new su2double* [geometry->nVertex[iMarker]]; for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - CSkinFriction[iMarker][iVertex] = 0.0; + CSkinFriction[iMarker][iVertex] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) { + CSkinFriction[iMarker][iVertex][iDim] = 0.0; + } } } @@ -12723,7 +12726,7 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) } CNSSolver::~CNSSolver(void) { - unsigned short iMarker; + unsigned short iMarker, iDim; if (CDrag_Visc != NULL) delete [] CDrag_Visc; if (CLift_Visc != NULL) delete [] CLift_Visc; @@ -12758,9 +12761,11 @@ CNSSolver::~CNSSolver(void) { if (CSkinFriction != NULL) { for (iMarker = 0; iMarker < nMarker; iMarker++) { - delete CSkinFriction[iMarker]; + for (iDim = 0; iDim < nDim; iDim++) { + delete CSkinFriction[iMarker][iDim]; + } + delete [] CSkinFriction; } - delete [] CSkinFriction; } } @@ -13228,7 +13233,7 @@ void CNSSolver::Viscous_Forces(CGeometry *geometry, CConfig *config) { unsigned short Boundary, Monitoring, iMarker, iMarker_Monitoring, iDim, jDim; su2double Viscosity = 0.0, div_vel, *Normal, MomentDist[3] = {0.0, 0.0, 0.0}, WallDist[3] = {0.0, 0.0, 0.0}, *Coord, *Coord_Normal, Area, WallShearStress, TauNormal, factor, RefTemp, RefVel2, - RefDensity, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, + RefDensity, GradTemperature, Density = 0.0, Vel[3] = {0.0, 0.0, 0.0}, WallDistMod, FrictionVel, Mach2Vel, Mach_Motion, UnitNormal[3] = {0.0, 0.0, 0.0}, TauElem[3] = {0.0, 0.0, 0.0}, TauTangent[3] = {0.0, 0.0, 0.0}, Tau[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Force[3] = {0.0, 0.0, 0.0}, Cp, thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Grad_Temp[3] = {0.0, 0.0, 0.0}, @@ -13371,19 +13376,25 @@ void CNSSolver::Viscous_Forces(CGeometry *geometry, CConfig *config) { } } - /*--- Compute wall shear stress (using the stress tensor) ---*/ + /*--- Compute wall shear stress (using the stress tensor). Compute wall skin friction coefficient, and heat flux on the wall ---*/ TauNormal = 0.0; for (iDim = 0; iDim < nDim; iDim++) TauNormal += TauElem[iDim] * UnitNormal[iDim]; - for (iDim = 0; iDim < nDim; iDim++) TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; - WallShearStress = 0.0; for (iDim = 0; iDim < nDim; iDim++) WallShearStress += TauTangent[iDim]*TauTangent[iDim]; + + WallShearStress = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; + CSkinFriction[iMarker][iVertex][iDim] = TauTangent[iDim] / (0.5*RefDensity*RefVel2); + WallShearStress += CSkinFriction[iMarker][iVertex][iDim]*CSkinFriction[iMarker][iVertex][iDim]; + } WallShearStress = sqrt(WallShearStress); + for (iDim = 0; iDim < nDim; iDim++) + Vel[iDim] = node[iPointNormal]->GetVelocity(iDim); + for (iDim = 0; iDim < nDim; iDim++) WallDist[iDim] = (Coord[iDim] - Coord_Normal[iDim]); WallDistMod = 0.0; for (iDim = 0; iDim < nDim; iDim++) WallDistMod += WallDist[iDim]*WallDist[iDim]; WallDistMod = sqrt(WallDistMod); - /*--- Compute wall skin friction coefficient, and heat flux on the wall ---*/ - CSkinFriction[iMarker][iVertex] = WallShearStress / (0.5*RefDensity*RefVel2); /*--- Compute y+ and non-dimensional velocity ---*/ From 7e81b39634892a19b18632f47530056f8eebe9e0 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Sun, 17 Apr 2016 22:05:56 -0700 Subject: [PATCH 2/2] Fixed some warnings. --- SU2_CFD/src/output_structure.cpp | 3 ++- SU2_CFD/src/solver_direct_mean.cpp | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/output_structure.cpp b/SU2_CFD/src/output_structure.cpp index 6c9f6f5d899..e031be9929c 100644 --- a/SU2_CFD/src/output_structure.cpp +++ b/SU2_CFD/src/output_structure.cpp @@ -91,7 +91,7 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, CSolver *FlowSolver, unsigned long iExtIter, unsigned short val_iZone) { - unsigned short iMarker, iDim; + unsigned short iMarker; unsigned long iPoint, iVertex, Global_Index; su2double PressCoeff = 0.0, SkinFrictionCoeff[3]; su2double xCoord = 0.0, yCoord = 0.0, zCoord = 0.0, Mach, Pressure; @@ -102,6 +102,7 @@ void COutput::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, #ifndef HAVE_MPI + unsigned short iDim; su2double HeatFlux; char buffer [50]; ofstream SurfFlow_file; diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 814adbb43c2..a96d4536655 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -13233,7 +13233,7 @@ void CNSSolver::Viscous_Forces(CGeometry *geometry, CConfig *config) { unsigned short Boundary, Monitoring, iMarker, iMarker_Monitoring, iDim, jDim; su2double Viscosity = 0.0, div_vel, *Normal, MomentDist[3] = {0.0, 0.0, 0.0}, WallDist[3] = {0.0, 0.0, 0.0}, *Coord, *Coord_Normal, Area, WallShearStress, TauNormal, factor, RefTemp, RefVel2, - RefDensity, GradTemperature, Density = 0.0, Vel[3] = {0.0, 0.0, 0.0}, WallDistMod, FrictionVel, + RefDensity, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, Mach2Vel, Mach_Motion, UnitNormal[3] = {0.0, 0.0, 0.0}, TauElem[3] = {0.0, 0.0, 0.0}, TauTangent[3] = {0.0, 0.0, 0.0}, Tau[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Force[3] = {0.0, 0.0, 0.0}, Cp, thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}, Grad_Temp[3] = {0.0, 0.0, 0.0}, @@ -13388,9 +13388,6 @@ void CNSSolver::Viscous_Forces(CGeometry *geometry, CConfig *config) { } WallShearStress = sqrt(WallShearStress); - for (iDim = 0; iDim < nDim; iDim++) - Vel[iDim] = node[iPointNormal]->GetVelocity(iDim); - for (iDim = 0; iDim < nDim; iDim++) WallDist[iDim] = (Coord[iDim] - Coord_Normal[iDim]); WallDistMod = 0.0; for (iDim = 0; iDim < nDim; iDim++) WallDistMod += WallDist[iDim]*WallDist[iDim]; WallDistMod = sqrt(WallDistMod);