From 4095025ca7ab5d35ab677fbbe5c8dd2db1fc881e Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:33:59 +0100 Subject: [PATCH 01/61] Adding new config enums and files --- Common/include/option_structure.hpp | 12 +++++++++--- .../output/filewriter/CParaviewVTMFileWriter.hpp | 4 ++++ .../output/filewriter/CParaviewXMLFileWriter.hpp | 4 ++++ .../src/output/filewriter/CParaviewVTMFileWriter.cpp | 0 .../src/output/filewriter/CParaviewXMLFileWriter.cpp | 0 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp create mode 100644 SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp create mode 100644 SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp create mode 100644 SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 36dfbbc4ceb..a1ae8a890c3 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1491,7 +1491,10 @@ enum ENUM_OUTPUT { MESH = 11, /*!< \brief SU2 mesh format. */ RESTART_BINARY = 12, /*!< \brief SU2 binary restart format. */ RESTART_ASCII = 13, /*!< \brief SU2 ASCII restart format. */ - CGNS = 14 /*!< \brief CGNS format. */ + CGNS = 14, /*!< \brief CGNS format. */ + PARAVIEW_XML = 15, /*!< \brief Paraview XML with binary data format */ + SURFACE_PARAVIEW_XML = 16, /*!< \brief Surface Paraview XML with binary data format */ + PARAVIEW_MULTIBLOCK = 17 /*!< \brief Paraview XML Multiblock */ }; static const map Output_Map = CCreateMap ("TECPLOT_ASCII", TECPLOT) @@ -1501,9 +1504,12 @@ static const map Output_Map = CCreateMap Date: Sun, 5 Jan 2020 23:35:03 +0100 Subject: [PATCH 02/61] Error checking for multizone and multiblock output --- Common/src/config_structure.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 959695ca49a..8bf68e3aa54 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -9464,7 +9464,28 @@ void CConfig::SetMultizone(CConfig *driver_config, CConfig **config_container){ SU2_MPI::Error("Option MULTIZONE_MESH must be the same in all zones.", CURRENT_FUNCTION); } } - + + bool multiblockDriver = false; + for (unsigned short iFiles = 0; iFiles < driver_config->GetnVolumeOutputFiles(); iFiles++){ + if (driver_config->GetVolumeOutputFiles()[iFiles] == PARAVIEW_MULTIBLOCK){ + multiblockDriver = true; + } + } + + bool multiblockZone = false; + for (unsigned short iZone = 0; iZone < nZone; iZone++){ + multiblockZone = false; + for (unsigned short iFiles = 0; iFiles < config_container[iZone]->GetnVolumeOutputFiles(); iFiles++){ + if (config_container[iZone]->GetVolumeOutputFiles()[iFiles] == PARAVIEW_MULTIBLOCK){ + multiblockZone = true; + } + } + if (multiblockZone != multiblockDriver){ + SU2_MPI::Error("To enable PARAVIEW_MULTIBLOCK output, add it to OUTPUT_FILES option in main config and\n" + "remove option from sub-config files.", CURRENT_FUNCTION); + } + } + /*--- Set the Restart iter for time dependent problems ---*/ if (driver_config->GetRestart()){ Unst_RestartIter = driver_config->GetRestart_Iter(); From fd0f845b8a7aa2e46cfcfdceaac7389d998b0b73 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:36:40 +0100 Subject: [PATCH 03/61] New filewriter constructor --- .../include/output/filewriter/CFileWriter.hpp | 14 +++++++++++--- .../output/filewriter/CParallelFileWriter.cpp | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index 02a2d1ade34..d7b729f2641 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -88,21 +88,29 @@ class CFileWriter{ * \brief Filename */ string fileName; - + /*! * \brief The parallel data sorter */ CParallelDataSorter* dataSorter; - + public: /*! * \brief Construct a file writer using field names, file extension and dimension. * \param[in] fields - A list of field names + * \param[in] fileName - The name of the file * \param[in] file_ext - The file extension to be attached to the filename * \param[in] nDim - Physical dimension */ CFileWriter(std::vector fields, string fileName, CParallelDataSorter* dataSorter, string file_ext, unsigned short nDim); - + + /*! + * \brief Construct a file writer using field names, file extension and dimension. + * \param[in] fileName - The name of the file + * \param[in] file_ext - The file extension to be attached to the filename + */ + CFileWriter(string fileName, string file_ext); + /*! * \brief Destructor */ diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index bc7eba7307b..b1826404f99 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -42,10 +42,26 @@ CFileWriter::CFileWriter(vector fields, string fileName, this->fileName += file_ext; file_size = 0.0; - + Bandwidth = 0.0; + } +CFileWriter::CFileWriter(string fileName,string file_ext): + file_ext(file_ext), + fileName(std::move(fileName)){ + + rank = SU2_MPI::GetRank(); + size = SU2_MPI::GetSize(); + + this->fileName += file_ext; + + file_size = 0.0; + Bandwidth = 0.0; + +} CFileWriter::~CFileWriter(){ } + + From a45d7a7ecd1d37b1396b1b885f9bb88aeb208b15 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:37:44 +0100 Subject: [PATCH 04/61] Added new routine to sort specified markers --- .../output/filewriter/CParallelDataSorter.hpp | 8 +++ .../filewriter/CSurfaceFVMDataSorter.hpp | 4 +- .../filewriter/CSurfaceFVMDataSorter.cpp | 61 ++++++++++++++++--- 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index 98b02a112b6..b1f44b741bf 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -121,6 +121,14 @@ class CParallelDataSorter{ * \param[in] val_sort - boolean controlling whether the elements are sorted or simply loaded by their owning rank. */ virtual void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort = true){} + + /*! + * \brief Sort the connectivities into data structures (only for surface data sorters). + * \param[in] config - Definition of the particular problem. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] markerList - A list of marker names that should be sorted. + */ + virtual void SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList){} /*! * \brief Get the number of points the local rank owns. diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index 33016eb2c58..a93ebeb335b 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -73,6 +73,8 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ unsigned long GetGlobalIndex(unsigned long iPoint) override{ return Renumber2Global[iPoint]; } + + void SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList) override; private: @@ -83,6 +85,6 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * \param[in] geometry - Geometrical definition of the problem. * \param[in] Elem_Type - VTK index of the element type being merged. */ - void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type); + void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, vector markerList); }; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 9c775de1f2f..bd787cc6cb3 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -440,9 +440,12 @@ void CSurfaceFVMDataSorter::SortOutputData() { we can allocate the new data structure to hold these points alone. Here, we also copy the data for those points from our volume data structure. ---*/ - if (passiveDoubleBuffer == nullptr){ - passiveDoubleBuffer = new passivedouble[nParallel_Poin*VARS_PER_POINT]; + if (passiveDoubleBuffer != NULL){ + delete [] passiveDoubleBuffer; } + + passiveDoubleBuffer = new passivedouble[nParallel_Poin*VARS_PER_POINT]; + for (int jj = 0; jj < VARS_PER_POINT; jj++) { count = 0; for (int ii = 0; ii < (int)volume_sorter->GetnPoints(); ii++) { @@ -1097,15 +1100,23 @@ void CSurfaceFVMDataSorter::SortOutputData() { void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) { + std::vector markerList; + + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ + if (config->GetMarker_All_Plotting(iMarker) == YES) { + markerList.push_back(config->GetMarker_All_TagBound(iMarker)); + } + } + /*--- Sort connectivity for each type of element (excluding halos). Note In these routines, we sort the connectivity into a linear partitioning across all processors based on the global index of the grid nodes. ---*/ /*--- Sort volumetric grid connectivity. ---*/ - SortSurfaceConnectivity(config, geometry, LINE ); - SortSurfaceConnectivity(config, geometry, TRIANGLE ); - SortSurfaceConnectivity(config, geometry, QUADRILATERAL); + SortSurfaceConnectivity(config, geometry, LINE , markerList); + SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); + SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; @@ -1119,7 +1130,31 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } -void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { +void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList) { + + /*--- Sort connectivity for each type of element (excluding halos). Note + In these routines, we sort the connectivity into a linear partitioning + across all processors based on the global index of the grid nodes. ---*/ + + /*--- Sort volumetric grid connectivity. ---*/ + + SortSurfaceConnectivity(config, geometry, LINE , markerList); + SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); + SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + + + unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; +#ifndef HAVE_MPI + nGlobal_Elem_Par = nTotal_Surf_Elem; +#else + SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); +#endif + + connectivity_sorted = true; + +} + +void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, vector markerList) { unsigned long iProcessor; unsigned short NODES_PER_ELEMENT; @@ -1176,7 +1211,12 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * nElem_Send[size] = 0; nElem_Recv[size] = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_Plotting(iMarker) == YES) { + + string markerTag = config->GetMarker_All_TagBound(iMarker); + + auto it = std::find(markerList.begin(), markerList.end(), markerTag); + + if (it != markerList.end()) { for (int ii = 0; ii < (int)geometry->GetnElem_Bound(iMarker); ii++) { @@ -1270,7 +1310,12 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * additional data that we will send to the other procs. ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_Plotting(iMarker) == YES) { + + string markerTag = config->GetMarker_All_TagBound(iMarker); + + auto it = std::find(markerList.begin(), markerList.end(), markerTag); + + if (it != markerList.end()) { for (int ii = 0; ii < (int)geometry->GetnElem_Bound(iMarker); ii++) { From 394005600c246d85fe23e471983e638923f50509 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:39:08 +0100 Subject: [PATCH 05/61] Adding VTM filewriter header --- .../filewriter/CParaviewVTMFileWriter.hpp | 90 ++++++++++++++++++- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index 99b69ce2284..1b570f12b05 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -1,4 +1,88 @@ -#ifndef CPARAVIEWVTMFILEWRITER_HPP -#define CPARAVIEWVTMFILEWRITER_HPP +/*! + * \file CParaviewVTMFileWriter.hpp + * \brief Headers fo paraview binary file writer class. + * \author T. Albring + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ -#endif // CPARAVIEWVTMFILEWRITER_HPP +#pragma once + +#include "CFileWriter.hpp" + +class CParaviewVTMFileWriter final: public CFileWriter{ + + stringstream output; + + string folderName; + \ + unsigned short iZone, nZone; + +public: + + /*! + * \brief File extension + */ + const static string fileExt; + + /*! + * \brief Construct a file writer using field names, dimension. + * \param[in] fileName - The name of the file + */ + CParaviewVTMFileWriter(string fileName, string folderName, unsigned short iZone, unsigned short nZone); + + /*! + * \brief Destructor + */ + ~CParaviewVTMFileWriter() override; + + /*! + * \brief Write sorted data to file in paraview binary file format + */ + void Write_Data() override; + + inline void StartBlock(string name){ + if (rank == MASTER_NODE){ + output << "" << endl; + } + } + + inline void EndBlock(){ + if (rank == MASTER_NODE){ + output << "" << endl; + } + } + + inline void AddDataset(string name, string file){ + if (rank == MASTER_NODE){ + output << "" << endl; + } + } + + inline void Clear(){ + output.clear(); + } + + inline string GetFolderName(){ + return folderName; + } +}; From 6fc9e045df919f37364e23fb0a0e8859b56bbbc7 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:39:26 +0100 Subject: [PATCH 06/61] Adding VTK XML filewriter header --- .../filewriter/CParaviewXMLFileWriter.hpp | 86 ++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index 49f04df9377..b984814135d 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -1,4 +1,84 @@ -#ifndef CPARAVIEWXMLFILEWRITER_HPP -#define CPARAVIEWXMLFILEWRITER_HPP +/*! + * \file CParaviewXMLFileWriter.hpp + * \brief Headers fo paraview binary file writer class. + * \author T. Albring + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CFileWriter.hpp" + +class CParaviewXMLFileWriter final: public CFileWriter{ + +private: + + enum class VTKDatatype { + FLOAT32, + INT32, + UINT8 + }; + + MPI_Offset disp; + MPI_File fhw; + + bool BigEndian; + + unsigned long dataOffset; + +public: + + /*! + * \brief File extension + */ + const static string fileExt; + + /*! + * \brief Construct a file writer using field names, dimension. + * \param[in] fields - A list of field names + * \param[in] nDim - Physical dimension + * \param[in] fileName - The name of the file + * \param[in] data_sorter - The parallel sorted data to write + */ + CParaviewXMLFileWriter(vector fields, unsigned short nDim, + string fileName, CParallelDataSorter* data_sorter); + + /*! + * \brief Destructor + */ + ~CParaviewXMLFileWriter() override; + + /*! + * \brief Write sorted data to file in paraview binary file format + */ + void Write_Data() override; + +private: + + void WriteString(std::string str, int rank); + + void AddDataArray(VTKDatatype type, string name, unsigned short nComponents, unsigned long size, unsigned long cumSize); + + void WriteDataArray(void *data, VTKDatatype type, unsigned long size, unsigned long cumSize, MPI_Offset offset); +}; -#endif // CPARAVIEWXMLFILEWRITER_HPP From dccbb718e999960f62b50bc1db203203fdb00f61 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:39:37 +0100 Subject: [PATCH 07/61] Adding files to meson --- SU2_CFD/src/meson.build | 2 ++ SU2_CFD/src/output/COutput.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 6352ed1662f..d237a92fb20 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -63,6 +63,8 @@ su2_cfd_src += files(['output/CAdjElasticityOutput.cpp', 'output/filewriter/CCSVFileWriter.cpp', 'output/filewriter/CSU2FileWriter.cpp', 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', 'output/filewriter/CSU2MeshFileWriter.cpp']) su2_cfd_src += files(['variables/CIncNSVariable.cpp', diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 16e199931b7..a31d12e8815 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -33,6 +33,8 @@ #include "../../include/output/filewriter/CSurfaceFEMDataSorter.hpp" #include "../../include/output/filewriter/CParaviewFileWriter.hpp" #include "../../include/output/filewriter/CParaviewBinaryFileWriter.hpp" +#include "../../include/output/filewriter/CParaviewXMLFileWriter.hpp" +#include "../../include/output/filewriter/CParaviewVTMFileWriter.hpp" #include "../../include/output/filewriter/CTecplotFileWriter.hpp" #include "../../include/output/filewriter/CTecplotBinaryFileWriter.hpp" #include "../../include/output/filewriter/CCSVFileWriter.hpp" From 598f26217a499f25c91fea3d164f72d73e1dc9ae Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:41:21 +0100 Subject: [PATCH 08/61] adding new file cases to output class --- SU2_CFD/src/output/COutput.cpp | 137 +++++++++++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index a31d12e8815..f1ca96a461b 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -431,22 +431,128 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f break; + case PARAVIEW_XML: + + if (fileName.empty()) + fileName = config->GetFilename(volumeFilename, "", curTimeIter); + + /*--- Load and sort the output data and connectivity. ---*/ + + volumeDataSorter->SortConnectivity(config, geometry, true); + + /*--- Write paraview binary ---*/ + if (rank == MASTER_NODE) { + (*fileWritingTable) << "Paraview" << fileName + CParaviewXMLFileWriter::fileExt; + } + + fileWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + + break; + case PARAVIEW_BINARY: - + if (fileName.empty()) fileName = config->GetFilename(volumeFilename, "", curTimeIter); - + /*--- Load and sort the output data and connectivity. ---*/ - + volumeDataSorter->SortConnectivity(config, geometry, true); - + /*--- Write paraview binary ---*/ if (rank == MASTER_NODE) { - (*fileWritingTable) << "Paraview" << fileName + CParaviewBinaryFileWriter::fileExt; + (*fileWritingTable) << "Paraview" << fileName + CParaviewBinaryFileWriter::fileExt; } - + fileWriter = new CParaviewBinaryFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + + break; + + case PARAVIEW_MULTIBLOCK: + if (fileName.empty()) + fileName = config->GetFilename(volumeFilename, "", curTimeIter); + + { + string folderName = fileName; + + if (config->GetMultizone_Problem()){ + fileName = "Multizone"; + } + fileWriter = new CParaviewVTMFileWriter(fileName, folderName, config->GetiZone(), config->GetnZone()); + + CParaviewVTMFileWriter* vtmWriter = dynamic_cast(fileWriter); + + CParaviewXMLFileWriter *XMLWriter = NULL; + if (rank == MASTER_NODE) { + (*fileWritingTable) << "Paraview Multiblock" + << fileName + CParaviewVTMFileWriter::fileExt + " -> " + vtmWriter->GetFolderName(); + } + fileName = "Internal"; + fileName = vtmWriter->GetFolderName() + "/" + fileName; + + vtmWriter->StartBlock("Zone " + PrintingToolbox::to_string(config->GetiZone())); + + vtmWriter->StartBlock("Internal"); + vtmWriter->AddDataset("Internal", fileName + CParaviewXMLFileWriter::fileExt); + vtmWriter->EndBlock(); + + /*--- Sort volume connectivity ---*/ + + volumeDataSorter->SortConnectivity(config, geometry, true); + + /*--- Create XML writer and write volume data to file ---*/ + + XMLWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + XMLWriter->Write_Data(); + delete XMLWriter; + + vtmWriter->StartBlock("Boundary"); + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_CfgFile(); iMarker++){ + + /*--- Get the name of the marker ---*/ + + string markerTag = config->GetMarker_CfgFile_TagBound(iMarker); + + + vector markerList; + /*--- If the current marker can be found on this partition, add it to the marker list. + * Note that we have to provide a vector of markers to the sorter routine, although we only do + * one marker at a time, i.e. markerList always contains one item. ---*/ + + for (unsigned short jMarker = 0; jMarker < config->GetnMarker_All(); jMarker++){ + + /*--- Write all markers to file, except send-receive markers ---*/ + + if (config->GetMarker_All_TagBound(jMarker) == markerTag && + config->GetMarker_All_KindBC(jMarker) != SEND_RECEIVE){ + markerList.push_back(markerTag); + } + } + + /*--- Only sort if there is at least one processor with this marker ---*/ + + int globalMarkerSize = 0, localMarkerSize = markerList.size(); + SU2_MPI::Allreduce(&localMarkerSize, &globalMarkerSize, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + + if (globalMarkerSize > 0){ + /*--- Sort connectivity of the current marker ---*/ + + surfaceDataSorter->SortConnectivity(config, geometry, markerList); + surfaceDataSorter->SortOutputData(); + + fileName = vtmWriter->GetFolderName() + "/" + markerTag; + XMLWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); + XMLWriter->Write_Data(); + delete XMLWriter; + + vtmWriter->AddDataset(markerTag, fileName + CParaviewXMLFileWriter::fileExt); + } + } + vtmWriter->EndBlock(); + vtmWriter->EndBlock(); + } + + break; case PARAVIEW: @@ -504,6 +610,25 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f fileWriter = new CParaviewBinaryFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); break; + + case SURFACE_PARAVIEW_XML: + + if (fileName.empty()) + fileName = config->GetFilename(surfaceFilename, "", curTimeIter); + + /*--- Load and sort the output data and connectivity. ---*/ + + surfaceDataSorter->SortConnectivity(config, geometry); + surfaceDataSorter->SortOutputData(); + + /*--- Write paraview binary ---*/ + if (rank == MASTER_NODE) { + (*fileWritingTable) << "Paraview surface" << fileName + CParaviewXMLFileWriter::fileExt; + } + + fileWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); + + break; case SURFACE_TECPLOT: From 8bf4ea10570c71c6454531a1a8edac58bd0da951 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:42:18 +0100 Subject: [PATCH 09/61] Adding vtm filewriter implementation --- .../filewriter/CParaviewVTMFileWriter.cpp | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index e69de29bb2d..0005579596e 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -0,0 +1,76 @@ +/*! + * \file CParaviewVTMFileWriter.cpp + * \brief Filewriter class for Paraview binary format. + * \author T. Albring + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/output/filewriter/CParaviewVTMFileWriter.hpp" +#include "../../../../Common/include/toolboxes/printing_toolbox.hpp" + +const string CParaviewVTMFileWriter::fileExt = ".vtm"; + +CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderName, unsigned short iZone, unsigned short nZone) + : CFileWriter(std::move(fileName), fileExt), + folderName(std::move(folderName)){ + + if (rank == MASTER_NODE) +#if defined(_WIN32) + _mkdir(this->folderName.c_str()); +#else + mkdir(this->folderName.c_str(), 0777); // notice that 777 is different than 0777 +#endif + + this->iZone = iZone; + this->nZone = nZone; +} + + +CParaviewVTMFileWriter::~CParaviewVTMFileWriter(){ + +} + +void CParaviewVTMFileWriter::Write_Data(){ + + if (rank == MASTER_NODE){ + ofstream multiBlockFile; + if (iZone == 0) + multiBlockFile.open (fileName.c_str()); + else + multiBlockFile.open(fileName.c_str(), ios::app); + + if (iZone == 0){ + multiBlockFile << "" << endl; + multiBlockFile << "" << endl; + } + + multiBlockFile << output.str(); + + if (iZone == nZone-1){ + multiBlockFile << "" << endl; + multiBlockFile << "" << endl; + } + multiBlockFile.close(); + } + +} \ No newline at end of file From 22b9f0aeed313bd5aa73fe2530e5a6620616a67b Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:42:35 +0100 Subject: [PATCH 10/61] Adding vtk xml writer implementation --- .../filewriter/CParaviewXMLFileWriter.cpp | 1023 +++++++++++++++++ 1 file changed, 1023 insertions(+) diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index e69de29bb2d..fe309f17e6a 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -0,0 +1,1023 @@ +/*! + * \file CParaviewXMLFileWriter.cpp + * \brief Filewriter class for Paraview binary format. + * \author T. Albring + * \version 7.0.0 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../../include/output/filewriter/CParaviewXMLFileWriter.hpp" +#include "../../../../Common/include/toolboxes/printing_toolbox.hpp" + +const string CParaviewXMLFileWriter::fileExt = ".vtu"; + +CParaviewXMLFileWriter::CParaviewXMLFileWriter(vector fields, unsigned short nDim, string fileName, + CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim){ + + /* Check for big endian. We have to swap bytes otherwise. + * Since size of character is 1 byte when the character pointer + * is de-referenced it will contain only first byte of integer. ---*/ + + BigEndian = false; + unsigned int i = 1; + char *c = (char*)&i; + if (*c) BigEndian = false; + else BigEndian = true; + +} + + +CParaviewXMLFileWriter::~CParaviewXMLFileWriter(){ + +} + +void CParaviewXMLFileWriter::Write_Data(){ + + + if (!dataSorter->GetConnectivitySorted()){ + SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); + } + + const int NCOORDS = 3; + + unsigned short iDim; + + dataOffset = 0; + + unsigned long iPoint, iElem; + + ofstream Paraview_File; + + const int MAX_STRING_LENGTH = 255; + char str_buf[MAX_STRING_LENGTH], fname[100]; + + strcpy(fname, fileName.c_str()); + + file_size = 0.0; + + /*--- Set a timer for the file writing. ---*/ + +#ifndef HAVE_MPI + StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + StartTime = MPI_Wtime(); +#endif + + /*--- Serial implementation in case we have not compiled with MPI. ---*/ + +#ifndef HAVE_MPI + + FILE* fhw; + fhw = fopen(fname, "wb"); + + unsigned long iNode2; + unsigned long nGlobal_Elem_Storage; + + /*--- Error check for opening the file. ---*/ + + if (!fhw) { + SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + + fileName, CURRENT_FUNCTION); + } + + /*--- File header written in ASCII. ---*/ + + strcpy(str_buf, "# vtk DataFile Version 3.0\n"); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + strcpy(str_buf, "vtk output\n"); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + strcpy(str_buf, "BINARY\n"); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + strcpy(str_buf, "DATASET UNSTRUCTURED_GRID\n"); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + /*--- Write the point coordinates. ---*/ + + unsigned long GlobalPoint = dataSorter->GetnPointsGlobal(); + + SPRINTF(str_buf, "POINTS %i float\n", (int)GlobalPoint); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + /*--- Load/write the 1D buffer of point coordinates. ---*/ + + float *coord_buf = new float[GlobalPoint*NCOORDS]; + for (iPoint = 0; iPoint < GlobalPoint; iPoint++) { + for (iDim = 0; iDim < NCOORDS; iDim++) { + if (nDim == 2 && iDim == 2) { + coord_buf[iPoint*NCOORDS + iDim] = 0.0; + } else { + float val = (float)dataSorter->GetData(iDim,iPoint); + coord_buf[iPoint*NCOORDS + iDim] = val; + } + } + } + if (!BigEndian) SwapBytes((char *)coord_buf, sizeof(float), 3*GlobalPoint); + + fwrite(coord_buf, sizeof(float), 3*GlobalPoint, fhw); + file_size += sizeof(char)*3*GlobalPoint; + + delete [] coord_buf; + + /*--- Write the connectivity data. ---*/ + + unsigned long nTot_Line; + unsigned long nTot_Tria, nTot_Quad; + unsigned long nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; + nTot_Line = dataSorter->GetnElem(LINE); + nTot_Tria = dataSorter->GetnElem(TRIANGLE); + nTot_Quad = dataSorter->GetnElem(QUADRILATERAL); + nTot_Tetr = dataSorter->GetnElem(TETRAHEDRON); + nTot_Hexa = dataSorter->GetnElem(HEXAHEDRON); + nTot_Pris = dataSorter->GetnElem(PRISM); + nTot_Pyra = dataSorter->GetnElem(PYRAMID); + nGlobal_Elem_Storage = (nTot_Line*3 + nTot_Tria*4 + nTot_Quad*5 + nTot_Tetr*5 + + nTot_Hexa*9 + nTot_Pris*7 + nTot_Pyra*6); + + int *conn_buf = NULL; + + SPRINTF (str_buf, "\nCELLS %i %i\n", (int)dataSorter->GetnElem(), + (int)nGlobal_Elem_Storage); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + conn_buf = new int[dataSorter->GetnElem()*(N_POINTS_HEXAHEDRON+1)]; + + + /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ + + + for (iElem = 0; iElem < nTot_Line; iElem++) { + iNode2 = iElem*(N_POINTS_LINE+1); + conn_buf[iNode2+0] = N_POINTS_LINE; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(LINE, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(LINE, iElem, 1)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Line*(N_POINTS_LINE+1)); + fwrite(conn_buf, sizeof(int), + nTot_Line*(N_POINTS_LINE+1), fhw); + + file_size += sizeof(int)*nTot_Line*(N_POINTS_LINE+1); + + for (iElem = 0; iElem < nTot_Tria; iElem++) { + iNode2 = iElem*(N_POINTS_TRIANGLE+1); + conn_buf[iNode2+0] = N_POINTS_TRIANGLE; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 1)-1; + conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 2)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Tria*(N_POINTS_TRIANGLE+1)); + fwrite(conn_buf, sizeof(int), + nTot_Tria*(N_POINTS_TRIANGLE+1), fhw); + file_size += sizeof(int)*nTot_Tria*(N_POINTS_TRIANGLE+1); + + for (iElem = 0; iElem < nTot_Quad; iElem++) { + iNode2 = iElem*(N_POINTS_QUADRILATERAL+1); + conn_buf[iNode2+0] = N_POINTS_QUADRILATERAL; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 1)-1; + conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 2)-1; + conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 3)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Quad*(N_POINTS_QUADRILATERAL+1)); + fwrite(conn_buf, sizeof(int), + nTot_Quad*(N_POINTS_QUADRILATERAL+1), fhw); + file_size += sizeof(int)*nTot_Quad*(N_POINTS_QUADRILATERAL+1); + + for (iElem = 0; iElem < nTot_Tetr; iElem++) { + iNode2 = iElem*(N_POINTS_TETRAHEDRON+1); + conn_buf[iNode2+0] = N_POINTS_TETRAHEDRON; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 1)-1; + conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 2)-1; + conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 3)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Tetr*(N_POINTS_TETRAHEDRON+1)); + fwrite(conn_buf, sizeof(int), + nTot_Tetr*(N_POINTS_TETRAHEDRON+1), fhw); + file_size += sizeof(int)*nTot_Tetr*(N_POINTS_TETRAHEDRON+1); + + for (iElem = 0; iElem < nTot_Hexa; iElem++) { + iNode2 = iElem*(N_POINTS_HEXAHEDRON+1); + conn_buf[iNode2+0] = N_POINTS_HEXAHEDRON; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 1)-1; + conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 2)-1; + conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 3)-1; + conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 4)-1; + conn_buf[iNode2+6] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 5)-1; + conn_buf[iNode2+7] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 6)-1; + conn_buf[iNode2+8] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 7)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Hexa*(N_POINTS_HEXAHEDRON+1)); + fwrite(conn_buf, sizeof(int), + nTot_Hexa*(N_POINTS_HEXAHEDRON+1), fhw); + file_size += sizeof(int)*nTot_Hexa*(N_POINTS_HEXAHEDRON+1); + + for (iElem = 0; iElem < nTot_Pris; iElem++) { + iNode2 = iElem*(N_POINTS_PRISM+1); + conn_buf[iNode2+0] = N_POINTS_PRISM; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(PRISM, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(PRISM, iElem, 1)-1; + conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(PRISM, iElem, 2)-1; + conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(PRISM, iElem, 3)-1; + conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(PRISM, iElem, 4)-1; + conn_buf[iNode2+6] = dataSorter->GetElem_Connectivity(PRISM, iElem, 5)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Pris*(N_POINTS_PRISM+1)); + fwrite(conn_buf, sizeof(int), + nTot_Pris*(N_POINTS_PRISM+1), fhw); + file_size += sizeof(int)*nTot_Pris*(N_POINTS_PRISM+1); + + for (iElem = 0; iElem < nTot_Pyra; iElem++) { + iNode2 = iElem*(N_POINTS_PYRAMID+1); + conn_buf[iNode2+0] = N_POINTS_PYRAMID; + conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 0)-1; + conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 1)-1; + conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 2)-1; + conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 3)-1; + conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 4)-1; + } + if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), + nTot_Pyra*(N_POINTS_PYRAMID+1)); + fwrite(conn_buf, sizeof(int), + nTot_Pyra*(N_POINTS_PYRAMID+1), fhw); + file_size += sizeof(int)*nTot_Pyra*(N_POINTS_PYRAMID+1); + + + if (conn_buf != NULL) delete [] conn_buf; + + /*--- Load/write the cell type for all elements in the file. ---*/ + + + SPRINTF (str_buf, "\nCELL_TYPES %i\n", SU2_TYPE::Int(dataSorter->GetnElem())); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); + + int *type_buf = NULL; + + type_buf = new int[dataSorter->GetnElem()]; + + for (iElem = 0; iElem < nTot_Line; iElem++) { + type_buf[iElem] = LINE; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Line); + fwrite(type_buf, sizeof(int), nTot_Line, fhw); + file_size += sizeof(int)*nTot_Line; + + for (iElem = 0; iElem < nTot_Tria; iElem++) { + type_buf[iElem] = TRIANGLE; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Tria); + fwrite(type_buf, sizeof(int), nTot_Tria, fhw); + file_size += sizeof(int)*nTot_Tria; + + for (iElem = 0; iElem < nTot_Quad; iElem++) { + type_buf[iElem] = QUADRILATERAL; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Quad); + fwrite(type_buf, sizeof(int), nTot_Quad, fhw); + file_size += sizeof(int)*nTot_Quad; + + for (iElem = 0; iElem < nTot_Tetr; iElem++) { + type_buf[iElem] = TETRAHEDRON; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Tetr); + fwrite(type_buf, sizeof(int), nTot_Tetr, fhw); + file_size += sizeof(int)*nTot_Tetr; + + for (iElem = 0; iElem < nTot_Hexa; iElem++) { + type_buf[iElem] = HEXAHEDRON; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Hexa); + fwrite(type_buf, sizeof(int), nTot_Hexa, fhw); + file_size += sizeof(int)*nTot_Hexa; + + for (iElem = 0; iElem < nTot_Pris; iElem++) { + type_buf[iElem] = PRISM; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Pris); + fwrite(type_buf, sizeof(int), nTot_Pris, fhw); + file_size += sizeof(int)*nTot_Pris; + + for (iElem = 0; iElem < nTot_Pyra; iElem++) { + type_buf[iElem] = PYRAMID; + } + if (!BigEndian) + SwapBytes((char *)type_buf, sizeof(int), nTot_Pyra); + fwrite(type_buf, sizeof(int), nTot_Pyra, fhw); + file_size += sizeof(int)*nTot_Pyra; + + + if (type_buf != NULL) delete [] type_buf; + + /*--- Now write the scalar and vector data (reuse the counts above). ---*/ + + SPRINTF (str_buf, "\nPOINT_DATA %i\n", (int)GlobalPoint); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)* strlen(str_buf); + + unsigned short varStart = 2; + if (nDim == 3) varStart++; + + /*--- Need to adjust container location to avoid PointID tag and coords. ---*/ + + unsigned short iField, VarCounter = varStart; + for (iField = varStart; iField < fieldnames.size(); iField++) { + + string fieldname = fieldnames[iField]; + fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), + fieldname.end()); + + bool output_variable = true, isVector = false; + size_t found = fieldnames[iField].find("_x"); + if (found!=string::npos) { + output_variable = true; + isVector = true; + } + found = fieldnames[iField].find("_y"); + if (found!=string::npos) { + //skip + output_variable = false; + VarCounter++; + } + found = fieldnames[iField].find("_z"); + if (found!=string::npos) { + //skip + output_variable = false; + VarCounter++; + } + + if (output_variable && isVector) { + + fieldname.erase(fieldname.end()-2,fieldname.end()); + SPRINTF (str_buf, "\nVECTORS %s float\n", fieldname.c_str()); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)* strlen(str_buf); + + /*--- Prepare the 1D data buffer on this rank. ---*/ + + float *vec_buf = new float[GlobalPoint*NCOORDS]; + + /*--- For now, create a temp 1D buffer to load up the data for writing. + This will be replaced with a derived data type most likely. ---*/ + + float val = 0.0; + for (iPoint = 0; iPoint < GlobalPoint; iPoint++) + for (iDim = 0; iDim < NCOORDS; iDim++) { + if (nDim == 2 && iDim == 2) { + vec_buf[iPoint*NCOORDS + iDim] = 0.0; + } else { + val = (float)dataSorter->GetData(VarCounter+iDim,iPoint); + vec_buf[iPoint*NCOORDS + iDim] = val; + } + } + if (!BigEndian) + SwapBytes((char *)vec_buf, sizeof(float), NCOORDS*GlobalPoint); + fwrite(vec_buf, sizeof(float), NCOORDS*GlobalPoint, fhw); + file_size += sizeof(float)*NCOORDS*GlobalPoint; + + delete [] vec_buf; + + VarCounter++; + + } else if (output_variable) { + + SPRINTF (str_buf, "\nSCALARS %s float 1\n", fieldname.c_str()); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)* strlen(str_buf); + + SPRINTF (str_buf, "LOOKUP_TABLE default\n"); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)* strlen(str_buf); + + /*--- Prepare the 1D data buffer on this rank. ---*/ + + float *scalar_buf = new float[GlobalPoint]; + + /*--- For now, create a temp 1D buffer to load up the data for writing. + This will be replaced with a derived data type most likely. ---*/ + + for (iPoint = 0; iPoint < GlobalPoint; iPoint++) { + float val = (float)dataSorter->GetData(VarCounter,iPoint); + scalar_buf[iPoint] = val; + } + if (!BigEndian) + SwapBytes((char *)scalar_buf, sizeof(float), GlobalPoint); + fwrite(scalar_buf, sizeof(float), GlobalPoint, fhw); + file_size += sizeof(float)*GlobalPoint; + + delete [] scalar_buf; + + VarCounter++; + } + + } + + /*--- Close the file. ---*/ + + fclose(fhw); + +#else + + /*--- Parallel binary output using MPI I/O. ---*/ + + int ierr; + + /*--- All ranks open the file using MPI. Here, we try to open the file with + exclusive so that an error is generated if the file exists. We always want + to write a fresh output file, so we delete any existing files and create + a new one. ---*/ + + ierr = MPI_File_open(MPI_COMM_WORLD, fname, + MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, + MPI_INFO_NULL, &fhw); + if (ierr != MPI_SUCCESS) { + MPI_File_close(&fhw); + if (rank == 0) + MPI_File_delete(fname, MPI_INFO_NULL); + ierr = MPI_File_open(MPI_COMM_WORLD, fname, + MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, + MPI_INFO_NULL, &fhw); + } + + /*--- Error check opening the file. ---*/ + + if (ierr) { + SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + + string(fname), CURRENT_FUNCTION); + } + + /*--- Write the initial strings to the file. Only the master will + write the header lines, but all ranks will store the offsets. ---*/ + + disp = 0; + + /*--- Communicate the number of total points that will be + written by each rank. After this communication, each proc knows how + many poinnts will be written before its location in the file and the + offsets can be correctly set. ---*/ + + unsigned long myPoint, GlobalPoint; + + GlobalPoint = dataSorter->GetnPointsGlobal(); + myPoint = dataSorter->GetnPoints(); + + /*--- Compute our local number of elements, the required storage, + and reduce the total number of elements and storage globally. ---*/ + + unsigned long nTot_Line; + unsigned long nTot_Tria, nTot_Quad; + unsigned long nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; + unsigned long myElem, myElemStorage, GlobalElem, GlobalElemStorage; + + unsigned long nParallel_Line = dataSorter->GetnElem(LINE), + nParallel_Tria = dataSorter->GetnElem(TRIANGLE), + nParallel_Quad = dataSorter->GetnElem(QUADRILATERAL), + nParallel_Tetr = dataSorter->GetnElem(TETRAHEDRON), + nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), + nParallel_Pris = dataSorter->GetnElem(PRISM), + nParallel_Pyra = dataSorter->GetnElem(PYRAMID); + + SU2_MPI::Allreduce(&nParallel_Line, &nTot_Line, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nParallel_Tria, &nTot_Tria, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nParallel_Quad, &nTot_Quad, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nParallel_Tetr, &nTot_Tetr, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nParallel_Hexa, &nTot_Hexa, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nParallel_Pris, &nTot_Pris, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nParallel_Pyra, &nTot_Pyra, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + myElem = (nParallel_Line + nParallel_Tria + nParallel_Quad + nParallel_Tetr + + nParallel_Hexa + nParallel_Pris + nParallel_Pyra); + myElemStorage = (nParallel_Line*2 + nParallel_Tria*3 + nParallel_Quad*4 + nParallel_Tetr*4 + + nParallel_Hexa*8 + nParallel_Pris*6 + nParallel_Pyra*5); + + GlobalElem = (nTot_Line + nTot_Tria + nTot_Quad + nTot_Tetr + + nTot_Hexa + nTot_Pris + nTot_Pyra); + GlobalElemStorage = (nTot_Line*2 + nTot_Tria*3 + nTot_Quad*4 + nTot_Tetr*4 + + nTot_Hexa*8 + nTot_Pris*6 + nTot_Pyra*5); + + /* Write the ASCII XML header. Note that we use the appended format for the data, + * which means that all data is appended at the end of the file in one binary blob. + */ + + if (!BigEndian){ + WriteString("\n", MASTER_NODE); + } else { + WriteString("\n", MASTER_NODE); + } + + WriteString("\n", MASTER_NODE); + + SPRINTF(str_buf, "\n", SU2_TYPE::Int(GlobalPoint), SU2_TYPE::Int(GlobalElem)); + + WriteString(std::string(str_buf), MASTER_NODE); + WriteString("\n", MASTER_NODE); + AddDataArray(VTKDatatype::FLOAT32, "", NCOORDS, myPoint*NCOORDS, GlobalPoint*NCOORDS); + WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); + AddDataArray(VTKDatatype::INT32, "connectivity", 1, myElemStorage, GlobalElemStorage); + AddDataArray(VTKDatatype::INT32, "offsets", 1, myElem, GlobalElem); + AddDataArray(VTKDatatype::UINT8, "types", 1, myElem, GlobalElem); + WriteString("\n", MASTER_NODE); + + WriteString("\n", MASTER_NODE); + + /*--- Adjust container start location to avoid point coords. ---*/ + + unsigned short varStart = 2; + if (nDim == 3) varStart++; + + /*--- Loop over all variables that have been registered in the output. ---*/ + + unsigned short iField, VarCounter = varStart; + for (iField = varStart; iField < fieldnames.size(); iField++) { + + string fieldname = fieldnames[iField]; + fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), + fieldname.end()); + + /*--- Check whether this field is a vector or scalar. ---*/ + + bool output_variable = true, isVector = false; + size_t found = fieldnames[iField].find("_x"); + if (found!=string::npos) { + output_variable = true; + isVector = true; + } + found = fieldnames[iField].find("_y"); + if (found!=string::npos) { + /*--- We have found a vector, so skip the Y component. ---*/ + output_variable = false; + VarCounter++; + } + found = fieldnames[iField].find("_z"); + if (found!=string::npos) { + /*--- We have found a vector, so skip the Z component. ---*/ + output_variable = false; + VarCounter++; + } + + /*--- Write the point data as an vector or a scalar. ---*/ + + if (output_variable && isVector) { + + /*--- Adjust the string name to remove the leading "X-" ---*/ + + fieldname.erase(fieldname.end()-2,fieldname.end()); + + AddDataArray(VTKDatatype::FLOAT32, fieldname, NCOORDS, myPoint*NCOORDS, GlobalPoint*NCOORDS); + + } else if (output_variable) { + + AddDataArray(VTKDatatype::FLOAT32, fieldname, 1, myPoint, GlobalPoint); + + } + + } + WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); + + int *nPoint_Snd = new int[size+1]; + int *nPoint_Cum = new int[size+1]; + + nPoint_Snd[0] = 0; nPoint_Cum[0] = 0; + for (int ii=1; ii < size; ii++) { + nPoint_Snd[ii] = myPoint; nPoint_Cum[ii] = 0; + } + nPoint_Snd[size] = myPoint; nPoint_Cum[size] = 0; + + /*--- Communicate the local counts to all ranks for building offsets. ---*/ + + SU2_MPI::Alltoall(&(nPoint_Snd[1]), 1, MPI_INT, + &(nPoint_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); + + /*--- Put the counters into cumulative storage format. ---*/ + + for (int ii = 0; ii < size; ii++) { + nPoint_Cum[ii+1] += nPoint_Cum[ii]; + } + + /*--- Now write all the data we have previously defined into the binary section of the file ---*/ + + WriteString("\n_", MASTER_NODE); + + /*--- Load/write the 1D buffer of point coordinates. Note that we + always have 3 coordinate dimensions, even for 2D problems. ---*/ + + float *coord_buf = new float[myPoint*NCOORDS]; + for (iPoint = 0; iPoint < myPoint; iPoint++) { + for (iDim = 0; iDim < NCOORDS; iDim++) { + if (nDim == 2 && iDim == 2) { + coord_buf[iPoint*NCOORDS + iDim] = 0.0; + } else { + float val = (float)dataSorter->GetData(iDim, iPoint); + coord_buf[iPoint*NCOORDS + iDim] = val; + } + } + } + + WriteDataArray((void*)coord_buf, VTKDatatype::FLOAT32, NCOORDS*myPoint, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); + + /*--- Free the coordinate array. ---*/ + + delete [] coord_buf; + + /*--- Communicate the number of total cells/storage that will be + written by each rank. After this communication, each proc knows how + many cells will be written before its location in the file and the + offsets can be correctly set. ---*/ + + int *nElem_Snd = new int[size+1]; int *nElemStorage_Snd = new int[size+1]; + int *nElem_Cum = new int[size+1]; int *nElemStorage_Cum = new int[size+1]; + + nElem_Snd[0] = 0; nElemStorage_Snd[0] = 0; + nElem_Cum[0] = 0; nElemStorage_Cum[0] = 0; + for (int ii=1; ii < size; ii++) { + nElem_Snd[ii] = myElem; nElemStorage_Snd[ii] = myElemStorage; + nElem_Cum[ii] = 0; nElemStorage_Cum[ii] = 0; + } + nElem_Snd[size] = myElem; nElemStorage_Snd[size] = myElemStorage; + nElem_Cum[size] = 0; nElemStorage_Cum[size] = 0; + + /*--- Communicate the local counts to all ranks for building offsets. ---*/ + + SU2_MPI::Alltoall(&(nElem_Snd[1]), 1, MPI_INT, + &(nElem_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); + + SU2_MPI::Alltoall(&(nElemStorage_Snd[1]), 1, MPI_INT, + &(nElemStorage_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); + + /*--- Put the counters into cumulative storage format. ---*/ + + for (int ii = 0; ii < size; ii++) { + nElem_Cum[ii+1] += nElem_Cum[ii]; + nElemStorage_Cum[ii+1] += nElemStorage_Cum[ii]; + } + + /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ + + int *conn_buf = new int[myElemStorage]; + int *offset_buf = new int[myElem]; + unsigned long iStorage = 0, iElemID = 0; + unsigned short iNode = 0; + + auto copyToBuffer = [&](GEO_TYPE type, unsigned long nElem, unsigned short nPoints){ + for (iElem = 0; iElem < nElem; iElem++) { + for (iNode = 0; iNode < nPoints; iNode++){ + conn_buf[iStorage+iNode] = dataSorter->GetElem_Connectivity(type, iElem, iNode)-1; + } + iStorage += nPoints; + offset_buf[iElemID++] = (iStorage + nElemStorage_Cum[rank]); + } + }; + + copyToBuffer(LINE, nParallel_Line, N_POINTS_LINE); + copyToBuffer(TRIANGLE, nParallel_Tria, N_POINTS_TRIANGLE); + copyToBuffer(QUADRILATERAL, nParallel_Quad, N_POINTS_QUADRILATERAL); + copyToBuffer(TETRAHEDRON, nParallel_Tetr, N_POINTS_TETRAHEDRON); + copyToBuffer(HEXAHEDRON, nParallel_Hexa, N_POINTS_HEXAHEDRON); + copyToBuffer(PRISM, nParallel_Pris, N_POINTS_PRISM); + copyToBuffer(PYRAMID, nParallel_Pyra, N_POINTS_PYRAMID); + + WriteDataArray((void*)conn_buf, VTKDatatype::INT32, myElemStorage, GlobalElemStorage, nElemStorage_Cum[rank]); + WriteDataArray((void*)offset_buf, VTKDatatype::INT32, myElem, GlobalElem, nElem_Cum[rank]); + + delete [] conn_buf; + delete [] offset_buf; + + /*--- Load/write the cell type for all elements in the file. ---*/ + + uint8_t *type_buf = new uint8_t[myElem]; + unsigned long jElem = 0; + + for (iElem = 0; iElem < nParallel_Line; iElem++) { + type_buf[jElem] = LINE; jElem++; + } + for (iElem = 0; iElem < nParallel_Tria; iElem++) { + type_buf[jElem] = TRIANGLE; jElem++; + } + for (iElem = 0; iElem < nParallel_Quad; iElem++) { + type_buf[jElem] = QUADRILATERAL; jElem++; + } + for (iElem = 0; iElem < nParallel_Tetr; iElem++) { + type_buf[jElem] = TETRAHEDRON; jElem++; + } + for (iElem = 0; iElem < nParallel_Hexa; iElem++) { + type_buf[jElem] = HEXAHEDRON; jElem++; + } + for (iElem = 0; iElem < nParallel_Pris; iElem++) { + type_buf[jElem] = PRISM; jElem++; + } + for (iElem = 0; iElem < nParallel_Pyra; iElem++) { + type_buf[jElem] = PYRAMID; jElem++; + } + + WriteDataArray((void*)type_buf, VTKDatatype::UINT8, myElem, GlobalElem, nElem_Cum[rank]); + + delete [] type_buf; + + /*--- Loop over all variables that have been registered in the output. ---*/ + + VarCounter = varStart; + for (iField = varStart; iField < fieldnames.size(); iField++) { + + string fieldname = fieldnames[iField]; + fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), + fieldname.end()); + + /*--- Check whether this field is a vector or scalar. ---*/ + + bool output_variable = true, isVector = false; + size_t found = fieldnames[iField].find("_x"); + if (found!=string::npos) { + output_variable = true; + isVector = true; + } + found = fieldnames[iField].find("_y"); + if (found!=string::npos) { + /*--- We have found a vector, so skip the Y component. ---*/ + output_variable = false; + VarCounter++; + } + found = fieldnames[iField].find("_z"); + if (found!=string::npos) { + /*--- We have found a vector, so skip the Z component. ---*/ + output_variable = false; + VarCounter++; + } + + /*--- Write the point data as an vector or a scalar. ---*/ + + if (output_variable && isVector) { + + /*--- Prepare the 1D data buffer on this rank. ---*/ + + float *vec_buf = new float[myPoint*NCOORDS]; + + /*--- Load up the buffer for writing this rank's vector data. ---*/ + + float val = 0.0; + for (iPoint = 0; iPoint < myPoint; iPoint++) { + for (iDim = 0; iDim < NCOORDS; iDim++) { + if (nDim == 2 && iDim == 2) { + vec_buf[iPoint*NCOORDS + iDim] = 0.0; + } else { + val = (float)dataSorter->GetData(VarCounter+iDim,iPoint); + vec_buf[iPoint*NCOORDS + iDim] = val; + } + } + } + + WriteDataArray((void*)vec_buf, VTKDatatype::FLOAT32, myPoint*NCOORDS, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); + + delete [] vec_buf; + + VarCounter++; + + } else if (output_variable) { + + /*--- Prepare the 1D data buffer on this rank. ---*/ + + float *scalar_buf = new float[myPoint]; + + /*--- For now, create a temp 1D buffer to load up the data for writing. + This will be replaced with a derived data type most likely. ---*/ + + for (iPoint = 0; iPoint < myPoint; iPoint++) { + float val = (float)dataSorter->GetData(VarCounter,iPoint); + scalar_buf[iPoint] = val; + } + + WriteDataArray((void*)scalar_buf, VTKDatatype::FLOAT32, myPoint, GlobalPoint, nPoint_Cum[rank]); + + delete [] scalar_buf; scalar_buf = NULL; + VarCounter++; + } + + } + + WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); + + /*--- All ranks close the file after writing. ---*/ + + MPI_File_close(&fhw); + + + /*--- Compute and store the write time. ---*/ + +#ifndef HAVE_MPI + StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + StopTime = MPI_Wtime(); +#endif + UsedTime = StopTime-StartTime; + + /*--- Communicate the total file size for the restart ---*/ + +#ifdef HAVE_MPI + su2double my_file_size = file_size; + SU2_MPI::Allreduce(&my_file_size, &file_size, 1, + MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); +#endif + + /*--- Compute and store the bandwidth ---*/ + + Bandwidth = file_size/(1.0e6)/UsedTime; + + /*--- Delete the offset counters that we needed for MPI IO. ---*/ + + delete [] nElem_Snd; delete [] nElem_Cum; + delete [] nElemStorage_Snd; delete [] nElemStorage_Cum; + delete [] nPoint_Snd; delete [] nPoint_Cum; + +#endif +} + + +void CParaviewXMLFileWriter::WriteString(std::string str, int rank){ + + /*--- Reset the file view before writing the next ASCII line for cells. ---*/ + + MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, + (char*)"native", MPI_INFO_NULL); + + if (SU2_MPI::GetRank() == rank) + MPI_File_write_at(fhw, disp, str.c_str(), strlen( str.c_str()), + MPI_CHAR, MPI_STATUS_IGNORE); + disp += strlen( str.c_str())*sizeof(char); + file_size += sizeof(char)*strlen( str.c_str()); + +} + +void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, unsigned long cumSize, MPI_Offset offset){ + + MPI_Datatype filetype; + MPI_Status status; + unsigned long totalByteSize, byteSize; + + std::string typeStr; + unsigned long typeSize; + switch (type) { + case VTKDatatype::FLOAT32: + typeStr = "\"Float32\""; + typeSize = sizeof(float); + break; + case VTKDatatype::INT32: + typeStr = "\"Int32\""; + typeSize = sizeof(int); + break; + case VTKDatatype::UINT8: + typeStr = "\"UInt8\""; + typeSize = sizeof(char); + break; + default: + SU2_MPI::Error("Unknown Type", CURRENT_FUNCTION); + break; + } + + /*--- Compute the size of the data to write in bytes ---*/ + + byteSize = arraySize*typeSize; + + /*--- The total data size ---*/ + + totalByteSize = cumSize*typeSize; + + /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ + + MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, + (char*)"native", MPI_INFO_NULL); + + if (SU2_MPI::GetRank() == MASTER_NODE) + MPI_File_write_at(fhw, disp, &totalByteSize, sizeof(int), + MPI_BYTE, MPI_STATUS_IGNORE); + + disp += sizeof(int); + + /*--- Prepare to write the actual data ---*/ + + MPI_Type_contiguous(byteSize, MPI_BYTE, &filetype); + MPI_Type_commit(&filetype); + + /*--- Set the view for the MPI file write, i.e., describe the + location in the file that this rank "sees" for writing its + piece of the file. ---*/ + + MPI_File_set_view(fhw, disp + offset*typeSize, MPI_BYTE, filetype, + (char*)"native", MPI_INFO_NULL); + + /*--- Collective call for all ranks to write simultaneously. ---*/ + + MPI_File_write_all(fhw, data, byteSize, MPI_BYTE, &status); + + MPI_Type_free(&filetype); + + disp += totalByteSize; + file_size += byteSize; + +} + +void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, + unsigned short nComponents, unsigned long arraySize, unsigned long cumSize){ + + /*--- Add quotation marks around the arguments ---*/ + + name = "\"" + name + "\""; + + string nComp ="\"" + PrintingToolbox::to_string(nComponents) + "\""; + + /*--- Full precision ASCII output of offset for 32 bit integer ---*/ + + stringstream ss; + ss.precision(10); ss.setf(std::ios::fixed, std::ios::floatfield); + ss << "\"" << dataOffset << "\""; + string offsetStr = ss.str(); + + std::string typeStr; + unsigned long typeSize, byteSize, totalByteSize; + switch (type) { + case VTKDatatype::FLOAT32: + typeStr = "\"Float32\""; + typeSize = sizeof(float); + break; + case VTKDatatype::INT32: + typeStr = "\"Int32\""; + typeSize = sizeof(int); + break; + case VTKDatatype::UINT8: + typeStr = "\"UInt8\""; + typeSize = sizeof(char); + break; + default: + SU2_MPI::Error("Unknown Type", CURRENT_FUNCTION); + break; + } + + /*--- Compute the size of the data to write in bytes ---*/ + + byteSize = arraySize*typeSize; + + /*--- Total data size ---*/ + + totalByteSize = cumSize*typeSize; + + /*--- Write the ASCII XML header information for this array ---*/ + + WriteString(string("\n"), MASTER_NODE); + + dataOffset += totalByteSize + sizeof(int); + +} From ad9969baf59091ef1befdceec783bb170b0d598d Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 5 Jan 2020 23:49:31 +0100 Subject: [PATCH 11/61] Added missing meson entries --- SU2_DEF/src/meson.build | 2 ++ SU2_DOT/src/meson.build | 8 ++++++-- SU2_SOL/src/meson.build | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/SU2_DEF/src/meson.build b/SU2_DEF/src/meson.build index 065973d9db5..77e29340049 100644 --- a/SU2_DEF/src/meson.build +++ b/SU2_DEF/src/meson.build @@ -21,6 +21,8 @@ if get_option('enable-normal') 'output/filewriter/CCSVFileWriter.cpp', 'output/filewriter/CSU2FileWriter.cpp', 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', 'output/filewriter/CSU2MeshFileWriter.cpp']) su2_def = executable('SU2_DEF', diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index f476c01ee85..42200a7c9bc 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -19,8 +19,10 @@ if get_option('enable-normal') 'output/filewriter/CSU2FileWriter.cpp', 'output/filewriter/CSU2BinaryFileWriter.cpp', 'output/filewriter/CSU2MeshFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot = executable('SU2_DOT', su2_dot_src, @@ -52,6 +54,8 @@ if get_option('enable-autodiff') 'output/filewriter/CSU2FileWriter.cpp', 'output/filewriter/CSU2BinaryFileWriter.cpp', 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', 'variables/CBaselineVariable.cpp', 'variables/CVariable.cpp']) diff --git a/SU2_SOL/src/meson.build b/SU2_SOL/src/meson.build index 2eef5a2f9a8..00f3da1813b 100644 --- a/SU2_SOL/src/meson.build +++ b/SU2_SOL/src/meson.build @@ -19,6 +19,8 @@ if get_option('enable-normal') 'output/filewriter/CSU2FileWriter.cpp', 'output/filewriter/CSU2BinaryFileWriter.cpp', 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', 'variables/CBaselineVariable.cpp', 'variables/CVariable.cpp']) From f288783bf86c48155fa007d03176dc09f1e7aee8 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 16:11:28 +0100 Subject: [PATCH 12/61] Added time value and data set writing to vtm output --- .../filewriter/CParaviewVTMFileWriter.hpp | 8 +++- SU2_CFD/src/output/COutput.cpp | 15 ++++---- .../filewriter/CParaviewVTMFileWriter.cpp | 38 ++++++++++++++++++- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index 1b570f12b05..76032a80108 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -34,9 +34,10 @@ class CParaviewVTMFileWriter final: public CFileWriter{ stringstream output; string folderName; - \ + unsigned short iZone, nZone; + su2double curTime; public: /*! @@ -48,7 +49,7 @@ class CParaviewVTMFileWriter final: public CFileWriter{ * \brief Construct a file writer using field names, dimension. * \param[in] fileName - The name of the file */ - CParaviewVTMFileWriter(string fileName, string folderName, unsigned short iZone, unsigned short nZone); + CParaviewVTMFileWriter(string fileName, string folderName, su2double time, unsigned short iZone, unsigned short nZone); /*! * \brief Destructor @@ -59,6 +60,9 @@ class CParaviewVTMFileWriter final: public CFileWriter{ * \brief Write sorted data to file in paraview binary file format */ void Write_Data() override; + + + void AddDataset(string name, string file, vector fieldNames, unsigned short nDim, CParallelDataSorter* dataSorter); inline void StartBlock(string name){ if (rank == MASTER_NODE){ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index f1ca96a461b..97b55a3993a 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1844,18 +1844,19 @@ void COutput::SetCommonHistoryFields(CConfig *config){ } void COutput::LoadCommonHistoryData(CConfig *config){ + + SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref()); + /*--- Update the current time time only if the time iteration has changed ---*/ + + if ((unsigned long)GetHistoryFieldValue("TIME_ITER") != curTimeIter){ + SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); + } + SetHistoryOutputValue("TIME_ITER", curTimeIter); SetHistoryOutputValue("INNER_ITER", curInnerIter); SetHistoryOutputValue("OUTER_ITER", curOuterIter); - if (config->GetTime_Domain()){ - SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref()); - if (curInnerIter == 0){ - SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); - } - } - su2double StopTime, UsedTime; #ifndef HAVE_MPI StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index 0005579596e..7ada999d13e 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -26,11 +26,12 @@ */ #include "../../../include/output/filewriter/CParaviewVTMFileWriter.hpp" +#include "../../../include/output/filewriter/CParaviewXMLFileWriter.hpp" #include "../../../../Common/include/toolboxes/printing_toolbox.hpp" const string CParaviewVTMFileWriter::fileExt = ".vtm"; -CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderName, unsigned short iZone, unsigned short nZone) +CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderName, su2double time, unsigned short iZone, unsigned short nZone) : CFileWriter(std::move(fileName), fileExt), folderName(std::move(folderName)){ @@ -43,6 +44,8 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderNam this->iZone = iZone; this->nZone = nZone; + + curTime = time; } @@ -52,6 +55,9 @@ CParaviewVTMFileWriter::~CParaviewVTMFileWriter(){ void CParaviewVTMFileWriter::Write_Data(){ + /*--- If we are in the first zone, create new file and write the file header, + * otherwise append to already existing file ---*/ + if (rank == MASTER_NODE){ ofstream multiBlockFile; if (iZone == 0) @@ -64,13 +70,41 @@ void CParaviewVTMFileWriter::Write_Data(){ multiBlockFile << "" << endl; } + /*--- Write all blocks that have been added ---*/ + multiBlockFile << output.str(); + /*--- If we are in the last zone, write the additional data and close all blocks ---*/ + if (iZone == nZone-1){ multiBlockFile << "" << endl; + multiBlockFile << "" << endl; + multiBlockFile << "" << endl; + multiBlockFile << curTime << endl; + multiBlockFile << "" << endl; + multiBlockFile << "" << endl; multiBlockFile << "" << endl; } multiBlockFile.close(); } -} \ No newline at end of file +} + +void CParaviewVTMFileWriter::AddDataset(string name, string file, vector fieldNames, + unsigned short nDim, CParallelDataSorter* dataSorter){ + + /*--- Construct the full file name incl. folder ---*/ + + string fullFilename = folderName + "/" + file; + + /*--- Create an XML writer and dump data into file ---*/ + + CParaviewXMLFileWriter* XMLWriter = new CParaviewXMLFileWriter(fieldNames, nDim, fullFilename, dataSorter); + XMLWriter->Write_Data(); + delete XMLWriter; + + /*--- Add the dataset to the vtm file ---*/ + + AddDataset(name, fullFilename + CParaviewXMLFileWriter::fileExt); + +} From b7e1861173a5e72a292d96033d05b224dd218da9 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 16:12:29 +0100 Subject: [PATCH 13/61] Updated vtk xml writer for serial compilation --- .../filewriter/CParaviewXMLFileWriter.hpp | 8 +- .../filewriter/CParaviewXMLFileWriter.cpp | 419 ++---------------- 2 files changed, 44 insertions(+), 383 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index b984814135d..da5f59a270d 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -39,11 +39,15 @@ class CParaviewXMLFileWriter final: public CFileWriter{ UINT8 }; +#ifdef HAVE_MPI MPI_Offset disp; MPI_File fhw; +#else + unsigned long disp; + FILE* fhw; +#endif bool BigEndian; - unsigned long dataOffset; public: @@ -79,6 +83,6 @@ class CParaviewXMLFileWriter final: public CFileWriter{ void AddDataArray(VTKDatatype type, string name, unsigned short nComponents, unsigned long size, unsigned long cumSize); - void WriteDataArray(void *data, VTKDatatype type, unsigned long size, unsigned long cumSize, MPI_Offset offset); + void WriteDataArray(void *data, VTKDatatype type, unsigned long size, unsigned long cumSize, unsigned long offset); }; diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index fe309f17e6a..b59a6dbf5cd 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -83,386 +83,12 @@ void CParaviewXMLFileWriter::Write_Data(){ StartTime = MPI_Wtime(); #endif - /*--- Serial implementation in case we have not compiled with MPI. ---*/ - -#ifndef HAVE_MPI - - FILE* fhw; - fhw = fopen(fname, "wb"); - - unsigned long iNode2; - unsigned long nGlobal_Elem_Storage; - - /*--- Error check for opening the file. ---*/ - - if (!fhw) { - SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - fileName, CURRENT_FUNCTION); - } - - /*--- File header written in ASCII. ---*/ - - strcpy(str_buf, "# vtk DataFile Version 3.0\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "vtk output\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "BINARY\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "DATASET UNSTRUCTURED_GRID\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - /*--- Write the point coordinates. ---*/ - - unsigned long GlobalPoint = dataSorter->GetnPointsGlobal(); - - SPRINTF(str_buf, "POINTS %i float\n", (int)GlobalPoint); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - /*--- Load/write the 1D buffer of point coordinates. ---*/ - - float *coord_buf = new float[GlobalPoint*NCOORDS]; - for (iPoint = 0; iPoint < GlobalPoint; iPoint++) { - for (iDim = 0; iDim < NCOORDS; iDim++) { - if (nDim == 2 && iDim == 2) { - coord_buf[iPoint*NCOORDS + iDim] = 0.0; - } else { - float val = (float)dataSorter->GetData(iDim,iPoint); - coord_buf[iPoint*NCOORDS + iDim] = val; - } - } - } - if (!BigEndian) SwapBytes((char *)coord_buf, sizeof(float), 3*GlobalPoint); - - fwrite(coord_buf, sizeof(float), 3*GlobalPoint, fhw); - file_size += sizeof(char)*3*GlobalPoint; - - delete [] coord_buf; - - /*--- Write the connectivity data. ---*/ - - unsigned long nTot_Line; - unsigned long nTot_Tria, nTot_Quad; - unsigned long nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; - nTot_Line = dataSorter->GetnElem(LINE); - nTot_Tria = dataSorter->GetnElem(TRIANGLE); - nTot_Quad = dataSorter->GetnElem(QUADRILATERAL); - nTot_Tetr = dataSorter->GetnElem(TETRAHEDRON); - nTot_Hexa = dataSorter->GetnElem(HEXAHEDRON); - nTot_Pris = dataSorter->GetnElem(PRISM); - nTot_Pyra = dataSorter->GetnElem(PYRAMID); - nGlobal_Elem_Storage = (nTot_Line*3 + nTot_Tria*4 + nTot_Quad*5 + nTot_Tetr*5 + - nTot_Hexa*9 + nTot_Pris*7 + nTot_Pyra*6); - - int *conn_buf = NULL; - - SPRINTF (str_buf, "\nCELLS %i %i\n", (int)dataSorter->GetnElem(), - (int)nGlobal_Elem_Storage); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - conn_buf = new int[dataSorter->GetnElem()*(N_POINTS_HEXAHEDRON+1)]; - - - /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ - - - for (iElem = 0; iElem < nTot_Line; iElem++) { - iNode2 = iElem*(N_POINTS_LINE+1); - conn_buf[iNode2+0] = N_POINTS_LINE; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(LINE, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(LINE, iElem, 1)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Line*(N_POINTS_LINE+1)); - fwrite(conn_buf, sizeof(int), - nTot_Line*(N_POINTS_LINE+1), fhw); - - file_size += sizeof(int)*nTot_Line*(N_POINTS_LINE+1); - - for (iElem = 0; iElem < nTot_Tria; iElem++) { - iNode2 = iElem*(N_POINTS_TRIANGLE+1); - conn_buf[iNode2+0] = N_POINTS_TRIANGLE; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 2)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Tria*(N_POINTS_TRIANGLE+1)); - fwrite(conn_buf, sizeof(int), - nTot_Tria*(N_POINTS_TRIANGLE+1), fhw); - file_size += sizeof(int)*nTot_Tria*(N_POINTS_TRIANGLE+1); - - for (iElem = 0; iElem < nTot_Quad; iElem++) { - iNode2 = iElem*(N_POINTS_QUADRILATERAL+1); - conn_buf[iNode2+0] = N_POINTS_QUADRILATERAL; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 3)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Quad*(N_POINTS_QUADRILATERAL+1)); - fwrite(conn_buf, sizeof(int), - nTot_Quad*(N_POINTS_QUADRILATERAL+1), fhw); - file_size += sizeof(int)*nTot_Quad*(N_POINTS_QUADRILATERAL+1); - - for (iElem = 0; iElem < nTot_Tetr; iElem++) { - iNode2 = iElem*(N_POINTS_TETRAHEDRON+1); - conn_buf[iNode2+0] = N_POINTS_TETRAHEDRON; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 3)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Tetr*(N_POINTS_TETRAHEDRON+1)); - fwrite(conn_buf, sizeof(int), - nTot_Tetr*(N_POINTS_TETRAHEDRON+1), fhw); - file_size += sizeof(int)*nTot_Tetr*(N_POINTS_TETRAHEDRON+1); - - for (iElem = 0; iElem < nTot_Hexa; iElem++) { - iNode2 = iElem*(N_POINTS_HEXAHEDRON+1); - conn_buf[iNode2+0] = N_POINTS_HEXAHEDRON; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 3)-1; - conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 4)-1; - conn_buf[iNode2+6] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 5)-1; - conn_buf[iNode2+7] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 6)-1; - conn_buf[iNode2+8] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 7)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Hexa*(N_POINTS_HEXAHEDRON+1)); - fwrite(conn_buf, sizeof(int), - nTot_Hexa*(N_POINTS_HEXAHEDRON+1), fhw); - file_size += sizeof(int)*nTot_Hexa*(N_POINTS_HEXAHEDRON+1); - - for (iElem = 0; iElem < nTot_Pris; iElem++) { - iNode2 = iElem*(N_POINTS_PRISM+1); - conn_buf[iNode2+0] = N_POINTS_PRISM; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(PRISM, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(PRISM, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(PRISM, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(PRISM, iElem, 3)-1; - conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(PRISM, iElem, 4)-1; - conn_buf[iNode2+6] = dataSorter->GetElem_Connectivity(PRISM, iElem, 5)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Pris*(N_POINTS_PRISM+1)); - fwrite(conn_buf, sizeof(int), - nTot_Pris*(N_POINTS_PRISM+1), fhw); - file_size += sizeof(int)*nTot_Pris*(N_POINTS_PRISM+1); - - for (iElem = 0; iElem < nTot_Pyra; iElem++) { - iNode2 = iElem*(N_POINTS_PYRAMID+1); - conn_buf[iNode2+0] = N_POINTS_PYRAMID; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 3)-1; - conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 4)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Pyra*(N_POINTS_PYRAMID+1)); - fwrite(conn_buf, sizeof(int), - nTot_Pyra*(N_POINTS_PYRAMID+1), fhw); - file_size += sizeof(int)*nTot_Pyra*(N_POINTS_PYRAMID+1); - - - if (conn_buf != NULL) delete [] conn_buf; - - /*--- Load/write the cell type for all elements in the file. ---*/ - - - SPRINTF (str_buf, "\nCELL_TYPES %i\n", SU2_TYPE::Int(dataSorter->GetnElem())); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); - - int *type_buf = NULL; - - type_buf = new int[dataSorter->GetnElem()]; - - for (iElem = 0; iElem < nTot_Line; iElem++) { - type_buf[iElem] = LINE; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Line); - fwrite(type_buf, sizeof(int), nTot_Line, fhw); - file_size += sizeof(int)*nTot_Line; - - for (iElem = 0; iElem < nTot_Tria; iElem++) { - type_buf[iElem] = TRIANGLE; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Tria); - fwrite(type_buf, sizeof(int), nTot_Tria, fhw); - file_size += sizeof(int)*nTot_Tria; - - for (iElem = 0; iElem < nTot_Quad; iElem++) { - type_buf[iElem] = QUADRILATERAL; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Quad); - fwrite(type_buf, sizeof(int), nTot_Quad, fhw); - file_size += sizeof(int)*nTot_Quad; - - for (iElem = 0; iElem < nTot_Tetr; iElem++) { - type_buf[iElem] = TETRAHEDRON; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Tetr); - fwrite(type_buf, sizeof(int), nTot_Tetr, fhw); - file_size += sizeof(int)*nTot_Tetr; - - for (iElem = 0; iElem < nTot_Hexa; iElem++) { - type_buf[iElem] = HEXAHEDRON; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Hexa); - fwrite(type_buf, sizeof(int), nTot_Hexa, fhw); - file_size += sizeof(int)*nTot_Hexa; - - for (iElem = 0; iElem < nTot_Pris; iElem++) { - type_buf[iElem] = PRISM; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Pris); - fwrite(type_buf, sizeof(int), nTot_Pris, fhw); - file_size += sizeof(int)*nTot_Pris; - - for (iElem = 0; iElem < nTot_Pyra; iElem++) { - type_buf[iElem] = PYRAMID; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Pyra); - fwrite(type_buf, sizeof(int), nTot_Pyra, fhw); - file_size += sizeof(int)*nTot_Pyra; - - - if (type_buf != NULL) delete [] type_buf; - - /*--- Now write the scalar and vector data (reuse the counts above). ---*/ - - SPRINTF (str_buf, "\nPOINT_DATA %i\n", (int)GlobalPoint); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); - - unsigned short varStart = 2; - if (nDim == 3) varStart++; - - /*--- Need to adjust container location to avoid PointID tag and coords. ---*/ - - unsigned short iField, VarCounter = varStart; - for (iField = varStart; iField < fieldnames.size(); iField++) { - - string fieldname = fieldnames[iField]; - fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), - fieldname.end()); - - bool output_variable = true, isVector = false; - size_t found = fieldnames[iField].find("_x"); - if (found!=string::npos) { - output_variable = true; - isVector = true; - } - found = fieldnames[iField].find("_y"); - if (found!=string::npos) { - //skip - output_variable = false; - VarCounter++; - } - found = fieldnames[iField].find("_z"); - if (found!=string::npos) { - //skip - output_variable = false; - VarCounter++; - } - - if (output_variable && isVector) { - - fieldname.erase(fieldname.end()-2,fieldname.end()); - SPRINTF (str_buf, "\nVECTORS %s float\n", fieldname.c_str()); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); - - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *vec_buf = new float[GlobalPoint*NCOORDS]; - - /*--- For now, create a temp 1D buffer to load up the data for writing. - This will be replaced with a derived data type most likely. ---*/ - - float val = 0.0; - for (iPoint = 0; iPoint < GlobalPoint; iPoint++) - for (iDim = 0; iDim < NCOORDS; iDim++) { - if (nDim == 2 && iDim == 2) { - vec_buf[iPoint*NCOORDS + iDim] = 0.0; - } else { - val = (float)dataSorter->GetData(VarCounter+iDim,iPoint); - vec_buf[iPoint*NCOORDS + iDim] = val; - } - } - if (!BigEndian) - SwapBytes((char *)vec_buf, sizeof(float), NCOORDS*GlobalPoint); - fwrite(vec_buf, sizeof(float), NCOORDS*GlobalPoint, fhw); - file_size += sizeof(float)*NCOORDS*GlobalPoint; - - delete [] vec_buf; - - VarCounter++; - - } else if (output_variable) { - - SPRINTF (str_buf, "\nSCALARS %s float 1\n", fieldname.c_str()); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); - - SPRINTF (str_buf, "LOOKUP_TABLE default\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); - - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *scalar_buf = new float[GlobalPoint]; - - /*--- For now, create a temp 1D buffer to load up the data for writing. - This will be replaced with a derived data type most likely. ---*/ - - for (iPoint = 0; iPoint < GlobalPoint; iPoint++) { - float val = (float)dataSorter->GetData(VarCounter,iPoint); - scalar_buf[iPoint] = val; - } - if (!BigEndian) - SwapBytes((char *)scalar_buf, sizeof(float), GlobalPoint); - fwrite(scalar_buf, sizeof(float), GlobalPoint, fhw); - file_size += sizeof(float)*GlobalPoint; - - delete [] scalar_buf; - - VarCounter++; - } - - } - - /*--- Close the file. ---*/ - - fclose(fhw); - -#else /*--- Parallel binary output using MPI I/O. ---*/ int ierr; +#ifdef HAVE_MPI /*--- All ranks open the file using MPI. Here, we try to open the file with exclusive so that an error is generated if the file exists. We always want to write a fresh output file, so we delete any existing files and create @@ -486,7 +112,16 @@ void CParaviewXMLFileWriter::Write_Data(){ SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + string(fname), CURRENT_FUNCTION); } +#else + fhw = fopen(fname, "wb"); + /*--- Error check for opening the file. ---*/ + if (!fhw) { + SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + + fileName, CURRENT_FUNCTION); + } +#endif + /*--- Write the initial strings to the file. Only the master will write the header lines, but all ranks will store the offsets. ---*/ @@ -847,10 +482,13 @@ void CParaviewXMLFileWriter::Write_Data(){ WriteString("\n", MASTER_NODE); WriteString("\n", MASTER_NODE); +#ifdef HAVE_MPI /*--- All ranks close the file after writing. ---*/ MPI_File_close(&fhw); - +#else + fclose(fhw); +#endif /*--- Compute and store the write time. ---*/ @@ -879,12 +517,12 @@ void CParaviewXMLFileWriter::Write_Data(){ delete [] nElemStorage_Snd; delete [] nElemStorage_Cum; delete [] nPoint_Snd; delete [] nPoint_Cum; -#endif } void CParaviewXMLFileWriter::WriteString(std::string str, int rank){ - + +#ifdef HAVE_MPI /*--- Reset the file view before writing the next ASCII line for cells. ---*/ MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, @@ -895,13 +533,18 @@ void CParaviewXMLFileWriter::WriteString(std::string str, int rank){ MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen( str.c_str())*sizeof(char); file_size += sizeof(char)*strlen( str.c_str()); +#else + char str_buf[255]; + strcpy(str_buf, str.c_str()); + fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); + file_size += sizeof(char)*strlen(str_buf); +#endif } -void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, unsigned long cumSize, MPI_Offset offset){ +void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, unsigned long cumSize, unsigned long offset){ - MPI_Datatype filetype; - MPI_Status status; + unsigned long totalByteSize, byteSize; std::string typeStr; @@ -932,6 +575,11 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign totalByteSize = cumSize*typeSize; +#ifdef HAVE_MPI + + MPI_Datatype filetype; + MPI_Status status; + /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, @@ -963,7 +611,16 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign disp += totalByteSize; file_size += byteSize; +#else + /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ + + fwrite(&totalByteSize, sizeof(int),1, fhw); + /*--- Write binary data ---*/ + + fwrite(data, sizeof(char), byteSize, fhw); + file_size += byteSize; +#endif } void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, From faad7dd2a7457090ec5b5eef35093f10c36e4f3b Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 16:12:52 +0100 Subject: [PATCH 14/61] Updated WriteToFile routine --- SU2_CFD/src/output/COutput.cpp | 40 +++++++------------ .../filewriter/CSurfaceFVMDataSorter.cpp | 3 ++ 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 97b55a3993a..6a106f77853 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -472,40 +472,29 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f if (fileName.empty()) fileName = config->GetFilename(volumeFilename, "", curTimeIter); + /*--- Sort volume connectivity ---*/ + + volumeDataSorter->SortConnectivity(config, geometry, true); + { string folderName = fileName; if (config->GetMultizone_Problem()){ - fileName = "Multizone"; + fileName = config->GetUnsteady_FileName("Multizone", curTimeIter, ""); } - fileWriter = new CParaviewVTMFileWriter(fileName, folderName, config->GetiZone(), config->GetnZone()); + fileWriter = new CParaviewVTMFileWriter(fileName, folderName, GetHistoryFieldValue("CUR_TIME"), config->GetiZone(), config->GetnZone()); CParaviewVTMFileWriter* vtmWriter = dynamic_cast(fileWriter); - CParaviewXMLFileWriter *XMLWriter = NULL; if (rank == MASTER_NODE) { (*fileWritingTable) << "Paraview Multiblock" << fileName + CParaviewVTMFileWriter::fileExt + " -> " + vtmWriter->GetFolderName(); } - fileName = "Internal"; - fileName = vtmWriter->GetFolderName() + "/" + fileName; - + fileName = "Internal"; vtmWriter->StartBlock("Zone " + PrintingToolbox::to_string(config->GetiZone())); - - vtmWriter->StartBlock("Internal"); - vtmWriter->AddDataset("Internal", fileName + CParaviewXMLFileWriter::fileExt); + vtmWriter->StartBlock(fileName); + vtmWriter->AddDataset(fileName, fileName, volumeFieldNames, nDim, volumeDataSorter); vtmWriter->EndBlock(); - - /*--- Sort volume connectivity ---*/ - - volumeDataSorter->SortConnectivity(config, geometry, true); - - /*--- Create XML writer and write volume data to file ---*/ - - XMLWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); - XMLWriter->Write_Data(); - delete XMLWriter; - vtmWriter->StartBlock("Boundary"); for (unsigned short iMarker = 0; iMarker < config->GetnMarker_CfgFile(); iMarker++){ @@ -535,20 +524,21 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f SU2_MPI::Allreduce(&localMarkerSize, &globalMarkerSize, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); if (globalMarkerSize > 0){ + /*--- Sort connectivity of the current marker ---*/ surfaceDataSorter->SortConnectivity(config, geometry, markerList); surfaceDataSorter->SortOutputData(); - fileName = vtmWriter->GetFolderName() + "/" + markerTag; - XMLWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); - XMLWriter->Write_Data(); - delete XMLWriter; + /*--- Add the dataset ---*/ - vtmWriter->AddDataset(markerTag, fileName + CParaviewXMLFileWriter::fileExt); + vtmWriter->AddDataset(markerTag, markerTag, volumeFieldNames, nDim, surfaceDataSorter); + } } + /*--- End "Boundary" block ---*/ vtmWriter->EndBlock(); + /*--- End "Zone" block ---*/ vtmWriter->EndBlock(); } diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index bd787cc6cb3..874cb35a780 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -1519,16 +1519,19 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * case LINE: nParallel_Line = nElem_Total; if (Conn_Line_Par != NULL) delete [] Conn_Line_Par; + Conn_Line_Par = NULL; if (nParallel_Line > 0) Conn_Line_Par = Conn_Elem; break; case TRIANGLE: nParallel_Tria = nElem_Total; if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; + Conn_Tria_Par = NULL; if (nParallel_Tria > 0) Conn_Tria_Par = Conn_Elem; break; case QUADRILATERAL: nParallel_Quad = nElem_Total; if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; + Conn_Quad_Par = NULL; if (nParallel_Quad > 0) Conn_Quad_Par = Conn_Elem; break; default: From e6c443c08b154b9b9cb960db353130fa4e7d359d Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 17:07:02 +0100 Subject: [PATCH 15/61] Small fix for AD compilation --- SU2_CFD/src/output/COutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 6a106f77853..c296ae66eab 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1839,7 +1839,7 @@ void COutput::LoadCommonHistoryData(CConfig *config){ /*--- Update the current time time only if the time iteration has changed ---*/ - if ((unsigned long)GetHistoryFieldValue("TIME_ITER") != curTimeIter){ + if (SU2_TYPE::Int(GetHistoryFieldValue("TIME_ITER")) != curTimeIter){ SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); } From c12c3f9e751145ca43cfce44baaa8adb33ebb4ad Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 20:02:56 +0100 Subject: [PATCH 16/61] adding case name field to config --- Common/include/config_structure.hpp | 7 +++++++ Common/include/config_structure.inl | 2 ++ Common/src/config_structure.cpp | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 141d1c30324..aca4cba5368 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -1118,6 +1118,7 @@ class CConfig { unsigned short pastix_verb_lvl; /*!< \brief Verbosity level for PaStiX */ unsigned short pastix_fill_lvl; /*!< \brief Fill level for PaStiX ILU */ + string caseName; /*!< \brief Name of the current case /*! * \brief Set the default values of config options not set in the config file using another config object. @@ -9292,6 +9293,12 @@ class CConfig { * \return if option was set in the config file */ bool OptionIsSet(string option); + + /*! + * \brief Get the name of the current case + * \return the case name + */ + string GetCaseName(); }; #include "config_structure.inl" diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index dcb0c245ddb..ed04eeaecfa 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -2073,3 +2073,5 @@ inline unsigned short* CConfig::GetVolumeOutputFiles() {return VolumeOutputFiles inline unsigned short CConfig::GetnVolumeOutputFiles() {return nVolumeOutputFiles;} inline bool CConfig::OptionIsSet(string option){ return all_options.find(option) == all_options.end();} + +inline string CConfig::GetCaseName(){ return caseName;} diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 8bf68e3aa54..11bd7c65d33 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -55,6 +55,12 @@ vector GEMM_Profile_MaxTime; /*!< \brief Maximum time spent for thi CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software, bool verb_high) { + /*--- Set the case name to the base config file name without extension ---*/ + + caseName = string(case_filename); + unsigned short lastindex = caseName.find_last_of("."); + caseName = caseName.substr(0, lastindex); + base_config = true; /*--- Store MPI rank and size ---*/ @@ -102,6 +108,8 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], unsigned short val_software, unsigned short val_iZone, unsigned short val_nZone, bool verb_high) { + caseName = config->GetCaseName(); + unsigned short val_nDim; base_config = false; @@ -157,6 +165,12 @@ CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], unsigned CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software) { + /*--- Set the case name to the base config file name without extension ---*/ + + caseName = string(case_filename); + unsigned short lastindex = caseName.find_last_of("."); + caseName = caseName.substr(0, lastindex); + base_config = true; nZone = 1; @@ -203,6 +217,12 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar CConfig::CConfig(char case_filename[MAX_STRING_SIZE], CConfig *config) { + /*--- Set the case name to the base config file name without extension ---*/ + + caseName = string(case_filename); + unsigned short lastindex = caseName.find_last_of("."); + caseName = caseName.substr(0, lastindex); + base_config = true; /*--- Store MPI rank and size ---*/ From b1bfc3e0e93d3ba010b9c721b8d009f67fde6918 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 20:04:29 +0100 Subject: [PATCH 17/61] Removed redundant information from filewriter/sorting routines --- .../output/filewriter/CCSVFileWriter.hpp | 2 +- .../output/filewriter/CFEMDataSorter.hpp | 4 +- .../output/filewriter/CFVMDataSorter.hpp | 4 +- .../include/output/filewriter/CFileWriter.hpp | 18 ++----- .../output/filewriter/CParallelDataSorter.hpp | 24 ++++++++- .../filewriter/CParaviewBinaryFileWriter.hpp | 3 +- .../output/filewriter/CParaviewFileWriter.hpp | 3 +- .../filewriter/CParaviewVTMFileWriter.hpp | 2 +- .../filewriter/CParaviewXMLFileWriter.hpp | 5 +- .../filewriter/CSU2BinaryFileWriter.hpp | 5 +- .../output/filewriter/CSU2FileWriter.hpp | 3 +- .../output/filewriter/CSU2MeshFileWriter.hpp | 5 +- .../filewriter/CSurfaceFEMDataSorter.hpp | 3 +- .../filewriter/CSurfaceFVMDataSorter.hpp | 3 +- .../filewriter/CTecplotBinaryFileWriter.hpp | 5 +- .../output/filewriter/CTecplotFileWriter.hpp | 5 +- .../src/output/filewriter/CCSVFileWriter.cpp | 31 ++++++------ .../src/output/filewriter/CFEMDataSorter.cpp | 3 +- .../src/output/filewriter/CFVMDataSorter.cpp | 3 +- .../output/filewriter/CParallelDataSorter.cpp | 5 +- .../output/filewriter/CParallelFileWriter.cpp | 11 ++--- .../filewriter/CParaviewBinaryFileWriter.cpp | 23 ++++----- .../output/filewriter/CParaviewFileWriter.cpp | 19 +++---- .../filewriter/CParaviewVTMFileWriter.cpp | 16 +++--- .../filewriter/CParaviewXMLFileWriter.cpp | 28 +++++------ .../filewriter/CSU2BinaryFileWriter.cpp | 12 ++--- .../src/output/filewriter/CSU2FileWriter.cpp | 16 +++--- .../output/filewriter/CSU2MeshFileWriter.cpp | 9 ++-- .../filewriter/CSurfaceFEMDataSorter.cpp | 3 +- .../filewriter/CSurfaceFVMDataSorter.cpp | 3 +- .../filewriter/CTecplotBinaryFileWriter.cpp | 49 ++++++++++--------- .../output/filewriter/CTecplotFileWriter.cpp | 17 ++++--- 32 files changed, 166 insertions(+), 176 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp b/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp index ec988cee9ee..52076316064 100644 --- a/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp @@ -37,7 +37,7 @@ class CCSVFileWriter final: public CFileWriter{ * \param[in] fields - A list of field names * \param[in] nDim - Physical dimension */ - CCSVFileWriter(vector fields, unsigned short nDim, string fileName, CParallelDataSorter* data_sorter); + CCSVFileWriter(string fileName, CParallelDataSorter* data_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp index 10c4de72cfc..3f9359e6c75 100644 --- a/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp @@ -37,9 +37,9 @@ class CFEMDataSorter final: public CParallelDataSorter{ * \brief Constructor * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] nFields - Number of output fields + * \param[in] fieldNames - Vector containing the field names */ - CFEMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields); + CFEMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp index 1b9bd85fe9e..b3d8d4cb3cf 100644 --- a/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp @@ -42,9 +42,9 @@ class CFVMDataSorter final: public CParallelDataSorter{ * \brief Constructor * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] nFields - Number of output fields + * \param[in] fieldNames - Vector containing the field names */ - CFVMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields); + CFVMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index d7b729f2641..be5d1b63a67 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -42,16 +42,6 @@ using namespace std; class CFileWriter{ protected: - /*! - * \brief Vector containing the field names - */ - std::vector fieldnames; - - /*! - * \brief The physical dimension of the problem - */ - unsigned short nDim; - /*! * \brief The MPI rank */ @@ -97,19 +87,17 @@ class CFileWriter{ public: /*! * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names * \param[in] fileName - The name of the file * \param[in] file_ext - The file extension to be attached to the filename - * \param[in] nDim - Physical dimension */ - CFileWriter(std::vector fields, string fileName, CParallelDataSorter* dataSorter, string file_ext, unsigned short nDim); + CFileWriter(string fileName, CParallelDataSorter* dataSorter, string file_ext); /*! * \brief Construct a file writer using field names, file extension and dimension. * \param[in] fileName - The name of the file - * \param[in] file_ext - The file extension to be attached to the filename + * \param[in] fileExt - The file extension to be attached to the filename */ - CFileWriter(string fileName, string file_ext); + CFileWriter(string fileName, string fileExt); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index b1f44b741bf..d2f4c206118 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -86,6 +86,10 @@ class CParallelDataSorter{ unsigned long *idSend; //!< Send buffer holding global indices that will be send to other processors int nSends, //!< Number of sends nRecvs; //!< Number of receives + + vector fieldNames; //!< Vector with names of the output fields + + unsigned short nDim; //!< Spatial dimension of the data /*! * \brief Prepare the send buffers by filling them with the global indices. @@ -100,9 +104,9 @@ class CParallelDataSorter{ /*! * \brief Constructor * \param[in] config - Pointer to the current config structure - * \param[in] nFields - Number of output fields + * \param[in] fieldNames - Vector containing the field names */ - CParallelDataSorter(CConfig *config, unsigned short nFields); + CParallelDataSorter(CConfig *config, vector fieldNames); /*! * \brief Destructor @@ -240,4 +244,20 @@ class CParallelDataSorter{ su2double GetUnsorted_Data(unsigned long iPoint, unsigned short iField){ return connSend[Index[iPoint] + iField]; } + + /*! + * \brief Get the vector containing the names of the output fields + * \return Vector of strings containing the field names + */ + vector GetFieldNames(){ + return fieldNames; + } + + /*! + * \brief Get the spatial dimension + * \return The spatial dimension + */ + unsigned short GetnDim(){ + return nDim; + } }; diff --git a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp index 4fced080172..83f36910a9e 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp @@ -45,8 +45,7 @@ class CParaviewBinaryFileWriter final: public CFileWriter{ * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write */ - CParaviewBinaryFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter); + CParaviewBinaryFileWriter(string fileName, CParallelDataSorter* data_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp index 4fb24cc8255..aa166d4cc28 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp @@ -44,8 +44,7 @@ class CParaviewFileWriter final: public CFileWriter{ * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write */ - CParaviewFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter); + CParaviewFileWriter(string fileName, CParallelDataSorter* data_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index 76032a80108..f8236f5b389 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -62,7 +62,7 @@ class CParaviewVTMFileWriter final: public CFileWriter{ void Write_Data() override; - void AddDataset(string name, string file, vector fieldNames, unsigned short nDim, CParallelDataSorter* dataSorter); + void AddDataset(string name, string file, CParallelDataSorter* dataSorter); inline void StartBlock(string name){ if (rank == MASTER_NODE){ diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index da5f59a270d..959aea50149 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -59,13 +59,10 @@ class CParaviewXMLFileWriter final: public CFileWriter{ /*! * \brief Construct a file writer using field names, dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write */ - CParaviewXMLFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter); + CParaviewXMLFileWriter(string fileName, CParallelDataSorter* data_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp index f5d771b6cf0..8189647899b 100644 --- a/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp @@ -40,13 +40,10 @@ class CSU2BinaryFileWriter final: public CFileWriter{ /*! * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write */ - CSU2BinaryFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter); + CSU2BinaryFileWriter(string fileName, CParallelDataSorter* data_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp index f52c214c525..909fad112db 100644 --- a/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp @@ -44,8 +44,7 @@ class CSU2FileWriter final: public CFileWriter{ * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write */ - CSU2FileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter); + CSU2FileWriter(string fileName, CParallelDataSorter* data_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp index 37a5e4a8c66..27ddc0de928 100644 --- a/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp @@ -42,15 +42,12 @@ class CSU2MeshFileWriter final: public CFileWriter{ /*! * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write * \param[in] iZone - Index of the current zone * \param[in] nZone - Number of zones */ - CSU2MeshFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter, + CSU2MeshFileWriter(string fileName, CParallelDataSorter* data_sorter, unsigned short iZone, unsigned short nZone); /*! diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp index 79358e026e9..4d4f74bb5e4 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp @@ -41,10 +41,9 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ * \brief Constructor * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] nFields - Number of output fields * \param[in] volume_sorter - Pointer to the corresponding volume sorter instance */ - CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields, CFEMDataSorter* volume_sorter); + CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* volume_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index a93ebeb335b..9e468781abd 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -40,10 +40,9 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * \brief Constructor * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] nFields - Number of output fields * \param[in] volume_sorter - Pointer to the corresponding volume sorter instance */ - CSurfaceFVMDataSorter(CConfig *config, CGeometry* geometry, unsigned short nFields, CFVMDataSorter* volume_sorter); + CSurfaceFVMDataSorter(CConfig *config, CGeometry* geometry, CFVMDataSorter* volume_sorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp index 2764f84f902..0733e6b85fe 100644 --- a/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp @@ -45,13 +45,10 @@ class CTecplotBinaryFileWriter final: public CFileWriter{ /*! * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension * \param[in] fileName - The name of the file * \param[in] data_sorter - The parallel sorted data to write */ - CTecplotBinaryFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter* data_sorter, + CTecplotBinaryFileWriter(string fileName, CParallelDataSorter* data_sorter, unsigned long time_iter, su2double timestep); /*! diff --git a/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp b/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp index 61fb25b1045..61e6dd8443c 100644 --- a/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp @@ -42,13 +42,10 @@ class CTecplotFileWriter final: public CFileWriter{ /*! * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension * \param[in] - The name of the file * \param[in] - The parallel sorted data to write */ - CTecplotFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter, + CTecplotFileWriter(string fileName, CParallelDataSorter *dataSorter, unsigned long time_iter, su2double timestep); /*! diff --git a/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp index cdfa3d05f79..0e947eb3c34 100644 --- a/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp @@ -28,9 +28,8 @@ #include "../../../include/output/filewriter/CCSVFileWriter.hpp" #include "../../../include/output/filewriter/CParallelDataSorter.hpp" -CCSVFileWriter::CCSVFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, std::move(".csv"), nDim){} +CCSVFileWriter::CCSVFileWriter(string fileName, CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fileName), dataSorter, std::move(".csv")){} CCSVFileWriter::~CCSVFileWriter(){ @@ -54,6 +53,8 @@ void CCSVFileWriter::Write_Data(){ unsigned long iPoint, index; unsigned long Buffer_Send_nVertex[1], *Buffer_Recv_nVertex = NULL; unsigned long nLocalVertex_Surface = 0, MaxLocalVertex_Surface = 0; + + const vector fieldNames = dataSorter->GetFieldNames(); ofstream Surf_file; Surf_file.precision(15); @@ -78,7 +79,7 @@ void CCSVFileWriter::Write_Data(){ /*--- Allocate buffers for send/recv of the data and global IDs. ---*/ - su2double *bufD_Send = new su2double[MaxLocalVertex_Surface*fieldnames.size()](); + su2double *bufD_Send = new su2double[MaxLocalVertex_Surface*fieldNames.size()](); su2double *bufD_Recv = NULL; unsigned long *bufL_Send = new unsigned long [MaxLocalVertex_Surface](); @@ -95,7 +96,7 @@ void CCSVFileWriter::Write_Data(){ /*--- Solution data. ---*/ - for (iVar = 0; iVar < fieldnames.size(); iVar++){ + for (iVar = 0; iVar < fieldNames.size(); iVar++){ bufD_Send[index] = dataSorter->GetData(iVar, iPoint); index++; } @@ -105,14 +106,14 @@ void CCSVFileWriter::Write_Data(){ /*--- Only the master rank allocates buffers for the recv. ---*/ if (rank == MASTER_NODE) { - bufD_Recv = new su2double[nProcessor*MaxLocalVertex_Surface*fieldnames.size()](); + bufD_Recv = new su2double[nProcessor*MaxLocalVertex_Surface*fieldNames.size()](); bufL_Recv = new unsigned long[nProcessor*MaxLocalVertex_Surface]; } /*--- Collective comms of the solution data and global IDs. ---*/ - SU2_MPI::Gather(bufD_Send, (int)MaxLocalVertex_Surface*fieldnames.size(), MPI_DOUBLE, - bufD_Recv, (int)MaxLocalVertex_Surface*fieldnames.size(), MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Gather(bufD_Send, (int)MaxLocalVertex_Surface*fieldNames.size(), MPI_DOUBLE, + bufD_Recv, (int)MaxLocalVertex_Surface*fieldNames.size(), MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); SU2_MPI::Gather(bufL_Send, (int)MaxLocalVertex_Surface, MPI_UNSIGNED_LONG, bufL_Recv, (int)MaxLocalVertex_Surface, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); @@ -125,10 +126,10 @@ void CCSVFileWriter::Write_Data(){ Surf_file.open(fileName.c_str(), ios::out); Surf_file << "\"Point\","; - for (iVar = 0; iVar < fieldnames.size()-1; iVar++) { - Surf_file << "\"" << fieldnames[iVar] << "\","; + for (iVar = 0; iVar < fieldNames.size()-1; iVar++) { + Surf_file << "\"" << fieldNames[iVar] << "\","; } - Surf_file << "\"" << fieldnames[fieldnames.size()-1] << "\"" << endl; + Surf_file << "\"" << fieldNames[fieldNames.size()-1] << "\"" << endl; /*--- Loop through all of the collected data and write each node's values ---*/ @@ -145,14 +146,14 @@ void CCSVFileWriter::Write_Data(){ /*--- Reset index for solution data access. ---*/ - index = (iProcessor*MaxLocalVertex_Surface*fieldnames.size() + - iPoint*fieldnames.size()); + index = (iProcessor*MaxLocalVertex_Surface*fieldNames.size() + + iPoint*fieldNames.size()); /*--- Write the solution data for each field variable. ---*/ - for (iVar = 0; iVar < fieldnames.size(); iVar++){ + for (iVar = 0; iVar < fieldNames.size(); iVar++){ Surf_file << scientific << bufD_Recv[index + iVar]; - if (iVar != fieldnames.size() -1) Surf_file << ", "; + if (iVar != fieldNames.size() -1) Surf_file << ", "; } Surf_file << endl; diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index 7306627bc9f..732ec8bb9a1 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -28,7 +28,8 @@ #include "../../../include/output/filewriter/CFEMDataSorter.hpp" #include "../../../../Common/include/fem_geometry_structure.hpp" -CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields) : CParallelDataSorter(config, nFields){ +CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames) : + CParallelDataSorter(config, fieldNames){ /*--- Create an object of the class CMeshFEM_DG and retrieve the necessary geometrical information for the FEM DG solver. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index 3b4c4897dd0..db1a2a4cf00 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -28,7 +28,8 @@ #include "../../../include/output/filewriter/CFVMDataSorter.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" -CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields) : CParallelDataSorter(config, nFields){ +CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames) : + CParallelDataSorter(config, fieldNames){ std::vector globalID; diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index 9d764c8dfc1..c281f1e1c34 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -28,12 +28,13 @@ #include "../../../include/output/filewriter/CParallelDataSorter.hpp" #include -CParallelDataSorter::CParallelDataSorter(CConfig *config, unsigned short nFields){ +CParallelDataSorter::CParallelDataSorter(CConfig *config, vector fieldNames) : + fieldNames(std::move(fieldNames)){ rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - GlobalField_Counter = nFields; + GlobalField_Counter = this->fieldNames.size(); nParallel_Hexa = 0; nParallel_Line = 0; diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index b1826404f99..0f677c7dbaf 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -28,10 +28,7 @@ #include "../../../include/output/filewriter/CFileWriter.hpp" -CFileWriter::CFileWriter(vector fields, string fileName, - CParallelDataSorter *dataSorter, string file_ext, unsigned short nDim): - fieldnames(std::move(fields)), - nDim(nDim), +CFileWriter::CFileWriter(string fileName, CParallelDataSorter *dataSorter, string file_ext): file_ext(file_ext), fileName(std::move(fileName)), dataSorter(dataSorter){ @@ -46,14 +43,14 @@ CFileWriter::CFileWriter(vector fields, string fileName, } -CFileWriter::CFileWriter(string fileName,string file_ext): - file_ext(file_ext), +CFileWriter::CFileWriter(string fileName, string fileExt): + file_ext(fileExt), fileName(std::move(fileName)){ rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - this->fileName += file_ext; + this->fileName += fileExt; file_size = 0.0; Bandwidth = 0.0; diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index a4fd7fea00b..af0186656aa 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -29,9 +29,8 @@ const string CParaviewBinaryFileWriter::fileExt = ".vtk"; -CParaviewBinaryFileWriter::CParaviewBinaryFileWriter(vector fields, unsigned short nDim, string fileName, - CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim){} +CParaviewBinaryFileWriter::CParaviewBinaryFileWriter(string fileName, CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fileName), dataSorter, fileExt){} CParaviewBinaryFileWriter::~CParaviewBinaryFileWriter(){ @@ -43,9 +42,11 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!dataSorter->GetConnectivitySorted()){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } + + const vector fieldNames = dataSorter->GetFieldNames(); - unsigned short iDim; - + unsigned short iDim = 0, nDim = dataSorter->GetnDim(); + unsigned long iPoint, iElem; ofstream Paraview_File; @@ -356,7 +357,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ /*--- Need to adjust container location to avoid PointID tag and coords. ---*/ unsigned short iField, VarCounter = varStart; - for (iField = varStart; iField < fieldnames.size(); iField++) { + for (iField = varStart; iField < fieldNames.size(); iField++) { string fieldname = fieldnames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), @@ -903,27 +904,27 @@ void CParaviewBinaryFileWriter::Write_Data(){ /*--- Loop over all variables that have been registered in the output. ---*/ unsigned short iField, VarCounter = varStart; - for (iField = varStart; iField < fieldnames.size(); iField++) { + for (iField = varStart; iField < fieldNames.size(); iField++) { - string fieldname = fieldnames[iField]; + string fieldname = fieldNames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), fieldname.end()); /*--- Check whether this field is a vector or scalar. ---*/ bool output_variable = true, isVector = false; - size_t found = fieldnames[iField].find("_x"); + size_t found = fieldNames[iField].find("_x"); if (found!=string::npos) { output_variable = true; isVector = true; } - found = fieldnames[iField].find("_y"); + found = fieldNames[iField].find("_y"); if (found!=string::npos) { /*--- We have found a vector, so skip the Y component. ---*/ output_variable = false; VarCounter++; } - found = fieldnames[iField].find("_z"); + found = fieldNames[iField].find("_z"); if (found!=string::npos) { /*--- We have found a vector, so skip the Z component. ---*/ output_variable = false; diff --git a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp index 6f0678c7bf0..e96eb9bdaf5 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp @@ -29,9 +29,8 @@ const string CParaviewFileWriter::fileExt = ".vtk"; -CParaviewFileWriter::CParaviewFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim){} +CParaviewFileWriter::CParaviewFileWriter(string fileName, CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fileName), dataSorter, fileExt){} CParaviewFileWriter::~CParaviewFileWriter(){} @@ -42,7 +41,7 @@ void CParaviewFileWriter::Write_Data(){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } - unsigned short iDim; + unsigned short iDim = 0, nDim = dataSorter->GetnDim(); unsigned long iPoint, iElem; @@ -51,6 +50,8 @@ void CParaviewFileWriter::Write_Data(){ ofstream Paraview_File; int iProcessor; + + const vector fieldNames = dataSorter->GetFieldNames(); /*--- Set a timer for the file writing. ---*/ @@ -267,19 +268,19 @@ void CParaviewFileWriter::Write_Data(){ /*--- Need to adjust container location to avoid PointID tag and coords. ---*/ unsigned short VarCounter = varStart; - for (unsigned short iField = varStart; iField < fieldnames.size(); iField++) { + for (unsigned short iField = varStart; iField < fieldNames.size(); iField++) { - string fieldname = fieldnames[iField]; + string fieldname = fieldNames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), fieldname.end()); bool output_variable = true, isVector = false; - size_t found = fieldnames[iField].find("_x"); + size_t found = fieldNames[iField].find("_x"); if (found!=string::npos) { output_variable = true; isVector = true; } - found = fieldnames[iField].find("_y"); + found = fieldNames[iField].find("_y"); if (found!=string::npos) { output_variable = false; //skip @@ -289,7 +290,7 @@ void CParaviewFileWriter::Write_Data(){ #endif VarCounter++; } -found = fieldnames[iField].find("_z"); + found = fieldNames[iField].find("_z"); if (found!=string::npos) { output_variable = false; //skip diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index 7ada999d13e..e89b27c1545 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -31,9 +31,10 @@ const string CParaviewVTMFileWriter::fileExt = ".vtm"; -CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderName, su2double time, unsigned short iZone, unsigned short nZone) +CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderName, su2double time, + unsigned short iZone, unsigned short nZone) : CFileWriter(std::move(fileName), fileExt), - folderName(std::move(folderName)){ + folderName(std::move(folderName)), iZone(iZone), nZone(nZone), curTime(time){ if (rank == MASTER_NODE) #if defined(_WIN32) @@ -41,11 +42,7 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderNam #else mkdir(this->folderName.c_str(), 0777); // notice that 777 is different than 0777 #endif - - this->iZone = iZone; - this->nZone = nZone; - - curTime = time; + } @@ -90,8 +87,7 @@ void CParaviewVTMFileWriter::Write_Data(){ } -void CParaviewVTMFileWriter::AddDataset(string name, string file, vector fieldNames, - unsigned short nDim, CParallelDataSorter* dataSorter){ +void CParaviewVTMFileWriter::AddDataset(string name, string file, CParallelDataSorter* dataSorter){ /*--- Construct the full file name incl. folder ---*/ @@ -99,7 +95,7 @@ void CParaviewVTMFileWriter::AddDataset(string name, string file, vector /*--- Create an XML writer and dump data into file ---*/ - CParaviewXMLFileWriter* XMLWriter = new CParaviewXMLFileWriter(fieldNames, nDim, fullFilename, dataSorter); + CParaviewXMLFileWriter* XMLWriter = new CParaviewXMLFileWriter(fullFilename, dataSorter); XMLWriter->Write_Data(); delete XMLWriter; diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index b59a6dbf5cd..8ba2693df16 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -30,9 +30,8 @@ const string CParaviewXMLFileWriter::fileExt = ".vtu"; -CParaviewXMLFileWriter::CParaviewXMLFileWriter(vector fields, unsigned short nDim, string fileName, - CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim){ +CParaviewXMLFileWriter::CParaviewXMLFileWriter(string fileName, CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fileName), dataSorter, fileExt){ /* Check for big endian. We have to swap bytes otherwise. * Since size of character is 1 byte when the character pointer @@ -59,8 +58,9 @@ void CParaviewXMLFileWriter::Write_Data(){ } const int NCOORDS = 3; + const vector fieldNames = dataSorter->GetFieldNames(); - unsigned short iDim; + unsigned short iDim = 0, nDim = dataSorter->GetnDim(); dataOffset = 0; @@ -212,27 +212,27 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Loop over all variables that have been registered in the output. ---*/ unsigned short iField, VarCounter = varStart; - for (iField = varStart; iField < fieldnames.size(); iField++) { + for (iField = varStart; iField < fieldNames.size(); iField++) { - string fieldname = fieldnames[iField]; + string fieldname = fieldNames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), fieldname.end()); /*--- Check whether this field is a vector or scalar. ---*/ bool output_variable = true, isVector = false; - size_t found = fieldnames[iField].find("_x"); + size_t found = fieldNames[iField].find("_x"); if (found!=string::npos) { output_variable = true; isVector = true; } - found = fieldnames[iField].find("_y"); + found = fieldNames[iField].find("_y"); if (found!=string::npos) { /*--- We have found a vector, so skip the Y component. ---*/ output_variable = false; VarCounter++; } - found = fieldnames[iField].find("_z"); + found = fieldNames[iField].find("_z"); if (found!=string::npos) { /*--- We have found a vector, so skip the Z component. ---*/ output_variable = false; @@ -402,27 +402,27 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Loop over all variables that have been registered in the output. ---*/ VarCounter = varStart; - for (iField = varStart; iField < fieldnames.size(); iField++) { + for (iField = varStart; iField < fieldNames.size(); iField++) { - string fieldname = fieldnames[iField]; + string fieldname = fieldNames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), fieldname.end()); /*--- Check whether this field is a vector or scalar. ---*/ bool output_variable = true, isVector = false; - size_t found = fieldnames[iField].find("_x"); + size_t found = fieldNames[iField].find("_x"); if (found!=string::npos) { output_variable = true; isVector = true; } - found = fieldnames[iField].find("_y"); + found = fieldNames[iField].find("_y"); if (found!=string::npos) { /*--- We have found a vector, so skip the Y component. ---*/ output_variable = false; VarCounter++; } - found = fieldnames[iField].find("_z"); + found = fieldNames[iField].find("_z"); if (found!=string::npos) { /*--- We have found a vector, so skip the Z component. ---*/ output_variable = false; diff --git a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp index 694b30c6809..5473c73731f 100644 --- a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp @@ -29,9 +29,8 @@ const string CSU2BinaryFileWriter::fileExt = ".dat"; -CSU2BinaryFileWriter::CSU2BinaryFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim){} +CSU2BinaryFileWriter::CSU2BinaryFileWriter(string fileName, CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fileName), dataSorter, fileExt){} CSU2BinaryFileWriter::~CSU2BinaryFileWriter(){ @@ -43,8 +42,9 @@ void CSU2BinaryFileWriter::Write_Data(){ /*--- Local variables ---*/ unsigned short iVar; - - unsigned short GlobalField_Counter = fieldnames.size(); + + const vector fieldNames = dataSorter->GetFieldNames(); + unsigned short GlobalField_Counter = fieldNames.size(); unsigned long nParallel_Poin = dataSorter->GetnPoints(); ofstream restart_file; @@ -163,7 +163,7 @@ void CSU2BinaryFileWriter::Write_Data(){ for (iVar = 0; iVar < GlobalField_Counter; iVar++) { disp = var_buf_size*sizeof(int) + iVar*CGNS_STRING_SIZE*sizeof(char); - strncpy(str_buf, fieldnames[iVar].c_str(), CGNS_STRING_SIZE); + strncpy(str_buf, fieldNames[iVar].c_str(), CGNS_STRING_SIZE); MPI_File_write_at(fhw, disp, str_buf, CGNS_STRING_SIZE, MPI_CHAR, MPI_STATUS_IGNORE); file_size += (su2double)CGNS_STRING_SIZE*sizeof(char); } diff --git a/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp index a9fc7355f44..5dfeb7cf14a 100644 --- a/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp @@ -29,9 +29,8 @@ const string CSU2FileWriter::fileExt = ".csv"; -CSU2FileWriter::CSU2FileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim){} +CSU2FileWriter::CSU2FileWriter(string fileName, CParallelDataSorter *dataSorter) : + CFileWriter(std::move(fileName), dataSorter, fileExt){} CSU2FileWriter::~CSU2FileWriter(){ @@ -48,6 +47,7 @@ void CSU2FileWriter::Write_Data(){ ofstream restart_file; int iProcessor; + const vector fieldNames = dataSorter->GetFieldNames(); /*--- Set a timer for the file writing. ---*/ @@ -63,9 +63,9 @@ void CSU2FileWriter::Write_Data(){ restart_file.open(fileName.c_str(), ios::out); restart_file.precision(15); restart_file << "\"PointID\""; - for (iVar = 0; iVar < fieldnames.size()-1; iVar++) - restart_file << ",\"" << fieldnames[iVar] << "\""; - restart_file << ",\"" << fieldnames[fieldnames.size()-1] << "\"" << endl; + for (iVar = 0; iVar < fieldNames.size()-1; iVar++) + restart_file << ",\"" << fieldNames[iVar] << "\""; + restart_file << ",\"" << fieldNames[fieldNames.size()-1] << "\"" << endl; restart_file.close(); } @@ -96,10 +96,10 @@ void CSU2FileWriter::Write_Data(){ /*--- Loop over the variables and write the values to file ---*/ - for (iVar = 0; iVar < fieldnames.size()-1; iVar++) { + for (iVar = 0; iVar < fieldNames.size()-1; iVar++) { restart_file << scientific << dataSorter->GetData(iVar, iPoint) << ", "; } - restart_file << scientific << dataSorter->GetData(fieldnames.size()-1, iPoint) << "\n"; + restart_file << scientific << dataSorter->GetData(fieldNames.size()-1, iPoint) << "\n"; } } diff --git a/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp index d581a7fbacf..53784b5b8a5 100644 --- a/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp @@ -30,10 +30,9 @@ const string CSU2MeshFileWriter::fileExt = ".su2"; -CSU2MeshFileWriter::CSU2MeshFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter, +CSU2MeshFileWriter::CSU2MeshFileWriter(string fileName, CParallelDataSorter *dataSorter, unsigned short iZone, unsigned short nZone) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim), iZone(iZone), nZone(nZone) {} + CFileWriter(std::move(fileName), dataSorter, fileExt), iZone(iZone), nZone(nZone) {} CSU2MeshFileWriter::~CSU2MeshFileWriter(){ @@ -77,7 +76,7 @@ void CSU2MeshFileWriter::Write_Data(){ /*--- Write dimensions data. ---*/ - output_file << "NDIME= " << nDim << endl; + output_file << "NDIME= " << dataSorter->GetnDim() << endl; output_file << "NELEM= " << dataSorter->GetnElem() << endl; @@ -179,7 +178,7 @@ void CSU2MeshFileWriter::Write_Data(){ /*--- Loop over the variables and write the values to file ---*/ - for (iDim = 0; iDim < nDim; iDim++) { + for (iDim = 0; iDim < dataSorter->GetnDim(); iDim++) { output_file << scientific << dataSorter->GetData(iDim, iPoint) << "\t"; } diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index acdb3648a18..65a1dcf6022 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -29,7 +29,8 @@ #include "../../../../Common/include/fem_geometry_structure.hpp" -CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields, CFEMDataSorter* volume_sorter) : CParallelDataSorter(config, nFields){ +CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* volume_sorter) : + CParallelDataSorter(config, volume_sorter->GetFieldNames()){ this->volume_sorter = volume_sorter; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 874cb35a780..5429cda08da 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -29,7 +29,8 @@ #include "../../../../Common/include/geometry/CGeometry.hpp" -CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometry, unsigned short nFields, CFVMDataSorter* volume_sorter) : CParallelDataSorter(config, nFields){ +CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometry, CFVMDataSorter* volume_sorter) : + CParallelDataSorter(config, volume_sorter->GetFieldNames()){ this->volume_sorter = volume_sorter; diff --git a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp index 5837b842e32..3624b6cd010 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp @@ -33,10 +33,9 @@ const string CTecplotBinaryFileWriter::fileExt = ".szplt"; -CTecplotBinaryFileWriter::CTecplotBinaryFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter, +CTecplotBinaryFileWriter::CTecplotBinaryFileWriter(string fileName, CParallelDataSorter *dataSorter, unsigned long time_iter, su2double timestep) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim), time_iter(time_iter), timestep(timestep){} + CFileWriter(std::move(fileName), dataSorter, fileExt), time_iter(time_iter), timestep(timestep){} CTecplotBinaryFileWriter::~CTecplotBinaryFileWriter(){} @@ -55,6 +54,8 @@ void CTecplotBinaryFileWriter::Write_Data(){ #endif #ifdef HAVE_TECIO + + const vector fieldNames = dataSorter->GetFieldNames(); /*--- Reduce the total number of each element. ---*/ @@ -88,10 +89,10 @@ void CTecplotBinaryFileWriter::Write_Data(){ string data_set_title = "Visualization of the solution"; ostringstream tecplot_variable_names; - for (size_t iVar = 0; iVar < fieldnames.size()-1; ++iVar) { - tecplot_variable_names << fieldnames[iVar] << ","; + for (size_t iVar = 0; iVar < fieldNames.size()-1; ++iVar) { + tecplot_variable_names << fieldNames[iVar] << ","; } - tecplot_variable_names << fieldnames[fieldnames.size()-1]; + tecplot_variable_names << fieldNames[fieldNames.size()-1]; void* file_handle = NULL; int32_t err = tecFileWriterOpen(fileName.c_str(), data_set_title.c_str(), tecplot_variable_names.str().c_str(), @@ -112,7 +113,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ num_nodes = static_cast(dataSorter->GetnPointsGlobal()); num_cells = static_cast(dataSorter->GetnElem()); - if (nDim == 3){ + if (dataSorter->GetnDim() == 3){ if ((nTot_Quad > 0 || nTot_Tria > 0) && (nTot_Hexa + nTot_Pris + nTot_Pyra + nTot_Tetr == 0)){ zone_type = ZONETYPE_FEQUADRILATERAL; } @@ -139,7 +140,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ } int32_t zone; - vector value_locations(fieldnames.size(), 1); /* Nodal variables. */ + vector value_locations(fieldNames.size(), 1); /* Nodal variables. */ err = tecZoneCreateFE(file_handle, "Zone", zone_type, num_nodes, num_cells, NULL, NULL, &value_locations[0], NULL, 0, 0, 0, &zone); if (err) cout << rank << ": Error creating Tecplot zone." << endl; if (is_unsteady) { @@ -254,19 +255,19 @@ void CTecplotBinaryFileWriter::Write_Data(){ MPI_COMM_WORLD); /* Now actually send and receive the data */ - vector data_to_send(max(1, total_num_nodes_to_send * (int)fieldnames.size())); - halo_var_data.resize(max((size_t)1, fieldnames.size() * num_halo_nodes)); + vector data_to_send(max(1, total_num_nodes_to_send * (int)fieldNames.size())); + halo_var_data.resize(max((size_t)1, fieldNames.size() * num_halo_nodes)); vector num_values_to_send(size); vector values_to_send_displacements(size); vector num_values_to_receive(size); size_t index = 0; for(int iRank = 0; iRank < size; ++iRank) { /* We send and receive GlobalField_Counter values per node. */ - num_values_to_send[iRank] = num_nodes_to_send[iRank] * fieldnames.size(); - values_to_send_displacements[iRank] = nodes_to_send_displacements[iRank] * fieldnames.size(); - num_values_to_receive[iRank] = num_nodes_to_receive[iRank] * fieldnames.size(); - values_to_receive_displacements[iRank] = nodes_to_receive_displacements[iRank] * fieldnames.size(); - for(iVar = 0; iVar < fieldnames.size(); ++iVar) + num_values_to_send[iRank] = num_nodes_to_send[iRank] * fieldNames.size(); + values_to_send_displacements[iRank] = nodes_to_send_displacements[iRank] * fieldNames.size(); + num_values_to_receive[iRank] = num_nodes_to_receive[iRank] * fieldNames.size(); + values_to_receive_displacements[iRank] = nodes_to_receive_displacements[iRank] * fieldNames.size(); + for(iVar = 0; iVar < fieldNames.size(); ++iVar) for(int iNode = 0; iNode < num_nodes_to_send[iRank]; ++iNode) { unsigned long node_offset = nodes_to_send[nodes_to_send_displacements[iRank] + iNode] - dataSorter->GetNodeBegin(rank) - 1; data_to_send[index++] =dataSorter->GetData(iVar,node_offset); @@ -286,7 +287,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ if (zone_type == ZONETYPE_FEBRICK) { std::vector values_to_write(dataSorter->GetnPoints()); - for (iVar = 0; err == 0 && iVar < fieldnames.size(); iVar++) { + for (iVar = 0; err == 0 && iVar < fieldNames.size(); iVar++) { for(unsigned long i = 0; i < dataSorter->GetnPoints(); ++i) values_to_write[i] = dataSorter->GetData(iVar, i); err = tecZoneVarWriteDoubleValues(file_handle, zone, iVar + 1, rank + 1, dataSorter->GetnPoints(), &values_to_write[0]); @@ -312,7 +313,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ if (rank_num_points > 0) { if (iRank == rank) { /* Output local data. */ std::vector values_to_write; - for (iVar = 0; err == 0 && iVar < fieldnames.size(); iVar++) { + for (iVar = 0; err == 0 && iVar < fieldNames.size(); iVar++) { values_to_write.resize(rank_num_points); for(unsigned long i = 0; i < (unsigned long)rank_num_points; ++i) values_to_write[i] = dataSorter->GetData(iVar,i); @@ -321,9 +322,9 @@ void CTecplotBinaryFileWriter::Write_Data(){ } } else { /* Receive data from other rank. */ - var_data.resize(max((int64_t)1, (int64_t)fieldnames.size() * rank_num_points)); - CBaseMPIWrapper::Recv(&var_data[0], fieldnames.size() * rank_num_points, MPI_DOUBLE, iRank, iRank, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - for (iVar = 0; err == 0 && iVar < fieldnames.size(); iVar++) { + var_data.resize(max((int64_t)1, (int64_t)fieldNames.size() * rank_num_points)); + CBaseMPIWrapper::Recv(&var_data[0], fieldNames.size() * rank_num_points, MPI_DOUBLE, iRank, iRank, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + for (iVar = 0; err == 0 && iVar < fieldNames.size(); iVar++) { err = tecZoneVarWriteDoubleValues(file_handle, zone, iVar + 1, 0, rank_num_points, &var_data[iVar * rank_num_points]); if (err) cout << rank << ": Error outputting Tecplot surface variable values." << endl; } @@ -337,9 +338,9 @@ void CTecplotBinaryFileWriter::Write_Data(){ SU2_MPI::Gather(&nPoint, 1, MPI_UNSIGNED_LONG, NULL, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); vector var_data; - size_t var_data_size = fieldnames.size() * dataSorter->GetnPoints(); + size_t var_data_size = fieldNames.size() * dataSorter->GetnPoints(); var_data.reserve(var_data_size); - for (iVar = 0; err == 0 && iVar < fieldnames.size() ; iVar++) + for (iVar = 0; err == 0 && iVar < fieldNames.size() ; iVar++) for(unsigned long i = 0; i < dataSorter->GetnPoints(); ++i) var_data.push_back(dataSorter->GetData(iVar,i)); @@ -353,11 +354,11 @@ void CTecplotBinaryFileWriter::Write_Data(){ unsigned short iVar; vector var_data; - size_t var_data_size = fieldnames.size() * dataSorter->GetnPoints(); + size_t var_data_size = fieldNames.size() * dataSorter->GetnPoints(); var_data.reserve(var_data_size); - for (iVar = 0; err == 0 && iVar < fieldnames.size(); iVar++) { + for (iVar = 0; err == 0 && iVar < fieldNames.size(); iVar++) { for(unsigned long i = 0; i < dataSorter->GetnPoints(); ++i) var_data.push_back(dataSorter->GetData(iVar,i)); err = tecZoneVarWriteDoubleValues(file_handle, zone, iVar + 1, 0, dataSorter->GetnPoints(), &var_data[iVar * dataSorter->GetnPoints()]); diff --git a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp index 2c7201b05f6..dff92d28d6b 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp @@ -29,10 +29,9 @@ const string CTecplotFileWriter::fileExt = ".dat"; -CTecplotFileWriter::CTecplotFileWriter(vector fields, unsigned short nDim, - string fileName, CParallelDataSorter *dataSorter, +CTecplotFileWriter::CTecplotFileWriter(string fileName, CParallelDataSorter *dataSorter, unsigned long time_iter, su2double timestep) : - CFileWriter(std::move(fields), std::move(fileName), dataSorter, fileExt, nDim), time_iter(time_iter), timestep(timestep){} + CFileWriter(std::move(fileName), dataSorter, fileExt), time_iter(time_iter), timestep(timestep){} CTecplotFileWriter::~CTecplotFileWriter(){} @@ -41,6 +40,8 @@ void CTecplotFileWriter::Write_Data(){ if (!dataSorter->GetConnectivitySorted()){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } + + const vector fieldNames = dataSorter->GetFieldNames(); unsigned short iVar; @@ -97,10 +98,10 @@ void CTecplotFileWriter::Write_Data(){ Tecplot_File << "TITLE = \"Visualization of the solution\"" << endl; Tecplot_File << "VARIABLES = "; - for (iVar = 0; iVar < fieldnames.size()-1; iVar++) { - Tecplot_File << "\"" << fieldnames[iVar] << "\","; + for (iVar = 0; iVar < fieldNames.size()-1; iVar++) { + Tecplot_File << "\"" << fieldNames[iVar] << "\","; } - Tecplot_File << "\"" << fieldnames[fieldnames.size()-1] << "\"" << endl; + Tecplot_File << "\"" << fieldNames[fieldNames.size()-1] << "\"" << endl; /*--- Write the header ---*/ @@ -112,7 +113,7 @@ void CTecplotFileWriter::Write_Data(){ Tecplot_File << "NODES= "<< dataSorter->GetnPointsGlobal() <<", ELEMENTS= "<< dataSorter->GetnElem(); - if (nDim == 3){ + if (dataSorter->GetnDim() == 3){ if ((nTot_Quad > 0 || nTot_Tria > 0) && (nTot_Hexa + nTot_Pris + nTot_Pyra + nTot_Tetr == 0)){ Tecplot_File << ", DATAPACKING=POINT, ZONETYPE=FEQUADRILATERAL" << endl; } @@ -148,7 +149,7 @@ void CTecplotFileWriter::Write_Data(){ for (iPoint = 0; iPoint < dataSorter->GetnPoints(); iPoint++) { - for (iVar = 0; iVar < fieldnames.size(); iVar++) + for (iVar = 0; iVar < fieldNames.size(); iVar++) Tecplot_File << scientific << dataSorter->GetData(iVar, iPoint) << "\t"; Tecplot_File << endl; } From 348fca09f6ebc0362f2277ad76bd687915cb52fe Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 20:05:03 +0100 Subject: [PATCH 18/61] Adapted allocation of filewriters/sorting routines --- SU2_CFD/src/output/COutput.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index c296ae66eab..e139e37adc4 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -282,19 +282,19 @@ void COutput::AllocateDataSorters(CConfig *config, CGeometry *geometry){ if (femOutput){ if (volumeDataSorter == nullptr) - volumeDataSorter = new CFEMDataSorter(config, geometry, nVolumeFields); + volumeDataSorter = new CFEMDataSorter(config, geometry, volumeFieldNames); if (surfaceDataSorter == nullptr) - surfaceDataSorter = new CSurfaceFEMDataSorter(config, geometry, nVolumeFields, + surfaceDataSorter = new CSurfaceFEMDataSorter(config, geometry, dynamic_cast(volumeDataSorter)); } else { if (volumeDataSorter == nullptr) - volumeDataSorter = new CFVMDataSorter(config, geometry, nVolumeFields); + volumeDataSorter = new CFVMDataSorter(config, geometry, volumeFieldNames); if (surfaceDataSorter == nullptr) - surfaceDataSorter = new CSurfaceFVMDataSorter(config, geometry, nVolumeFields, + surfaceDataSorter = new CSurfaceFVMDataSorter(config, geometry, dynamic_cast(volumeDataSorter)); } @@ -340,7 +340,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "CSV file" << fileName + CSU2FileWriter::fileExt; } - fileWriter = new CSU2FileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); + fileWriter = new CSU2FileWriter(fileName, surfaceDataSorter); break; @@ -353,7 +353,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "SU2 ASCII restart" << fileName + CSU2FileWriter::fileExt; } - fileWriter = new CSU2FileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + fileWriter = new CSU2FileWriter(fileName, volumeDataSorter); break; @@ -366,7 +366,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "SU2 restart" << fileName + CSU2BinaryFileWriter::fileExt; } - fileWriter = new CSU2BinaryFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + fileWriter = new CSU2BinaryFileWriter(fileName, volumeDataSorter); break; @@ -385,7 +385,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "SU2 mesh" << fileName + CSU2MeshFileWriter::fileExt; } - fileWriter = new CSU2MeshFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter, + fileWriter = new CSU2MeshFileWriter(fileName, volumeDataSorter, config->GetiZone(), config->GetnZone()); @@ -406,7 +406,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Tecplot" << fileName + CTecplotBinaryFileWriter::fileExt; } - fileWriter = new CTecplotBinaryFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter, + fileWriter = new CTecplotBinaryFileWriter(fileName, volumeDataSorter, curTimeIter, GetHistoryFieldValue("TIME_STEP")); break; @@ -426,7 +426,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Tecplot ASCII" << fileName + CTecplotFileWriter::fileExt; } - fileWriter = new CTecplotFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter, + fileWriter = new CTecplotFileWriter(fileName, volumeDataSorter, curTimeIter, GetHistoryFieldValue("TIME_STEP")); break; @@ -445,7 +445,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview" << fileName + CParaviewXMLFileWriter::fileExt; } - fileWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + fileWriter = new CParaviewXMLFileWriter(fileName, volumeDataSorter); break; @@ -559,7 +559,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview ASCII" << fileName + CParaviewFileWriter::fileExt; } - fileWriter = new CParaviewFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + fileWriter = new CParaviewFileWriter(fileName, volumeDataSorter); break; @@ -578,7 +578,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview ASCII surface" << fileName + CParaviewFileWriter::fileExt; } - fileWriter = new CParaviewFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); + fileWriter = new CParaviewFileWriter(fileName, surfaceDataSorter); break; @@ -597,7 +597,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview surface" << fileName + CParaviewBinaryFileWriter::fileExt; } - fileWriter = new CParaviewBinaryFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); + fileWriter = new CParaviewBinaryFileWriter(fileName, surfaceDataSorter); break; @@ -616,7 +616,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview surface" << fileName + CParaviewXMLFileWriter::fileExt; } - fileWriter = new CParaviewXMLFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter); + fileWriter = new CParaviewXMLFileWriter(fileName, surfaceDataSorter); break; @@ -635,7 +635,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Tecplot ASCII surface" << fileName + CTecplotFileWriter::fileExt; } - fileWriter = new CTecplotFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter, + fileWriter = new CTecplotFileWriter(fileName, surfaceDataSorter, curTimeIter, GetHistoryFieldValue("TIME_STEP")); break; @@ -655,7 +655,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Tecplot surface" << fileName + CTecplotBinaryFileWriter::fileExt; } - fileWriter = new CTecplotBinaryFileWriter(volumeFieldNames, nDim, fileName, surfaceDataSorter, + fileWriter = new CTecplotBinaryFileWriter(fileName, surfaceDataSorter, curTimeIter, GetHistoryFieldValue("TIME_STEP")); break; From 68abcfc453c4757e9fa159408f545611f78d7944 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 20:05:38 +0100 Subject: [PATCH 19/61] Added more comments to multiblock section and changed filename to be the casename --- SU2_CFD/src/output/COutput.cpp | 72 ++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index e139e37adc4..e7156d85765 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -463,26 +463,34 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview" << fileName + CParaviewBinaryFileWriter::fileExt; } - fileWriter = new CParaviewBinaryFileWriter(volumeFieldNames, nDim, fileName, volumeDataSorter); + fileWriter = new CParaviewBinaryFileWriter(fileName, volumeDataSorter); break; case PARAVIEW_MULTIBLOCK: + { - if (fileName.empty()) - fileName = config->GetFilename(volumeFilename, "", curTimeIter); - - /*--- Sort volume connectivity ---*/ - - volumeDataSorter->SortConnectivity(config, geometry, true); - - { - string folderName = fileName; + if (fileName.empty()) + fileName = config->GetFilename(volumeFilename, "", curTimeIter); - if (config->GetMultizone_Problem()){ - fileName = config->GetUnsteady_FileName("Multizone", curTimeIter, ""); - } - fileWriter = new CParaviewVTMFileWriter(fileName, folderName, GetHistoryFieldValue("CUR_TIME"), config->GetiZone(), config->GetnZone()); + /*--- Sort volume connectivity ---*/ + + volumeDataSorter->SortConnectivity(config, geometry, true); + + /*--- The file name will be the folder name where the data files are stored ---*/ + + const string folderName = fileName; + + /*--- The file name of the multiblock file is the case name (i.e. the config file name w/o ext.) ---*/ + + fileName = config->GetUnsteady_FileName(config->GetCaseName(), curTimeIter, ""); + + /*--- Allocate the vtm file writer ---*/ + + fileWriter = new CParaviewVTMFileWriter(fileName, folderName, GetHistoryFieldValue("CUR_TIME"), + config->GetiZone(), config->GetnZone()); + + /*--- We cast the pointer to its true type, to avoid virtual functions ---*/ CParaviewVTMFileWriter* vtmWriter = dynamic_cast(fileWriter); @@ -490,49 +498,61 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f (*fileWritingTable) << "Paraview Multiblock" << fileName + CParaviewVTMFileWriter::fileExt + " -> " + vtmWriter->GetFolderName(); } - fileName = "Internal"; + + /*--- Open a block for the zone ---*/ + vtmWriter->StartBlock("Zone " + PrintingToolbox::to_string(config->GetiZone())); + + fileName = "Internal"; + + /*--- Open a block for the internal (volume) data and add the dataset ---*/ + vtmWriter->StartBlock(fileName); - vtmWriter->AddDataset(fileName, fileName, volumeFieldNames, nDim, volumeDataSorter); + vtmWriter->AddDataset(fileName, fileName, volumeDataSorter); vtmWriter->EndBlock(); + + /*--- Open a block for the boundary ---*/ + vtmWriter->StartBlock("Boundary"); + + /*--- Loop over all markers used in the config file ---*/ + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_CfgFile(); iMarker++){ /*--- Get the name of the marker ---*/ string markerTag = config->GetMarker_CfgFile_TagBound(iMarker); - - vector markerList; - /*--- If the current marker can be found on this partition, add it to the marker list. + /*--- If the current marker can be found on this partition store its name. * Note that we have to provide a vector of markers to the sorter routine, although we only do - * one marker at a time, i.e. markerList always contains one item. ---*/ + * one marker at a time, i.e. ::marker always contains one item. ---*/ + vector marker; for (unsigned short jMarker = 0; jMarker < config->GetnMarker_All(); jMarker++){ - /*--- Write all markers to file, except send-receive markers ---*/ + /*--- We want to write all markers except send-receive markers ---*/ if (config->GetMarker_All_TagBound(jMarker) == markerTag && config->GetMarker_All_KindBC(jMarker) != SEND_RECEIVE){ - markerList.push_back(markerTag); + marker.push_back(markerTag); } } - /*--- Only sort if there is at least one processor with this marker ---*/ + /*--- Only sort if there is at least one processor that has this marker ---*/ - int globalMarkerSize = 0, localMarkerSize = markerList.size(); + int globalMarkerSize = 0, localMarkerSize = marker.size(); SU2_MPI::Allreduce(&localMarkerSize, &globalMarkerSize, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); if (globalMarkerSize > 0){ /*--- Sort connectivity of the current marker ---*/ - surfaceDataSorter->SortConnectivity(config, geometry, markerList); + surfaceDataSorter->SortConnectivity(config, geometry, marker); surfaceDataSorter->SortOutputData(); /*--- Add the dataset ---*/ - vtmWriter->AddDataset(markerTag, markerTag, volumeFieldNames, nDim, surfaceDataSorter); + vtmWriter->AddDataset(markerTag, markerTag, surfaceDataSorter); } } From 2fa3dfc7db84df39f688b404f3473480c22964c8 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 20:26:15 +0100 Subject: [PATCH 20/61] Changed folder name to case name and moved zone data to folder --- SU2_CFD/src/output/COutput.cpp | 8 ++------ SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp | 5 +++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index e7156d85765..03f863b45a7 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -476,18 +476,14 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f /*--- Sort volume connectivity ---*/ volumeDataSorter->SortConnectivity(config, geometry, true); - - /*--- The file name will be the folder name where the data files are stored ---*/ - - const string folderName = fileName; - + /*--- The file name of the multiblock file is the case name (i.e. the config file name w/o ext.) ---*/ fileName = config->GetUnsteady_FileName(config->GetCaseName(), curTimeIter, ""); /*--- Allocate the vtm file writer ---*/ - fileWriter = new CParaviewVTMFileWriter(fileName, folderName, GetHistoryFieldValue("CUR_TIME"), + fileWriter = new CParaviewVTMFileWriter(fileName, fileName, GetHistoryFieldValue("CUR_TIME"), config->GetiZone(), config->GetnZone()); /*--- We cast the pointer to its true type, to avoid virtual functions ---*/ diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index e89b27c1545..762077aaada 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -40,7 +40,8 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderNam #if defined(_WIN32) _mkdir(this->folderName.c_str()); #else - mkdir(this->folderName.c_str(), 0777); // notice that 777 is different than 0777 + mkdir(this->folderName.c_str(), 0777); + mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str(), 0777); #endif } @@ -91,7 +92,7 @@ void CParaviewVTMFileWriter::AddDataset(string name, string file, CParallelDataS /*--- Construct the full file name incl. folder ---*/ - string fullFilename = folderName + "/" + file; + string fullFilename = folderName + "/zone_" + to_string(iZone) + "/" + file; /*--- Create an XML writer and dump data into file ---*/ From 166ce1aab15e2b568d595defd2166632922dc961 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 22:52:51 +0100 Subject: [PATCH 21/61] Added multizone name to vtm file --- SU2_CFD/src/output/COutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 03f863b45a7..448d380ba40 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -497,7 +497,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f /*--- Open a block for the zone ---*/ - vtmWriter->StartBlock("Zone " + PrintingToolbox::to_string(config->GetiZone())); + vtmWriter->StartBlock(multiZoneHeaderString); fileName = "Internal"; From 08f5f3b5206b12deb7a4ae1ecee4607acf76010e Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 6 Jan 2020 22:53:24 +0100 Subject: [PATCH 22/61] Some fixes --- SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp | 2 ++ SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp | 2 ++ SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp | 6 +++--- SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp | 2 +- SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp | 2 ++ SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp | 2 ++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index 732ec8bb9a1..ff1e4aa1c9c 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -31,6 +31,8 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames) : CParallelDataSorter(config, fieldNames){ + nDim = geometry->GetnDim(); + /*--- Create an object of the class CMeshFEM_DG and retrieve the necessary geometrical information for the FEM DG solver. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index db1a2a4cf00..06aed90523b 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -30,6 +30,8 @@ CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames) : CParallelDataSorter(config, fieldNames){ + + nDim = geometry->GetnDim(); std::vector globalID; diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index af0186656aa..f46b52bd3b0 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -359,12 +359,12 @@ void CParaviewBinaryFileWriter::Write_Data(){ unsigned short iField, VarCounter = varStart; for (iField = varStart; iField < fieldNames.size(); iField++) { - string fieldname = fieldnames[iField]; + string fieldname = fieldNames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), fieldname.end()); bool output_variable = true, isVector = false; - size_t found = fieldnames[iField].find("_x"); + size_t found = fieldNames[iField].find("_x"); if (found!=string::npos) { output_variable = true; isVector = true; @@ -375,7 +375,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ output_variable = false; VarCounter++; } - found = fieldnames[iField].find("_z"); + found = fieldNames[iField].find("_z"); if (found!=string::npos) { //skip output_variable = false; diff --git a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp index 5473c73731f..7e27f87226b 100644 --- a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp @@ -92,7 +92,7 @@ void CSU2BinaryFileWriter::Write_Data(){ needed for when we read the strings later. ---*/ for (iVar = 0; iVar < GlobalField_Counter; iVar++) { - strncpy(str_buf, fieldnames[iVar].c_str(), CGNS_STRING_SIZE); + strncpy(str_buf, fieldNames[iVar].c_str(), CGNS_STRING_SIZE); fwrite(str_buf, CGNS_STRING_SIZE, sizeof(char), fhw); file_size += (su2double)CGNS_STRING_SIZE*sizeof(char); } diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 65a1dcf6022..2b6fea820b5 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -32,6 +32,8 @@ CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* volume_sorter) : CParallelDataSorter(config, volume_sorter->GetFieldNames()){ + nDim = geometry->GetnDim(); + this->volume_sorter = volume_sorter; connectivity_sorted = false; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 5429cda08da..09847c91020 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -32,6 +32,8 @@ CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometry, CFVMDataSorter* volume_sorter) : CParallelDataSorter(config, volume_sorter->GetFieldNames()){ + nDim = geometry->GetnDim(); + this->volume_sorter = volume_sorter; connectivity_sorted = false; From 778a6f07826db9186fbc04c68b38d3fd81e27c47 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 7 Jan 2020 11:32:53 +0100 Subject: [PATCH 23/61] Adding comments --- .../filewriter/CParaviewVTMFileWriter.hpp | 47 ++++++++++++++--- .../filewriter/CParaviewXMLFileWriter.hpp | 50 ++++++++++++++++++- .../filewriter/CParaviewBinaryFileWriter.cpp | 2 +- .../filewriter/CParaviewXMLFileWriter.cpp | 12 +++-- 4 files changed, 97 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index f8236f5b389..51e4f32b598 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -31,13 +31,31 @@ class CParaviewVTMFileWriter final: public CFileWriter{ + /*! + * \brief String stream that stores the content of the vtm file + */ stringstream output; + /*! + * \brief The folder name where all the files associated with the datasets will be stored + */ string folderName; - unsigned short iZone, nZone; + /*! + * \brief The current zone index + */ + unsigned short iZone; + /*! + * \brief The total number of zones + */ + unsigned short nZone; + + /*! + * \brief Current physical time + */ su2double curTime; + public: /*! @@ -61,31 +79,48 @@ class CParaviewVTMFileWriter final: public CFileWriter{ */ void Write_Data() override; - + /*! + * \brief Add a new dataset by writing data from a datasorter to file and adding it to the vtm file + * \param[in] name - The name of the dataset + * \param[in] file - The name of the vtu dataset file to write + * \param[in] dataSorter - Datasorter object containing the actual data. Note, data must be sorted. + */ void AddDataset(string name, string file, CParallelDataSorter* dataSorter); + /*! + * \brief Start a new block + * \param[in] name - The name of the block + */ inline void StartBlock(string name){ if (rank == MASTER_NODE){ output << "" << endl; } } + /*! + * \brief Close currently opened block + */ inline void EndBlock(){ if (rank == MASTER_NODE){ output << "" << endl; } } + /*! + * \brief Add a new dataset by writing it to the vtm file + * \param[in] name - Name of the dataset + * \param[in] file - vtu file where the data is stored + */ inline void AddDataset(string name, string file){ if (rank == MASTER_NODE){ output << "" << endl; } } - inline void Clear(){ - output.clear(); - } - + /*! + * \brief Get the name of the folder where the data will be stored + * \return The folder name + */ inline string GetFolderName(){ return folderName; } diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index 959aea50149..29bd3889be9 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -33,6 +33,9 @@ class CParaviewXMLFileWriter final: public CFileWriter{ private: + /*! + * \brief Enum that defines the VTK datatypes + */ enum class VTKDatatype { FLOAT32, INT32, @@ -40,14 +43,36 @@ class CParaviewXMLFileWriter final: public CFileWriter{ }; #ifdef HAVE_MPI + /*! + * \brief The displacement that every process has in the current file view + */ MPI_Offset disp; + + /*! + * \brief The file handle for writing + */ MPI_File fhw; #else + + /*! + * \brief The displacement that every process has in the current file view + */ unsigned long disp; + + /*! + * \brief The file handle for writing + */ FILE* fhw; #endif + /*! + * \brief Boolean storing whether we are on a big or little endian machine + */ bool BigEndian; + + /*! + * \brief The current data offset that is used to find data in the binary blob at the end of the file + */ unsigned long dataOffset; public: @@ -76,10 +101,31 @@ class CParaviewXMLFileWriter final: public CFileWriter{ private: + /*! + * \brief Write a string to the vtu file + * \param[in] str - The string to write to file + * \param[in] rank - The rank that should write the string + */ void WriteString(std::string str, int rank); - void AddDataArray(VTKDatatype type, string name, unsigned short nComponents, unsigned long size, unsigned long cumSize); + /*! + * \brief Add a new data array definition to the vtu file. + * \param[in] type - The vtk datatype + * \param[in] name - The name of the array + * \param[in] nComponents - The number of components + * \param[in] size - The total size of the array + * \param[in] globalSize - The global size of the array over all processors + */ + void AddDataArray(VTKDatatype type, string name, unsigned short nComponents, unsigned long size, unsigned long globalSize); - void WriteDataArray(void *data, VTKDatatype type, unsigned long size, unsigned long cumSize, unsigned long offset); + /*! + * \brief Write an array that has previously been defined with ::AddDataArray to the vtu file in binary format + * \param[in] data - Pointer to the data + * \param[in] type - The vtk datatype + * \param[in] size - The total size of the array + * \param[in] globalSize - The global size of the array over all processors + * \param[in] offset - The displacement in the file view for the current processor + */ + void WriteDataArray(void *data, VTKDatatype type, unsigned long size, unsigned long globalSize, unsigned long offset); }; diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index f46b52bd3b0..e2c511677f6 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -369,7 +369,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ output_variable = true; isVector = true; } - found = fieldnames[iField].find("_y"); + found = fieldNames[iField].find("_y"); if (found!=string::npos) { //skip output_variable = false; diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 8ba2693df16..7d2baaff85a 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -190,7 +190,8 @@ void CParaviewXMLFileWriter::Write_Data(){ WriteString("\n", MASTER_NODE); - SPRINTF(str_buf, "\n", SU2_TYPE::Int(GlobalPoint), SU2_TYPE::Int(GlobalElem)); + SPRINTF(str_buf, "\n", + SU2_TYPE::Int(GlobalPoint), SU2_TYPE::Int(GlobalElem)); WriteString(std::string(str_buf), MASTER_NODE); WriteString("\n", MASTER_NODE); @@ -542,7 +543,8 @@ void CParaviewXMLFileWriter::WriteString(std::string str, int rank){ } -void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, unsigned long cumSize, unsigned long offset){ +void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, + unsigned long globalSize, unsigned long offset){ unsigned long totalByteSize, byteSize; @@ -573,7 +575,7 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign /*--- The total data size ---*/ - totalByteSize = cumSize*typeSize; + totalByteSize = globalSize*typeSize; #ifdef HAVE_MPI @@ -624,7 +626,7 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign } void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, - unsigned short nComponents, unsigned long arraySize, unsigned long cumSize){ + unsigned short nComponents, unsigned long arraySize, unsigned long globalSize){ /*--- Add quotation marks around the arguments ---*/ @@ -665,7 +667,7 @@ void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, /*--- Total data size ---*/ - totalByteSize = cumSize*typeSize; + totalByteSize = globalSize*typeSize; /*--- Write the ASCII XML header information for this array ---*/ From 37770b4b462fba4c9488f0eec289ba3db7ad6bdb Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 7 Jan 2020 13:50:17 +0100 Subject: [PATCH 24/61] Fix for windows compilation --- SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index 762077aaada..ec26b6b9d60 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -37,8 +37,9 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderNam folderName(std::move(folderName)), iZone(iZone), nZone(nZone), curTime(time){ if (rank == MASTER_NODE) -#if defined(_WIN32) +#if defined(_WIN32) || defined(_WIN64) || defined (__WINDOWS__) _mkdir(this->folderName.c_str()); + _mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str()); #else mkdir(this->folderName.c_str(), 0777); mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str(), 0777); From e89a29884790093f531724f5cbc14567469cd7bf Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 7 Jan 2020 15:02:10 +0100 Subject: [PATCH 25/61] Added const and missing windows includes --- SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp | 2 +- SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index 51e4f32b598..8c3a20f82ff 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -121,7 +121,7 @@ class CParaviewVTMFileWriter final: public CFileWriter{ * \brief Get the name of the folder where the data will be stored * \return The folder name */ - inline string GetFolderName(){ + inline string GetFolderName() const{ return folderName; } }; diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index ec26b6b9d60..6168a6aef77 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -28,6 +28,9 @@ #include "../../../include/output/filewriter/CParaviewVTMFileWriter.hpp" #include "../../../include/output/filewriter/CParaviewXMLFileWriter.hpp" #include "../../../../Common/include/toolboxes/printing_toolbox.hpp" +#if defined(_WIN32) || defined(_WIN64) || defined (__WINDOWS__) +#include +#endif const string CParaviewVTMFileWriter::fileExt = ".vtm"; From 52abba311d5bfb0605c807453710ce007ca3b83f Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Thu, 9 Jan 2020 18:17:12 +0100 Subject: [PATCH 26/61] Used split to determine case name --- Common/src/config_structure.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 11bd7c65d33..71d22b3bf48 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -57,9 +57,7 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar /*--- Set the case name to the base config file name without extension ---*/ - caseName = string(case_filename); - unsigned short lastindex = caseName.find_last_of("."); - caseName = caseName.substr(0, lastindex); + caseName = PrintingToolbox::split(string(case_filename),'.')[0]; base_config = true; @@ -167,9 +165,7 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar /*--- Set the case name to the base config file name without extension ---*/ - caseName = string(case_filename); - unsigned short lastindex = caseName.find_last_of("."); - caseName = caseName.substr(0, lastindex); + caseName = PrintingToolbox::split(string(case_filename),'.')[0]; base_config = true; @@ -219,9 +215,7 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], CConfig *config) { /*--- Set the case name to the base config file name without extension ---*/ - caseName = string(case_filename); - unsigned short lastindex = caseName.find_last_of("."); - caseName = caseName.substr(0, lastindex); + caseName = PrintingToolbox::split(string(case_filename),'.')[0]; base_config = true; From 43be40ef51d3dd5f4911d83fdb056aad4782a3c5 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Thu, 9 Jan 2020 18:27:45 +0100 Subject: [PATCH 27/61] Made variable names more consistent and shadowing of inherited variables --- .../output/filewriter/CCSVFileWriter.hpp | 8 +- .../output/filewriter/CFEMDataSorter.hpp | 6 +- .../output/filewriter/CFVMDataSorter.hpp | 8 +- .../include/output/filewriter/CFileWriter.hpp | 35 +++--- .../output/filewriter/CParallelDataSorter.hpp | 38 +++--- .../filewriter/CParaviewBinaryFileWriter.hpp | 10 +- .../output/filewriter/CParaviewFileWriter.hpp | 10 +- .../filewriter/CParaviewVTMFileWriter.hpp | 8 +- .../filewriter/CParaviewXMLFileWriter.hpp | 12 +- .../filewriter/CSU2BinaryFileWriter.hpp | 8 +- .../output/filewriter/CSU2FileWriter.hpp | 10 +- .../output/filewriter/CSU2MeshFileWriter.hpp | 14 +-- .../filewriter/CSurfaceFEMDataSorter.hpp | 10 +- .../filewriter/CSurfaceFVMDataSorter.hpp | 12 +- .../filewriter/CTecplotBinaryFileWriter.hpp | 16 +-- .../output/filewriter/CTecplotFileWriter.hpp | 16 +-- .../src/output/filewriter/CCSVFileWriter.cpp | 4 +- .../src/output/filewriter/CFEMDataSorter.cpp | 6 +- .../src/output/filewriter/CFVMDataSorter.cpp | 6 +- .../output/filewriter/CParallelDataSorter.cpp | 8 +- .../output/filewriter/CParallelFileWriter.cpp | 26 ++--- .../filewriter/CParaviewBinaryFileWriter.cpp | 108 +++++++++--------- .../output/filewriter/CParaviewFileWriter.cpp | 18 +-- .../filewriter/CParaviewVTMFileWriter.cpp | 10 +- .../filewriter/CParaviewXMLFileWriter.cpp | 50 ++++---- .../filewriter/CSU2BinaryFileWriter.cpp | 34 +++--- .../src/output/filewriter/CSU2FileWriter.cpp | 18 +-- .../output/filewriter/CSU2MeshFileWriter.cpp | 6 +- .../filewriter/CSurfaceFEMDataSorter.cpp | 14 +-- .../filewriter/CSurfaceFVMDataSorter.cpp | 28 ++--- .../filewriter/CTecplotBinaryFileWriter.cpp | 26 ++--- .../output/filewriter/CTecplotFileWriter.cpp | 26 ++--- 32 files changed, 306 insertions(+), 303 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp b/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp index 52076316064..ce1d5fe2e26 100644 --- a/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp @@ -33,11 +33,11 @@ class CCSVFileWriter final: public CFileWriter{ public: /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension + * \brief Construct a file writer using field name and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write */ - CCSVFileWriter(string fileName, CParallelDataSorter* data_sorter); + CCSVFileWriter(string valFileName, CParallelDataSorter* valDataSorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp index 3f9359e6c75..a83605f8b1f 100644 --- a/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp @@ -37,9 +37,9 @@ class CFEMDataSorter final: public CParallelDataSorter{ * \brief Constructor * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] fieldNames - Vector containing the field names + * \param[in] valFieldNames - Vector containing the field names */ - CFEMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames); + CFEMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames); /*! * \brief Destructor @@ -59,7 +59,7 @@ class CFEMDataSorter final: public CParallelDataSorter{ * \input iPoint - the point ID. * \return Global index of a specific point. */ - unsigned long GetGlobalIndex(unsigned long iPoint) override{ + unsigned long GetGlobalIndex(unsigned long iPoint) const override{ return linearPartitioner->GetFirstIndexOnRank(rank) + iPoint; } diff --git a/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp index b3d8d4cb3cf..eb53750e20f 100644 --- a/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp @@ -42,9 +42,9 @@ class CFVMDataSorter final: public CParallelDataSorter{ * \brief Constructor * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] fieldNames - Vector containing the field names + * \param[in] valFieldNames - Vector containing the field names */ - CFVMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames); + CFVMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames); /*! * \brief Destructor @@ -64,7 +64,7 @@ class CFVMDataSorter final: public CParallelDataSorter{ * \input iPoint - the point ID. * \return Global index of a specific point. */ - unsigned long GetGlobalIndex(unsigned long iPoint) override { + unsigned long GetGlobalIndex(unsigned long iPoint) const override { return linearPartitioner->GetFirstIndexOnRank(rank) + iPoint; } @@ -73,7 +73,7 @@ class CFVMDataSorter final: public CParallelDataSorter{ * \param[in] iPoint - ID of the point * \return if the point is a halo node. */ - bool GetHalo(unsigned long iPoint) {return Local_Halo[iPoint];} + bool GetHalo(unsigned long iPoint) const {return Local_Halo[iPoint];} private: diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index be5d1b63a67..9a58deb1267 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -55,13 +55,13 @@ class CFileWriter{ /*! * \brief The file extension to be attached to the filename. */ - std::string file_ext; + std::string fileExt; - su2double StartTime, /*!< \brief Start time for time measurement */ - StopTime , /*!< \brief Stop time for time measurement */ - UsedTime , /*!< \brief Used time for time measurement */ - Bandwidth, /*!< \brief Used bandwidth */ - file_size; /*!< \brief Size of the last written file */ + su2double startTime, /*!< \brief Start time for time measurement */ + stopTime , /*!< \brief Stop time for time measurement */ + usedTime , /*!< \brief Used time for time measurement */ + bandwidth, /*!< \brief Used bandwidth */ + fileSize; /*!< \brief Size of the last written file */ /*! * \brief Determine the file size @@ -86,18 +86,19 @@ class CFileWriter{ public: /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fileName - The name of the file - * \param[in] file_ext - The file extension to be attached to the filename + * \brief Construct a file writer using field names, the data sorter and the file extension. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write + * \param[in] valFileExt - The file extension. */ - CFileWriter(string fileName, CParallelDataSorter* dataSorter, string file_ext); + CFileWriter(string valFileName, CParallelDataSorter* valDataSorter, string valFileExt); /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fileName - The name of the file - * \param[in] fileExt - The file extension to be attached to the filename + * \brief Construct a file writer using field names, file extension. + * \param[in] valFileName - The name of the file + * \param[in] valFileExt - The file extension to be attached to the filename */ - CFileWriter(string fileName, string fileExt); + CFileWriter(string valFileName, string valFileExt); /*! * \brief Destructor @@ -112,18 +113,18 @@ class CFileWriter{ /*! * \brief Get the bandwith used for the last writing */ - su2double Get_Bandwidth(){return Bandwidth;} + su2double Get_Bandwidth() const {return bandwidth;} /*! * \brief Get the filesize of the last written file. */ - su2double Get_Filesize(){return file_size;} + su2double Get_Filesize() const {return fileSize;} /*! * \brief Get the used time of the last file writing. * \return */ - su2double Get_UsedTime(){return UsedTime;} + su2double Get_UsedTime() const {return usedTime;} }; diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index d2f4c206118..642e705e385 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -73,7 +73,7 @@ class CParallelDataSorter{ unsigned short GlobalField_Counter; //!< Number of output fields - bool connectivity_sorted; //!< Boolean to store information on whether the connectivity is sorted + bool connectivitySorted; //!< Boolean to store information on whether the connectivity is sorted int *nPoint_Send; //!< Number of points this processor has to send to other processors int *nPoint_Recv; //!< Number of points this processor receives from other processors @@ -106,7 +106,7 @@ class CParallelDataSorter{ * \param[in] config - Pointer to the current config structure * \param[in] fieldNames - Vector containing the field names */ - CParallelDataSorter(CConfig *config, vector fieldNames); + CParallelDataSorter(CConfig *config, const vector &valFieldNames); /*! * \brief Destructor @@ -138,32 +138,32 @@ class CParallelDataSorter{ * \brief Get the number of points the local rank owns. * \return local number of points. */ - unsigned long GetnPoints(){return nParallel_Poin;} + unsigned long GetnPoints() const {return nParallel_Poin;} /*! * \brief Get the number of points to sort. * \return local number of points. */ - unsigned long GetnLocalPointSort(){return nLocalPoint_Sort;} + unsigned long GetnLocalPointSort() const {return nLocalPoint_Sort;} /*! * \brief Get the global number of points (accumulated from all ranks) * \return Global number of points. */ - unsigned long GetnPointsGlobal(){return nGlobal_Poin_Par;} + unsigned long GetnPointsGlobal() const {return nGlobal_Poin_Par;} /*! * \brief Get the global of elements (accumulated from all ranks and element types) * \return Global number elements. */ - unsigned long GetnElem(){return nGlobal_Elem_Par;} + unsigned long GetnElem() const {return nGlobal_Elem_Par;} /*! * \brief Get the local number of elements of a specific type that the current rank owns * \input type - The type of element, ref GEO_TYPE * \return Local number of elements of a specific type. */ - unsigned long GetnElem(GEO_TYPE type); + unsigned long GetnElem(GEO_TYPE type) const; /*! * \brief Get the connectivity of specific element. @@ -172,21 +172,21 @@ class CParallelDataSorter{ * \input iNode - The node ID * \return the connected node. */ - unsigned long GetElem_Connectivity(GEO_TYPE type, unsigned long iElem, unsigned long iNode); + unsigned long GetElem_Connectivity(GEO_TYPE type, unsigned long iElem, unsigned long iNode) const ; /*! * \brief Beginning node ID of the linear partition owned by a specific processor. * \input rank - the processor rank. * \return The beginning node ID. */ - unsigned long GetNodeBegin(unsigned short rank){return linearPartitioner->GetFirstIndexOnRank(rank);} + unsigned long GetNodeBegin(unsigned short rank) const {return linearPartitioner->GetFirstIndexOnRank(rank);} /*! * \brief Ending node ID of the linear partition owned by a specific processor. * \input rank - the processor rank. * \return The ending node ID. */ - unsigned long GetNodeEnd(unsigned short rank){return linearPartitioner->GetLastIndexOnRank(rank);} + unsigned long GetNodeEnd(unsigned short rank) const {return linearPartitioner->GetLastIndexOnRank(rank);} /*! * \brief Get the value of the linear partitioned data. @@ -194,40 +194,40 @@ class CParallelDataSorter{ * \input iPoint - the point ID. * \return the value of the data field at a point. */ - passivedouble GetData(unsigned short iField, unsigned long iPoint) {return passiveDoubleBuffer[iPoint*GlobalField_Counter + iField];} + passivedouble GetData(unsigned short iField, unsigned long iPoint) const {return passiveDoubleBuffer[iPoint*GlobalField_Counter + iField];} /*! * \brief Get the pointer to the sorted linear partitioned data. * \return Pointer to the sorted data. */ - const passivedouble *GetData() {return passiveDoubleBuffer;} + const passivedouble *GetData() const {return passiveDoubleBuffer;} /*! * \brief Get the global index of a point. * \input iPoint - the point ID. * \return Global index of a specific point. */ - virtual unsigned long GetGlobalIndex(unsigned long iPoint){return 0;} + virtual unsigned long GetGlobalIndex(unsigned long iPoint) const {return 0;} /*! * \brief Get the cumulated number of points * \input rank - the processor rank. * \return The cumulated number of points up to certain processor rank. */ - unsigned long GetnPointCumulative(unsigned short rank){return linearPartitioner->GetCumulativeSizeBeforeRank(rank);} + unsigned long GetnPointCumulative(unsigned short rank) const {return linearPartitioner->GetCumulativeSizeBeforeRank(rank);} /*! * \brief Get the linear number of points * \input rank - the processor rank. * \return The linear number of points up to certain processor rank. */ - unsigned long GetnPointLinear(unsigned short rank){return linearPartitioner->GetSizeOnRank(rank);} + unsigned long GetnPointLinear(unsigned short rank) const {return linearPartitioner->GetSizeOnRank(rank);} /*! * \brief Check whether the current connectivity is sorted (i.e. if SortConnectivity has been called) * \return if the connectivity is sorted. */ - bool GetConnectivitySorted(){return connectivity_sorted;} + bool GetConnectivitySorted() const {return connectivitySorted;} /*! * \brief Set the value of a specific field at a point. @@ -241,7 +241,7 @@ class CParallelDataSorter{ connSend[Index[iPoint] + iField] = data; } - su2double GetUnsorted_Data(unsigned long iPoint, unsigned short iField){ + su2double GetUnsorted_Data(unsigned long iPoint, unsigned short iField) const { return connSend[Index[iPoint] + iField]; } @@ -249,7 +249,7 @@ class CParallelDataSorter{ * \brief Get the vector containing the names of the output fields * \return Vector of strings containing the field names */ - vector GetFieldNames(){ + const vector& GetFieldNames() const{ return fieldNames; } @@ -257,7 +257,7 @@ class CParallelDataSorter{ * \brief Get the spatial dimension * \return The spatial dimension */ - unsigned short GetnDim(){ + unsigned short GetnDim() const { return nDim; } }; diff --git a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp index 83f36910a9e..ce4384bed83 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp @@ -39,13 +39,11 @@ class CParaviewBinaryFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write */ - CParaviewBinaryFileWriter(string fileName, CParallelDataSorter* data_sorter); + CParaviewBinaryFileWriter(string valFileName, CParallelDataSorter* valDataSorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp index aa166d4cc28..425d48df373 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp @@ -38,13 +38,11 @@ class CParaviewFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write */ - CParaviewFileWriter(string fileName, CParallelDataSorter* data_sorter); + CParaviewFileWriter(string valFileName, CParallelDataSorter* valDataSorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index 8c3a20f82ff..c04ac44b2fc 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -65,9 +65,13 @@ class CParaviewVTMFileWriter final: public CFileWriter{ /*! * \brief Construct a file writer using field names, dimension. - * \param[in] fileName - The name of the file + * \param[in] valFileName - The name of the file + * \param[in] valFolderName - The name of the output folder + * \param[in] valTime - The current physical time + * \param[in] valiZone - The index of the current zone + * \param[in] valnZone - The total number of zones */ - CParaviewVTMFileWriter(string fileName, string folderName, su2double time, unsigned short iZone, unsigned short nZone); + CParaviewVTMFileWriter(string valFileName, string valFolderName, su2double valTime, unsigned short valiZone, unsigned short valnZone); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index 29bd3889be9..d8187baaf3f 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -68,7 +68,7 @@ class CParaviewXMLFileWriter final: public CFileWriter{ /*! * \brief Boolean storing whether we are on a big or little endian machine */ - bool BigEndian; + bool bigEndian; /*! * \brief The current data offset that is used to find data in the binary blob at the end of the file @@ -83,11 +83,11 @@ class CParaviewXMLFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, dimension. - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write */ - CParaviewXMLFileWriter(string fileName, CParallelDataSorter* data_sorter); + CParaviewXMLFileWriter(string valFileName, CParallelDataSorter* valDataSorter); /*! * \brief Destructor @@ -106,7 +106,7 @@ class CParaviewXMLFileWriter final: public CFileWriter{ * \param[in] str - The string to write to file * \param[in] rank - The rank that should write the string */ - void WriteString(std::string str, int rank); + void WriteString(std::string str, int rankOut); /*! * \brief Add a new data array definition to the vtu file. diff --git a/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp index 8189647899b..686eceac08e 100644 --- a/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp @@ -39,11 +39,11 @@ class CSU2BinaryFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write */ - CSU2BinaryFileWriter(string fileName, CParallelDataSorter* data_sorter); + CSU2BinaryFileWriter(string valFileName, CParallelDataSorter* valDataSorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp index 909fad112db..eed8b44b658 100644 --- a/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp @@ -38,13 +38,11 @@ class CSU2FileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fields - A list of field names - * \param[in] nDim - Physical dimension - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write */ - CSU2FileWriter(string fileName, CParallelDataSorter* data_sorter); + CSU2FileWriter(string valFileName, CParallelDataSorter* valDataSorter); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp index 27ddc0de928..05c2e4455d6 100644 --- a/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp @@ -41,14 +41,14 @@ class CSU2MeshFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write - * \param[in] iZone - Index of the current zone - * \param[in] nZone - Number of zones + * \brief Construct a file writer using field names, dimension. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write + * \param[in] valiZone - The index of the current zone + * \param[in] valnZone - The total number of zones */ - CSU2MeshFileWriter(string fileName, CParallelDataSorter* data_sorter, - unsigned short iZone, unsigned short nZone); + CSU2MeshFileWriter(string valFileName, CParallelDataSorter* valDataSorter, + unsigned short valiZone, unsigned short valnZone); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp index 4d4f74bb5e4..a3f4808ac56 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp @@ -31,19 +31,19 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ - CFEMDataSorter* volume_sorter; //!< Pointer to the volume sorter instance + CFEMDataSorter* volumeSorter; //!< Pointer to the volume sorter instance //! Structure to map the local sorted point ID to the global point ID std::vector globalSurfaceDOFIDs; public: /*! - * \brief Constructor + * \brief Construct a file writer using field names and the data sorter. * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] volume_sorter - Pointer to the corresponding volume sorter instance + * \param[in] valVolumeSorter - The datasorter containing the volume data */ - CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* volume_sorter); + CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* valVolumeSorter); /*! * \brief Destructor @@ -70,7 +70,7 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ * \input iPoint - the point ID. * \return Global index of a specific point. */ - unsigned long GetGlobalIndex(unsigned long iPoint) override { + unsigned long GetGlobalIndex(unsigned long iPoint) const override { return globalSurfaceDOFIDs[iPoint]; } diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index 9e468781abd..aaa4adc55b9 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -31,18 +31,18 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ - CFVMDataSorter* volume_sorter; //!< Pointer to the volume sorter instance + CFVMDataSorter* volumeSorter; //!< Pointer to the volume sorter instance //! Structure to map the local sorted point ID to the global point ID map Renumber2Global; public: /*! - * \brief Constructor + * \brief Construct a file writer using field names and the data sorter. * \param[in] config - Pointer to the current config structure * \param[in] geometry - Pointer to the current geometry - * \param[in] volume_sorter - Pointer to the corresponding volume sorter instance + * \param[in] valVolumeSorter - The datasorter containing the volume data */ - CSurfaceFVMDataSorter(CConfig *config, CGeometry* geometry, CFVMDataSorter* volume_sorter); + CSurfaceFVMDataSorter(CConfig *config, CGeometry* geometry, CFVMDataSorter* valVolumeSorter); /*! * \brief Destructor @@ -69,8 +69,8 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * \input iPoint - the point ID. * \return Global index of a specific point. */ - unsigned long GetGlobalIndex(unsigned long iPoint) override{ - return Renumber2Global[iPoint]; + unsigned long GetGlobalIndex(unsigned long iPoint) const override{ + return Renumber2Global.at(iPoint); } void SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList) override; diff --git a/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp index 0733e6b85fe..091366df6a2 100644 --- a/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp @@ -33,8 +33,8 @@ class CTecplotBinaryFileWriter final: public CFileWriter{ - unsigned long time_iter; //!< Current value of the time iteration - su2double timestep; //!< Current value of the time step + unsigned long timeIter; //!< Current value of the time iteration + su2double timeStep; //!< Current value of the time step public: @@ -44,12 +44,14 @@ class CTecplotBinaryFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] fileName - The name of the file - * \param[in] data_sorter - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write + * \param[in] valTimeIter - The current time iteration + * \param[in] valTimeStep - The current physical time step value */ - CTecplotBinaryFileWriter(string fileName, CParallelDataSorter* data_sorter, - unsigned long time_iter, su2double timestep); + CTecplotBinaryFileWriter(string valFileName, CParallelDataSorter* valDataSorter, + unsigned long valTimeIter, su2double valTimeStep); /*! * \brief Destructor diff --git a/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp b/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp index 61e6dd8443c..951d1d68a22 100644 --- a/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp @@ -30,8 +30,8 @@ class CTecplotFileWriter final: public CFileWriter{ - unsigned long time_iter; //!< Current value of the time iteration - su2double timestep; //!< Current value of the time step + unsigned long timeIter; //!< Current value of the time iteration + su2double timeStep; //!< Current value of the time step public: @@ -41,12 +41,14 @@ class CTecplotFileWriter final: public CFileWriter{ const static string fileExt; /*! - * \brief Construct a file writer using field names, file extension and dimension. - * \param[in] - The name of the file - * \param[in] - The parallel sorted data to write + * \brief Construct a file writer using field names and the data sorter. + * \param[in] valFileName - The name of the file + * \param[in] valDataSorter - The parallel sorted data to write + * \param[in] valTimeIter - The current time iteration + * \param[in] valTimeStep - The current physical time step value */ - CTecplotFileWriter(string fileName, CParallelDataSorter *dataSorter, - unsigned long time_iter, su2double timestep); + CTecplotFileWriter(string valFileName, CParallelDataSorter* valDataSorter, + unsigned long valTimeIter, su2double valTimeStep); /*! * \brief Destructor diff --git a/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp index 0e947eb3c34..c3aac5aeb9c 100644 --- a/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp @@ -28,8 +28,8 @@ #include "../../../include/output/filewriter/CCSVFileWriter.hpp" #include "../../../include/output/filewriter/CParallelDataSorter.hpp" -CCSVFileWriter::CCSVFileWriter(string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fileName), dataSorter, std::move(".csv")){} +CCSVFileWriter::CCSVFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : + CFileWriter(std::move(valFileName), valDataSorter, std::move(".csv")){} CCSVFileWriter::~CCSVFileWriter(){ diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index ff1e4aa1c9c..d1d1d82cebc 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -28,8 +28,8 @@ #include "../../../include/output/filewriter/CFEMDataSorter.hpp" #include "../../../../Common/include/fem_geometry_structure.hpp" -CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames) : - CParallelDataSorter(config, fieldNames){ +CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames) : + CParallelDataSorter(config, valFieldNames){ nDim = geometry->GetnDim(); @@ -113,7 +113,7 @@ void CFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool SU2_MPI::Allreduce(&nTotal_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - connectivity_sorted = true; + connectivitySorted = true; } diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index 06aed90523b..dd0c9cd997c 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -28,8 +28,8 @@ #include "../../../include/output/filewriter/CFVMDataSorter.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" -CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, vector fieldNames) : - CParallelDataSorter(config, fieldNames){ +CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames) : + CParallelDataSorter(config, valFieldNames){ nDim = geometry->GetnDim(); @@ -132,7 +132,7 @@ void CFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool SU2_MPI::Allreduce(&nTotal_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - connectivity_sorted = true; + connectivitySorted = true; } diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index c281f1e1c34..63380747579 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -28,8 +28,8 @@ #include "../../../include/output/filewriter/CParallelDataSorter.hpp" #include -CParallelDataSorter::CParallelDataSorter(CConfig *config, vector fieldNames) : - fieldNames(std::move(fieldNames)){ +CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector &valFieldNames) : + fieldNames(std::move(valFieldNames)){ rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); @@ -94,7 +94,7 @@ CParallelDataSorter::~CParallelDataSorter(){ } -unsigned long CParallelDataSorter::GetnElem(GEO_TYPE type){ +unsigned long CParallelDataSorter::GetnElem(GEO_TYPE type) const { switch (type) { case LINE: @@ -404,7 +404,7 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector& globalI delete [] idIndex; } -unsigned long CParallelDataSorter::GetElem_Connectivity(GEO_TYPE type, unsigned long iElem, unsigned long iNode) { +unsigned long CParallelDataSorter::GetElem_Connectivity(GEO_TYPE type, unsigned long iElem, unsigned long iNode) const { switch (type) { case LINE: diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index 0f677c7dbaf..fcca8484095 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -28,32 +28,32 @@ #include "../../../include/output/filewriter/CFileWriter.hpp" -CFileWriter::CFileWriter(string fileName, CParallelDataSorter *dataSorter, string file_ext): - file_ext(file_ext), - fileName(std::move(fileName)), - dataSorter(dataSorter){ +CFileWriter::CFileWriter(string valFileName, CParallelDataSorter *valDataSorter, string valFileExt): + fileExt(valFileExt), + fileName(std::move(valFileName)), + dataSorter(valDataSorter){ rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - this->fileName += file_ext; + this->fileName += valFileExt; - file_size = 0.0; - Bandwidth = 0.0; + fileSize = 0.0; + bandwidth = 0.0; } -CFileWriter::CFileWriter(string fileName, string fileExt): - file_ext(fileExt), - fileName(std::move(fileName)){ +CFileWriter::CFileWriter(string valFileName, string valFileExt): + fileExt(valFileExt), + fileName(std::move(valFileName)){ rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - this->fileName += fileExt; + this->fileName += valFileExt; - file_size = 0.0; - Bandwidth = 0.0; + fileSize = 0.0; + bandwidth = 0.0; } diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index e2c511677f6..2b93a8f7d90 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -29,8 +29,8 @@ const string CParaviewBinaryFileWriter::fileExt = ".vtk"; -CParaviewBinaryFileWriter::CParaviewBinaryFileWriter(string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fileName), dataSorter, fileExt){} +CParaviewBinaryFileWriter::CParaviewBinaryFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt){} CParaviewBinaryFileWriter::~CParaviewBinaryFileWriter(){ @@ -68,14 +68,14 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (*c) BigEndian = false; else BigEndian = true; - file_size = 0.0; + fileSize = 0.0; /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif /*--- Serial implementation in case we have not compiled with MPI. ---*/ @@ -99,19 +99,19 @@ void CParaviewBinaryFileWriter::Write_Data(){ strcpy(str_buf, "# vtk DataFile Version 3.0\n"); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); strcpy(str_buf, "vtk output\n"); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); strcpy(str_buf, "BINARY\n"); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); strcpy(str_buf, "DATASET UNSTRUCTURED_GRID\n"); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Write the point coordinates. ---*/ @@ -119,7 +119,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ SPRINTF(str_buf, "POINTS %i float\n", (int)GlobalPoint); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Load/write the 1D buffer of point coordinates. ---*/ @@ -137,7 +137,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)coord_buf, sizeof(float), 3*GlobalPoint); fwrite(coord_buf, sizeof(float), 3*GlobalPoint, fhw); - file_size += sizeof(char)*3*GlobalPoint; + fileSize += sizeof(char)*3*GlobalPoint; delete [] coord_buf; @@ -161,7 +161,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ SPRINTF (str_buf, "\nCELLS %i %i\n", (int)dataSorter->GetnElem(), (int)nGlobal_Elem_Storage); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); conn_buf = new int[dataSorter->GetnElem()*(N_POINTS_HEXAHEDRON+1)]; @@ -180,7 +180,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ fwrite(conn_buf, sizeof(int), nTot_Line*(N_POINTS_LINE+1), fhw); - file_size += sizeof(int)*nTot_Line*(N_POINTS_LINE+1); + fileSize += sizeof(int)*nTot_Line*(N_POINTS_LINE+1); for (iElem = 0; iElem < nTot_Tria; iElem++) { iNode2 = iElem*(N_POINTS_TRIANGLE+1); @@ -193,7 +193,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ nTot_Tria*(N_POINTS_TRIANGLE+1)); fwrite(conn_buf, sizeof(int), nTot_Tria*(N_POINTS_TRIANGLE+1), fhw); - file_size += sizeof(int)*nTot_Tria*(N_POINTS_TRIANGLE+1); + fileSize += sizeof(int)*nTot_Tria*(N_POINTS_TRIANGLE+1); for (iElem = 0; iElem < nTot_Quad; iElem++) { iNode2 = iElem*(N_POINTS_QUADRILATERAL+1); @@ -207,7 +207,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ nTot_Quad*(N_POINTS_QUADRILATERAL+1)); fwrite(conn_buf, sizeof(int), nTot_Quad*(N_POINTS_QUADRILATERAL+1), fhw); - file_size += sizeof(int)*nTot_Quad*(N_POINTS_QUADRILATERAL+1); + fileSize += sizeof(int)*nTot_Quad*(N_POINTS_QUADRILATERAL+1); for (iElem = 0; iElem < nTot_Tetr; iElem++) { iNode2 = iElem*(N_POINTS_TETRAHEDRON+1); @@ -221,7 +221,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ nTot_Tetr*(N_POINTS_TETRAHEDRON+1)); fwrite(conn_buf, sizeof(int), nTot_Tetr*(N_POINTS_TETRAHEDRON+1), fhw); - file_size += sizeof(int)*nTot_Tetr*(N_POINTS_TETRAHEDRON+1); + fileSize += sizeof(int)*nTot_Tetr*(N_POINTS_TETRAHEDRON+1); for (iElem = 0; iElem < nTot_Hexa; iElem++) { iNode2 = iElem*(N_POINTS_HEXAHEDRON+1); @@ -239,7 +239,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ nTot_Hexa*(N_POINTS_HEXAHEDRON+1)); fwrite(conn_buf, sizeof(int), nTot_Hexa*(N_POINTS_HEXAHEDRON+1), fhw); - file_size += sizeof(int)*nTot_Hexa*(N_POINTS_HEXAHEDRON+1); + fileSize += sizeof(int)*nTot_Hexa*(N_POINTS_HEXAHEDRON+1); for (iElem = 0; iElem < nTot_Pris; iElem++) { iNode2 = iElem*(N_POINTS_PRISM+1); @@ -255,7 +255,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ nTot_Pris*(N_POINTS_PRISM+1)); fwrite(conn_buf, sizeof(int), nTot_Pris*(N_POINTS_PRISM+1), fhw); - file_size += sizeof(int)*nTot_Pris*(N_POINTS_PRISM+1); + fileSize += sizeof(int)*nTot_Pris*(N_POINTS_PRISM+1); for (iElem = 0; iElem < nTot_Pyra; iElem++) { iNode2 = iElem*(N_POINTS_PYRAMID+1); @@ -270,7 +270,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ nTot_Pyra*(N_POINTS_PYRAMID+1)); fwrite(conn_buf, sizeof(int), nTot_Pyra*(N_POINTS_PYRAMID+1), fhw); - file_size += sizeof(int)*nTot_Pyra*(N_POINTS_PYRAMID+1); + fileSize += sizeof(int)*nTot_Pyra*(N_POINTS_PYRAMID+1); if (conn_buf != NULL) delete [] conn_buf; @@ -280,7 +280,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ SPRINTF (str_buf, "\nCELL_TYPES %i\n", SU2_TYPE::Int(dataSorter->GetnElem())); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); int *type_buf = NULL; @@ -292,7 +292,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Line); fwrite(type_buf, sizeof(int), nTot_Line, fhw); - file_size += sizeof(int)*nTot_Line; + fileSize += sizeof(int)*nTot_Line; for (iElem = 0; iElem < nTot_Tria; iElem++) { type_buf[iElem] = TRIANGLE; @@ -300,7 +300,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Tria); fwrite(type_buf, sizeof(int), nTot_Tria, fhw); - file_size += sizeof(int)*nTot_Tria; + fileSize += sizeof(int)*nTot_Tria; for (iElem = 0; iElem < nTot_Quad; iElem++) { type_buf[iElem] = QUADRILATERAL; @@ -308,7 +308,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Quad); fwrite(type_buf, sizeof(int), nTot_Quad, fhw); - file_size += sizeof(int)*nTot_Quad; + fileSize += sizeof(int)*nTot_Quad; for (iElem = 0; iElem < nTot_Tetr; iElem++) { type_buf[iElem] = TETRAHEDRON; @@ -316,7 +316,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Tetr); fwrite(type_buf, sizeof(int), nTot_Tetr, fhw); - file_size += sizeof(int)*nTot_Tetr; + fileSize += sizeof(int)*nTot_Tetr; for (iElem = 0; iElem < nTot_Hexa; iElem++) { type_buf[iElem] = HEXAHEDRON; @@ -324,7 +324,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Hexa); fwrite(type_buf, sizeof(int), nTot_Hexa, fhw); - file_size += sizeof(int)*nTot_Hexa; + fileSize += sizeof(int)*nTot_Hexa; for (iElem = 0; iElem < nTot_Pris; iElem++) { type_buf[iElem] = PRISM; @@ -332,7 +332,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Pris); fwrite(type_buf, sizeof(int), nTot_Pris, fhw); - file_size += sizeof(int)*nTot_Pris; + fileSize += sizeof(int)*nTot_Pris; for (iElem = 0; iElem < nTot_Pyra; iElem++) { type_buf[iElem] = PYRAMID; @@ -340,7 +340,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), nTot_Pyra); fwrite(type_buf, sizeof(int), nTot_Pyra, fhw); - file_size += sizeof(int)*nTot_Pyra; + fileSize += sizeof(int)*nTot_Pyra; if (type_buf != NULL) delete [] type_buf; @@ -349,7 +349,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ SPRINTF (str_buf, "\nPOINT_DATA %i\n", (int)GlobalPoint); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); + fileSize += sizeof(char)* strlen(str_buf); unsigned short varStart = 2; if (nDim == 3) varStart++; @@ -387,7 +387,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ fieldname.erase(fieldname.end()-2,fieldname.end()); SPRINTF (str_buf, "\nVECTORS %s float\n", fieldname.c_str()); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); + fileSize += sizeof(char)* strlen(str_buf); /*--- Prepare the 1D data buffer on this rank. ---*/ @@ -409,7 +409,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)vec_buf, sizeof(float), NCOORDS*GlobalPoint); fwrite(vec_buf, sizeof(float), NCOORDS*GlobalPoint, fhw); - file_size += sizeof(float)*NCOORDS*GlobalPoint; + fileSize += sizeof(float)*NCOORDS*GlobalPoint; delete [] vec_buf; @@ -419,11 +419,11 @@ void CParaviewBinaryFileWriter::Write_Data(){ SPRINTF (str_buf, "\nSCALARS %s float 1\n", fieldname.c_str()); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); + fileSize += sizeof(char)* strlen(str_buf); SPRINTF (str_buf, "LOOKUP_TABLE default\n"); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)* strlen(str_buf); + fileSize += sizeof(char)* strlen(str_buf); /*--- Prepare the 1D data buffer on this rank. ---*/ @@ -439,7 +439,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!BigEndian) SwapBytes((char *)scalar_buf, sizeof(float), GlobalPoint); fwrite(scalar_buf, sizeof(float), GlobalPoint, fhw); - file_size += sizeof(float)*GlobalPoint; + fileSize += sizeof(float)*GlobalPoint; delete [] scalar_buf; @@ -495,7 +495,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); strcpy(str_buf, "vtk output\n"); @@ -503,21 +503,21 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); strcpy(str_buf, "BINARY\n"); if (rank == MASTER_NODE) MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); strcpy(str_buf, "DATASET UNSTRUCTURED_GRID\n"); if (rank == MASTER_NODE) MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Communicate the number of total points that will be written by each rank. After this communication, each proc knows how @@ -555,7 +555,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Load/write the 1D buffer of point coordinates. Note that we always have 3 coordinate dimensions, even for 2D problems. ---*/ @@ -602,7 +602,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ /*--- Update the displacement position for MPI IO. ---*/ disp += NCOORDS*nPoint_Cum[size]*sizeof(float); - file_size += sizeof(float)*myPoint*NCOORDS; + fileSize += sizeof(float)*myPoint*NCOORDS; /*--- Free the derived datatype and coordinate array. ---*/ @@ -694,7 +694,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ @@ -803,7 +803,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ disp += nElemStorage_Cum[size]*sizeof(int); - file_size += sizeof(int)*myElemStorage; + fileSize += sizeof(int)*myElemStorage; /*--- Free the derived datatype. ---*/ @@ -819,7 +819,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); int *type_buf = new int[myElem]; unsigned long jElem = 0; @@ -878,7 +878,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ disp += nElem_Cum[size]*sizeof(int); - file_size += sizeof(int)*myElem; + fileSize += sizeof(int)*myElem; /*--- Free the derived datatype. ---*/ @@ -894,7 +894,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Adjust container start location to avoid point coords. ---*/ @@ -945,7 +945,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Prepare the 1D data buffer on this rank. ---*/ @@ -997,7 +997,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ disp += NCOORDS*nPoint_Cum[size]*sizeof(float); - file_size += sizeof(float)*myPoint*NCOORDS; + fileSize += sizeof(float)*myPoint*NCOORDS; /*--- Free the derived datatype and coordinate array. ---*/ @@ -1015,7 +1015,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, (char*)"native", MPI_INFO_NULL); @@ -1024,7 +1024,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen(str_buf)*sizeof(char); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); /*--- Prepare the 1D data buffer on this rank. ---*/ @@ -1069,7 +1069,7 @@ void CParaviewBinaryFileWriter::Write_Data(){ disp += nPoint_Cum[size]*sizeof(float); - file_size += sizeof(float)*myPoint; + fileSize += sizeof(float)*myPoint; /*--- Free the derived datatype and coordinate array. ---*/ @@ -1091,21 +1091,21 @@ void CParaviewBinaryFileWriter::Write_Data(){ #ifndef HAVE_MPI StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StopTime = MPI_Wtime(); + stopTime = MPI_Wtime(); #endif - UsedTime = StopTime-StartTime; + usedTime = stopTime-startTime; /*--- Communicate the total file size for the restart ---*/ #ifdef HAVE_MPI - su2double my_file_size = file_size; - SU2_MPI::Allreduce(&my_file_size, &file_size, 1, + su2double my_fileSize = fileSize; + SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif /*--- Compute and store the bandwidth ---*/ - Bandwidth = file_size/(1.0e6)/UsedTime; + bandwidth = fileSize/(1.0e6)/usedTime; /*--- Delete the offset counters that we needed for MPI IO. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp index e96eb9bdaf5..74a9beea5db 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp @@ -29,8 +29,8 @@ const string CParaviewFileWriter::fileExt = ".vtk"; -CParaviewFileWriter::CParaviewFileWriter(string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fileName), dataSorter, fileExt){} +CParaviewFileWriter::CParaviewFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt){} CParaviewFileWriter::~CParaviewFileWriter(){} @@ -56,9 +56,9 @@ void CParaviewFileWriter::Write_Data(){ /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif /*--- Open Paraview ASCII file and write the header. ---*/ @@ -378,16 +378,16 @@ void CParaviewFileWriter::Write_Data(){ /*--- Compute and store the write time. ---*/ #ifndef HAVE_MPI - StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StopTime = MPI_Wtime(); + stopTime = MPI_Wtime(); #endif - UsedTime = StopTime-StartTime; + usedTime = stopTime-startTime; - file_size = Determine_Filesize(fileName); + fileSize = Determine_Filesize(fileName); /*--- Compute and store the bandwidth ---*/ - Bandwidth = file_size/(1.0e6)/UsedTime; + bandwidth = fileSize/(1.0e6)/usedTime; } diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index 6168a6aef77..4911929cbc4 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -34,10 +34,10 @@ const string CParaviewVTMFileWriter::fileExt = ".vtm"; -CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderName, su2double time, - unsigned short iZone, unsigned short nZone) - : CFileWriter(std::move(fileName), fileExt), - folderName(std::move(folderName)), iZone(iZone), nZone(nZone), curTime(time){ +CParaviewVTMFileWriter::CParaviewVTMFileWriter(string valFileName, string valFolderName, su2double valTime, + unsigned short valiZone, unsigned short valnZone) + : CFileWriter(std::move(valFileName), fileExt), + folderName(std::move(valFolderName)), iZone(valiZone), nZone(valnZone), curTime(valTime){ if (rank == MASTER_NODE) #if defined(_WIN32) || defined(_WIN64) || defined (__WINDOWS__) @@ -45,7 +45,7 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string fileName, string folderNam _mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str()); #else mkdir(this->folderName.c_str(), 0777); - mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str(), 0777); + mkdir((this->folderName + "/zone_" + to_string(valiZone)).c_str(), 0777); #endif } diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 7d2baaff85a..85ce8f16457 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -30,18 +30,18 @@ const string CParaviewXMLFileWriter::fileExt = ".vtu"; -CParaviewXMLFileWriter::CParaviewXMLFileWriter(string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fileName), dataSorter, fileExt){ +CParaviewXMLFileWriter::CParaviewXMLFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt){ /* Check for big endian. We have to swap bytes otherwise. * Since size of character is 1 byte when the character pointer * is de-referenced it will contain only first byte of integer. ---*/ - BigEndian = false; + bigEndian = false; unsigned int i = 1; char *c = (char*)&i; - if (*c) BigEndian = false; - else BigEndian = true; + if (*c) bigEndian = false; + else bigEndian = true; } @@ -73,14 +73,14 @@ void CParaviewXMLFileWriter::Write_Data(){ strcpy(fname, fileName.c_str()); - file_size = 0.0; + fileSize = 0.0; /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif @@ -182,7 +182,7 @@ void CParaviewXMLFileWriter::Write_Data(){ * which means that all data is appended at the end of the file in one binary blob. */ - if (!BigEndian){ + if (!bigEndian){ WriteString("\n", MASTER_NODE); } else { WriteString("\n", MASTER_NODE); @@ -494,23 +494,23 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Compute and store the write time. ---*/ #ifndef HAVE_MPI - StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StopTime = MPI_Wtime(); + stopTime = MPI_Wtime(); #endif - UsedTime = StopTime-StartTime; + usedTime = stopTime-startTime; /*--- Communicate the total file size for the restart ---*/ #ifdef HAVE_MPI - su2double my_file_size = file_size; - SU2_MPI::Allreduce(&my_file_size, &file_size, 1, + su2double my_fileSize = fileSize; + SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif /*--- Compute and store the bandwidth ---*/ - Bandwidth = file_size/(1.0e6)/UsedTime; + bandwidth = fileSize/(1.0e6)/usedTime; /*--- Delete the offset counters that we needed for MPI IO. ---*/ @@ -521,24 +521,24 @@ void CParaviewXMLFileWriter::Write_Data(){ } -void CParaviewXMLFileWriter::WriteString(std::string str, int rank){ +void CParaviewXMLFileWriter::WriteString(std::string str, int rankOut){ #ifdef HAVE_MPI /*--- Reset the file view before writing the next ASCII line for cells. ---*/ MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); + "native", MPI_INFO_NULL); - if (SU2_MPI::GetRank() == rank) - MPI_File_write_at(fhw, disp, str.c_str(), strlen( str.c_str()), + if (SU2_MPI::GetRank() == rankOut) + MPI_File_write_at(fhw, disp, str.c_str(), int(strlen(str.c_str())), MPI_CHAR, MPI_STATUS_IGNORE); disp += strlen( str.c_str())*sizeof(char); - file_size += sizeof(char)*strlen( str.c_str()); + fileSize += sizeof(char)*strlen( str.c_str()); #else char str_buf[255]; strcpy(str_buf, str.c_str()); fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - file_size += sizeof(char)*strlen(str_buf); + fileSize += sizeof(char)*strlen(str_buf); #endif } @@ -595,7 +595,7 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign /*--- Prepare to write the actual data ---*/ - MPI_Type_contiguous(byteSize, MPI_BYTE, &filetype); + MPI_Type_contiguous(int(byteSize), MPI_BYTE, &filetype); MPI_Type_commit(&filetype); /*--- Set the view for the MPI file write, i.e., describe the @@ -607,12 +607,12 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign /*--- Collective call for all ranks to write simultaneously. ---*/ - MPI_File_write_all(fhw, data, byteSize, MPI_BYTE, &status); + MPI_File_write_all(fhw, data, int(byteSize), MPI_BYTE, &status); MPI_Type_free(&filetype); disp += totalByteSize; - file_size += byteSize; + fileSize += byteSize; #else /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ @@ -621,7 +621,7 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign /*--- Write binary data ---*/ fwrite(data, sizeof(char), byteSize, fhw); - file_size += byteSize; + fileSize += byteSize; #endif } diff --git a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp index 7e27f87226b..a25d10ea677 100644 --- a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp @@ -29,8 +29,8 @@ const string CSU2BinaryFileWriter::fileExt = ".dat"; -CSU2BinaryFileWriter::CSU2BinaryFileWriter(string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fileName), dataSorter, fileExt){} +CSU2BinaryFileWriter::CSU2BinaryFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt){} CSU2BinaryFileWriter::~CSU2BinaryFileWriter(){ @@ -50,7 +50,7 @@ void CSU2BinaryFileWriter::Write_Data(){ ofstream restart_file; char str_buf[CGNS_STRING_SIZE], fname[100]; - file_size = 0.0; + fileSize = 0.0; strcpy(fname, fileName.c_str()); @@ -66,9 +66,9 @@ void CSU2BinaryFileWriter::Write_Data(){ /*--- Set a timer for the binary file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif #ifndef HAVE_MPI @@ -85,7 +85,7 @@ void CSU2BinaryFileWriter::Write_Data(){ /*--- First, write the number of variables and points. ---*/ fwrite(var_buf, var_buf_size, sizeof(int), fhw); - file_size += (su2double)var_buf_size*sizeof(int); + fileSize += (su2double)var_buf_size*sizeof(int); /*--- Write the variable names to the file. Note that we are adopting a fixed length of 33 for the string length to match with CGNS. This is @@ -94,13 +94,13 @@ void CSU2BinaryFileWriter::Write_Data(){ for (iVar = 0; iVar < GlobalField_Counter; iVar++) { strncpy(str_buf, fieldNames[iVar].c_str(), CGNS_STRING_SIZE); fwrite(str_buf, CGNS_STRING_SIZE, sizeof(char), fhw); - file_size += (su2double)CGNS_STRING_SIZE*sizeof(char); + fileSize += (su2double)CGNS_STRING_SIZE*sizeof(char); } /*--- Call to write the entire restart file data in binary in one shot. ---*/ fwrite(dataSorter->GetData(), nParallel_Poin*GlobalField_Counter, sizeof(passivedouble), fhw); - file_size += (su2double)nParallel_Poin*GlobalField_Counter*sizeof(passivedouble); + fileSize += (su2double)nParallel_Poin*GlobalField_Counter*sizeof(passivedouble); /*--- Close the file. ---*/ @@ -155,7 +155,7 @@ void CSU2BinaryFileWriter::Write_Data(){ if (rank == MASTER_NODE) { MPI_File_write(fhw, var_buf, var_buf_size, MPI_INT, MPI_STATUS_IGNORE); - file_size += (su2double)var_buf_size*sizeof(int); + fileSize += (su2double)var_buf_size*sizeof(int); /*--- Write the variable names to the file. Note that we are adopting a fixed length of 33 for the string length to match with CGNS. This is @@ -165,7 +165,7 @@ void CSU2BinaryFileWriter::Write_Data(){ disp = var_buf_size*sizeof(int) + iVar*CGNS_STRING_SIZE*sizeof(char); strncpy(str_buf, fieldNames[iVar].c_str(), CGNS_STRING_SIZE); MPI_File_write_at(fhw, disp, str_buf, CGNS_STRING_SIZE, MPI_CHAR, MPI_STATUS_IGNORE); - file_size += (su2double)CGNS_STRING_SIZE*sizeof(char); + fileSize += (su2double)CGNS_STRING_SIZE*sizeof(char); } } @@ -184,7 +184,7 @@ void CSU2BinaryFileWriter::Write_Data(){ /*--- Collective call for all ranks to write to their view simultaneously. ---*/ MPI_File_write_all(fhw, dataSorter->GetData(), GlobalField_Counter*nParallel_Poin, MPI_DOUBLE, &status); - file_size += (su2double)GlobalField_Counter*nParallel_Poin*sizeof(passivedouble); + fileSize += (su2double)GlobalField_Counter*nParallel_Poin*sizeof(passivedouble); /*--- Free the derived datatype. ---*/ @@ -203,22 +203,22 @@ void CSU2BinaryFileWriter::Write_Data(){ /*--- Compute and store the write time. ---*/ #ifndef HAVE_MPI - StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StopTime = MPI_Wtime(); + stopTime = MPI_Wtime(); #endif - UsedTime = StopTime-StartTime; + usedTime = stopTime-startTime; /*--- Communicate the total file size for the restart ---*/ #ifdef HAVE_MPI - su2double my_file_size = file_size; - SU2_MPI::Allreduce(&my_file_size, &file_size, 1, + su2double my_fileSize = fileSize; + SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif /*--- Compute and store the bandwidth ---*/ - Bandwidth = file_size/(1.0e6)/UsedTime; + bandwidth = fileSize/(1.0e6)/usedTime; } diff --git a/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp index 5dfeb7cf14a..47dcc239dc5 100644 --- a/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp @@ -29,8 +29,8 @@ const string CSU2FileWriter::fileExt = ".csv"; -CSU2FileWriter::CSU2FileWriter(string fileName, CParallelDataSorter *dataSorter) : - CFileWriter(std::move(fileName), dataSorter, fileExt){} +CSU2FileWriter::CSU2FileWriter(string valFileName, CParallelDataSorter *valDataSorter) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt){} CSU2FileWriter::~CSU2FileWriter(){ @@ -52,9 +52,9 @@ void CSU2FileWriter::Write_Data(){ /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif /*--- Only the master node writes the header. ---*/ @@ -114,19 +114,19 @@ void CSU2FileWriter::Write_Data(){ /*--- Compute and store the write time. ---*/ #ifndef HAVE_MPI - StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StopTime = MPI_Wtime(); + stopTime = MPI_Wtime(); #endif - UsedTime = StopTime-StartTime; + usedTime = stopTime-startTime; /*--- Determine the file size ---*/ - file_size = Determine_Filesize(fileName); + fileSize = Determine_Filesize(fileName); /*--- Compute and store the bandwidth ---*/ - Bandwidth = file_size/(1.0e6)/UsedTime; + bandwidth = fileSize/(1.0e6)/usedTime; /*--- All processors close the file. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp index 53784b5b8a5..9408e133bf1 100644 --- a/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp @@ -30,9 +30,9 @@ const string CSU2MeshFileWriter::fileExt = ".su2"; -CSU2MeshFileWriter::CSU2MeshFileWriter(string fileName, CParallelDataSorter *dataSorter, - unsigned short iZone, unsigned short nZone) : - CFileWriter(std::move(fileName), dataSorter, fileExt), iZone(iZone), nZone(nZone) {} +CSU2MeshFileWriter::CSU2MeshFileWriter(string valFileName, CParallelDataSorter *valDataSorter, + unsigned short valiZone, unsigned short valnZone) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt), iZone(valiZone), nZone(valnZone) {} CSU2MeshFileWriter::~CSU2MeshFileWriter(){ diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 2b6fea820b5..4ea8a07b2ab 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -29,14 +29,14 @@ #include "../../../../Common/include/fem_geometry_structure.hpp" -CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* volume_sorter) : - CParallelDataSorter(config, volume_sorter->GetFieldNames()){ +CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* valVolumeSorter) : + CParallelDataSorter(config, valVolumeSorter->GetFieldNames()){ nDim = geometry->GetnDim(); - this->volume_sorter = volume_sorter; + this->volumeSorter = valVolumeSorter; - connectivity_sorted = false; + connectivitySorted = false; /*--- Create an object of the class CMeshFEM_DG and retrieve the necessary geometrical information for the FEM DG solver. ---*/ @@ -81,7 +81,7 @@ CSurfaceFEMDataSorter::~CSurfaceFEMDataSorter(){ void CSurfaceFEMDataSorter::SortOutputData() { - if (!connectivity_sorted){ + if (!connectivitySorted){ SU2_MPI::Error("Connectivity must be sorted before sorting output data", CURRENT_FUNCTION); } @@ -234,7 +234,7 @@ void CSurfaceFEMDataSorter::SortOutputData() { const unsigned long ii = globalSurfaceDOFIDs[i] - linearPartitioner->GetCumulativeSizeBeforeRank(rank); for(int jj=0; jjGetData(jj,ii); + passiveDoubleBuffer[i*VARS_PER_POINT+jj] = volumeSorter->GetData(jj,ii); } /*--- Reduce the total number of surf points we have. This will be @@ -350,7 +350,7 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - connectivity_sorted = true; + connectivitySorted = true; } diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 09847c91020..5f2cdfb3275 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -29,14 +29,14 @@ #include "../../../../Common/include/geometry/CGeometry.hpp" -CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometry, CFVMDataSorter* volume_sorter) : - CParallelDataSorter(config, volume_sorter->GetFieldNames()){ +CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometry, CFVMDataSorter* valVolumeSorter) : + CParallelDataSorter(config, valVolumeSorter->GetFieldNames()){ nDim = geometry->GetnDim(); - this->volume_sorter = volume_sorter; + this->volumeSorter = valVolumeSorter; - connectivity_sorted = false; + connectivitySorted = false; nGlobalPoint_Sort = geometry->GetGlobal_nPointDomain(); nLocalPoint_Sort = geometry->GetnPointDomain(); @@ -390,11 +390,11 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Create a local data structure that acts as a mask to extract the set of points within the local set that are on the surface. ---*/ - int *surfPoint = new int[volume_sorter->GetnPoints()]; - for (iPoint = 0; iPoint < volume_sorter->GetnPoints(); iPoint++) surfPoint[iPoint] = -1; + int *surfPoint = new int[volumeSorter->GetnPoints()]; + for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) surfPoint[iPoint] = -1; for (int ii = 0; ii < nElem_Recv[size]; ii++) { - surfPoint[(int)idRecv[ii] - volume_sorter->GetNodeBegin(rank)] = (int)idRecv[ii]; + surfPoint[(int)idRecv[ii] - volumeSorter->GetNodeBegin(rank)] = (int)idRecv[ii]; } /*--- First, add up the number of surface points I have on my rank. ---*/ @@ -402,7 +402,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { nParallel_Poin = 0; Renumber2Global.clear(); - for (iPoint = 0; iPoint < volume_sorter->GetnPoints(); iPoint++) { + for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) { if (surfPoint[iPoint] != -1) { /*--- Save the global index values for CSV output. ---*/ @@ -451,9 +451,9 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int jj = 0; jj < VARS_PER_POINT; jj++) { count = 0; - for (int ii = 0; ii < (int)volume_sorter->GetnPoints(); ii++) { + for (int ii = 0; ii < (int)volumeSorter->GetnPoints(); ii++) { if (surfPoint[ii] !=-1) { - passiveDoubleBuffer[count*VARS_PER_POINT + jj] = volume_sorter->GetData(jj,ii); + passiveDoubleBuffer[count*VARS_PER_POINT + jj] = volumeSorter->GetData(jj,ii); count++; } } @@ -477,7 +477,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { unsigned long *renumbP = new unsigned long[nParallel_Poin](); count = 0; - for (iPoint = 0; iPoint < volume_sorter->GetnPoints(); iPoint++) { + for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) { if (surfPoint[iPoint] != -1) { globalP[count] = surfPoint[iPoint]; renumbP[count] = count + nPoint_Recv[rank]; @@ -1129,7 +1129,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - connectivity_sorted = true; + connectivitySorted = true; } @@ -1153,7 +1153,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - connectivity_sorted = true; + connectivitySorted = true; } @@ -1362,7 +1362,7 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * as a halo cell. We will use this later to sort and remove any duplicates from the connectivity list. ---*/ - if (volume_sorter->GetHalo(iPoint)) haloSend[mm] = true; + if (volumeSorter->GetHalo(iPoint)) haloSend[mm] = true; } diff --git a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp index 3624b6cd010..cae5257fdbf 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp @@ -33,9 +33,9 @@ const string CTecplotBinaryFileWriter::fileExt = ".szplt"; -CTecplotBinaryFileWriter::CTecplotBinaryFileWriter(string fileName, CParallelDataSorter *dataSorter, - unsigned long time_iter, su2double timestep) : - CFileWriter(std::move(fileName), dataSorter, fileExt), time_iter(time_iter), timestep(timestep){} +CTecplotBinaryFileWriter::CTecplotBinaryFileWriter(string valFileName, CParallelDataSorter *valDataSorter, + unsigned long valTimeIter, su2double valTimeStep) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt), timeIter(valTimeIter), timeStep(valTimeStep){} CTecplotBinaryFileWriter::~CTecplotBinaryFileWriter(){} @@ -48,9 +48,9 @@ void CTecplotBinaryFileWriter::Write_Data(){ /*--- Set a timer for the binary file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif #ifdef HAVE_TECIO @@ -134,9 +134,9 @@ void CTecplotBinaryFileWriter::Write_Data(){ bool is_unsteady = false; passivedouble solution_time = 0.0; - if (timestep > 0.0){ + if (timeStep > 0.0){ is_unsteady = true; - solution_time = SU2_TYPE::GetValue(timestep)*time_iter; + solution_time = SU2_TYPE::GetValue(timeStep)*timeIter; } int32_t zone; @@ -144,7 +144,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ err = tecZoneCreateFE(file_handle, "Zone", zone_type, num_nodes, num_cells, NULL, NULL, &value_locations[0], NULL, 0, 0, 0, &zone); if (err) cout << rank << ": Error creating Tecplot zone." << endl; if (is_unsteady) { - err = tecZoneSetUnsteadyOptions(file_handle, zone, solution_time, time_iter + 1); + err = tecZoneSetUnsteadyOptions(file_handle, zone, solution_time, timeIter + 1); if (err) cout << rank << ": Error setting Tecplot zone unsteady options." << std::endl; } @@ -600,17 +600,17 @@ void CTecplotBinaryFileWriter::Write_Data(){ /*--- Compute and store the write time. ---*/ #ifndef HAVE_MPI - StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StopTime = MPI_Wtime(); + stopTime = MPI_Wtime(); #endif - UsedTime = StopTime-StartTime; + usedTime = stopTime-startTime; - file_size = Determine_Filesize(fileName); + fileSize = Determine_Filesize(fileName); /*--- Compute and store the bandwidth ---*/ - Bandwidth = file_size/(1.0e6)/UsedTime; + bandwidth = fileSize/(1.0e6)/usedTime; } diff --git a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp index dff92d28d6b..5a982197129 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp @@ -29,9 +29,9 @@ const string CTecplotFileWriter::fileExt = ".dat"; -CTecplotFileWriter::CTecplotFileWriter(string fileName, CParallelDataSorter *dataSorter, - unsigned long time_iter, su2double timestep) : - CFileWriter(std::move(fileName), dataSorter, fileExt), time_iter(time_iter), timestep(timestep){} +CTecplotFileWriter::CTecplotFileWriter(string valFileName, CParallelDataSorter *valDataSorter, + unsigned long valTimeIter, su2double valTimeStep) : + CFileWriter(std::move(valFileName), valDataSorter, fileExt), timeIter(valTimeIter), timeStep(valTimeStep){} CTecplotFileWriter::~CTecplotFileWriter(){} @@ -51,14 +51,14 @@ void CTecplotFileWriter::Write_Data(){ ofstream Tecplot_File; - file_size = 0.0; + fileSize = 0.0; /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI - StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); #else - StartTime = MPI_Wtime(); + startTime = MPI_Wtime(); #endif /*--- Reduce the total number of each element. ---*/ @@ -107,8 +107,8 @@ void CTecplotFileWriter::Write_Data(){ Tecplot_File << "ZONE "; - if (timestep > 0.0){ - Tecplot_File << "STRANDID="< 0.0){ + Tecplot_File << "STRANDID="< Date: Thu, 9 Jan 2020 18:28:27 +0100 Subject: [PATCH 29/61] Replaced some of the pointers with vectors --- .../filewriter/CParaviewXMLFileWriter.cpp | 97 ++++++------------- 1 file changed, 30 insertions(+), 67 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index d72210cc26a..9f566d99af4 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -266,9 +266,9 @@ void CParaviewXMLFileWriter::Write_Data(){ nPoint_Snd[0] = 0; nPoint_Cum[0] = 0; for (int ii=1; ii < size; ii++) { - nPoint_Snd[ii] = myPoint; nPoint_Cum[ii] = 0; + nPoint_Snd[ii] = int(myPoint); nPoint_Cum[ii] = 0; } - nPoint_Snd[size] = myPoint; nPoint_Cum[size] = 0; + nPoint_Snd[size] = int(myPoint); nPoint_Cum[size] = 0; /*--- Communicate the local counts to all ranks for building offsets. ---*/ @@ -288,24 +288,20 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Load/write the 1D buffer of point coordinates. Note that we always have 3 coordinate dimensions, even for 2D problems. ---*/ - float *coord_buf = new float[myPoint*NCOORDS]; + vector dataBufferFloat(myPoint*NCOORDS); for (iPoint = 0; iPoint < myPoint; iPoint++) { for (iDim = 0; iDim < NCOORDS; iDim++) { if (nDim == 2 && iDim == 2) { - coord_buf[iPoint*NCOORDS + iDim] = 0.0; + dataBufferFloat[iPoint*NCOORDS + iDim] = 0.0; } else { float val = (float)dataSorter->GetData(iDim, iPoint); - coord_buf[iPoint*NCOORDS + iDim] = val; + dataBufferFloat[iPoint*NCOORDS + iDim] = val; } } } - WriteDataArray((void*)coord_buf, VTKDatatype::FLOAT32, NCOORDS*myPoint, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, NCOORDS*myPoint, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); - /*--- Free the coordinate array. ---*/ - - delete [] coord_buf; - /*--- Communicate the number of total cells/storage that will be written by each rank. After this communication, each proc knows how many cells will be written before its location in the file and the @@ -317,10 +313,10 @@ void CParaviewXMLFileWriter::Write_Data(){ nElem_Snd[0] = 0; nElemStorage_Snd[0] = 0; nElem_Cum[0] = 0; nElemStorage_Cum[0] = 0; for (int ii=1; ii < size; ii++) { - nElem_Snd[ii] = myElem; nElemStorage_Snd[ii] = myElemStorage; + nElem_Snd[ii] = int(myElem); nElemStorage_Snd[ii] = int(myElemStorage); nElem_Cum[ii] = 0; nElemStorage_Cum[ii] = 0; } - nElem_Snd[size] = myElem; nElemStorage_Snd[size] = myElemStorage; + nElem_Snd[size] = int(myElem); nElemStorage_Snd[size] = int(myElemStorage); nElem_Cum[size] = 0; nElemStorage_Cum[size] = 0; /*--- Communicate the local counts to all ranks for building offsets. ---*/ @@ -340,18 +336,18 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ - int *conn_buf = new int[myElemStorage]; - int *offset_buf = new int[myElem]; + vector connBuf(myElemStorage); + vector offsetBuf(myElem); unsigned long iStorage = 0, iElemID = 0; unsigned short iNode = 0; auto copyToBuffer = [&](GEO_TYPE type, unsigned long nElem, unsigned short nPoints){ for (iElem = 0; iElem < nElem; iElem++) { for (iNode = 0; iNode < nPoints; iNode++){ - conn_buf[iStorage+iNode] = dataSorter->GetElem_Connectivity(type, iElem, iNode)-1; + connBuf[iStorage+iNode] = int(dataSorter->GetElem_Connectivity(type, iElem, iNode)-1); } iStorage += nPoints; - offset_buf[iElemID++] = (iStorage + nElemStorage_Cum[rank]); + offsetBuf[iElemID++] = int(iStorage + nElemStorage_Cum[rank]); } }; @@ -363,52 +359,29 @@ void CParaviewXMLFileWriter::Write_Data(){ copyToBuffer(PRISM, nParallel_Pris, N_POINTS_PRISM); copyToBuffer(PYRAMID, nParallel_Pyra, N_POINTS_PYRAMID); - WriteDataArray((void*)conn_buf, VTKDatatype::INT32, myElemStorage, GlobalElemStorage, nElemStorage_Cum[rank]); - WriteDataArray((void*)offset_buf, VTKDatatype::INT32, myElem, GlobalElem, nElem_Cum[rank]); - - delete [] conn_buf; - delete [] offset_buf; + WriteDataArray(connBuf.data(), VTKDatatype::INT32, myElemStorage, GlobalElemStorage, nElemStorage_Cum[rank]); + WriteDataArray(offsetBuf.data(), VTKDatatype::INT32, myElem, GlobalElem, nElem_Cum[rank]); /*--- Load/write the cell type for all elements in the file. ---*/ - uint8_t *type_buf = new uint8_t[myElem]; - unsigned long jElem = 0; - - for (iElem = 0; iElem < nParallel_Line; iElem++) { - type_buf[jElem] = LINE; jElem++; - } - for (iElem = 0; iElem < nParallel_Tria; iElem++) { - type_buf[jElem] = TRIANGLE; jElem++; - } - for (iElem = 0; iElem < nParallel_Quad; iElem++) { - type_buf[jElem] = QUADRILATERAL; jElem++; - } - for (iElem = 0; iElem < nParallel_Tetr; iElem++) { - type_buf[jElem] = TETRAHEDRON; jElem++; - } - for (iElem = 0; iElem < nParallel_Hexa; iElem++) { - type_buf[jElem] = HEXAHEDRON; jElem++; - } - for (iElem = 0; iElem < nParallel_Pris; iElem++) { - type_buf[jElem] = PRISM; jElem++; - } - for (iElem = 0; iElem < nParallel_Pyra; iElem++) { - type_buf[jElem] = PYRAMID; jElem++; - } + vector typeBuf(myElem); + vector::iterator typeIter = typeBuf.begin(); - WriteDataArray((void*)type_buf, VTKDatatype::UINT8, myElem, GlobalElem, nElem_Cum[rank]); - - delete [] type_buf; + std::fill(typeIter, typeIter+nParallel_Line, LINE); typeIter += nParallel_Line; + std::fill(typeIter, typeIter+nParallel_Tria, TRIANGLE); typeIter += nParallel_Tria; + std::fill(typeIter, typeIter+nParallel_Quad, QUADRILATERAL); typeIter += nParallel_Quad; + std::fill(typeIter, typeIter+nParallel_Tetr, TETRAHEDRON); typeIter += nParallel_Tetr; + std::fill(typeIter, typeIter+nParallel_Hexa, HEXAHEDRON); typeIter += nParallel_Hexa; + std::fill(typeIter, typeIter+nParallel_Pris, PRISM); typeIter += nParallel_Pris; + std::fill(typeIter, typeIter+nParallel_Pyra, PYRAMID); typeIter += nParallel_Pyra; + + WriteDataArray(typeBuf.data(), VTKDatatype::UINT8, myElem, GlobalElem, nElem_Cum[rank]); /*--- Loop over all variables that have been registered in the output. ---*/ VarCounter = varStart; for (iField = varStart; iField < fieldNames.size(); iField++) { - string fieldname = fieldNames[iField]; - fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), - fieldname.end()); - /*--- Check whether this field is a vector or scalar. ---*/ bool output_variable = true, isVector = false; @@ -434,47 +407,37 @@ void CParaviewXMLFileWriter::Write_Data(){ if (output_variable && isVector) { - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *vec_buf = new float[myPoint*NCOORDS]; - /*--- Load up the buffer for writing this rank's vector data. ---*/ float val = 0.0; for (iPoint = 0; iPoint < myPoint; iPoint++) { for (iDim = 0; iDim < NCOORDS; iDim++) { if (nDim == 2 && iDim == 2) { - vec_buf[iPoint*NCOORDS + iDim] = 0.0; + dataBufferFloat[iPoint*NCOORDS + iDim] = 0.0; } else { val = (float)dataSorter->GetData(VarCounter+iDim,iPoint); - vec_buf[iPoint*NCOORDS + iDim] = val; + dataBufferFloat[iPoint*NCOORDS + iDim] = val; } } } - WriteDataArray((void*)vec_buf, VTKDatatype::FLOAT32, myPoint*NCOORDS, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint*NCOORDS, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); - delete [] vec_buf; - VarCounter++; } else if (output_variable) { - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *scalar_buf = new float[myPoint]; /*--- For now, create a temp 1D buffer to load up the data for writing. This will be replaced with a derived data type most likely. ---*/ for (iPoint = 0; iPoint < myPoint; iPoint++) { float val = (float)dataSorter->GetData(VarCounter,iPoint); - scalar_buf[iPoint] = val; + dataBufferFloat[iPoint] = val; } - WriteDataArray((void*)scalar_buf, VTKDatatype::FLOAT32, myPoint, GlobalPoint, nPoint_Cum[rank]); + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint, GlobalPoint, nPoint_Cum[rank]); - delete [] scalar_buf; scalar_buf = NULL; VarCounter++; } From 2253229d711e27820d6dcf517d0732de37a47625 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Thu, 9 Jan 2020 18:34:43 +0100 Subject: [PATCH 30/61] Removed trailing whitespaces --- .../output/filewriter/CCSVFileWriter.hpp | 2 +- .../output/filewriter/CFEMDataSorter.hpp | 2 +- .../output/filewriter/CFVMDataSorter.hpp | 2 +- .../include/output/filewriter/CFileWriter.hpp | 10 +- .../output/filewriter/CParallelDataSorter.hpp | 12 +- .../filewriter/CParaviewBinaryFileWriter.hpp | 2 +- .../output/filewriter/CParaviewFileWriter.hpp | 2 +- .../filewriter/CParaviewVTMFileWriter.hpp | 22 +- .../filewriter/CParaviewXMLFileWriter.hpp | 26 +-- .../filewriter/CSU2BinaryFileWriter.hpp | 2 +- .../output/filewriter/CSU2FileWriter.hpp | 2 +- .../output/filewriter/CSU2MeshFileWriter.hpp | 2 +- .../filewriter/CSurfaceFEMDataSorter.hpp | 2 +- .../filewriter/CSurfaceFVMDataSorter.hpp | 4 +- .../filewriter/CTecplotBinaryFileWriter.hpp | 4 +- .../output/filewriter/CTecplotFileWriter.hpp | 4 +- .../src/output/filewriter/CCSVFileWriter.cpp | 4 +- .../src/output/filewriter/CFEMDataSorter.cpp | 4 +- .../src/output/filewriter/CFVMDataSorter.cpp | 4 +- .../output/filewriter/CParallelDataSorter.cpp | 4 +- .../output/filewriter/CParallelFileWriter.cpp | 12 +- .../filewriter/CParaviewBinaryFileWriter.cpp | 6 +- .../output/filewriter/CParaviewFileWriter.cpp | 4 +- .../filewriter/CParaviewVTMFileWriter.cpp | 44 ++-- .../filewriter/CParaviewXMLFileWriter.cpp | 192 +++++++++--------- .../filewriter/CSU2BinaryFileWriter.cpp | 4 +- .../src/output/filewriter/CSU2FileWriter.cpp | 2 +- .../output/filewriter/CSU2MeshFileWriter.cpp | 2 +- .../filewriter/CSurfaceFEMDataSorter.cpp | 4 +- .../filewriter/CSurfaceFVMDataSorter.cpp | 26 +-- .../filewriter/CTecplotBinaryFileWriter.cpp | 4 +- .../output/filewriter/CTecplotFileWriter.cpp | 4 +- 32 files changed, 210 insertions(+), 210 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp b/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp index ce1d5fe2e26..0606d76aef3 100644 --- a/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CCSVFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp index a83605f8b1f..41b04b0e9ff 100644 --- a/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CFEMDataSorter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp index eb53750e20f..52a8f7f14be 100644 --- a/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CFVMDataSorter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index 9a58deb1267..1b245356d72 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -78,12 +78,12 @@ class CFileWriter{ * \brief Filename */ string fileName; - + /*! * \brief The parallel data sorter */ CParallelDataSorter* dataSorter; - + public: /*! * \brief Construct a file writer using field names, the data sorter and the file extension. @@ -92,14 +92,14 @@ class CFileWriter{ * \param[in] valFileExt - The file extension. */ CFileWriter(string valFileName, CParallelDataSorter* valDataSorter, string valFileExt); - + /*! * \brief Construct a file writer using field names, file extension. * \param[in] valFileName - The name of the file * \param[in] valFileExt - The file extension to be attached to the filename */ CFileWriter(string valFileName, string valFileExt); - + /*! * \brief Destructor */ diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index 642e705e385..6453cefeee5 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -86,9 +86,9 @@ class CParallelDataSorter{ unsigned long *idSend; //!< Send buffer holding global indices that will be send to other processors int nSends, //!< Number of sends nRecvs; //!< Number of receives - + vector fieldNames; //!< Vector with names of the output fields - + unsigned short nDim; //!< Spatial dimension of the data /*! @@ -125,7 +125,7 @@ class CParallelDataSorter{ * \param[in] val_sort - boolean controlling whether the elements are sorted or simply loaded by their owning rank. */ virtual void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort = true){} - + /*! * \brief Sort the connectivities into data structures (only for surface data sorters). * \param[in] config - Definition of the particular problem. @@ -244,7 +244,7 @@ class CParallelDataSorter{ su2double GetUnsorted_Data(unsigned long iPoint, unsigned short iField) const { return connSend[Index[iPoint] + iField]; } - + /*! * \brief Get the vector containing the names of the output fields * \return Vector of strings containing the field names @@ -252,7 +252,7 @@ class CParallelDataSorter{ const vector& GetFieldNames() const{ return fieldNames; } - + /*! * \brief Get the spatial dimension * \return The spatial dimension diff --git a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp index ce4384bed83..d5ac228add4 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp index 425d48df373..6c1a8feaafd 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp index c04ac44b2fc..46bd81bbc6a 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewVTMFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -35,27 +35,27 @@ class CParaviewVTMFileWriter final: public CFileWriter{ * \brief String stream that stores the content of the vtm file */ stringstream output; - + /*! * \brief The folder name where all the files associated with the datasets will be stored */ string folderName; - + /*! * \brief The current zone index */ unsigned short iZone; - + /*! * \brief The total number of zones */ unsigned short nZone; - + /*! * \brief Current physical time */ su2double curTime; - + public: /*! @@ -82,7 +82,7 @@ class CParaviewVTMFileWriter final: public CFileWriter{ * \brief Write sorted data to file in paraview binary file format */ void Write_Data() override; - + /*! * \brief Add a new dataset by writing data from a datasorter to file and adding it to the vtm file * \param[in] name - The name of the dataset @@ -98,9 +98,9 @@ class CParaviewVTMFileWriter final: public CFileWriter{ inline void StartBlock(string name){ if (rank == MASTER_NODE){ output << "" << endl; - } + } } - + /*! * \brief Close currently opened block */ @@ -109,7 +109,7 @@ class CParaviewVTMFileWriter final: public CFileWriter{ output << "" << endl; } } - + /*! * \brief Add a new dataset by writing it to the vtm file * \param[in] name - Name of the dataset @@ -120,7 +120,7 @@ class CParaviewVTMFileWriter final: public CFileWriter{ output << "" << endl; } } - + /*! * \brief Get the name of the folder where the data will be stored * \return The folder name diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index 9a598a53f78..f1b65cdb2aa 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -32,7 +32,7 @@ class CParaviewXMLFileWriter final: public CFileWriter{ private: - + /*! * \brief Enum that defines the VTK datatypes */ @@ -41,40 +41,40 @@ class CParaviewXMLFileWriter final: public CFileWriter{ INT32, UINT8 }; - + #ifdef HAVE_MPI /*! * \brief The displacement that every process has in the current file view */ MPI_Offset disp; - + /*! * \brief The file handle for writing */ MPI_File fhw; #else - + /*! * \brief The displacement that every process has in the current file view */ unsigned long disp; - + /*! * \brief The file handle for writing */ FILE* fhw; #endif - + /*! * \brief Boolean storing whether we are on a big or little endian machine */ bool bigEndian; - + /*! * \brief The current data offset that is used to find data in the binary blob at the end of the file */ unsigned long dataOffset; - + public: /*! @@ -107,7 +107,7 @@ class CParaviewXMLFileWriter final: public CFileWriter{ * \param[in] rank - The rank that should write the string */ void WriteString(std::string str, int rankOut); - + /*! * \brief Add a new data array definition to the vtu file. * \param[in] type - The vtk datatype @@ -117,11 +117,11 @@ class CParaviewXMLFileWriter final: public CFileWriter{ * \param[in] globalSize - The global size of the array over all processors */ void AddDataArray(VTKDatatype type, string name, unsigned short nComponents, unsigned long size, unsigned long globalSize); - + /*! * \brief Write an array that has previously been defined with ::AddDataArray to the vtu file in binary format * \param[in] data - Pointer to the data - * \param[in] type - The vtk datatype + * \param[in] type - The vtk datatype * \param[in] size - The total size of the array * \param[in] globalSize - The global size of the array over all processors * \param[in] offset - The displacement in the file view for the current processor @@ -146,7 +146,7 @@ class CParaviewXMLFileWriter final: public CFileWriter{ break; case VTKDatatype::UINT8: typeStr = "\"UInt8\""; - typeSize = sizeof(char); + typeSize = sizeof(char); break; default: SU2_MPI::Error("Unknown Type", CURRENT_FUNCTION); diff --git a/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp index 686eceac08e..26e33f48179 100644 --- a/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2BinaryFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp index eed8b44b658..5a1fa44e5bd 100644 --- a/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp b/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp index 05c2e4455d6..237c7e46b32 100644 --- a/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp index a3f4808ac56..5ed79491aae 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index aaa4adc55b9..c3ec2f99a21 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -72,7 +72,7 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ unsigned long GetGlobalIndex(unsigned long iPoint) const override{ return Renumber2Global.at(iPoint); } - + void SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList) override; diff --git a/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp index 091366df6a2..228a9ab95bc 100644 --- a/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CTecplotBinaryFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -47,7 +47,7 @@ class CTecplotBinaryFileWriter final: public CFileWriter{ * \brief Construct a file writer using field names and the data sorter. * \param[in] valFileName - The name of the file * \param[in] valDataSorter - The parallel sorted data to write - * \param[in] valTimeIter - The current time iteration + * \param[in] valTimeIter - The current time iteration * \param[in] valTimeStep - The current physical time step value */ CTecplotBinaryFileWriter(string valFileName, CParallelDataSorter* valDataSorter, diff --git a/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp b/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp index 951d1d68a22..5a8c529ccf5 100644 --- a/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CTecplotFileWriter.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -44,7 +44,7 @@ class CTecplotFileWriter final: public CFileWriter{ * \brief Construct a file writer using field names and the data sorter. * \param[in] valFileName - The name of the file * \param[in] valDataSorter - The parallel sorted data to write - * \param[in] valTimeIter - The current time iteration + * \param[in] valTimeIter - The current time iteration * \param[in] valTimeStep - The current physical time step value */ CTecplotFileWriter(string valFileName, CParallelDataSorter* valDataSorter, diff --git a/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp index c3aac5aeb9c..19411400f94 100644 --- a/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCSVFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -53,7 +53,7 @@ void CCSVFileWriter::Write_Data(){ unsigned long iPoint, index; unsigned long Buffer_Send_nVertex[1], *Buffer_Recv_nVertex = NULL; unsigned long nLocalVertex_Surface = 0, MaxLocalVertex_Surface = 0; - + const vector fieldNames = dataSorter->GetFieldNames(); ofstream Surf_file; diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index d1d1d82cebc..135d5a56648 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -32,7 +32,7 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vecto CParallelDataSorter(config, valFieldNames){ nDim = geometry->GetnDim(); - + /*--- Create an object of the class CMeshFEM_DG and retrieve the necessary geometrical information for the FEM DG solver. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index dd0c9cd997c..a585ca4e194 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -28,9 +28,9 @@ #include "../../../include/output/filewriter/CFVMDataSorter.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" -CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames) : +CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames) : CParallelDataSorter(config, valFieldNames){ - + nDim = geometry->GetnDim(); std::vector globalID; diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index 63380747579..f4ceaf81fac 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -28,7 +28,7 @@ #include "../../../include/output/filewriter/CParallelDataSorter.hpp" #include -CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector &valFieldNames) : +CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector &valFieldNames) : fieldNames(std::move(valFieldNames)){ rank = SU2_MPI::GetRank(); diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index fcca8484095..f3cb56135a8 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -40,21 +40,21 @@ CFileWriter::CFileWriter(string valFileName, CParallelDataSorter *valDataSorter, fileSize = 0.0; bandwidth = 0.0; - + } CFileWriter::CFileWriter(string valFileName, string valFileExt): fileExt(valFileExt), fileName(std::move(valFileName)){ - + rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - + this->fileName += valFileExt; - + fileSize = 0.0; bandwidth = 0.0; - + } CFileWriter::~CFileWriter(){ diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index 2b93a8f7d90..b9145f4e390 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -42,11 +42,11 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!dataSorter->GetConnectivitySorted()){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } - + const vector fieldNames = dataSorter->GetFieldNames(); unsigned short iDim = 0, nDim = dataSorter->GetnDim(); - + unsigned long iPoint, iElem; ofstream Paraview_File; diff --git a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp index 74a9beea5db..9078cfa2e64 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -50,7 +50,7 @@ void CParaviewFileWriter::Write_Data(){ ofstream Paraview_File; int iProcessor; - + const vector fieldNames = dataSorter->GetFieldNames(); /*--- Set a timer for the file writing. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index 4911929cbc4..b52021646df 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -34,17 +34,17 @@ const string CParaviewVTMFileWriter::fileExt = ".vtm"; -CParaviewVTMFileWriter::CParaviewVTMFileWriter(string valFileName, string valFolderName, su2double valTime, +CParaviewVTMFileWriter::CParaviewVTMFileWriter(string valFileName, string valFolderName, su2double valTime, unsigned short valiZone, unsigned short valnZone) : CFileWriter(std::move(valFileName), fileExt), folderName(std::move(valFolderName)), iZone(valiZone), nZone(valnZone), curTime(valTime){ - + if (rank == MASTER_NODE) #if defined(_WIN32) || defined(_WIN64) || defined (__WINDOWS__) _mkdir(this->folderName.c_str()); _mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str()); -#else - mkdir(this->folderName.c_str(), 0777); +#else + mkdir(this->folderName.c_str(), 0777); mkdir((this->folderName + "/zone_" + to_string(valiZone)).c_str(), 0777); #endif @@ -56,28 +56,28 @@ CParaviewVTMFileWriter::~CParaviewVTMFileWriter(){ } void CParaviewVTMFileWriter::Write_Data(){ - - /*--- If we are in the first zone, create new file and write the file header, + + /*--- If we are in the first zone, create new file and write the file header, * otherwise append to already existing file ---*/ - + if (rank == MASTER_NODE){ ofstream multiBlockFile; if (iZone == 0) multiBlockFile.open (fileName.c_str()); - else + else multiBlockFile.open(fileName.c_str(), ios::app); - + if (iZone == 0){ multiBlockFile << "" << endl; multiBlockFile << "" << endl; } - + /*--- Write all blocks that have been added ---*/ - + multiBlockFile << output.str(); - + /*--- If we are in the last zone, write the additional data and close all blocks ---*/ - + if (iZone == nZone-1){ multiBlockFile << "" << endl; multiBlockFile << "" << endl; @@ -89,23 +89,23 @@ void CParaviewVTMFileWriter::Write_Data(){ } multiBlockFile.close(); } - + } void CParaviewVTMFileWriter::AddDataset(string name, string file, CParallelDataSorter* dataSorter){ - + /*--- Construct the full file name incl. folder ---*/ - + string fullFilename = folderName + "/zone_" + to_string(iZone) + "/" + file; - + /*--- Create an XML writer and dump data into file ---*/ - + CParaviewXMLFileWriter* XMLWriter = new CParaviewXMLFileWriter(fullFilename, dataSorter); XMLWriter->Write_Data(); delete XMLWriter; - + /*--- Add the dataset to the vtm file ---*/ - + AddDataset(name, fullFilename + CParaviewXMLFileWriter::fileExt); - + } diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 9f566d99af4..2c571790862 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -32,7 +32,7 @@ const string CParaviewXMLFileWriter::fileExt = ".vtu"; CParaviewXMLFileWriter::CParaviewXMLFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : CFileWriter(std::move(valFileName), valDataSorter, fileExt){ - + /* Check for big endian. We have to swap bytes otherwise. * Since size of character is 1 byte when the character pointer * is de-referenced it will contain only first byte of integer. ---*/ @@ -42,7 +42,7 @@ CParaviewXMLFileWriter::CParaviewXMLFileWriter(string valFileName, CParallelData char *c = (char*)&i; if (*c) bigEndian = false; else bigEndian = true; - + } @@ -51,17 +51,17 @@ CParaviewXMLFileWriter::~CParaviewXMLFileWriter(){ } void CParaviewXMLFileWriter::Write_Data(){ - - + + if (!dataSorter->GetConnectivitySorted()){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } - - const int NCOORDS = 3; + + const int NCOORDS = 3; const vector fieldNames = dataSorter->GetFieldNames(); unsigned short iDim = 0, nDim = dataSorter->GetnDim(); - + dataOffset = 0; unsigned long iPoint, iElem; @@ -120,13 +120,13 @@ void CParaviewXMLFileWriter::Write_Data(){ SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + fileName, CURRENT_FUNCTION); } -#endif - +#endif + /*--- Write the initial strings to the file. Only the master will write the header lines, but all ranks will store the offsets. ---*/ disp = 0; - + /*--- Communicate the number of total points that will be written by each rank. After this communication, each proc knows how many poinnts will be written before its location in the file and the @@ -152,7 +152,7 @@ void CParaviewXMLFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); - + SU2_MPI::Allreduce(&nParallel_Line, &nTot_Line, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); SU2_MPI::Allreduce(&nParallel_Tria, &nTot_Tria, 1, @@ -177,50 +177,50 @@ void CParaviewXMLFileWriter::Write_Data(){ nTot_Hexa + nTot_Pris + nTot_Pyra); GlobalElemStorage = (nTot_Line*2 + nTot_Tria*3 + nTot_Quad*4 + nTot_Tetr*4 + nTot_Hexa*8 + nTot_Pris*6 + nTot_Pyra*5); - + /* Write the ASCII XML header. Note that we use the appended format for the data, * which means that all data is appended at the end of the file in one binary blob. */ - + if (!bigEndian){ WriteString("\n", MASTER_NODE); } else { - WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); } - WriteString("\n", MASTER_NODE); - - SPRINTF(str_buf, "\n", + WriteString("\n", MASTER_NODE); + + SPRINTF(str_buf, "\n", SU2_TYPE::Int(GlobalPoint), SU2_TYPE::Int(GlobalElem)); - + WriteString(std::string(str_buf), MASTER_NODE); - WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); AddDataArray(VTKDatatype::FLOAT32, "", NCOORDS, myPoint*NCOORDS, GlobalPoint*NCOORDS); WriteString("\n", MASTER_NODE); WriteString("\n", MASTER_NODE); AddDataArray(VTKDatatype::INT32, "connectivity", 1, myElemStorage, GlobalElemStorage); AddDataArray(VTKDatatype::INT32, "offsets", 1, myElem, GlobalElem); AddDataArray(VTKDatatype::UINT8, "types", 1, myElem, GlobalElem); - WriteString("\n", MASTER_NODE); - + WriteString("\n", MASTER_NODE); + WriteString("\n", MASTER_NODE); - + /*--- Adjust container start location to avoid point coords. ---*/ - + unsigned short varStart = 2; if (nDim == 3) varStart++; - + /*--- Loop over all variables that have been registered in the output. ---*/ - + unsigned short iField, VarCounter = varStart; for (iField = varStart; iField < fieldNames.size(); iField++) { - + string fieldname = fieldNames[iField]; fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), fieldname.end()); - + /*--- Check whether this field is a vector or scalar. ---*/ - + bool output_variable = true, isVector = false; size_t found = fieldNames[iField].find("_x"); if (found!=string::npos) { @@ -239,28 +239,28 @@ void CParaviewXMLFileWriter::Write_Data(){ output_variable = false; VarCounter++; } - + /*--- Write the point data as an vector or a scalar. ---*/ - + if (output_variable && isVector) { - + /*--- Adjust the string name to remove the leading "X-" ---*/ - + fieldname.erase(fieldname.end()-2,fieldname.end()); - + AddDataArray(VTKDatatype::FLOAT32, fieldname, NCOORDS, myPoint*NCOORDS, GlobalPoint*NCOORDS); - + } else if (output_variable) { - + AddDataArray(VTKDatatype::FLOAT32, fieldname, 1, myPoint, GlobalPoint); - + } - + } WriteString("\n", MASTER_NODE); WriteString("\n", MASTER_NODE); WriteString("\n", MASTER_NODE); - + int *nPoint_Snd = new int[size+1]; int *nPoint_Cum = new int[size+1]; @@ -280,11 +280,11 @@ void CParaviewXMLFileWriter::Write_Data(){ for (int ii = 0; ii < size; ii++) { nPoint_Cum[ii+1] += nPoint_Cum[ii]; } - + /*--- Now write all the data we have previously defined into the binary section of the file ---*/ - + WriteString("\n_", MASTER_NODE); - + /*--- Load/write the 1D buffer of point coordinates. Note that we always have 3 coordinate dimensions, even for 2D problems. ---*/ @@ -301,7 +301,7 @@ void CParaviewXMLFileWriter::Write_Data(){ } WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, NCOORDS*myPoint, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); - + /*--- Communicate the number of total cells/storage that will be written by each rank. After this communication, each proc knows how many cells will be written before its location in the file and the @@ -333,14 +333,14 @@ void CParaviewXMLFileWriter::Write_Data(){ nElem_Cum[ii+1] += nElem_Cum[ii]; nElemStorage_Cum[ii+1] += nElemStorage_Cum[ii]; } - + /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ vector connBuf(myElemStorage); vector offsetBuf(myElem); unsigned long iStorage = 0, iElemID = 0; unsigned short iNode = 0; - + auto copyToBuffer = [&](GEO_TYPE type, unsigned long nElem, unsigned short nPoints){ for (iElem = 0; iElem < nElem; iElem++) { for (iNode = 0; iNode < nPoints; iNode++){ @@ -350,7 +350,7 @@ void CParaviewXMLFileWriter::Write_Data(){ offsetBuf[iElemID++] = int(iStorage + nElemStorage_Cum[rank]); } }; - + copyToBuffer(LINE, nParallel_Line, N_POINTS_LINE); copyToBuffer(TRIANGLE, nParallel_Tria, N_POINTS_TRIANGLE); copyToBuffer(QUADRILATERAL, nParallel_Quad, N_POINTS_QUADRILATERAL); @@ -361,12 +361,12 @@ void CParaviewXMLFileWriter::Write_Data(){ WriteDataArray(connBuf.data(), VTKDatatype::INT32, myElemStorage, GlobalElemStorage, nElemStorage_Cum[rank]); WriteDataArray(offsetBuf.data(), VTKDatatype::INT32, myElem, GlobalElem, nElem_Cum[rank]); - + /*--- Load/write the cell type for all elements in the file. ---*/ vector typeBuf(myElem); vector::iterator typeIter = typeBuf.begin(); - + std::fill(typeIter, typeIter+nParallel_Line, LINE); typeIter += nParallel_Line; std::fill(typeIter, typeIter+nParallel_Tria, TRIANGLE); typeIter += nParallel_Tria; std::fill(typeIter, typeIter+nParallel_Quad, QUADRILATERAL); typeIter += nParallel_Quad; @@ -374,7 +374,7 @@ void CParaviewXMLFileWriter::Write_Data(){ std::fill(typeIter, typeIter+nParallel_Hexa, HEXAHEDRON); typeIter += nParallel_Hexa; std::fill(typeIter, typeIter+nParallel_Pris, PRISM); typeIter += nParallel_Pris; std::fill(typeIter, typeIter+nParallel_Pyra, PYRAMID); typeIter += nParallel_Pyra; - + WriteDataArray(typeBuf.data(), VTKDatatype::UINT8, myElem, GlobalElem, nElem_Cum[rank]); /*--- Loop over all variables that have been registered in the output. ---*/ @@ -420,7 +420,7 @@ void CParaviewXMLFileWriter::Write_Data(){ } } } - + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint*NCOORDS, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); VarCounter++; @@ -435,17 +435,17 @@ void CParaviewXMLFileWriter::Write_Data(){ float val = (float)dataSorter->GetData(VarCounter,iPoint); dataBufferFloat[iPoint] = val; } - + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint, GlobalPoint, nPoint_Cum[rank]); - + VarCounter++; } } - + WriteString("\n", MASTER_NODE); WriteString("\n", MASTER_NODE); - + #ifdef HAVE_MPI /*--- All ranks close the file after writing. ---*/ @@ -486,12 +486,12 @@ void CParaviewXMLFileWriter::Write_Data(){ void CParaviewXMLFileWriter::WriteString(std::string str, int rankOut){ -#ifdef HAVE_MPI +#ifdef HAVE_MPI /*--- Reset the file view before writing the next ASCII line for cells. ---*/ MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL); - + if (SU2_MPI::GetRank() == rankOut) MPI_File_write_at(fhw, disp, str.c_str(), int(strlen(str.c_str())), MPI_CHAR, MPI_STATUS_IGNORE); @@ -503,113 +503,113 @@ void CParaviewXMLFileWriter::WriteString(std::string str, int rankOut){ fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); fileSize += sizeof(char)*strlen(str_buf); #endif - + } -void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, +void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, unsigned long globalSize, unsigned long offset){ - + unsigned long totalByteSize, byteSize; - + std::string typeStr; unsigned long typeSize; - + GetTypeInfo(type, typeStr, typeSize); - + /*--- Compute the size of the data to write in bytes ---*/ - + byteSize = arraySize*typeSize; - + /*--- The total data size ---*/ - + totalByteSize = globalSize*typeSize; - + #ifdef HAVE_MPI - + MPI_Datatype filetype; MPI_Status status; - + /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ - + MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, (char*)"native", MPI_INFO_NULL); - + if (SU2_MPI::GetRank() == MASTER_NODE) MPI_File_write_at(fhw, disp, &totalByteSize, sizeof(int), MPI_BYTE, MPI_STATUS_IGNORE); - + disp += sizeof(int); - + /*--- Prepare to write the actual data ---*/ - + MPI_Type_contiguous(int(byteSize), MPI_BYTE, &filetype); MPI_Type_commit(&filetype); - + /*--- Set the view for the MPI file write, i.e., describe the location in the file that this rank "sees" for writing its piece of the file. ---*/ - + MPI_File_set_view(fhw, disp + offset*typeSize, MPI_BYTE, filetype, (char*)"native", MPI_INFO_NULL); - + /*--- Collective call for all ranks to write simultaneously. ---*/ - + MPI_File_write_all(fhw, data, int(byteSize), MPI_BYTE, &status); MPI_Type_free(&filetype); - + disp += totalByteSize; fileSize += byteSize; #else /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ fwrite(&totalByteSize, sizeof(int),1, fhw); - + /*--- Write binary data ---*/ - + fwrite(data, sizeof(char), byteSize, fhw); fileSize += byteSize; #endif } -void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, +void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, unsigned short nComponents, unsigned long arraySize, unsigned long globalSize){ - + /*--- Add quotation marks around the arguments ---*/ - + name = "\"" + name + "\""; - + string nComp ="\"" + PrintingToolbox::to_string(nComponents) + "\""; - + /*--- Full precision ASCII output of offset for 32 bit integer ---*/ - + stringstream ss; ss.precision(10); ss.setf(std::ios::fixed, std::ios::floatfield); ss << "\"" << dataOffset << "\""; string offsetStr = ss.str(); - + std::string typeStr; unsigned long typeSize, byteSize, totalByteSize; - + GetTypeInfo(type, typeStr, typeSize); /*--- Compute the size of the data to write in bytes ---*/ - + byteSize = arraySize*typeSize; - + /*--- Total data size ---*/ - + totalByteSize = globalSize*typeSize; - + /*--- Write the ASCII XML header information for this array ---*/ - + WriteString(string("\n"), MASTER_NODE); - + string(" format=\"appended\"/>\n"), MASTER_NODE); + dataOffset += totalByteSize + sizeof(int); - + } diff --git a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp index a25d10ea677..571d144e100 100644 --- a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -42,7 +42,7 @@ void CSU2BinaryFileWriter::Write_Data(){ /*--- Local variables ---*/ unsigned short iVar; - + const vector fieldNames = dataSorter->GetFieldNames(); unsigned short GlobalField_Counter = fieldNames.size(); unsigned long nParallel_Poin = dataSorter->GetnPoints(); diff --git a/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp index 47dcc239dc5..2e61a890b39 100644 --- a/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp index 9408e133bf1..0df64b8b2af 100644 --- a/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 4ea8a07b2ab..8d6cb17c81b 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -33,7 +33,7 @@ CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometr CParallelDataSorter(config, valVolumeSorter->GetFieldNames()){ nDim = geometry->GetnDim(); - + this->volumeSorter = valVolumeSorter; connectivitySorted = false; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 5f2cdfb3275..ee760aded69 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -33,7 +33,7 @@ CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometr CParallelDataSorter(config, valVolumeSorter->GetFieldNames()){ nDim = geometry->GetnDim(); - + this->volumeSorter = valVolumeSorter; connectivitySorted = false; @@ -446,9 +446,9 @@ void CSurfaceFVMDataSorter::SortOutputData() { if (passiveDoubleBuffer != NULL){ delete [] passiveDoubleBuffer; } - + passiveDoubleBuffer = new passivedouble[nParallel_Poin*VARS_PER_POINT]; - + for (int jj = 0; jj < VARS_PER_POINT; jj++) { count = 0; for (int ii = 0; ii < (int)volumeSorter->GetnPoints(); ii++) { @@ -1104,13 +1104,13 @@ void CSurfaceFVMDataSorter::SortOutputData() { void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) { std::vector markerList; - + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ if (config->GetMarker_All_Plotting(iMarker) == YES) { markerList.push_back(config->GetMarker_All_TagBound(iMarker)); } } - + /*--- Sort connectivity for each type of element (excluding halos). Note In these routines, we sort the connectivity into a linear partitioning across all processors based on the global index of the grid nodes. ---*/ @@ -1214,11 +1214,11 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * nElem_Send[size] = 0; nElem_Recv[size] = 0; for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - + string markerTag = config->GetMarker_All_TagBound(iMarker); - + auto it = std::find(markerList.begin(), markerList.end(), markerTag); - + if (it != markerList.end()) { for (int ii = 0; ii < (int)geometry->GetnElem_Bound(iMarker); ii++) { @@ -1313,11 +1313,11 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * additional data that we will send to the other procs. ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - + string markerTag = config->GetMarker_All_TagBound(iMarker); - + auto it = std::find(markerList.begin(), markerList.end(), markerTag); - + if (it != markerList.end()) { for (int ii = 0; ii < (int)geometry->GetnElem_Bound(iMarker); ii++) { @@ -1528,13 +1528,13 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * case TRIANGLE: nParallel_Tria = nElem_Total; if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; - Conn_Tria_Par = NULL; + Conn_Tria_Par = NULL; if (nParallel_Tria > 0) Conn_Tria_Par = Conn_Elem; break; case QUADRILATERAL: nParallel_Quad = nElem_Total; if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; - Conn_Quad_Par = NULL; + Conn_Quad_Par = NULL; if (nParallel_Quad > 0) Conn_Quad_Par = Conn_Elem; break; default: diff --git a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp index cae5257fdbf..5ee46228e36 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -54,7 +54,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ #endif #ifdef HAVE_TECIO - + const vector fieldNames = dataSorter->GetFieldNames(); /*--- Reduce the total number of each element. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp index 5a982197129..1b2cc4388f4 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -40,7 +40,7 @@ void CTecplotFileWriter::Write_Data(){ if (!dataSorter->GetConnectivitySorted()){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } - + const vector fieldNames = dataSorter->GetFieldNames(); unsigned short iVar; From 1708fa3935540c9ab7db319809146921141ae9f4 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Thu, 9 Jan 2020 19:04:47 +0100 Subject: [PATCH 31/61] Added marker specific sorting routine to FEM sorter --- .../output/filewriter/CParallelDataSorter.hpp | 2 +- .../filewriter/CSurfaceFEMDataSorter.hpp | 21 +++++++--- .../filewriter/CSurfaceFVMDataSorter.hpp | 17 ++++++-- .../filewriter/CSurfaceFEMDataSorter.cpp | 42 ++++++++++++++++--- .../filewriter/CSurfaceFVMDataSorter.cpp | 5 ++- 5 files changed, 69 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index 6453cefeee5..09f53ee946b 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -132,7 +132,7 @@ class CParallelDataSorter{ * \param[in] geometry - Geometrical definition of the problem. * \param[in] markerList - A list of marker names that should be sorted. */ - virtual void SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList){} + virtual void SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList){} /*! * \brief Get the number of points the local rank owns. diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp index 5ed79491aae..6f19c88f575 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp @@ -58,12 +58,22 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ void SortOutputData() override; /*! - * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. + * \brief Sort the connectivities on the surface into data structures used for output file writing. + * All markers in MARKER_PLOTTING will be sorted. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_sort - boolean controlling whether the elements are sorted or simply loaded by their owning rank. + * \param[in] surf - boolean controlling whether surface or volume connectivity should be sorted. */ - void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; + void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; + + /*! + * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. + * Only markers in the markerList argument will be sorted. + * \param[in] config - Definition of the particular problem. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] markerList - List of markers to sort. + */ + void SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList) override; /*! * \brief Get the global index of a point. @@ -77,11 +87,12 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ private: /*! - * \brief Sort the connectivity for a single surface element type into a linear partitioning across all processors (DG-FEM solver). + * \brief Sort the connectivity for a single surface element type into a linear partitioning across all processors. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] Elem_Type - VTK index of the element type being merged. */ - void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type); + void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, + const vector &markerList); }; diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index c3ec2f99a21..a930699a0b2 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -57,13 +57,23 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ void SortOutputData() override; /*! - * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. + * \brief Sort the connectivities on the surface into data structures used for output file writing. + * All markers in MARKER_PLOTTING will be sorted. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] surf - boolean controlling whether surface or volume connectivity should be sorted. */ void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; + /*! + * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. + * Only markers in the markerList argument will be sorted. + * \param[in] config - Definition of the particular problem. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] markerList - List of markers to sort. + */ + void SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList) override; + /*! * \brief Get the global index of a point. * \input iPoint - the point ID. @@ -73,8 +83,6 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ return Renumber2Global.at(iPoint); } - void SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList) override; - private: @@ -84,6 +92,7 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * \param[in] geometry - Geometrical definition of the problem. * \param[in] Elem_Type - VTK index of the element type being merged. */ - void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, vector markerList); + void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, + const vector &markerList); }; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 8d6cb17c81b..fbbc8639dff 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -337,10 +337,18 @@ void CSurfaceFEMDataSorter::SortOutputData() { } void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) { + + std::vector markerList; - SortSurfaceConnectivity(config, geometry, LINE ); - SortSurfaceConnectivity(config, geometry, TRIANGLE ); - SortSurfaceConnectivity(config, geometry, QUADRILATERAL); + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ + if (config->GetMarker_All_Plotting(iMarker) == YES) { + markerList.push_back(config->GetMarker_All_TagBound(iMarker)); + } + } + + SortSurfaceConnectivity(config, geometry, LINE , markerList); + SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); + SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; @@ -354,9 +362,27 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } +void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList) { + + SortSurfaceConnectivity(config, geometry, LINE , markerList); + SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); + SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + + + unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; +#ifndef HAVE_MPI + nGlobal_Elem_Par = nTotal_Surf_Elem; +#else + SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); +#endif + + connectivitySorted = true; + +} -void CSurfaceFEMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type) { +void CSurfaceFEMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, + const vector &markerList) { /* Determine the number of nodes for this element type. */ unsigned short NODES_PER_ELEMENT = 0; @@ -401,7 +427,9 @@ void CSurfaceFEMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * unsigned long nSubElem_Local = 0; for(unsigned short iMarker=0; iMarker < config->GetnMarker_All(); ++iMarker) { if( !boundaries[iMarker].periodicBoundary ) { - if (config->GetMarker_All_Plotting(iMarker) == YES) { + string markerTag = config->GetMarker_All_TagBound(iMarker); + auto it = std::find(markerList.begin(), markerList.end(), markerTag); + if (it != markerList.end()) { const vector &surfElem = boundaries[iMarker].surfElem; for(unsigned long i=0; iGetnMarker_All(); ++iMarker) { if( !boundaries[iMarker].periodicBoundary ) { - if (config->GetMarker_All_Plotting(iMarker) == YES) { + string markerTag = config->GetMarker_All_TagBound(iMarker); + auto it = std::find(markerList.begin(), markerList.end(), markerTag); + if (it != markerList.end()) { const vector &surfElem = boundaries[iMarker].surfElem; /* Loop over the surface elements of this boundary marker. */ diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index ee760aded69..1bf77c3ad9c 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -1133,7 +1133,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } -void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, vector markerList) { +void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList) { /*--- Sort connectivity for each type of element (excluding halos). Note In these routines, we sort the connectivity into a linear partitioning @@ -1157,7 +1157,8 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } -void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, vector markerList) { +void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, + const vector &markerList) { unsigned long iProcessor; unsigned short NODES_PER_ELEMENT; From 87c8117629a583359f5e45fb6552dd44b36d313c Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Thu, 9 Jan 2020 19:26:41 +0100 Subject: [PATCH 32/61] Small fix --- .../src/output/filewriter/CSurfaceFEMDataSorter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index fbbc8639dff..75a07843422 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -224,10 +224,12 @@ void CSurfaceFEMDataSorter::SortOutputData() { /* Allocate the memory for Parallel_Surf_Data. */ nParallel_Poin = globalSurfaceDOFIDs.size(); - if (passiveDoubleBuffer == nullptr){ - passiveDoubleBuffer = new passivedouble[nParallel_Poin*VARS_PER_POINT]; + if (passiveDoubleBuffer != NULL){ + delete [] passiveDoubleBuffer; } + passiveDoubleBuffer = new passivedouble[nParallel_Poin*VARS_PER_POINT]; + /* Determine the local index of the global surface DOFs and copy the data into Parallel_Surf_Data. */ for(unsigned long i=0; iGetnMarker_All(); ++iMarker) { if( !boundaries[iMarker].periodicBoundary ) { - string markerTag = config->GetMarker_All_TagBound(iMarker); + string markerTag = boundaries[iMarker].markerTag; auto it = std::find(markerList.begin(), markerList.end(), markerTag); if (it != markerList.end()) { const vector &surfElem = boundaries[iMarker].surfElem; @@ -450,7 +452,7 @@ void CSurfaceFEMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * unsigned long kNode = 0; for(unsigned short iMarker=0; iMarker < config->GetnMarker_All(); ++iMarker) { if( !boundaries[iMarker].periodicBoundary ) { - string markerTag = config->GetMarker_All_TagBound(iMarker); + string markerTag = boundaries[iMarker].markerTag; auto it = std::find(markerList.begin(), markerList.end(), markerTag); if (it != markerList.end()) { const vector &surfElem = boundaries[iMarker].surfElem; From 81d6264790f452eb835edad09657ebe708a67660 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 10 Jan 2020 11:43:40 +0100 Subject: [PATCH 33/61] replacing most map accesses with at function --- SU2_CFD/include/output/COutput.hpp | 6 +- SU2_CFD/src/output/COutput.cpp | 93 +++++++++++++++--------------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 828bdf4471b..e45ce0754ba 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -356,11 +356,11 @@ class COutput { * \return Value of the field */ su2double GetHistoryFieldValue(string field){ - return historyOutput_Map[field].value; + return historyOutput_Map.at(field).value; } su2double GetHistoryFieldValuePerSurface(string field, unsigned short iMarker){ - return historyOutputPerSurface_Map[field][iMarker].value; + return historyOutputPerSurface_Map.at(field)[iMarker].value; } /*! @@ -371,7 +371,7 @@ class COutput { vector GetHistoryGroup(string groupname){ vector HistoryGroup; for (unsigned short iField = 0; iField < historyOutput_Map.size(); iField++){ - if (historyOutput_Map[historyOutput_List[iField]].outputGroup == groupname){ + if (historyOutput_Map.at(historyOutput_List[iField]).outputGroup == groupname){ HistoryGroup.push_back((historyOutput_Map[historyOutput_List[iField]])); } } diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 448d380ba40..871c404169f 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -768,19 +768,19 @@ void COutput::PrintConvergenceSummary(){ ConvSummary.PrintHeader(); for (unsigned short iField_Conv = 0; iField_Conv < convFields.size(); iField_Conv++){ const string &convField = convFields[iField_Conv]; - if (historyOutput_Map[convField].fieldType == HistoryFieldType::COEFFICIENT) { + if (historyOutput_Map.at(convField).fieldType == HistoryFieldType::COEFFICIENT) { string convMark = "No"; - if ( historyOutput_Map["CAUCHY_" + convField].value < cauchyEps) convMark = "Yes"; - ConvSummary << historyOutput_Map["CAUCHY_" + convField].fieldName - << historyOutput_Map["CAUCHY_" + convField].value + if ( historyOutput_Map.at("CAUCHY_" + convField).value < cauchyEps) convMark = "Yes"; + ConvSummary << historyOutput_Map.at("CAUCHY_" + convField).fieldName + << historyOutput_Map.at("CAUCHY_" + convField).value << " < " + PrintingToolbox::to_string(cauchyEps) << convMark; } - else if (historyOutput_Map[convField].fieldType == HistoryFieldType::RESIDUAL || - historyOutput_Map[convField].fieldType == HistoryFieldType::AUTO_RESIDUAL) { + else if (historyOutput_Map.at(convField).fieldType == HistoryFieldType::RESIDUAL || + historyOutput_Map.at(convField).fieldType == HistoryFieldType::AUTO_RESIDUAL) { string convMark = "No"; - if (historyOutput_Map[convField].value < minLogResidual) convMark = "Yes"; - ConvSummary << historyOutput_Map[convField].fieldName - << historyOutput_Map[convField].value + if (historyOutput_Map.at(convField).value < minLogResidual) convMark = "Yes"; + ConvSummary << historyOutput_Map.at(convField).fieldName + << historyOutput_Map.at(convField).value << " < " + PrintingToolbox::to_string(minLogResidual) << convMark; } } @@ -799,11 +799,11 @@ bool COutput::Convergence_Monitoring(CConfig *config, unsigned long Iteration) { const string &convField = convFields[iField_Conv]; if (historyOutput_Map.count(convField) > 0){ - su2double monitor = historyOutput_Map[convField].value; + su2double monitor = historyOutput_Map.at(convField).value; /*--- Cauchy based convergence criteria ---*/ - if (historyOutput_Map[convField].fieldType == HistoryFieldType::COEFFICIENT) { + if (historyOutput_Map.at(convField).fieldType == HistoryFieldType::COEFFICIENT) { if (Iteration == 0){ for (iCounter = 0; iCounter < nCauchy_Elems; iCounter++){ @@ -841,8 +841,8 @@ bool COutput::Convergence_Monitoring(CConfig *config, unsigned long Iteration) { /*--- Residual based convergence criteria ---*/ - if (historyOutput_Map[convField].fieldType == HistoryFieldType::RESIDUAL || - historyOutput_Map[convField].fieldType == HistoryFieldType::AUTO_RESIDUAL) { + if (historyOutput_Map.at(convField).fieldType == HistoryFieldType::RESIDUAL || + historyOutput_Map.at(convField).fieldType == HistoryFieldType::AUTO_RESIDUAL) { /*--- Check the convergence ---*/ @@ -907,7 +907,7 @@ void COutput::SetHistoryFile_Header(CConfig *config) { for (iField_Output = 0; iField_Output < historyOutput_List.size(); iField_Output++){ const string &fieldIdentifier = historyOutput_List[iField_Output]; - const HistoryOutputField &field = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField &field = historyOutput_Map.at(fieldIdentifier); for (iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ const string & requestedField = requestedHistoryFields[iReqField]; if (requestedField == field.outputGroup || (requestedField == fieldIdentifier)){ @@ -921,7 +921,7 @@ void COutput::SetHistoryFile_Header(CConfig *config) { for (iField_Output = 0; iField_Output < historyOutputPerSurface_List.size(); iField_Output++){ const string &fieldIdentifier = historyOutputPerSurface_List[iField_Output]; for (iMarker = 0; iMarker < historyOutputPerSurface_Map[fieldIdentifier].size(); iMarker++){ - const HistoryOutputField &field = historyOutputPerSurface_Map[fieldIdentifier][iMarker]; + const HistoryOutputField &field = historyOutputPerSurface_Map.at(fieldIdentifier)[iMarker]; for (iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ const string &requestedField = requestedHistoryFields[iReqField]; if (requestedField == field.outputGroup || (requestedField == fieldIdentifier)){ @@ -950,7 +950,7 @@ void COutput::SetHistoryFile_Output(CConfig *config) { for (iField_Output = 0; iField_Output < historyOutput_List.size(); iField_Output++){ const string &fieldIdentifier = historyOutput_List[iField_Output]; - const HistoryOutputField &field = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField &field = historyOutput_Map.at(fieldIdentifier); for (iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ const string &RequestedField = requestedHistoryFields[iReqField]; if (RequestedField == field.outputGroup){ @@ -962,7 +962,7 @@ void COutput::SetHistoryFile_Output(CConfig *config) { for (iField_Output = 0; iField_Output < historyOutputPerSurface_List.size(); iField_Output++){ const string &fieldIdentifier = historyOutputPerSurface_List[iField_Output]; for (iMarker = 0; iMarker < historyOutputPerSurface_Map[fieldIdentifier].size(); iMarker++){ - const HistoryOutputField &field = historyOutputPerSurface_Map[fieldIdentifier][iMarker]; + const HistoryOutputField &field = historyOutputPerSurface_Map.at(fieldIdentifier)[iMarker]; for (iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ const string &RequestedField = requestedHistoryFields[iReqField]; if (RequestedField == field.outputGroup){ @@ -992,28 +992,28 @@ void COutput::SetScreen_Output(CConfig *config) { stringstream out; RequestedField = requestedScreenFields[iReqField]; if (historyOutput_Map.count(RequestedField) > 0){ - switch (historyOutput_Map[RequestedField].screenFormat) { + switch (historyOutput_Map.at(RequestedField).screenFormat) { case ScreenOutputFormat::INTEGER: - PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(historyOutput_Map[RequestedField].value), fieldWidth); + PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(historyOutput_Map.at(RequestedField).value), fieldWidth); break; case ScreenOutputFormat::FIXED: - PrintingToolbox::PrintScreenFixed(out, historyOutput_Map[RequestedField].value, fieldWidth); + PrintingToolbox::PrintScreenFixed(out, historyOutput_Map.at(RequestedField).value, fieldWidth); break; case ScreenOutputFormat::SCIENTIFIC: - PrintingToolbox::PrintScreenScientific(out, historyOutput_Map[RequestedField].value, fieldWidth); + PrintingToolbox::PrintScreenScientific(out, historyOutput_Map.at(RequestedField).value, fieldWidth); break; } } if (historyOutputPerSurface_Map.count(RequestedField) > 0){ - switch (historyOutputPerSurface_Map[RequestedField][0].screenFormat) { + switch (historyOutputPerSurface_Map.at(RequestedField)[0].screenFormat) { case ScreenOutputFormat::INTEGER: - PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(historyOutputPerSurface_Map[RequestedField][0].value), fieldWidth); + PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(historyOutputPerSurface_Map.at(RequestedField)[0].value), fieldWidth); break; case ScreenOutputFormat::FIXED: - PrintingToolbox::PrintScreenFixed(out, historyOutputPerSurface_Map[RequestedField][0].value, fieldWidth); + PrintingToolbox::PrintScreenFixed(out, historyOutputPerSurface_Map.at(RequestedField)[0].value, fieldWidth); break; case ScreenOutputFormat::SCIENTIFIC: - PrintingToolbox::PrintScreenScientific(out, historyOutputPerSurface_Map[RequestedField][0].value, fieldWidth); + PrintingToolbox::PrintScreenScientific(out, historyOutputPerSurface_Map.at(RequestedField)[0].value, fieldWidth); break; } } @@ -1149,10 +1149,10 @@ void COutput::CheckHistoryOutput(){ for (unsigned short iReqField = 0; iReqField < nRequestedScreenFields; iReqField++){ requestedField = requestedScreenFields[iReqField]; if (historyOutput_Map.count(requestedField) > 0){ - convergenceTable->AddColumn(historyOutput_Map[requestedField].fieldName, fieldWidth); + convergenceTable->AddColumn(historyOutput_Map.at(requestedField).fieldName, fieldWidth); } else if (historyOutputPerSurface_Map.count(requestedField) > 0){ - convergenceTable->AddColumn(historyOutputPerSurface_Map[requestedField][0].fieldName, fieldWidth); + convergenceTable->AddColumn(historyOutputPerSurface_Map.at(requestedField)[0].fieldName, fieldWidth); }else { FieldsToRemove.push_back(requestedField); } @@ -1196,7 +1196,7 @@ void COutput::CheckHistoryOutput(){ for (unsigned short iField_Output = 0; iField_Output < historyOutput_List.size(); iField_Output++){ const string &fieldReference = historyOutput_List[iField_Output]; if (historyOutput_Map.count(fieldReference) > 0){ - const HistoryOutputField &field = historyOutput_Map[fieldReference]; + const HistoryOutputField &field = historyOutput_Map.at(fieldReference); for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ requestedField = requestedHistoryFields[iReqField]; if (requestedField == field.outputGroup){ @@ -1209,8 +1209,8 @@ void COutput::CheckHistoryOutput(){ for (unsigned short iField_Output = 0; iField_Output < historyOutputPerSurface_List.size(); iField_Output++){ const string &fieldReference = historyOutputPerSurface_List[iField_Output]; if (historyOutputPerSurface_Map.count(fieldReference) > 0){ - for (unsigned short iMarker = 0; iMarker < historyOutputPerSurface_Map[fieldReference].size(); iMarker++){ - const HistoryOutputField &Field = historyOutputPerSurface_Map[fieldReference][iMarker]; + for (unsigned short iMarker = 0; iMarker < historyOutputPerSurface_Map.at(fieldReference).size(); iMarker++){ + const HistoryOutputField &Field = historyOutputPerSurface_Map.at(fieldReference)[iMarker]; for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ requestedField = requestedHistoryFields[iReqField]; if (requestedField == Field.outputGroup){ @@ -1323,7 +1323,7 @@ void COutput::PreprocessVolumeOutput(CConfig *config){ const string &fieldReference = volumeOutput_List[iField_Output]; if (volumeOutput_Map.count(fieldReference) > 0){ - VolumeOutputField &Field = volumeOutput_Map[fieldReference]; + VolumeOutputField &Field = volumeOutput_Map.at(fieldReference); /*--- Loop through all fields specified in the config ---*/ @@ -1469,7 +1469,7 @@ void COutput::SetVolumeOutputValue(string name, unsigned long iPoint, su2double * the same for every value of iPoint --- */ if (volumeOutput_Map.count(name) > 0){ - const short Offset = volumeOutput_Map[name].offset; + const short Offset = volumeOutput_Map.at(name).offset; fieldIndexCache.push_back(Offset); if (Offset != -1){ volumeDataSorter->SetUnsorted_Data(iPoint, Offset, value); @@ -1501,7 +1501,7 @@ su2double COutput::GetVolumeOutputValue(string name, unsigned long iPoint){ * the same for every value of iPoint --- */ if (volumeOutput_Map.count(name) > 0){ - const short Offset = volumeOutput_Map[name].offset; + const short Offset = volumeOutput_Map.at(name).offset; fieldGetIndexCache.push_back(Offset); if (Offset != -1){ return volumeDataSorter->GetUnsorted_Data(iPoint, Offset); @@ -1537,7 +1537,7 @@ void COutput::SetAvgVolumeOutputValue(string name, unsigned long iPoint, su2doub * the same for every value of iPoint --- */ if (volumeOutput_Map.count(name) > 0){ - const short Offset = volumeOutput_Map[name].offset; + const short Offset = volumeOutput_Map.at(name).offset; fieldIndexCache.push_back(Offset); if (Offset != -1){ @@ -1579,7 +1579,7 @@ void COutput::Postprocess_HistoryData(CConfig *config){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ const string &fieldIdentifier = historyOutput_List[iField]; - const HistoryOutputField ¤tField = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField ¤tField = historyOutput_Map.at(fieldIdentifier); if (currentField.fieldType == HistoryFieldType::RESIDUAL){ if ( SetInit_Residuals(config) || (currentField.value > initialResiduals[fieldIdentifier]) ) { initialResiduals[fieldIdentifier] = currentField.value; @@ -1627,7 +1627,7 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ const string &fieldIdentifier = historyOutput_List[iField]; - const HistoryOutputField ¤tField = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField ¤tField = historyOutput_Map.at(fieldIdentifier); if (currentField.fieldType == HistoryFieldType::RESIDUAL){ AddHistoryOutput("REL_" + fieldIdentifier, "rel" + currentField.fieldName, currentField.screenFormat, "REL_" + currentField.outputGroup, "Relative residual.", HistoryFieldType::AUTO_RESIDUAL); @@ -1646,7 +1646,7 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ if (config->GetTime_Domain()){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ const string &fieldIdentifier = historyOutput_List[iField]; - const HistoryOutputField ¤tField = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField ¤tField = historyOutput_Map.at(fieldIdentifier); if (currentField.fieldType == HistoryFieldType::COEFFICIENT){ AddHistoryOutput("TAVG_" + fieldIdentifier, "tavg[" + currentField.fieldName + "]", currentField.screenFormat, "TAVG_" + currentField.outputGroup, "Time averaged values.", @@ -1658,7 +1658,7 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ if (config->GetDirectDiff()){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ const string &fieldIdentifier = historyOutput_List[iField]; - const HistoryOutputField ¤tField = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField ¤tField = historyOutput_Map.at(fieldIdentifier); if (currentField.fieldType == HistoryFieldType::COEFFICIENT){ AddHistoryOutput("D_" + fieldIdentifier, "d[" + currentField.fieldName + "]", currentField.screenFormat, "D_" + currentField.outputGroup, @@ -1670,7 +1670,7 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ if (config->GetTime_Domain() && config->GetDirectDiff()){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ const string &fieldIdentifier = historyOutput_List[iField]; - const HistoryOutputField ¤tField = historyOutput_Map[fieldIdentifier]; + const HistoryOutputField ¤tField = historyOutput_Map.at(fieldIdentifier); if (currentField.fieldType == HistoryFieldType::COEFFICIENT){ AddHistoryOutput("D_TAVG_" + fieldIdentifier, "dtavg[" + currentField.fieldName + "]", currentField.screenFormat, "D_TAVG_" + currentField.outputGroup, @@ -1683,8 +1683,9 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ const string &convField = convFields[iFieldConv]; if (historyOutput_Map.count(convField) > 0){ if (historyOutput_Map[convField].fieldType == HistoryFieldType::COEFFICIENT){ - AddHistoryOutput("CAUCHY_" + convField, "Cauchy[" + historyOutput_Map[convField].fieldName + "]", ScreenOutputFormat::SCIENTIFIC, "CAUCHY", - "Cauchy residual value of field set with CONV_FIELD." ,HistoryFieldType::AUTO_COEFFICIENT); + AddHistoryOutput("CAUCHY_" + convField, "Cauchy[" + historyOutput_Map.at(convField).fieldName + "]", + ScreenOutputFormat::SCIENTIFIC, "CAUCHY", "Cauchy residual value of field set with CONV_FIELD.", + HistoryFieldType::AUTO_COEFFICIENT); } } } @@ -1888,7 +1889,7 @@ void COutput::PrintHistoryFields(){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ - HistoryOutputField &Field = historyOutput_Map[historyOutput_List[iField]]; + HistoryOutputField &Field = historyOutput_Map.at(historyOutput_List[iField]); if (Field.description != ""){ if (historyOutput_List[iField].size() > NameSize){ @@ -1915,7 +1916,7 @@ void COutput::PrintHistoryFields(){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ - HistoryOutputField &Field = historyOutput_Map[historyOutput_List[iField]]; + HistoryOutputField &Field = historyOutput_Map.at(historyOutput_List[iField]); if (Field.fieldType == HistoryFieldType::DEFAULT || Field.fieldType == HistoryFieldType::COEFFICIENT @@ -1958,7 +1959,7 @@ void COutput::PrintHistoryFields(){ for (unsigned short iField = 0; iField < historyOutput_List.size(); iField++){ - HistoryOutputField &Field = historyOutput_Map[historyOutput_List[iField]]; + HistoryOutputField &Field = historyOutput_Map.at(historyOutput_List[iField]); if ((Field.fieldType == HistoryFieldType::AUTO_COEFFICIENT || Field.fieldType == HistoryFieldType::AUTO_RESIDUAL) && (GroupVisited.count(Field.outputGroup) == 0)){ @@ -1996,7 +1997,7 @@ void COutput::PrintVolumeFields(){ for (unsigned short iField = 0; iField < volumeOutput_List.size(); iField++){ - VolumeOutputField &Field = volumeOutput_Map[volumeOutput_List[iField]]; + VolumeOutputField &Field = volumeOutput_Map.at(volumeOutput_List[iField]); if (Field.description != ""){ if (volumeOutput_List[iField].size() > NameSize){ @@ -2022,7 +2023,7 @@ void COutput::PrintVolumeFields(){ for (unsigned short iField = 0; iField < volumeOutput_List.size(); iField++){ - VolumeOutputField &Field = volumeOutput_Map[volumeOutput_List[iField]]; + VolumeOutputField &Field = volumeOutput_Map.at(volumeOutput_List[iField]); if (Field.description != "") VolumeFieldTable << volumeOutput_List[iField] << Field.outputGroup << Field.description; From 32895cd204db48bf04c4342e5e2c0b3ba32ca5a4 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 10 Jan 2020 11:44:11 +0100 Subject: [PATCH 34/61] Disabling per-zone history files by default --- SU2_CFD/src/output/CMultizoneOutput.cpp | 2 +- SU2_CFD/src/output/COutput.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/output/CMultizoneOutput.cpp b/SU2_CFD/src/output/CMultizoneOutput.cpp index 1d753e15dcd..2bf7f492234 100644 --- a/SU2_CFD/src/output/CMultizoneOutput.cpp +++ b/SU2_CFD/src/output/CMultizoneOutput.cpp @@ -67,7 +67,7 @@ CMultizoneOutput::CMultizoneOutput(CConfig* driver_config, CConfig** config, uns multiZoneHeaderString = "Multizone Summary"; - historyFilename = "multizone_history"; + historyFilename = driver_config->GetCaseName(); /*--- Add the correct file extension depending on the file format ---*/ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 871c404169f..169fe8cc284 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1024,7 +1024,7 @@ void COutput::SetScreen_Output(CConfig *config) { void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){ - noWriting = !wrt; + noWriting = !wrt || !WriteHistoryFile_Output(config); /*--- Set the common output fields ---*/ @@ -1791,6 +1791,12 @@ bool COutput::WriteHistoryFile_Output(CConfig *config) { unsigned long HistoryWrt_Freq_Outer = config->GetHistory_Wrt_Freq(1); unsigned long HistoryWrt_Freq_Time = config->GetHistory_Wrt_Freq(0); + if (config->GetMultizone_Problem() && !config->GetWrt_ZoneConv()){ + + return false; + + } + /*--- Check if screen output should be written --- */ if (!PrintOutput(curTimeIter, HistoryWrt_Freq_Time)&& From 953ada71cc5c62823164dc857515b15086984300 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 10 Jan 2020 16:24:05 +0100 Subject: [PATCH 35/61] Small fix --- SU2_CFD/src/output/COutput.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 169fe8cc284..dde404e7fc5 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1024,7 +1024,7 @@ void COutput::SetScreen_Output(CConfig *config) { void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){ - noWriting = !wrt || !WriteHistoryFile_Output(config); + noWriting = !wrt; /*--- Set the common output fields ---*/ @@ -1052,8 +1052,8 @@ void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){ CheckHistoryOutput(); /*--- Open history file and print the header ---*/ - - PrepareHistoryFile(config); + if (!config->GetMultizone_Problem() || config->GetWrt_ZoneConv()) + PrepareHistoryFile(config); total_width = nRequestedScreenFields*fieldWidth + (nRequestedScreenFields-1); From 156a0826f0102beee1cefed24fbb090cebef059e Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 14 Jan 2020 14:55:55 +0100 Subject: [PATCH 36/61] Small fixes and comments --- Common/src/config_structure.cpp | 3 ++ SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 2 +- SU2_CFD/src/output/COutput.cpp | 2 +- .../filewriter/CParaviewXMLFileWriter.cpp | 34 +++++++++---------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 71d22b3bf48..8aa61678139 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -774,6 +774,7 @@ void CConfig::SetPointersNull(void) { HistoryOutput = NULL; VolumeOutput = NULL; VolumeOutputFiles = NULL; + ConvField = NULL; /*--- Variable initialization ---*/ @@ -7550,6 +7551,8 @@ CConfig::~CConfig(void) { if (VolumeOutput != NULL) delete [] VolumeOutput; if (Mesh_Box_Size != NULL) delete [] Mesh_Box_Size; if (VolumeOutputFiles != NULL) delete [] VolumeOutputFiles; + + if (ConvField != NULL) delete [] ConvField; } diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index b2900cdd348..5e347f32d17 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -271,7 +271,7 @@ bool CSinglezoneDriver::Monitor(unsigned long TimeIter){ if ((MaxIterationsReached || InnerConvergence) && (rank == MASTER_NODE)) { cout << endl << "----------------------------- Solver Exit -------------------------------" << endl; if (InnerConvergence) cout << "All convergence criteria satisfied." << endl; - else cout << endl << "Maximum number of iterations reached (ITER = " << nInnerIter << " ) before convergence." << endl; + else cout << endl << "Maximum number of iterations reached (ITER = " << nInnerIter << ") before convergence." << endl; output_container[ZONE_0]->PrintConvergenceSummary(); cout << "-------------------------------------------------------------------------" << endl; } diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index dde404e7fc5..8c64f1baa07 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -492,7 +492,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f if (rank == MASTER_NODE) { (*fileWritingTable) << "Paraview Multiblock" - << fileName + CParaviewVTMFileWriter::fileExt + " -> " + vtmWriter->GetFolderName(); + << fileName + CParaviewVTMFileWriter::fileExt; } /*--- Open a block for the zone ---*/ diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 2c571790862..9eda9f0b907 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -52,29 +52,27 @@ CParaviewXMLFileWriter::~CParaviewXMLFileWriter(){ void CParaviewXMLFileWriter::Write_Data(){ - if (!dataSorter->GetConnectivitySorted()){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } + /*--- We always have 3 coords, independent of the actual value of nDim ---*/ + const int NCOORDS = 3; - const vector fieldNames = dataSorter->GetFieldNames(); - - unsigned short iDim = 0, nDim = dataSorter->GetnDim(); - - dataOffset = 0; + const unsigned short nDim = dataSorter->GetnDim(); + unsigned short iDim = 0; + + /*--- Array containing the field names we want to output ---*/ + + const vector& fieldNames = dataSorter->GetFieldNames(); unsigned long iPoint, iElem; - - ofstream Paraview_File; - - const int MAX_STRING_LENGTH = 255; - char str_buf[MAX_STRING_LENGTH], fname[100]; - - strcpy(fname, fileName.c_str()); + + char str_buf[255]; fileSize = 0.0; - + dataOffset = 0; + /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI @@ -94,14 +92,14 @@ void CParaviewXMLFileWriter::Write_Data(){ to write a fresh output file, so we delete any existing files and create a new one. ---*/ - ierr = MPI_File_open(MPI_COMM_WORLD, fname, + ierr = MPI_File_open(MPI_COMM_WORLD, fileName.c_str(), MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, MPI_INFO_NULL, &fhw); if (ierr != MPI_SUCCESS) { MPI_File_close(&fhw); if (rank == 0) - MPI_File_delete(fname, MPI_INFO_NULL); - ierr = MPI_File_open(MPI_COMM_WORLD, fname, + MPI_File_delete(fileName.c_str(), MPI_INFO_NULL); + ierr = MPI_File_open(MPI_COMM_WORLD, fileName.c_str(), MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, MPI_INFO_NULL, &fhw); } @@ -110,7 +108,7 @@ void CParaviewXMLFileWriter::Write_Data(){ if (ierr) { SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - string(fname), CURRENT_FUNCTION); + string(fileName), CURRENT_FUNCTION); } #else fhw = fopen(fname, "wb"); From d1a19c540445d0391bf2dcb105601fe415aea846 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 14 Jan 2020 16:11:32 +0100 Subject: [PATCH 37/61] Small fix for non-mpi compilation --- SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 9eda9f0b907..9d7fe0d565b 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -108,10 +108,10 @@ void CParaviewXMLFileWriter::Write_Data(){ if (ierr) { SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - string(fileName), CURRENT_FUNCTION); + fileName, CURRENT_FUNCTION); } #else - fhw = fopen(fname, "wb"); + fhw = fopen(fileName.c_str(), "wb"); /*--- Error check for opening the file. ---*/ if (!fhw) { From 5bcc0ba98cebc02caca8edd8f0f5d22827a6c0d3 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Wed, 15 Jan 2020 14:17:25 +0100 Subject: [PATCH 38/61] Fixed whitespaces in all output files --- .../include/output/CAdjElasticityOutput.hpp | 2 +- SU2_CFD/include/output/CAdjFlowIncOutput.hpp | 6 +- SU2_CFD/include/output/CAdjFlowOutput.hpp | 2 +- SU2_CFD/include/output/CAdjHeatOutput.hpp | 2 +- SU2_CFD/include/output/CBaselineOutput.hpp | 2 +- SU2_CFD/include/output/CElasticityOutput.hpp | 2 +- SU2_CFD/include/output/CFlowCompFEMOutput.hpp | 2 +- SU2_CFD/include/output/CFlowCompOutput.hpp | 2 +- SU2_CFD/include/output/CFlowIncOutput.hpp | 2 +- SU2_CFD/include/output/CFlowOutput.hpp | 2 +- SU2_CFD/include/output/CHeatOutput.hpp | 2 +- SU2_CFD/include/output/CMeshOutput.hpp | 2 +- SU2_CFD/include/output/CMultizoneOutput.hpp | 2 +- SU2_CFD/include/output/COutput.hpp | 4 +- SU2_CFD/include/output/COutputLegacy.hpp | 2 +- .../filewriter/CSurfaceFEMDataSorter.hpp | 4 +- .../filewriter/CSurfaceFVMDataSorter.hpp | 6 +- .../include/output/tools/CWindowingTools.hpp | 2 +- SU2_CFD/src/output/CAdjElasticityOutput.cpp | 2 +- SU2_CFD/src/output/CAdjFlowCompOutput.cpp | 2 +- SU2_CFD/src/output/CAdjFlowIncOutput.cpp | 2 +- SU2_CFD/src/output/CAdjHeatOutput.cpp | 2 +- SU2_CFD/src/output/CBaselineOutput.cpp | 2 +- SU2_CFD/src/output/CElasticityOutput.cpp | 6 +- SU2_CFD/src/output/CFlowCompFEMOutput.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 16 +-- SU2_CFD/src/output/CFlowIncOutput.cpp | 20 +-- SU2_CFD/src/output/CFlowOutput.cpp | 2 +- SU2_CFD/src/output/CHeatOutput.cpp | 2 +- SU2_CFD/src/output/CMeshOutput.cpp | 2 +- SU2_CFD/src/output/CMultizoneOutput.cpp | 2 +- SU2_CFD/src/output/COutput.cpp | 124 +++++++++--------- .../filewriter/CParaviewXMLFileWriter.cpp | 10 +- .../filewriter/CSurfaceFEMDataSorter.cpp | 2 +- .../filewriter/CSurfaceFVMDataSorter.cpp | 2 +- SU2_CFD/src/output/tools/CWindowingTools.cpp | 2 +- SU2_DOT/src/meson.build | 92 ++++++------- 37 files changed, 171 insertions(+), 171 deletions(-) diff --git a/SU2_CFD/include/output/CAdjElasticityOutput.hpp b/SU2_CFD/include/output/CAdjElasticityOutput.hpp index 5209c10c171..6f7dd5c9b18 100644 --- a/SU2_CFD/include/output/CAdjElasticityOutput.hpp +++ b/SU2_CFD/include/output/CAdjElasticityOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp index fcd6e7d4bf6..e800dd509fb 100644 --- a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -37,8 +37,8 @@ class CAdjFlowIncOutput final: public COutput { private: - unsigned short turb_model; /*!< \brief The kind of turbulence model*/ - bool heat; /*!< \brief Boolean indicating whether have a heat problem*/ + unsigned short turb_model; /*!< \brief The kind of turbulence model*/ + bool heat; /*!< \brief Boolean indicating whether have a heat problem*/ bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/ public: diff --git a/SU2_CFD/include/output/CAdjFlowOutput.hpp b/SU2_CFD/include/output/CAdjFlowOutput.hpp index 98a2b7f511d..b5edb94919f 100644 --- a/SU2_CFD/include/output/CAdjFlowOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CAdjHeatOutput.hpp b/SU2_CFD/include/output/CAdjHeatOutput.hpp index b9bd919d234..f6d00015ddf 100644 --- a/SU2_CFD/include/output/CAdjHeatOutput.hpp +++ b/SU2_CFD/include/output/CAdjHeatOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CBaselineOutput.hpp b/SU2_CFD/include/output/CBaselineOutput.hpp index 87c48fccfc6..cde5de6183d 100644 --- a/SU2_CFD/include/output/CBaselineOutput.hpp +++ b/SU2_CFD/include/output/CBaselineOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CElasticityOutput.hpp b/SU2_CFD/include/output/CElasticityOutput.hpp index 63fbea8b97d..db6bfe77431 100644 --- a/SU2_CFD/include/output/CElasticityOutput.hpp +++ b/SU2_CFD/include/output/CElasticityOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp index 881f0bd9ba3..6e827a1a6ec 100644 --- a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index 7e7d78d0d60..a63b261c920 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CFlowIncOutput.hpp b/SU2_CFD/include/output/CFlowIncOutput.hpp index 06470d7551b..17e631fe23b 100644 --- a/SU2_CFD/include/output/CFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CFlowIncOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index c95cfb20695..5456d68d90c 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CHeatOutput.hpp b/SU2_CFD/include/output/CHeatOutput.hpp index 4ba40cd1e98..c5a1e46a641 100644 --- a/SU2_CFD/include/output/CHeatOutput.hpp +++ b/SU2_CFD/include/output/CHeatOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CMeshOutput.hpp b/SU2_CFD/include/output/CMeshOutput.hpp index 96f8ed61ae2..8b3d8460332 100644 --- a/SU2_CFD/include/output/CMeshOutput.hpp +++ b/SU2_CFD/include/output/CMeshOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/CMultizoneOutput.hpp b/SU2_CFD/include/output/CMultizoneOutput.hpp index 0af442e1795..446fdd08abe 100644 --- a/SU2_CFD/include/output/CMultizoneOutput.hpp +++ b/SU2_CFD/include/output/CMultizoneOutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 7fef9a3add0..fd6579eaf99 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -224,7 +224,7 @@ class COutput { su2double initResidual; /*!< \brief Initial value of the residual to evaluate the convergence level. */ vector convFields; /*!< \brief Name of the field to be monitored for convergence. */ - /*----------------------------- Adaptive CFL ----------------------------*/ + /*----------------------------- Adaptive CFL ----------------------------*/ su2double rhoResNew, /*!< New value of the residual for adaptive CFL routine. */ rhoResOld; /*!< Old value of the residual for adaptive CFL routine. */ diff --git a/SU2_CFD/include/output/COutputLegacy.hpp b/SU2_CFD/include/output/COutputLegacy.hpp index 9d62a1bbb40..7a32ccc9c70 100644 --- a/SU2_CFD/include/output/COutputLegacy.hpp +++ b/SU2_CFD/include/output/COutputLegacy.hpp @@ -7,7 +7,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp index 6f19c88f575..85aa72ebec5 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp @@ -67,8 +67,8 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; /*! - * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. - * Only markers in the markerList argument will be sorted. + * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. + * Only markers in the markerList argument will be sorted. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] markerList - List of markers to sort. diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index a930699a0b2..06e01f16aea 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -66,14 +66,14 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; /*! - * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. - * Only markers in the markerList argument will be sorted. + * \brief Sort the connectivities (volume and surface) into data structures used for output file writing. + * Only markers in the markerList argument will be sorted. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] markerList - List of markers to sort. */ void SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList) override; - + /*! * \brief Get the global index of a point. * \input iPoint - the point ID. diff --git a/SU2_CFD/include/output/tools/CWindowingTools.hpp b/SU2_CFD/include/output/tools/CWindowingTools.hpp index d0f2e9f07ab..688d8153fd5 100644 --- a/SU2_CFD/include/output/tools/CWindowingTools.hpp +++ b/SU2_CFD/include/output/tools/CWindowingTools.hpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CAdjElasticityOutput.cpp b/SU2_CFD/src/output/CAdjElasticityOutput.cpp index 8e47cce60af..f3f60adeaf5 100644 --- a/SU2_CFD/src/output/CAdjElasticityOutput.cpp +++ b/SU2_CFD/src/output/CAdjElasticityOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp index 526416815a1..8df167eba77 100644 --- a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index c10140927ac..544cbfd12bb 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CAdjHeatOutput.cpp b/SU2_CFD/src/output/CAdjHeatOutput.cpp index 2fc086d0964..d76223f0f04 100644 --- a/SU2_CFD/src/output/CAdjHeatOutput.cpp +++ b/SU2_CFD/src/output/CAdjHeatOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CBaselineOutput.cpp b/SU2_CFD/src/output/CBaselineOutput.cpp index 7a8fde8e5ba..1d79d555a14 100644 --- a/SU2_CFD/src/output/CBaselineOutput.cpp +++ b/SU2_CFD/src/output/CBaselineOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index d8c5db7b995..ee81a1013ee 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -133,8 +133,8 @@ void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("LINSOL_ITER", fea_solver->GetIterLinSolver()); SetHistoryOutputValue("LINSOL_RESIDUAL", log10(fea_solver->GetResLinSolver())); - -} + +} void CElasticityOutput::SetHistoryOutputFields(CConfig *config){ diff --git a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp index 26c494f0859..61213f582e8 100644 --- a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index de4f4d1e477..35f5b23c833 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -236,15 +236,15 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: Temperature AddHistoryOutput("TEMPERATURE", "Temp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total avg. temperature on all surfaces set with MARKER_MONITORING.", HistoryFieldType::COEFFICIENT); /// END_GROUP - + AddHistoryOutput("MIN_DELTA_TIME", "Min DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum local time step"); AddHistoryOutput("MAX_DELTA_TIME", "Max DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum local time step"); - + AddHistoryOutput("MIN_CFL", "Min CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum of the local CFL numbers"); AddHistoryOutput("MAX_CFL", "Max CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum of the local CFL numbers"); AddHistoryOutput("AVG_CFL", "Avg CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current average of the local CFL numbers"); - - /// /// BEGIN_GROUP: FIXED_CL, DESCRIPTION: Relevant outputs for the Fixed CL mode + + /// /// BEGIN_GROUP: FIXED_CL, DESCRIPTION: Relevant outputs for the Fixed CL mode if (config->GetFixed_CL_Mode()){ /// DESCRIPTION: Difference between current and target CL @@ -641,14 +641,14 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetHistoryOutputValue("HEATFLUX", flow_solver->GetTotal_HeatFlux()); SetHistoryOutputValue("HEATFLUX_MAX", flow_solver->GetTotal_MaxHeatFlux()); SetHistoryOutputValue("TEMPERATURE", flow_solver->GetTotal_AvgTemperature()); - + SetHistoryOutputValue("MIN_DELTA_TIME", flow_solver->GetMin_Delta_Time()); SetHistoryOutputValue("MAX_DELTA_TIME", flow_solver->GetMax_Delta_Time()); - + SetHistoryOutputValue("MIN_CFL", flow_solver->GetMin_CFL_Local()); SetHistoryOutputValue("MAX_CFL", flow_solver->GetMax_CFL_Local()); SetHistoryOutputValue("AVG_CFL", flow_solver->GetAvg_CFL_Local()); - + SetHistoryOutputValue("LINSOL_ITER", flow_solver->GetIterLinSolver()); SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetResLinSolver())); diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 2c4e1e59da8..652c68a7228 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -193,7 +193,7 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("MIN_DELTA_TIME", "Min DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum local time step"); AddHistoryOutput("MAX_DELTA_TIME", "Max DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum local time step"); - + AddHistoryOutput("MIN_CFL", "Min CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum of the local CFL numbers"); AddHistoryOutput("MAX_CFL", "Max CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum of the local CFL numbers"); AddHistoryOutput("AVG_CFL", "Avg CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current average of the local CFL numbers"); @@ -295,21 +295,21 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv SetHistoryOutputValue("LINSOL_ITER", flow_solver->GetIterLinSolver()); SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetResLinSolver())); - + if (config->GetDeform_Mesh()){ SetHistoryOutputValue("DEFORM_MIN_VOLUME", mesh_solver->GetMinimum_Volume()); SetHistoryOutputValue("DEFORM_MAX_VOLUME", mesh_solver->GetMaximum_Volume()); SetHistoryOutputValue("DEFORM_ITER", mesh_solver->GetIterLinSolver()); SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetResLinSolver())); } - + SetHistoryOutputValue("MIN_DELTA_TIME", flow_solver->GetMin_Delta_Time()); SetHistoryOutputValue("MAX_DELTA_TIME", flow_solver->GetMax_Delta_Time()); - + SetHistoryOutputValue("MIN_CFL", flow_solver->GetMin_CFL_Local()); SetHistoryOutputValue("MAX_CFL", flow_solver->GetMax_CFL_Local()); SetHistoryOutputValue("AVG_CFL", flow_solver->GetAvg_CFL_Local()); - + /*--- Set the analyse surface history values --- */ SetAnalyzeSurface(flow_solver, geometry, config, false); @@ -602,10 +602,10 @@ void CFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolv } bool CFlowIncOutput::SetInit_Residuals(CConfig *config){ - - return (config->GetTime_Marching() != STEADY && (curInnerIter == 0))|| - (config->GetTime_Marching() == STEADY && (curInnerIter < 2)); - + + return (config->GetTime_Marching() != STEADY && (curInnerIter == 0))|| + (config->GetTime_Marching() == STEADY && (curInnerIter < 2)); + } bool CFlowIncOutput::SetUpdate_Averages(CConfig *config){ diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 576dbd74310..b06b2fc8650 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index 7996de870a0..8cb97267204 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CMeshOutput.cpp b/SU2_CFD/src/output/CMeshOutput.cpp index 94b81a6c0dd..34d4198cca9 100644 --- a/SU2_CFD/src/output/CMeshOutput.cpp +++ b/SU2_CFD/src/output/CMeshOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/CMultizoneOutput.cpp b/SU2_CFD/src/output/CMultizoneOutput.cpp index 2bf7f492234..c2a36fad535 100644 --- a/SU2_CFD/src/output/CMultizoneOutput.cpp +++ b/SU2_CFD/src/output/CMultizoneOutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 790942ceb3e..039f0dfd233 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) @@ -451,122 +451,122 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f break; case PARAVIEW_XML: - + if (fileName.empty()) fileName = config->GetFilename(volumeFilename, "", curTimeIter); - + /*--- Load and sort the output data and connectivity. ---*/ - + volumeDataSorter->SortConnectivity(config, geometry, true); - + /*--- Write paraview binary ---*/ if (rank == MASTER_NODE) { (*fileWritingTable) << "Paraview" << fileName + CParaviewXMLFileWriter::fileExt; } - + fileWriter = new CParaviewXMLFileWriter(fileName, volumeDataSorter); - + break; - + case PARAVIEW_BINARY: - + if (fileName.empty()) fileName = config->GetFilename(volumeFilename, "", curTimeIter); - + /*--- Load and sort the output data and connectivity. ---*/ - + volumeDataSorter->SortConnectivity(config, geometry, true); - + /*--- Write paraview binary ---*/ if (rank == MASTER_NODE) { (*fileWritingTable) << "Paraview" << fileName + CParaviewBinaryFileWriter::fileExt; } - + fileWriter = new CParaviewBinaryFileWriter(fileName, volumeDataSorter); - + break; - + case PARAVIEW_MULTIBLOCK: - { + { if (fileName.empty()) fileName = config->GetFilename(volumeFilename, "", curTimeIter); - + /*--- Sort volume connectivity ---*/ - - volumeDataSorter->SortConnectivity(config, geometry, true); + + volumeDataSorter->SortConnectivity(config, geometry, true); /*--- The file name of the multiblock file is the case name (i.e. the config file name w/o ext.) ---*/ - + fileName = config->GetUnsteady_FileName(config->GetCaseName(), curTimeIter, ""); - + /*--- Allocate the vtm file writer ---*/ - - fileWriter = new CParaviewVTMFileWriter(fileName, fileName, GetHistoryFieldValue("CUR_TIME"), + + fileWriter = new CParaviewVTMFileWriter(fileName, fileName, GetHistoryFieldValue("CUR_TIME"), config->GetiZone(), config->GetnZone()); - + /*--- We cast the pointer to its true type, to avoid virtual functions ---*/ - + CParaviewVTMFileWriter* vtmWriter = dynamic_cast(fileWriter); - + if (rank == MASTER_NODE) { - (*fileWritingTable) << "Paraview Multiblock" + (*fileWritingTable) << "Paraview Multiblock" << fileName + CParaviewVTMFileWriter::fileExt; } - + /*--- Open a block for the zone ---*/ - + vtmWriter->StartBlock(multiZoneHeaderString); - - fileName = "Internal"; - + + fileName = "Internal"; + /*--- Open a block for the internal (volume) data and add the dataset ---*/ - + vtmWriter->StartBlock(fileName); vtmWriter->AddDataset(fileName, fileName, volumeDataSorter); vtmWriter->EndBlock(); - + /*--- Open a block for the boundary ---*/ - + vtmWriter->StartBlock("Boundary"); - + /*--- Loop over all markers used in the config file ---*/ - + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_CfgFile(); iMarker++){ - + /*--- Get the name of the marker ---*/ - + string markerTag = config->GetMarker_CfgFile_TagBound(iMarker); - + /*--- If the current marker can be found on this partition store its name. - * Note that we have to provide a vector of markers to the sorter routine, although we only do + * Note that we have to provide a vector of markers to the sorter routine, although we only do * one marker at a time, i.e. ::marker always contains one item. ---*/ - - vector marker; - for (unsigned short jMarker = 0; jMarker < config->GetnMarker_All(); jMarker++){ + + vector marker; + for (unsigned short jMarker = 0; jMarker < config->GetnMarker_All(); jMarker++){ /*--- We want to write all markers except send-receive markers ---*/ - - if (config->GetMarker_All_TagBound(jMarker) == markerTag && + + if (config->GetMarker_All_TagBound(jMarker) == markerTag && config->GetMarker_All_KindBC(jMarker) != SEND_RECEIVE){ marker.push_back(markerTag); } } - + /*--- Only sort if there is at least one processor that has this marker ---*/ - - int globalMarkerSize = 0, localMarkerSize = marker.size(); + + int globalMarkerSize = 0, localMarkerSize = marker.size(); SU2_MPI::Allreduce(&localMarkerSize, &globalMarkerSize, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); - + if (globalMarkerSize > 0){ - + /*--- Sort connectivity of the current marker ---*/ - + surfaceDataSorter->SortConnectivity(config, geometry, marker); surfaceDataSorter->SortOutputData(); - + /*--- Add the dataset ---*/ - + vtmWriter->AddDataset(markerTag, markerTag, surfaceDataSorter); } @@ -576,8 +576,8 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f /*--- End "Zone" block ---*/ vtmWriter->EndBlock(); } - - + + break; case PARAVIEW: @@ -635,7 +635,7 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f fileWriter = new CParaviewBinaryFileWriter(fileName, surfaceDataSorter); break; - + case SURFACE_PARAVIEW_XML: if (fileName.empty()) @@ -1931,7 +1931,7 @@ bool COutput::WriteHistoryFile_Output(CConfig *config) { return false; } - + /*--- Check if screen output should be written --- */ if (!PrintOutput(curTimeIter, HistoryWrt_Freq_Time)&& @@ -1992,15 +1992,15 @@ void COutput::SetCommonHistoryFields(CConfig *config){ } void COutput::LoadCommonHistoryData(CConfig *config){ - + SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref()); /*--- Update the current time time only if the time iteration has changed ---*/ - + if (SU2_TYPE::Int(GetHistoryFieldValue("TIME_ITER")) != curTimeIter){ - SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); + SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); } - + SetHistoryOutputValue("TIME_ITER", curTimeIter); SetHistoryOutputValue("INNER_ITER", curInnerIter); SetHistoryOutputValue("OUTER_ITER", curOuterIter); diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 9d7fe0d565b..57a601b972e 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -57,22 +57,22 @@ void CParaviewXMLFileWriter::Write_Data(){ } /*--- We always have 3 coords, independent of the actual value of nDim ---*/ - + const int NCOORDS = 3; const unsigned short nDim = dataSorter->GetnDim(); unsigned short iDim = 0; - + /*--- Array containing the field names we want to output ---*/ - + const vector& fieldNames = dataSorter->GetFieldNames(); unsigned long iPoint, iElem; - + char str_buf[255]; fileSize = 0.0; dataOffset = 0; - + /*--- Set a timer for the file writing. ---*/ #ifndef HAVE_MPI diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 75a07843422..517a46f3477 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -339,7 +339,7 @@ void CSurfaceFEMDataSorter::SortOutputData() { } void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) { - + std::vector markerList; for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++){ diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 1bf77c3ad9c..1e4045c357e 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -1157,7 +1157,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } -void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, +void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, const vector &markerList) { unsigned long iProcessor; diff --git a/SU2_CFD/src/output/tools/CWindowingTools.cpp b/SU2_CFD/src/output/tools/CWindowingTools.cpp index eae5c814996..9ea5fb9c41e 100644 --- a/SU2_CFD/src/output/tools/CWindowingTools.cpp +++ b/SU2_CFD/src/output/tools/CWindowingTools.cpp @@ -6,7 +6,7 @@ * * SU2 Project Website: https://su2code.github.io * - * The SU2 Project is maintained by the SU2 Foundation + * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index cfadee40df7..85d63a57554 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -1,29 +1,29 @@ su2_dot_src = ['SU2_DOT.cpp'] if get_option('enable-normal') su2_cfd_obj = su2_cfd.extract_objects(['solver_structure.cpp', - 'CMarkerProfileReaderFVM.cpp', - 'output/COutput.cpp', - 'output/output_structure_legacy.cpp', - 'output/tools/CWindowingTools.cpp', - 'output/CBaselineOutput.cpp', - 'output/filewriter/CParallelDataSorter.cpp', - 'output/filewriter/CParallelFileWriter.cpp', - 'output/filewriter/CFEMDataSorter.cpp', - 'output/filewriter/CSurfaceFEMDataSorter.cpp', - 'output/filewriter/CFVMDataSorter.cpp', - 'output/filewriter/CSurfaceFVMDataSorter.cpp', - 'output/filewriter/CCSVFileWriter.cpp', - 'output/filewriter/CTecplotFileWriter.cpp', - 'output/filewriter/CTecplotBinaryFileWriter.cpp', - 'output/filewriter/CParaviewFileWriter.cpp', - 'output/filewriter/CParaviewBinaryFileWriter.cpp', - 'output/filewriter/CSU2FileWriter.cpp', - 'output/filewriter/CSU2BinaryFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp', - 'output/filewriter/CParaviewXMLFileWriter.cpp', - 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'CMarkerProfileReaderFVM.cpp', + 'output/COutput.cpp', + 'output/output_structure_legacy.cpp', + 'output/tools/CWindowingTools.cpp', + 'output/CBaselineOutput.cpp', + 'output/filewriter/CParallelDataSorter.cpp', + 'output/filewriter/CParallelFileWriter.cpp', + 'output/filewriter/CFEMDataSorter.cpp', + 'output/filewriter/CSurfaceFEMDataSorter.cpp', + 'output/filewriter/CFVMDataSorter.cpp', + 'output/filewriter/CSurfaceFVMDataSorter.cpp', + 'output/filewriter/CCSVFileWriter.cpp', + 'output/filewriter/CTecplotFileWriter.cpp', + 'output/filewriter/CTecplotBinaryFileWriter.cpp', + 'output/filewriter/CParaviewFileWriter.cpp', + 'output/filewriter/CParaviewBinaryFileWriter.cpp', + 'output/filewriter/CSU2FileWriter.cpp', + 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot = executable('SU2_DOT', su2_dot_src, @@ -37,29 +37,29 @@ endif if get_option('enable-autodiff') su2_dot_src_ad = ['SU2_DOT.cpp'] su2_cfd_obj_ad = su2_cfd_ad.extract_objects(['solver_structure.cpp', - 'CMarkerProfileReaderFVM.cpp', - 'output/COutput.cpp', - 'output/tools/CWindowingTools.cpp', - 'output/output_structure_legacy.cpp', - 'output/CBaselineOutput.cpp', - 'output/filewriter/CParallelDataSorter.cpp', - 'output/filewriter/CParallelFileWriter.cpp', - 'output/filewriter/CFEMDataSorter.cpp', - 'output/filewriter/CSurfaceFEMDataSorter.cpp', - 'output/filewriter/CFVMDataSorter.cpp', - 'output/filewriter/CSurfaceFVMDataSorter.cpp', - 'output/filewriter/CCSVFileWriter.cpp', - 'output/filewriter/CTecplotFileWriter.cpp', - 'output/filewriter/CTecplotBinaryFileWriter.cpp', - 'output/filewriter/CParaviewFileWriter.cpp', - 'output/filewriter/CParaviewBinaryFileWriter.cpp', - 'output/filewriter/CSU2FileWriter.cpp', - 'output/filewriter/CSU2BinaryFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp', - 'output/filewriter/CParaviewXMLFileWriter.cpp', - 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'CMarkerProfileReaderFVM.cpp', + 'output/COutput.cpp', + 'output/tools/CWindowingTools.cpp', + 'output/output_structure_legacy.cpp', + 'output/CBaselineOutput.cpp', + 'output/filewriter/CParallelDataSorter.cpp', + 'output/filewriter/CParallelFileWriter.cpp', + 'output/filewriter/CFEMDataSorter.cpp', + 'output/filewriter/CSurfaceFEMDataSorter.cpp', + 'output/filewriter/CFVMDataSorter.cpp', + 'output/filewriter/CSurfaceFVMDataSorter.cpp', + 'output/filewriter/CCSVFileWriter.cpp', + 'output/filewriter/CTecplotFileWriter.cpp', + 'output/filewriter/CTecplotBinaryFileWriter.cpp', + 'output/filewriter/CParaviewFileWriter.cpp', + 'output/filewriter/CParaviewBinaryFileWriter.cpp', + 'output/filewriter/CSU2FileWriter.cpp', + 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CParaviewXMLFileWriter.cpp', + 'output/filewriter/CParaviewVTMFileWriter.cpp', + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot_ad = executable('SU2_DOT_AD', su2_dot_src_ad, From 757898afbc89dcb2904a696b8b40c256b71ef363 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Wed, 15 Jan 2020 15:00:42 +0100 Subject: [PATCH 39/61] Adding const --- Common/include/config_structure.hpp | 2 +- Common/include/config_structure.inl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 042a9ea15ce..547ed90d362 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -9360,7 +9360,7 @@ class CConfig { * \brief Get the name of the current case * \return the case name */ - string GetCaseName(); + const string& GetCaseName() const; }; #include "config_structure.inl" diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index 48e22e2961c..308b098d45a 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -2090,4 +2090,4 @@ inline unsigned short CConfig::GetnVolumeOutputFiles() {return nVolumeOutputFile inline bool CConfig::OptionIsSet(string option){ return all_options.find(option) == all_options.end();} -inline string CConfig::GetCaseName(){ return caseName;} +inline const string& CConfig::GetCaseName() const { return caseName;} From dff465c004e12440fcbed8ae45e72ba6e1966ede Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 14:09:23 +0100 Subject: [PATCH 40/61] Adding common routines to write to a file using MPI I/O the CFileWriter class --- .../include/output/filewriter/CFileWriter.hpp | 68 ++++++- .../output/filewriter/CParallelFileWriter.cpp | 188 ++++++++++++++++++ 2 files changed, 255 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index 1b245356d72..9f242255499 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -83,6 +83,29 @@ class CFileWriter{ * \brief The parallel data sorter */ CParallelDataSorter* dataSorter; + +#ifdef HAVE_MPI + /*! + * \brief The displacement that every process has in the current file view + */ + MPI_Offset disp; + + /*! + * \brief The file handle for writing + */ + MPI_File fhw; +#else + + /*! + * \brief The displacement that every process has in the current file view + */ + unsigned long disp; + + /*! + * \brief The file handle for writing + */ + FILE* fhw; +#endif public: /*! @@ -122,9 +145,52 @@ class CFileWriter{ /*! * \brief Get the used time of the last file writing. - * \return + * \return The time used to write to file. */ su2double Get_UsedTime() const {return usedTime;} + +protected: + + /*! + * \brief Collectively write a binary data array distributed over all processors to file using MPI I/O. + * \param[in] data - Pointer to the data to write. + * \param sizeInBytes - The size of the data in bytes on this processor. + * \param totalSizeInBytes - The total size of the array accumulated over all processors. + * \param offset - The offset in bytes of the chunk of data the current processor owns within the global array. + * \return Boolean indicating whether the writing was successful. + */ + bool WriteMPIBinaryDataAll(void *data, unsigned long sizeInBytes, unsigned long totalSizeInBytes, unsigned long offset); + /*! + * \brief Write a binary data array to a currently opened file using MPI I/O. Note: routine must be called collectively, + * although only one processor writes its data. + * \param[in] data - Pointer to the beginning of the data. Can be NULL for all processors that do not write. + * \param[in] sizeInBytes - The size of the data in bytes. + * \param[in] processor - Rank of the processor that should write its data. + * \return Boolean indicating whether the writing was successful. + */ + bool WriteMPIBinaryData(void *data, unsigned long sizeInBytes, unsigned short processor); + + /*! + * \brief Write a string to a currently opened file using MPI I/O. Note: routine must be called collectively, + * although only one processor writes the string. + * \param[in] str - The string to write to file. + * \param[in] processor - Rank of the processor that should the string. + * \return + */ + bool WriteMPIString(const std::string& str, unsigned short processor); + + /*! + * \brief Open a file to write using MPI I/O. Already existing file is deleted. + * \return Boolean indicating whether the opening was successful. + */ + bool OpenMPIFile(); + + /*! + * \brief Close a file using MPI I/O. + * \return Boolean indicating whether the closing was successful. + */ + bool CloseMPIFile(); + }; diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index f3cb56135a8..513ac8c6ebc 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -61,4 +61,192 @@ CFileWriter::~CFileWriter(){ } +bool CFileWriter::WriteMPIBinaryDataAll(void *data, unsigned long sizeInBytes, + unsigned long totalSizeInBytes, unsigned long offsetInBytes){ + +#ifdef HAVE_MPI + + MPI_Datatype filetype; + + /*--- Prepare to write the actual data ---*/ + + MPI_Type_contiguous(int(sizeInBytes), MPI_BYTE, &filetype); + MPI_Type_commit(&filetype); + + /*--- Set the view for the MPI file write, i.e., describe the + location in the file that this rank "sees" for writing its + piece of the file. ---*/ + + MPI_File_set_view(fhw, disp + offsetInBytes, MPI_BYTE, filetype, + (char*)"native", MPI_INFO_NULL); + + /*--- Collective call for all ranks to write simultaneously. ---*/ + + int ierr = MPI_File_write_all(fhw, data, int(sizeInBytes), MPI_BYTE, MPI_STATUS_IGNORE); + + MPI_Type_free(&filetype); + + disp += totalSizeInBytes; + fileSize += sizeInBytes; + + return (ierr == MPI_SUCCESS); +#else + + unsigned long bytesWritten; + + /*--- Write binary data ---*/ + + bytesWritte = fwrite(data, sizeof(char), sizeInBytes, fhw); + fileSize += byteSize; + + return (bytesWritten == sizeInBytes); +#endif + +} + +bool CFileWriter::WriteMPIBinaryData(void *data, unsigned long sizeInBytes, unsigned short processor){ + +#ifdef HAVE_MPI + + int ierr = MPI_SUCCESS; + + /*--- Reset the file view. ---*/ + + MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, + (char*)"native", MPI_INFO_NULL); + + if (rank == processor) + ierr = MPI_File_write_at(fhw, disp, data, int(sizeInBytes), MPI_BYTE, MPI_STATUS_IGNORE); + + disp += sizeInBytes; + fileSize += sizeInBytes; + + return (ierr == MPI_SUCCESS); +#else + + unsigned long bytesWritten = sizeInBytes; + + /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ + + bytesWritten = fwrite(&totalByteSize, sizeof(int),1, fhw); + + return (bytesWritten == sizeInBytes); + +#endif + +} + +bool CFileWriter::WriteMPIString(const string &str, unsigned short processor){ + +#ifdef HAVE_MPI + + int ierr = MPI_SUCCESS; + + /*--- Reset the file view. ---*/ + + MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, + (char*)"native", MPI_INFO_NULL); + + if (SU2_MPI::GetRank() == processor) + ierr = MPI_File_write_at(fhw, disp, str.c_str(), str.size(), + MPI_CHAR, MPI_STATUS_IGNORE); + disp += str.size()*sizeof(char); + fileSize += sizeof(char)*str.size(); + + return (ierr == MPI_SUCCESS); + +#else + unsigned long bytesWritten; + bytesWritten = fwrite(str.c_str(), sizeof(char), str.size(), fhw); + + fileSize += bytesWritten; + + return (bytesWritten == sizeInBytes); + +#endif + +} + +bool CFileWriter::OpenMPIFile(){ + + int ierr; + +#ifdef HAVE_MPI + /*--- All ranks open the file using MPI. Here, we try to open the file with + exclusive so that an error is generated if the file exists. We always want + to write a fresh output file, so we delete any existing files and create + a new one. ---*/ + + ierr = MPI_File_open(MPI_COMM_WORLD, fileName.c_str(), + MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, + MPI_INFO_NULL, &fhw); + if (ierr != MPI_SUCCESS) { + MPI_File_close(&fhw); + if (rank == 0) + MPI_File_delete(fileName.c_str(), MPI_INFO_NULL); + ierr = MPI_File_open(MPI_COMM_WORLD, fileName.c_str(), + MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, + MPI_INFO_NULL, &fhw); + } + + /*--- Error check opening the file. ---*/ + + if (ierr) { + SU2_MPI::Error(string("Unable to open file ") + + fileName, CURRENT_FUNCTION); + } +#else + fhw = fopen(fileName.c_str(), "wb"); + /*--- Error check for opening the file. ---*/ + + if (!fhw) { + SU2_MPI::Error(string("Unable to open file ") + + fileName, CURRENT_FUNCTION); + } +#endif + + disp = 0.0; + fileSize = 0.0; + + /*--- Set a timer for the file writing. ---*/ + +#ifndef HAVE_MPI + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + startTime = MPI_Wtime(); +#endif + + return true; +} + +bool CFileWriter::CloseMPIFile(){ + +#ifdef HAVE_MPI + /*--- All ranks close the file after writing. ---*/ + + MPI_File_close(&fhw); +#else + fclose(fhw); +#endif + /*--- Compute and store the write time. ---*/ + +#ifndef HAVE_MPI + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + stopTime = MPI_Wtime(); +#endif + usedTime = stopTime-startTime; + + /*--- Communicate the total file size for the restart ---*/ + + su2double my_fileSize = fileSize; + SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, + MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + /*--- Compute and store the bandwidth ---*/ + + bandwidth = fileSize/(1.0e6)/usedTime; + + return true; +} From 52d6eac7bc0bad42058d3a21142d74acca5cc5b1 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 14:10:02 +0100 Subject: [PATCH 41/61] use new routines for MPI I/O writing in XML writer --- .../filewriter/CParaviewXMLFileWriter.hpp | 7 - .../filewriter/CParaviewXMLFileWriter.cpp | 206 +++--------------- 2 files changed, 35 insertions(+), 178 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index f1b65cdb2aa..05644bf11a5 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -101,13 +101,6 @@ class CParaviewXMLFileWriter final: public CFileWriter{ private: - /*! - * \brief Write a string to the vtu file - * \param[in] str - The string to write to file - * \param[in] rank - The rank that should write the string - */ - void WriteString(std::string str, int rankOut); - /*! * \brief Add a new data array definition to the vtu file. * \param[in] type - The vtk datatype diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 57a601b972e..65652af332a 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -70,61 +70,10 @@ void CParaviewXMLFileWriter::Write_Data(){ char str_buf[255]; - fileSize = 0.0; + OpenMPIFile(); + dataOffset = 0; - /*--- Set a timer for the file writing. ---*/ - -#ifndef HAVE_MPI - startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - startTime = MPI_Wtime(); -#endif - - - /*--- Parallel binary output using MPI I/O. ---*/ - - int ierr; - -#ifdef HAVE_MPI - /*--- All ranks open the file using MPI. Here, we try to open the file with - exclusive so that an error is generated if the file exists. We always want - to write a fresh output file, so we delete any existing files and create - a new one. ---*/ - - ierr = MPI_File_open(MPI_COMM_WORLD, fileName.c_str(), - MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, - MPI_INFO_NULL, &fhw); - if (ierr != MPI_SUCCESS) { - MPI_File_close(&fhw); - if (rank == 0) - MPI_File_delete(fileName.c_str(), MPI_INFO_NULL); - ierr = MPI_File_open(MPI_COMM_WORLD, fileName.c_str(), - MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, - MPI_INFO_NULL, &fhw); - } - - /*--- Error check opening the file. ---*/ - - if (ierr) { - SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - fileName, CURRENT_FUNCTION); - } -#else - fhw = fopen(fileName.c_str(), "wb"); - /*--- Error check for opening the file. ---*/ - - if (!fhw) { - SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - fileName, CURRENT_FUNCTION); - } -#endif - - /*--- Write the initial strings to the file. Only the master will - write the header lines, but all ranks will store the offsets. ---*/ - - disp = 0; - /*--- Communicate the number of total points that will be written by each rank. After this communication, each proc knows how many poinnts will be written before its location in the file and the @@ -181,27 +130,27 @@ void CParaviewXMLFileWriter::Write_Data(){ */ if (!bigEndian){ - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); } else { - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); } - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); SPRINTF(str_buf, "\n", SU2_TYPE::Int(GlobalPoint), SU2_TYPE::Int(GlobalElem)); - WriteString(std::string(str_buf), MASTER_NODE); - WriteString("\n", MASTER_NODE); + WriteMPIString(std::string(str_buf), MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); AddDataArray(VTKDatatype::FLOAT32, "", NCOORDS, myPoint*NCOORDS, GlobalPoint*NCOORDS); - WriteString("\n", MASTER_NODE); - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); AddDataArray(VTKDatatype::INT32, "connectivity", 1, myElemStorage, GlobalElemStorage); AddDataArray(VTKDatatype::INT32, "offsets", 1, myElem, GlobalElem); AddDataArray(VTKDatatype::UINT8, "types", 1, myElem, GlobalElem); - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); /*--- Adjust container start location to avoid point coords. ---*/ @@ -255,9 +204,9 @@ void CParaviewXMLFileWriter::Write_Data(){ } } - WriteString("\n", MASTER_NODE); - WriteString("\n", MASTER_NODE); - WriteString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); int *nPoint_Snd = new int[size+1]; int *nPoint_Cum = new int[size+1]; @@ -281,7 +230,7 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Now write all the data we have previously defined into the binary section of the file ---*/ - WriteString("\n_", MASTER_NODE); + WriteMPIString("\n_", MASTER_NODE); /*--- Load/write the 1D buffer of point coordinates. Note that we always have 3 coordinate dimensions, even for 2D problems. ---*/ @@ -441,37 +390,10 @@ void CParaviewXMLFileWriter::Write_Data(){ } - WriteString("\n", MASTER_NODE); - WriteString("\n", MASTER_NODE); - -#ifdef HAVE_MPI - /*--- All ranks close the file after writing. ---*/ - - MPI_File_close(&fhw); -#else - fclose(fhw); -#endif - - /*--- Compute and store the write time. ---*/ + WriteMPIString("\n", MASTER_NODE); + WriteMPIString("\n", MASTER_NODE); -#ifndef HAVE_MPI - stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - stopTime = MPI_Wtime(); -#endif - usedTime = stopTime-startTime; - - /*--- Communicate the total file size for the restart ---*/ - -#ifdef HAVE_MPI - su2double my_fileSize = fileSize; - SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, - MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); -#endif - - /*--- Compute and store the bandwidth ---*/ - - bandwidth = fileSize/(1.0e6)/usedTime; + CloseMPIFile(); /*--- Delete the offset counters that we needed for MPI IO. ---*/ @@ -481,34 +403,11 @@ void CParaviewXMLFileWriter::Write_Data(){ } - -void CParaviewXMLFileWriter::WriteString(std::string str, int rankOut){ - -#ifdef HAVE_MPI - /*--- Reset the file view before writing the next ASCII line for cells. ---*/ - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - "native", MPI_INFO_NULL); - - if (SU2_MPI::GetRank() == rankOut) - MPI_File_write_at(fhw, disp, str.c_str(), int(strlen(str.c_str())), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen( str.c_str())*sizeof(char); - fileSize += sizeof(char)*strlen( str.c_str()); -#else - char str_buf[255]; - strcpy(str_buf, str.c_str()); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); -#endif - -} - void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, unsigned long globalSize, unsigned long offset){ - unsigned long totalByteSize, byteSize; + int totalByteSize, byteSize; std::string typeStr; unsigned long typeSize; @@ -523,52 +422,17 @@ void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsign totalByteSize = globalSize*typeSize; -#ifdef HAVE_MPI - - MPI_Datatype filetype; - MPI_Status status; - - /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); - - if (SU2_MPI::GetRank() == MASTER_NODE) - MPI_File_write_at(fhw, disp, &totalByteSize, sizeof(int), - MPI_BYTE, MPI_STATUS_IGNORE); - - disp += sizeof(int); - - /*--- Prepare to write the actual data ---*/ - - MPI_Type_contiguous(int(byteSize), MPI_BYTE, &filetype); - MPI_Type_commit(&filetype); - - /*--- Set the view for the MPI file write, i.e., describe the - location in the file that this rank "sees" for writing its - piece of the file. ---*/ - - MPI_File_set_view(fhw, disp + offset*typeSize, MPI_BYTE, filetype, - (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write simultaneously. ---*/ - - MPI_File_write_all(fhw, data, int(byteSize), MPI_BYTE, &status); - - MPI_Type_free(&filetype); - - disp += totalByteSize; - fileSize += byteSize; -#else - /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ - - fwrite(&totalByteSize, sizeof(int),1, fhw); - - /*--- Write binary data ---*/ - - fwrite(data, sizeof(char), byteSize, fhw); - fileSize += byteSize; -#endif + /*--- Only the master node writes the total size in bytes as int32 in front of the array data ---*/ + + if (!WriteMPIBinaryData(&totalByteSize, sizeof(int), MASTER_NODE)){ + SU2_MPI::Error("Writing array size failed", CURRENT_FUNCTION); + } + + /*--- Collectively write all the data ---*/ + + if (!WriteMPIBinaryDataAll(data, byteSize, totalByteSize, offset*typeSize)){ + SU2_MPI::Error("Writing data array failed", CURRENT_FUNCTION); + } } void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, @@ -602,11 +466,11 @@ void CParaviewXMLFileWriter::AddDataArray(VTKDatatype type, string name, /*--- Write the ASCII XML header information for this array ---*/ - WriteString(string("\n"), MASTER_NODE); + WriteMPIString(string("\n"), MASTER_NODE); dataOffset += totalByteSize + sizeof(int); From 177545e7799e014a8b86bb0b3d10adf77ec71b31 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 14:36:09 +0100 Subject: [PATCH 42/61] use new routines for MPI I/O writing in SU2 binary writer --- .../include/output/filewriter/CFileWriter.hpp | 4 +- .../output/filewriter/CParallelFileWriter.cpp | 4 +- .../filewriter/CSU2BinaryFileWriter.cpp | 197 +++--------------- 3 files changed, 38 insertions(+), 167 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index 9f242255499..10ea94b29e4 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -159,7 +159,7 @@ class CFileWriter{ * \param offset - The offset in bytes of the chunk of data the current processor owns within the global array. * \return Boolean indicating whether the writing was successful. */ - bool WriteMPIBinaryDataAll(void *data, unsigned long sizeInBytes, unsigned long totalSizeInBytes, unsigned long offset); + bool WriteMPIBinaryDataAll(const void *data, unsigned long sizeInBytes, unsigned long totalSizeInBytes, unsigned long offset); /*! * \brief Write a binary data array to a currently opened file using MPI I/O. Note: routine must be called collectively, @@ -169,7 +169,7 @@ class CFileWriter{ * \param[in] processor - Rank of the processor that should write its data. * \return Boolean indicating whether the writing was successful. */ - bool WriteMPIBinaryData(void *data, unsigned long sizeInBytes, unsigned short processor); + bool WriteMPIBinaryData(const void *data, unsigned long sizeInBytes, unsigned short processor); /*! * \brief Write a string to a currently opened file using MPI I/O. Note: routine must be called collectively, diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index 513ac8c6ebc..38dd50ac5bc 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -61,7 +61,7 @@ CFileWriter::~CFileWriter(){ } -bool CFileWriter::WriteMPIBinaryDataAll(void *data, unsigned long sizeInBytes, +bool CFileWriter::WriteMPIBinaryDataAll(const void *data, unsigned long sizeInBytes, unsigned long totalSizeInBytes, unsigned long offsetInBytes){ #ifdef HAVE_MPI @@ -104,7 +104,7 @@ bool CFileWriter::WriteMPIBinaryDataAll(void *data, unsigned long sizeInBytes, } -bool CFileWriter::WriteMPIBinaryData(void *data, unsigned long sizeInBytes, unsigned short processor){ +bool CFileWriter::WriteMPIBinaryData(const void *data, unsigned long sizeInBytes, unsigned short processor){ #ifdef HAVE_MPI diff --git a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp index 571d144e100..5410c61bf71 100644 --- a/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CSU2BinaryFileWriter.cpp @@ -43,182 +43,53 @@ void CSU2BinaryFileWriter::Write_Data(){ unsigned short iVar; - const vector fieldNames = dataSorter->GetFieldNames(); - unsigned short GlobalField_Counter = fieldNames.size(); + const vector& fieldNames = dataSorter->GetFieldNames(); + unsigned short nVar = fieldNames.size(); unsigned long nParallel_Poin = dataSorter->GetnPoints(); + unsigned long nPoint_Global = dataSorter->GetnPointsGlobal(); - ofstream restart_file; - char str_buf[CGNS_STRING_SIZE], fname[100]; - - fileSize = 0.0; - - strcpy(fname, fileName.c_str()); + char str_buf[CGNS_STRING_SIZE]; /*--- Prepare the first ints containing the counts. The first is a magic number that we can use to check for binary files (it is the hex representation for "SU2"). The second two values are number of variables - and number of points (DoFs). The last two values are for metadata: - one int for ExtIter and 8 su2doubles. ---*/ + and number of points (DoFs). ---*/ int var_buf_size = 5; - int var_buf[5] = {535532, GlobalField_Counter, (int)dataSorter->GetnPointsGlobal(), 0, 0}; - - /*--- Set a timer for the binary file writing. ---*/ - -#ifndef HAVE_MPI - startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - startTime = MPI_Wtime(); -#endif - -#ifndef HAVE_MPI - - FILE* fhw; - fhw = fopen(fname, "wb"); - - /*--- Error check for opening the file. ---*/ - - if (!fhw) { - SU2_MPI::Error(string("Unable to open SU2 restart file ") + string(fname), CURRENT_FUNCTION); - } - - /*--- First, write the number of variables and points. ---*/ - - fwrite(var_buf, var_buf_size, sizeof(int), fhw); - fileSize += (su2double)var_buf_size*sizeof(int); + int var_buf[5] = {535532, nVar, (int)nPoint_Global, 0, 0}; + /*--- Open the file using MPI I/O ---*/ + + OpenMPIFile(); + + /*--- First, write the number of variables and points (i.e., cols and rows), + which we will need in order to read the file later. Also, write the + variable string names here. Only the master rank writes the header. ---*/ + + WriteMPIBinaryData(var_buf, var_buf_size*sizeof(int), MASTER_NODE); + /*--- Write the variable names to the file. Note that we are adopting a fixed length of 33 for the string length to match with CGNS. This is needed for when we read the strings later. ---*/ - - for (iVar = 0; iVar < GlobalField_Counter; iVar++) { + + for (iVar = 0; iVar < nVar; iVar++) { strncpy(str_buf, fieldNames[iVar].c_str(), CGNS_STRING_SIZE); - fwrite(str_buf, CGNS_STRING_SIZE, sizeof(char), fhw); - fileSize += (su2double)CGNS_STRING_SIZE*sizeof(char); + WriteMPIBinaryData(str_buf, CGNS_STRING_SIZE*sizeof(char), MASTER_NODE); } - - /*--- Call to write the entire restart file data in binary in one shot. ---*/ - - fwrite(dataSorter->GetData(), nParallel_Poin*GlobalField_Counter, sizeof(passivedouble), fhw); - fileSize += (su2double)nParallel_Poin*GlobalField_Counter*sizeof(passivedouble); - - /*--- Close the file. ---*/ - - fclose(fhw); - -#else - - /*--- Parallel binary output using MPI I/O. ---*/ - - MPI_File fhw; - SU2_MPI::Status status; - MPI_Datatype etype, filetype; - MPI_Offset disp; - int ierr; - - /*--- We're writing only su2doubles in the data portion of the file. ---*/ - - etype = MPI_DOUBLE; - - /*--- Define a derived datatype for this ranks contiguous chunk of data - that will be placed in the restart (1D array size = num points * num vars). ---*/ - - MPI_Type_contiguous(nParallel_Poin*GlobalField_Counter, MPI_DOUBLE, &filetype); - MPI_Type_commit(&filetype); - - /*--- All ranks open the file using MPI. Here, we try to open the file with - exclusive so that an error is generated if the file exists. We always want - to write a fresh restart file, so we delete any existing files and create - a new one. ---*/ - - ierr = MPI_File_open(MPI_COMM_WORLD, fname, - MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, - MPI_INFO_NULL, &fhw); - if (ierr != MPI_SUCCESS) { - MPI_File_close(&fhw); - if (rank == 0) - MPI_File_delete(fname, MPI_INFO_NULL); - ierr = MPI_File_open(MPI_COMM_WORLD, fname, - MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, - MPI_INFO_NULL, &fhw); - } - - /*--- Error check opening the file. ---*/ - - if (ierr) { - SU2_MPI::Error(string("Unable to open SU2 restart file ") + string(fname), CURRENT_FUNCTION); - } - - /*--- First, write the number of variables and points (i.e., cols and rows), - which we will need in order to read the file later. Also, write the - variable string names here. Only the master rank writes the header. ---*/ - - if (rank == MASTER_NODE) { - MPI_File_write(fhw, var_buf, var_buf_size, MPI_INT, MPI_STATUS_IGNORE); - fileSize += (su2double)var_buf_size*sizeof(int); - - /*--- Write the variable names to the file. Note that we are adopting a - fixed length of 33 for the string length to match with CGNS. This is - needed for when we read the strings later. ---*/ - - for (iVar = 0; iVar < GlobalField_Counter; iVar++) { - disp = var_buf_size*sizeof(int) + iVar*CGNS_STRING_SIZE*sizeof(char); - strncpy(str_buf, fieldNames[iVar].c_str(), CGNS_STRING_SIZE); - MPI_File_write_at(fhw, disp, str_buf, CGNS_STRING_SIZE, MPI_CHAR, MPI_STATUS_IGNORE); - fileSize += (su2double)CGNS_STRING_SIZE*sizeof(char); - } - } - - /*--- Compute the offset for this rank's linear partition of the data in bytes. - After the calculations above, we have the partition sizes store in nPoint_Linear - in cumulative storage format. ---*/ - - disp = (var_buf_size*sizeof(int) + GlobalField_Counter*CGNS_STRING_SIZE*sizeof(char) + - GlobalField_Counter*dataSorter->GetnPointCumulative(rank)*sizeof(passivedouble)); - - /*--- Set the view for the MPI file write, i.e., describe the location in - the file that this rank "sees" for writing its piece of the restart file. ---*/ - - MPI_File_set_view(fhw, disp, etype, filetype, (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write to their view simultaneously. ---*/ - - MPI_File_write_all(fhw, dataSorter->GetData(), GlobalField_Counter*nParallel_Poin, MPI_DOUBLE, &status); - fileSize += (su2double)GlobalField_Counter*nParallel_Poin*sizeof(passivedouble); - - /*--- Free the derived datatype. ---*/ - - MPI_Type_free(&filetype); - - /*--- Reset the file view before writing the metadata. ---*/ - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, (char*)"native", MPI_INFO_NULL); - - /*--- All ranks close the file after writing. ---*/ - - MPI_File_close(&fhw); - -#endif - - /*--- Compute and store the write time. ---*/ - -#ifndef HAVE_MPI - stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - stopTime = MPI_Wtime(); -#endif - usedTime = stopTime-startTime; - - /*--- Communicate the total file size for the restart ---*/ - -#ifdef HAVE_MPI - su2double my_fileSize = fileSize; - SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, - MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); -#endif - - /*--- Compute and store the bandwidth ---*/ - - bandwidth = fileSize/(1.0e6)/usedTime; + + /*--- Compute various data sizes --- */ + + unsigned long sizeInBytesPerPoint = sizeof(passivedouble)*nVar; + unsigned long sizeInBytesLocal = sizeInBytesPerPoint*nParallel_Poin; + unsigned long sizeInBytesGlobal = sizeInBytesPerPoint*nPoint_Global; + unsigned long offsetInBytes = sizeInBytesPerPoint*dataSorter->GetnPointCumulative(rank); + + /*--- Collectively write the actual data to file ---*/ + + WriteMPIBinaryDataAll(dataSorter->GetData(), sizeInBytesLocal, sizeInBytesGlobal, offsetInBytes); + + /*--- Close the file ---*/ + + CloseMPIFile(); } From ce030e5e172fd6137ca43e983b4c60a9d968e257 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 18:12:17 +0100 Subject: [PATCH 43/61] Some small refactoring of how the number of elements are stored in the data sorter --- .../output/filewriter/CParallelDataSorter.hpp | 38 +++++++--- .../src/output/filewriter/CFEMDataSorter.cpp | 21 ++---- .../src/output/filewriter/CFVMDataSorter.cpp | 33 ++++----- .../output/filewriter/CParallelDataSorter.cpp | 69 ++++++------------- .../filewriter/CSurfaceFEMDataSorter.cpp | 51 +++++++------- .../filewriter/CSurfaceFVMDataSorter.cpp | 62 ++++++++--------- 6 files changed, 125 insertions(+), 149 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index 09f53ee946b..dd3f425363a 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -50,13 +50,7 @@ class CParallelDataSorter{ unsigned long nGlobal_Poin_Par; //!< Global number of points without halos before sorting unsigned long nGlobal_Elem_Par; //!< Global number of elems without halos before sorting unsigned long nParallel_Poin; //!< Local number of points after sorting on this proc - unsigned long nParallel_Line, //!< Local number of line elements after sorting on this proc - nParallel_Tria, //!< Local number of triangle elements after sorting on this proc - nParallel_Quad, //!< Local number of quad elements after sorting on this proc - nParallel_Tetr, //!< Local number of tetrahedral elements after sorting on this proc - nParallel_Hexa, //!< Local number of hexhedral elements after sorting on this proc - nParallel_Pris, //!< Local number of prism elements after sorting on this proc - nParallel_Pyra; //!< Local number of pyramid elements after sorting on this proc + int *Conn_Line_Par; //!< Local connectivity of line elements after sorting on this proc int *Conn_Tria_Par; //!< Local connectivity of triangle elements after sorting on this proc int *Conn_Quad_Par; //!< Local connectivity of quad elements after sorting on this proc @@ -65,6 +59,15 @@ class CParallelDataSorter{ int *Conn_Pris_Par; //!< Local connectivity of prism elements after sorting on this proc int *Conn_Pyra_Par; //!< Local connectivity of pyramid elements after sorting on this proc + array nGlobal_Elem; //!< Global number of elements after sorting on this proc + array nParallel_Elem; //!< Local number of elements after sorting on this proc + + /*! + * \brief Map that stores the index for each GEO_TYPE type where to find information + * in the element arrays. + */ + static const map TypeMap; + unsigned long nGlobalPoint_Sort; //!< Global number of points without halos after sorting unsigned long nLocalPoint_Sort; //!< Local number of points without halos after sorting on this proc @@ -163,7 +166,26 @@ class CParallelDataSorter{ * \input type - The type of element, ref GEO_TYPE * \return Local number of elements of a specific type. */ - unsigned long GetnElem(GEO_TYPE type) const; + unsigned long GetnElem(GEO_TYPE type) const { + return nParallel_Elem[TypeMap.at(type)]; + } + + /*! + * \brief Get the global number of elements of a specific type + * \input type - The type of element, ref GEO_TYPE + * \return global number of elements of a specific type. + */ + unsigned long GetnElemGlobal(GEO_TYPE type) const { + return nGlobal_Elem[TypeMap.at(type)]; + } + + /*! + * \brief Get the global number of elements + * \return global number of elements. + */ + unsigned long GetnElemGlobal() const { + return nGlobal_Elem_Par; + } /*! * \brief Get the connectivity of specific element. diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index 135d5a56648..0941964d4bc 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -27,6 +27,7 @@ #include "../../../include/output/filewriter/CFEMDataSorter.hpp" #include "../../../../Common/include/fem_geometry_structure.hpp" +#include CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames) : CParallelDataSorter(config, valFieldNames){ @@ -103,16 +104,12 @@ void CFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool SortVolumetricConnectivity(config, geometry, PRISM ); SortVolumetricConnectivity(config, geometry, PYRAMID ); - /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - unsigned long nTotal_Elem = nParallel_Tria + nParallel_Quad + nParallel_Tetr + nParallel_Hexa + nParallel_Pris + nParallel_Pyra; -#ifndef HAVE_MPI - nGlobal_Elem_Par = nTotal_Elem; -#else - SU2_MPI::Allreduce(&nTotal_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif - + SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); + connectivitySorted = true; } @@ -213,37 +210,33 @@ void CFEMDataSorter::SortVolumetricConnectivity(CConfig *config, CGeometry *geom Conn_SubElem[kNode] = connSubElems[k] + volElem[i].offsetDOFsSolGlobal + 1; } } + + nParallel_Elem[TypeMap.at(Elem_Type)] = nSubElem_Local; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ switch (Elem_Type) { case TRIANGLE: - nParallel_Tria = nSubElem_Local; if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; Conn_Tria_Par = Conn_SubElem; break; case QUADRILATERAL: - nParallel_Quad = nSubElem_Local; if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; Conn_Quad_Par = Conn_SubElem; break; case TETRAHEDRON: - nParallel_Tetr = nSubElem_Local; if (Conn_Tetr_Par != NULL) delete [] Conn_Tetr_Par; Conn_Tetr_Par = Conn_SubElem; break; case HEXAHEDRON: - nParallel_Hexa = nSubElem_Local; if (Conn_Hexa_Par != NULL) delete [] Conn_Hexa_Par; Conn_Hexa_Par = Conn_SubElem; break; case PRISM: - nParallel_Pris = nSubElem_Local; if (Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; Conn_Pris_Par = Conn_SubElem; break; case PYRAMID: - nParallel_Pyra = nSubElem_Local; if (Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; Conn_Pyra_Par = Conn_SubElem; break; diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index a585ca4e194..d91b58bc8c2 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -27,6 +27,7 @@ #include "../../../include/output/filewriter/CFVMDataSorter.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" +#include CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vector &valFieldNames) : CParallelDataSorter(config, valFieldNames){ @@ -121,16 +122,12 @@ void CFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool SortVolumetricConnectivity(config, geometry, HEXAHEDRON, val_sort); SortVolumetricConnectivity(config, geometry, PRISM, val_sort); SortVolumetricConnectivity(config, geometry, PYRAMID, val_sort); - - + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - unsigned long nTotal_Elem = nParallel_Tria + nParallel_Quad + nParallel_Tetr + nParallel_Hexa + nParallel_Pris + nParallel_Pyra; -#ifndef HAVE_MPI - nGlobal_Elem_Par = nTotal_Elem; -#else - SU2_MPI::Allreduce(&nTotal_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif + SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); connectivitySorted = true; @@ -487,40 +484,36 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, } } } + + nParallel_Elem[TypeMap.at(Elem_Type)] = nElem_Total; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ switch (Elem_Type) { case TRIANGLE: - nParallel_Tria = nElem_Total; if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; - if (nParallel_Tria > 0) Conn_Tria_Par = Conn_Elem; + if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Tria_Par = Conn_Elem; break; case QUADRILATERAL: - nParallel_Quad = nElem_Total; if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; - if (nParallel_Quad > 0) Conn_Quad_Par = Conn_Elem; + if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Quad_Par = Conn_Elem; break; case TETRAHEDRON: - nParallel_Tetr = nElem_Total; if (Conn_Tetr_Par != NULL) delete [] Conn_Tetr_Par; - if (nParallel_Tetr > 0) Conn_Tetr_Par = Conn_Elem; + if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Tetr_Par = Conn_Elem; break; case HEXAHEDRON: - nParallel_Hexa = nElem_Total; if (Conn_Hexa_Par != NULL) delete [] Conn_Hexa_Par; - if (nParallel_Hexa > 0) Conn_Hexa_Par = Conn_Elem; + if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Hexa_Par = Conn_Elem; break; case PRISM: - nParallel_Pris = nElem_Total; if (Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; - if (nParallel_Pris > 0) Conn_Pris_Par = Conn_Elem; + if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Pris_Par = Conn_Elem; break; case PYRAMID: - nParallel_Pyra = nElem_Total; if (Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; - if (nParallel_Pyra > 0) Conn_Pyra_Par = Conn_Elem; + if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Pyra_Par = Conn_Elem; break; default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index f4ceaf81fac..ddb4ffad9a8 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -28,6 +28,16 @@ #include "../../../include/output/filewriter/CParallelDataSorter.hpp" #include +const map CParallelDataSorter::TypeMap = { + {LINE, 0}, + {TRIANGLE, 1}, + {QUADRILATERAL, 2}, + {TETRAHEDRON, 3}, + {HEXAHEDRON, 4}, + {PRISM, 5}, + {PYRAMID, 6} +}; + CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector &valFieldNames) : fieldNames(std::move(valFieldNames)){ @@ -36,14 +46,6 @@ CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector & GlobalField_Counter = this->fieldNames.size(); - nParallel_Hexa = 0; - nParallel_Line = 0; - nParallel_Quad = 0; - nParallel_Tetr = 0; - nParallel_Pris = 0; - nParallel_Pyra = 0; - nParallel_Tria = 0; - Conn_Line_Par = NULL; Conn_Hexa_Par = NULL; Conn_Pris_Par = NULL; @@ -70,6 +72,9 @@ CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector & nPoint_Recv = new int[size+1](); linearPartitioner = NULL; + + nParallel_Elem.fill(0); + nGlobal_Elem.fill(0); } @@ -80,53 +85,19 @@ CParallelDataSorter::~CParallelDataSorter(){ /*--- Deallocate memory for connectivity data on each processor. ---*/ - if (nParallel_Line > 0 && Conn_Line_Par != NULL) delete [] Conn_Line_Par; - if (nParallel_Tria > 0 && Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; - if (nParallel_Quad > 0 && Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; - if (nParallel_Tetr > 0 && Conn_Tetr_Par != NULL) delete [] Conn_Tetr_Par; - if (nParallel_Hexa > 0 && Conn_Hexa_Par != NULL) delete [] Conn_Hexa_Par; - if (nParallel_Pris > 0 && Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; - if (nParallel_Pyra > 0 && Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; + if (GetnElem(LINE) > 0 && Conn_Line_Par != NULL) delete [] Conn_Line_Par; + if (GetnElem(TRIANGLE) > 0 && Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; + if (GetnElem(QUADRILATERAL) > 0 && Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; + if (GetnElem(TETRAHEDRON) > 0 && Conn_Tetr_Par != NULL) delete [] Conn_Tetr_Par; + if (GetnElem(HEXAHEDRON) > 0 && Conn_Hexa_Par != NULL) delete [] Conn_Hexa_Par; + if (GetnElem(PRISM) > 0 && Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; + if (GetnElem(PYRAMID) > 0 && Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; if (connSend != NULL) delete [] connSend; if (dataBuffer != NULL) delete [] dataBuffer; } - -unsigned long CParallelDataSorter::GetnElem(GEO_TYPE type) const { - - switch (type) { - case LINE: - return nParallel_Line; - break; - case TRIANGLE: - return nParallel_Tria; - break; - case QUADRILATERAL: - return nParallel_Quad; - break; - case TETRAHEDRON: - return nParallel_Tetr; - break; - case HEXAHEDRON: - return nParallel_Hexa; - break; - case PRISM: - return nParallel_Pris; - break; - case PYRAMID: - return nParallel_Pyra; - break; - default: - break; - } - - SU2_MPI::Error("GEO_TYPE not found", CURRENT_FUNCTION); - - return 0; -} - void CParallelDataSorter::SortOutputData() { int VARS_PER_POINT = GlobalField_Counter; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 517a46f3477..77358c37229 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -27,7 +27,7 @@ #include "../../../include/output/filewriter/CSurfaceFEMDataSorter.hpp" #include "../../../../Common/include/fem_geometry_structure.hpp" - +#include CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometry, CFEMDataSorter* valVolumeSorter) : CParallelDataSorter(config, valVolumeSorter->GetFieldNames()){ @@ -86,6 +86,10 @@ void CSurfaceFEMDataSorter::SortOutputData() { } const int VARS_PER_POINT = GlobalField_Counter; + + const unsigned long nElemLine = GetnElem(LINE); + const unsigned long nElemTria = GetnElem(TRIANGLE); + const unsigned long nElemQuad = GetnElem(QUADRILATERAL); /*---------------------------------------------------*/ /*--- Step 1: Determine the global DOF ID's of the */ @@ -96,21 +100,21 @@ void CSurfaceFEMDataSorter::SortOutputData() { DOF ID's in a vector. Subtract 1, because the stored connectivities are 1 based. */ globalSurfaceDOFIDs.clear(); - globalSurfaceDOFIDs.reserve(nParallel_Line*N_POINTS_LINE + - nParallel_Tria*N_POINTS_TRIANGLE + - nParallel_Quad*N_POINTS_QUADRILATERAL); + globalSurfaceDOFIDs.reserve(nElemLine*N_POINTS_LINE + + nElemTria*N_POINTS_TRIANGLE + + nElemQuad*N_POINTS_QUADRILATERAL); - for(unsigned long i=0; i<(nParallel_Line*N_POINTS_LINE); ++i) { + for(unsigned long i=0; isecond; - for(unsigned long i=0; i<(nParallel_Tria*N_POINTS_TRIANGLE); ++i) + for(unsigned long i=0; isecond; - for(unsigned long i=0; i<(nParallel_Quad*N_POINTS_QUADRILATERAL); ++i) + for(unsigned long i=0; isecond; } @@ -351,14 +355,12 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - - unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; -#ifndef HAVE_MPI - nGlobal_Elem_Par = nTotal_Surf_Elem; -#else - SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif + SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); connectivitySorted = true; @@ -370,13 +372,11 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; -#ifndef HAVE_MPI - nGlobal_Elem_Par = nTotal_Surf_Elem; -#else - SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif + SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); connectivitySorted = true; @@ -479,22 +479,21 @@ void CSurfaceFEMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * } } } + + nParallel_Elem[TypeMap.at(Elem_Type)] = nSubElem_Local; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ switch (Elem_Type) { case LINE: - nParallel_Line = nSubElem_Local; if (Conn_Line_Par != NULL) delete [] Conn_Line_Par; Conn_Line_Par = Conn_SubElem; break; case TRIANGLE: - nParallel_Tria = nSubElem_Local; if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; Conn_Tria_Par = Conn_SubElem; break; case QUADRILATERAL: - nParallel_Quad = nSubElem_Local; if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; Conn_Quad_Par = Conn_SubElem; break; diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 1e4045c357e..1469028780d 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -27,7 +27,7 @@ #include "../../../include/output/filewriter/CSurfaceFVMDataSorter.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" - +#include CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometry, CFVMDataSorter* valVolumeSorter) : CParallelDataSorter(config, valVolumeSorter->GetFieldNames()){ @@ -69,7 +69,10 @@ void CSurfaceFVMDataSorter::SortOutputData() { SU2_MPI::Status status; int ind; #endif - + + const unsigned long nElemLine = GetnElem(LINE); + const unsigned long nElemTria = GetnElem(TRIANGLE); + const unsigned long nElemQuad = GetnElem(QUADRILATERAL); /*--- Prepare to check and communicate the nodes that each proc has locally from the surface connectivity. ---*/ @@ -88,7 +91,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Loop through our local line elements and check where each of the grid nodes resides based on global index. ---*/ - for (int ii = 0; ii < (int)nParallel_Line; ii++) { + for (int ii = 0; ii < (int)nElemLine; ii++) { for ( int jj = 0; jj < N_POINTS_LINE; jj++ ) { /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ @@ -116,7 +119,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - for (int ii = 0; ii < (int)nParallel_Tria; ii++) { + for (int ii = 0; ii < (int)nElemTria; ii++) { for ( int jj = 0; jj < N_POINTS_TRIANGLE; jj++ ) { /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ @@ -144,7 +147,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - for (int ii = 0; ii < (int)nParallel_Quad; ii++) { + for (int ii = 0; ii < (int)nElemQuad; ii++) { for ( int jj = 0; jj < N_POINTS_QUADRILATERAL; jj++ ) { /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ @@ -207,7 +210,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Now loop back through the local connectivities for the surface elements and load up the global IDs for sending to their home proc. ---*/ - for (int ii = 0; ii < (int)nParallel_Line; ii++) { + for (int ii = 0; ii < (int)nElemLine; ii++) { for ( int jj = 0; jj < N_POINTS_LINE; jj++ ) { /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ @@ -241,7 +244,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - for (int ii = 0; ii < (int)nParallel_Tria; ii++) { + for (int ii = 0; ii < (int)nElemTria; ii++) { for ( int jj = 0; jj < N_POINTS_TRIANGLE; jj++ ) { /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ @@ -275,7 +278,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - for (int ii = 0; ii < (int)nParallel_Quad; ii++) { + for (int ii = 0; ii < (int)nElemQuad; ii++) { for ( int jj = 0; jj < N_POINTS_QUADRILATERAL; jj++ ) { /*--- Get global index. Note the -1 since it was 1-based for viz. ---*/ @@ -736,7 +739,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { vector::iterator it; vector outliers; - for (int ii = 0; ii < (int)nParallel_Line; ii++) { + for (int ii = 0; ii < (int)nElemLine; ii++) { for ( int jj = 0; jj < N_POINTS_LINE; jj++ ) { iNode = ii*N_POINTS_LINE+jj; @@ -757,7 +760,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - for (int ii = 0; ii < (int)nParallel_Tria; ii++) { + for (int ii = 0; ii < (int)nElemTria; ii++) { for ( int jj = 0; jj < N_POINTS_TRIANGLE; jj++ ) { iNode = ii*N_POINTS_TRIANGLE + jj; @@ -778,7 +781,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=0; ii < size; ii++) nElem_Flag[ii]= -1; - for (int ii = 0; ii < (int)nParallel_Quad; ii++) { + for (int ii = 0; ii < (int)nElemQuad; ii++) { for ( int jj = 0; jj < N_POINTS_QUADRILATERAL; jj++ ) { iNode = ii*N_POINTS_QUADRILATERAL+jj; @@ -1058,20 +1061,20 @@ void CSurfaceFVMDataSorter::SortOutputData() { using our completed map with the new global renumbering. Whew!! Note the -1 when accessing the conn from the map. ---*/ - for (iElem = 0; iElem < nParallel_Line; iElem++) { + for (iElem = 0; iElem < nElemLine; iElem++) { iNode = (int)iElem*N_POINTS_LINE; Conn_Line_Par[iNode+0] = (int)Global2Renumber[Conn_Line_Par[iNode+0]-1]; Conn_Line_Par[iNode+1] = (int)Global2Renumber[Conn_Line_Par[iNode+1]-1]; } - for (iElem = 0; iElem < nParallel_Tria; iElem++) { + for (iElem = 0; iElem < nElemTria; iElem++) { iNode = (int)iElem*N_POINTS_TRIANGLE; Conn_Tria_Par[iNode+0] = (int)Global2Renumber[Conn_Tria_Par[iNode+0]-1]; Conn_Tria_Par[iNode+1] = (int)Global2Renumber[Conn_Tria_Par[iNode+1]-1]; Conn_Tria_Par[iNode+2] = (int)Global2Renumber[Conn_Tria_Par[iNode+2]-1]; } - for (iElem = 0; iElem < nParallel_Quad; iElem++) { + for (iElem = 0; iElem < nElemQuad; iElem++) { iNode = (int)iElem*N_POINTS_QUADRILATERAL; Conn_Quad_Par[iNode+0] = (int)Global2Renumber[Conn_Quad_Par[iNode+0]-1]; Conn_Quad_Par[iNode+1] = (int)Global2Renumber[Conn_Quad_Par[iNode+1]-1]; @@ -1121,13 +1124,11 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; -#ifndef HAVE_MPI - nGlobal_Elem_Par = nTotal_Surf_Elem; -#else - SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif + SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); connectivitySorted = true; @@ -1145,13 +1146,11 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - unsigned long nTotal_Surf_Elem = nParallel_Line + nParallel_Tria + nParallel_Quad; -#ifndef HAVE_MPI - nGlobal_Elem_Par = nTotal_Surf_Elem; -#else - SU2_MPI::Allreduce(&nTotal_Surf_Elem, &nGlobal_Elem_Par, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif + SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); connectivitySorted = true; @@ -1516,27 +1515,26 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * } } + nParallel_Elem[TypeMap.at(Elem_Type)] = nElem_Total; + /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ switch (Elem_Type) { case LINE: - nParallel_Line = nElem_Total; if (Conn_Line_Par != NULL) delete [] Conn_Line_Par; Conn_Line_Par = NULL; - if (nParallel_Line > 0) Conn_Line_Par = Conn_Elem; + if (GetnElem(LINE) > 0) Conn_Line_Par = Conn_Elem; break; case TRIANGLE: - nParallel_Tria = nElem_Total; if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; Conn_Tria_Par = NULL; - if (nParallel_Tria > 0) Conn_Tria_Par = Conn_Elem; + if (GetnElem(TRIANGLE) > 0) Conn_Tria_Par = Conn_Elem; break; case QUADRILATERAL: - nParallel_Quad = nElem_Total; if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; Conn_Quad_Par = NULL; - if (nParallel_Quad > 0) Conn_Quad_Par = Conn_Elem; + if (GetnElem(QUADRILATERAL) > 0) Conn_Quad_Par = Conn_Elem; break; default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); From 4088ce3e2e90f64c4295e0460f286c576286666e Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 18:13:03 +0100 Subject: [PATCH 44/61] Updating legacy paraview writer to use the new functions --- .../filewriter/CParaviewBinaryFileWriter.hpp | 8 +- .../filewriter/CParaviewBinaryFileWriter.cpp | 1021 +++-------------- 2 files changed, 142 insertions(+), 887 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp index d5ac228add4..e6a4e003786 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewBinaryFileWriter.hpp @@ -30,7 +30,13 @@ #include "CFileWriter.hpp" class CParaviewBinaryFileWriter final: public CFileWriter{ - + private: + + /*! + * \brief Boolean storing whether we are on a big or little endian machine + */ + bool bigEndian; + public: /*! diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index b9145f4e390..bc88a291cdd 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -30,7 +30,18 @@ const string CParaviewBinaryFileWriter::fileExt = ".vtk"; CParaviewBinaryFileWriter::CParaviewBinaryFileWriter(string valFileName, CParallelDataSorter *valDataSorter) : - CFileWriter(std::move(valFileName), valDataSorter, fileExt){} + CFileWriter(std::move(valFileName), valDataSorter, fileExt){ + + /* Check for big endian. We have to swap bytes otherwise. + * Since size of character is 1 byte when the character pointer + * is de-referenced it will contain only first byte of integer. ---*/ + + bigEndian = false; + unsigned int i = 1; + char *c = (char*)&i; + if (*c) bigEndian = false; + else bigEndian = true; +} CParaviewBinaryFileWriter::~CParaviewBinaryFileWriter(){ @@ -43,481 +54,25 @@ void CParaviewBinaryFileWriter::Write_Data(){ SU2_MPI::Error("Connectivity must be sorted.", CURRENT_FUNCTION); } - const vector fieldNames = dataSorter->GetFieldNames(); + const vector& fieldNames = dataSorter->GetFieldNames(); unsigned short iDim = 0, nDim = dataSorter->GetnDim(); unsigned long iPoint, iElem; - ofstream Paraview_File; - const int MAX_STRING_LENGTH = 255; - char str_buf[MAX_STRING_LENGTH], fname[100]; + char str_buf[MAX_STRING_LENGTH]; const int NCOORDS = 3; - strcpy(fname, fileName.c_str()); - - /* Check for big endian. We have to swap bytes otherwise. - * Since size of character is 1 byte when the character pointer - * is de-referenced it will contain only first byte of integer. ---*/ - - bool BigEndian = false; - unsigned int i = 1; - char *c = (char*)&i; - if (*c) BigEndian = false; - else BigEndian = true; - - fileSize = 0.0; - - /*--- Set a timer for the file writing. ---*/ - -#ifndef HAVE_MPI - startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - startTime = MPI_Wtime(); -#endif - - /*--- Serial implementation in case we have not compiled with MPI. ---*/ - -#ifndef HAVE_MPI - - FILE* fhw; - fhw = fopen(fname, "wb"); - - unsigned long iNode2; - unsigned long nGlobal_Elem_Storage; - - /*--- Error check for opening the file. ---*/ - - if (!fhw) { - SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - fileName, CURRENT_FUNCTION); - } - - /*--- File header written in ASCII. ---*/ - - strcpy(str_buf, "# vtk DataFile Version 3.0\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "vtk output\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "BINARY\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "DATASET UNSTRUCTURED_GRID\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - /*--- Write the point coordinates. ---*/ - - unsigned long GlobalPoint = dataSorter->GetnPointsGlobal(); - - SPRINTF(str_buf, "POINTS %i float\n", (int)GlobalPoint); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - /*--- Load/write the 1D buffer of point coordinates. ---*/ - - float *coord_buf = new float[GlobalPoint*NCOORDS]; - for (iPoint = 0; iPoint < GlobalPoint; iPoint++) { - for (iDim = 0; iDim < NCOORDS; iDim++) { - if (nDim == 2 && iDim == 2) { - coord_buf[iPoint*NCOORDS + iDim] = 0.0; - } else { - float val = (float)dataSorter->GetData(iDim,iPoint); - coord_buf[iPoint*NCOORDS + iDim] = val; - } - } - } - if (!BigEndian) SwapBytes((char *)coord_buf, sizeof(float), 3*GlobalPoint); - - fwrite(coord_buf, sizeof(float), 3*GlobalPoint, fhw); - fileSize += sizeof(char)*3*GlobalPoint; - - delete [] coord_buf; - - /*--- Write the connectivity data. ---*/ - - unsigned long nTot_Line; - unsigned long nTot_Tria, nTot_Quad; - unsigned long nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; - nTot_Line = dataSorter->GetnElem(LINE); - nTot_Tria = dataSorter->GetnElem(TRIANGLE); - nTot_Quad = dataSorter->GetnElem(QUADRILATERAL); - nTot_Tetr = dataSorter->GetnElem(TETRAHEDRON); - nTot_Hexa = dataSorter->GetnElem(HEXAHEDRON); - nTot_Pris = dataSorter->GetnElem(PRISM); - nTot_Pyra = dataSorter->GetnElem(PYRAMID); - nGlobal_Elem_Storage = (nTot_Line*3 + nTot_Tria*4 + nTot_Quad*5 + nTot_Tetr*5 + - nTot_Hexa*9 + nTot_Pris*7 + nTot_Pyra*6); - - int *conn_buf = NULL; - - SPRINTF (str_buf, "\nCELLS %i %i\n", (int)dataSorter->GetnElem(), - (int)nGlobal_Elem_Storage); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - conn_buf = new int[dataSorter->GetnElem()*(N_POINTS_HEXAHEDRON+1)]; - - - /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ - - - for (iElem = 0; iElem < nTot_Line; iElem++) { - iNode2 = iElem*(N_POINTS_LINE+1); - conn_buf[iNode2+0] = N_POINTS_LINE; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(LINE, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(LINE, iElem, 1)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Line*(N_POINTS_LINE+1)); - fwrite(conn_buf, sizeof(int), - nTot_Line*(N_POINTS_LINE+1), fhw); - - fileSize += sizeof(int)*nTot_Line*(N_POINTS_LINE+1); - - for (iElem = 0; iElem < nTot_Tria; iElem++) { - iNode2 = iElem*(N_POINTS_TRIANGLE+1); - conn_buf[iNode2+0] = N_POINTS_TRIANGLE; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 2)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Tria*(N_POINTS_TRIANGLE+1)); - fwrite(conn_buf, sizeof(int), - nTot_Tria*(N_POINTS_TRIANGLE+1), fhw); - fileSize += sizeof(int)*nTot_Tria*(N_POINTS_TRIANGLE+1); - - for (iElem = 0; iElem < nTot_Quad; iElem++) { - iNode2 = iElem*(N_POINTS_QUADRILATERAL+1); - conn_buf[iNode2+0] = N_POINTS_QUADRILATERAL; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 3)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Quad*(N_POINTS_QUADRILATERAL+1)); - fwrite(conn_buf, sizeof(int), - nTot_Quad*(N_POINTS_QUADRILATERAL+1), fhw); - fileSize += sizeof(int)*nTot_Quad*(N_POINTS_QUADRILATERAL+1); - - for (iElem = 0; iElem < nTot_Tetr; iElem++) { - iNode2 = iElem*(N_POINTS_TETRAHEDRON+1); - conn_buf[iNode2+0] = N_POINTS_TETRAHEDRON; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 3)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Tetr*(N_POINTS_TETRAHEDRON+1)); - fwrite(conn_buf, sizeof(int), - nTot_Tetr*(N_POINTS_TETRAHEDRON+1), fhw); - fileSize += sizeof(int)*nTot_Tetr*(N_POINTS_TETRAHEDRON+1); - - for (iElem = 0; iElem < nTot_Hexa; iElem++) { - iNode2 = iElem*(N_POINTS_HEXAHEDRON+1); - conn_buf[iNode2+0] = N_POINTS_HEXAHEDRON; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 3)-1; - conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 4)-1; - conn_buf[iNode2+6] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 5)-1; - conn_buf[iNode2+7] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 6)-1; - conn_buf[iNode2+8] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 7)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Hexa*(N_POINTS_HEXAHEDRON+1)); - fwrite(conn_buf, sizeof(int), - nTot_Hexa*(N_POINTS_HEXAHEDRON+1), fhw); - fileSize += sizeof(int)*nTot_Hexa*(N_POINTS_HEXAHEDRON+1); - - for (iElem = 0; iElem < nTot_Pris; iElem++) { - iNode2 = iElem*(N_POINTS_PRISM+1); - conn_buf[iNode2+0] = N_POINTS_PRISM; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(PRISM, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(PRISM, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(PRISM, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(PRISM, iElem, 3)-1; - conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(PRISM, iElem, 4)-1; - conn_buf[iNode2+6] = dataSorter->GetElem_Connectivity(PRISM, iElem, 5)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Pris*(N_POINTS_PRISM+1)); - fwrite(conn_buf, sizeof(int), - nTot_Pris*(N_POINTS_PRISM+1), fhw); - fileSize += sizeof(int)*nTot_Pris*(N_POINTS_PRISM+1); - - for (iElem = 0; iElem < nTot_Pyra; iElem++) { - iNode2 = iElem*(N_POINTS_PYRAMID+1); - conn_buf[iNode2+0] = N_POINTS_PYRAMID; - conn_buf[iNode2+1] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 0)-1; - conn_buf[iNode2+2] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 1)-1; - conn_buf[iNode2+3] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 2)-1; - conn_buf[iNode2+4] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 3)-1; - conn_buf[iNode2+5] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 4)-1; - } - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), - nTot_Pyra*(N_POINTS_PYRAMID+1)); - fwrite(conn_buf, sizeof(int), - nTot_Pyra*(N_POINTS_PYRAMID+1), fhw); - fileSize += sizeof(int)*nTot_Pyra*(N_POINTS_PYRAMID+1); - - - if (conn_buf != NULL) delete [] conn_buf; - - /*--- Load/write the cell type for all elements in the file. ---*/ - - - SPRINTF (str_buf, "\nCELL_TYPES %i\n", SU2_TYPE::Int(dataSorter->GetnElem())); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)*strlen(str_buf); - - int *type_buf = NULL; - - type_buf = new int[dataSorter->GetnElem()]; - - for (iElem = 0; iElem < nTot_Line; iElem++) { - type_buf[iElem] = LINE; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Line); - fwrite(type_buf, sizeof(int), nTot_Line, fhw); - fileSize += sizeof(int)*nTot_Line; - - for (iElem = 0; iElem < nTot_Tria; iElem++) { - type_buf[iElem] = TRIANGLE; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Tria); - fwrite(type_buf, sizeof(int), nTot_Tria, fhw); - fileSize += sizeof(int)*nTot_Tria; - - for (iElem = 0; iElem < nTot_Quad; iElem++) { - type_buf[iElem] = QUADRILATERAL; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Quad); - fwrite(type_buf, sizeof(int), nTot_Quad, fhw); - fileSize += sizeof(int)*nTot_Quad; - - for (iElem = 0; iElem < nTot_Tetr; iElem++) { - type_buf[iElem] = TETRAHEDRON; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Tetr); - fwrite(type_buf, sizeof(int), nTot_Tetr, fhw); - fileSize += sizeof(int)*nTot_Tetr; - - for (iElem = 0; iElem < nTot_Hexa; iElem++) { - type_buf[iElem] = HEXAHEDRON; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Hexa); - fwrite(type_buf, sizeof(int), nTot_Hexa, fhw); - fileSize += sizeof(int)*nTot_Hexa; - - for (iElem = 0; iElem < nTot_Pris; iElem++) { - type_buf[iElem] = PRISM; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Pris); - fwrite(type_buf, sizeof(int), nTot_Pris, fhw); - fileSize += sizeof(int)*nTot_Pris; - - for (iElem = 0; iElem < nTot_Pyra; iElem++) { - type_buf[iElem] = PYRAMID; - } - if (!BigEndian) - SwapBytes((char *)type_buf, sizeof(int), nTot_Pyra); - fwrite(type_buf, sizeof(int), nTot_Pyra, fhw); - fileSize += sizeof(int)*nTot_Pyra; - - - if (type_buf != NULL) delete [] type_buf; - - /*--- Now write the scalar and vector data (reuse the counts above). ---*/ - - SPRINTF (str_buf, "\nPOINT_DATA %i\n", (int)GlobalPoint); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)* strlen(str_buf); - - unsigned short varStart = 2; - if (nDim == 3) varStart++; - - /*--- Need to adjust container location to avoid PointID tag and coords. ---*/ - - unsigned short iField, VarCounter = varStart; - for (iField = varStart; iField < fieldNames.size(); iField++) { - - string fieldname = fieldNames[iField]; - fieldname.erase(remove(fieldname.begin(), fieldname.end(), '"'), - fieldname.end()); - - bool output_variable = true, isVector = false; - size_t found = fieldNames[iField].find("_x"); - if (found!=string::npos) { - output_variable = true; - isVector = true; - } - found = fieldNames[iField].find("_y"); - if (found!=string::npos) { - //skip - output_variable = false; - VarCounter++; - } - found = fieldNames[iField].find("_z"); - if (found!=string::npos) { - //skip - output_variable = false; - VarCounter++; - } - - if (output_variable && isVector) { - - fieldname.erase(fieldname.end()-2,fieldname.end()); - SPRINTF (str_buf, "\nVECTORS %s float\n", fieldname.c_str()); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)* strlen(str_buf); - - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *vec_buf = new float[GlobalPoint*NCOORDS]; - - /*--- For now, create a temp 1D buffer to load up the data for writing. - This will be replaced with a derived data type most likely. ---*/ - - float val = 0.0; - for (iPoint = 0; iPoint < GlobalPoint; iPoint++) - for (iDim = 0; iDim < NCOORDS; iDim++) { - if (nDim == 2 && iDim == 2) { - vec_buf[iPoint*NCOORDS + iDim] = 0.0; - } else { - val = (float)dataSorter->GetData(VarCounter+iDim,iPoint); - vec_buf[iPoint*NCOORDS + iDim] = val; - } - } - if (!BigEndian) - SwapBytes((char *)vec_buf, sizeof(float), NCOORDS*GlobalPoint); - fwrite(vec_buf, sizeof(float), NCOORDS*GlobalPoint, fhw); - fileSize += sizeof(float)*NCOORDS*GlobalPoint; - - delete [] vec_buf; - - VarCounter++; - - } else if (output_variable) { - - SPRINTF (str_buf, "\nSCALARS %s float 1\n", fieldname.c_str()); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)* strlen(str_buf); - - SPRINTF (str_buf, "LOOKUP_TABLE default\n"); - fwrite(str_buf, sizeof(char), strlen(str_buf), fhw); - fileSize += sizeof(char)* strlen(str_buf); - - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *scalar_buf = new float[GlobalPoint]; - - /*--- For now, create a temp 1D buffer to load up the data for writing. - This will be replaced with a derived data type most likely. ---*/ - - for (iPoint = 0; iPoint < GlobalPoint; iPoint++) { - float val = (float)dataSorter->GetData(VarCounter,iPoint); - scalar_buf[iPoint] = val; - } - if (!BigEndian) - SwapBytes((char *)scalar_buf, sizeof(float), GlobalPoint); - fwrite(scalar_buf, sizeof(float), GlobalPoint, fhw); - fileSize += sizeof(float)*GlobalPoint; - - delete [] scalar_buf; - - VarCounter++; - } - - } - - /*--- Close the file. ---*/ - - fclose(fhw); - -#else - - /*--- Parallel binary output using MPI I/O. ---*/ - - MPI_File fhw; - SU2_MPI::Status status; - MPI_Datatype etype, filetype; - MPI_Offset disp, disp2; - int ierr; - - /*--- All ranks open the file using MPI. Here, we try to open the file with - exclusive so that an error is generated if the file exists. We always want - to write a fresh output file, so we delete any existing files and create - a new one. ---*/ - - ierr = MPI_File_open(MPI_COMM_WORLD, fname, - MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, - MPI_INFO_NULL, &fhw); - if (ierr != MPI_SUCCESS) { - MPI_File_close(&fhw); - if (rank == 0) - MPI_File_delete(fname, MPI_INFO_NULL); - ierr = MPI_File_open(MPI_COMM_WORLD, fname, - MPI_MODE_CREATE|MPI_MODE_EXCL|MPI_MODE_WRONLY, - MPI_INFO_NULL, &fhw); - } - - /*--- Error check opening the file. ---*/ - - if (ierr) { - SU2_MPI::Error(string("Unable to open VTK binary legacy file ") + - string(fname), CURRENT_FUNCTION); - } - - /*--- Write the initial strings to the file. Only the master will - write the header lines, but all ranks will store the offsets. ---*/ - - disp = 0; - strcpy(str_buf, "# vtk DataFile Version 3.0\n"); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - - strcpy(str_buf, "vtk output\n"); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "BINARY\n"); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - strcpy(str_buf, "DATASET UNSTRUCTURED_GRID\n"); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); + OpenMPIFile(); + + string header = "# vtk DataFile Version 3.0\n" + "vtk output\n" + "BINARY\n" + "DATASET UNSTRUCTURED_GRID\n"; + + WriteMPIString(header, MASTER_NODE); /*--- Communicate the number of total points that will be written by each rank. After this communication, each proc knows how @@ -551,72 +106,40 @@ void CParaviewBinaryFileWriter::Write_Data(){ } SPRINTF(str_buf, "POINTS %i float\n", SU2_TYPE::Int(GlobalPoint)); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); + + WriteMPIString(string(str_buf), MASTER_NODE); /*--- Load/write the 1D buffer of point coordinates. Note that we always have 3 coordinate dimensions, even for 2D problems. ---*/ - - float *coord_buf = new float[myPoint*NCOORDS]; + + vector dataBufferFloat(myPoint*NCOORDS); for (iPoint = 0; iPoint < myPoint; iPoint++) { for (iDim = 0; iDim < NCOORDS; iDim++) { if (nDim == 2 && iDim == 2) { - coord_buf[iPoint*NCOORDS + iDim] = 0.0; + dataBufferFloat[iPoint*NCOORDS + iDim] = 0.0; } else { float val = (float)dataSorter->GetData(iDim, iPoint); - coord_buf[iPoint*NCOORDS + iDim] = val; + dataBufferFloat[iPoint*NCOORDS + iDim] = val; } } } - if (!BigEndian) SwapBytes((char *)coord_buf, sizeof(float), myPoint*NCOORDS); - - /*--- We will write the point coordinates as floats. ---*/ - - etype = MPI_FLOAT; - - /*--- Define a derived datatype for this ranks contiguous - chunk of data that will be placed in the file. ---*/ - - MPI_Type_contiguous(myPoint*NCOORDS, MPI_FLOAT, &filetype); - MPI_Type_commit(&filetype); - - /*--- Compute the offset for this rank's linear partition of the - data in bytes. ---*/ - - disp2 = disp + NCOORDS*nPoint_Cum[rank]*sizeof(float); - - /*--- Set the view for the MPI file write, i.e., describe the - location in the file that this rank "sees" for writing its - piece of the file. ---*/ - - MPI_File_set_view(fhw, disp2, etype, filetype, - (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write simultaneously. ---*/ - - MPI_File_write_all(fhw, coord_buf, myPoint*NCOORDS, MPI_FLOAT, &status); - - /*--- Update the displacement position for MPI IO. ---*/ - - disp += NCOORDS*nPoint_Cum[size]*sizeof(float); - fileSize += sizeof(float)*myPoint*NCOORDS; - - /*--- Free the derived datatype and coordinate array. ---*/ - - MPI_Type_free(&filetype); - delete [] coord_buf; + + if (!bigEndian) SwapBytes((char *)dataBufferFloat.data(), sizeof(float), myPoint*NCOORDS); + + /*--- Compute various data sizes --- */ + + unsigned long sizeInBytesPerPoint = sizeof(float)*NCOORDS; + unsigned long sizeInBytesLocal = sizeInBytesPerPoint*myPoint; + unsigned long sizeInBytesGlobal = sizeInBytesPerPoint*GlobalPoint; + unsigned long offsetInBytes = sizeInBytesPerPoint*dataSorter->GetnPointCumulative(rank); + + WriteMPIBinaryDataAll(dataBufferFloat.data(), sizeInBytesLocal, sizeInBytesGlobal, offsetInBytes); /*--- Compute our local number of elements, the required storage, and reduce the total number of elements and storage globally. ---*/ - unsigned long nTot_Line; - unsigned long nTot_Tria, nTot_Quad; - unsigned long nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; unsigned long myElem, myElemStorage, GlobalElem, GlobalElemStorage; - + unsigned long nParallel_Line = dataSorter->GetnElem(LINE), nParallel_Tria = dataSorter->GetnElem(TRIANGLE), nParallel_Quad = dataSorter->GetnElem(QUADRILATERAL), @@ -624,33 +147,33 @@ void CParaviewBinaryFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); - - SU2_MPI::Allreduce(&nParallel_Line, &nTot_Line, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tria, &nTot_Tria, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Quad, &nTot_Quad, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tetr, &nTot_Tetr, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Hexa, &nTot_Hexa, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pris, &nTot_Pris, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pyra, &nTot_Pyra, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - - myElem = (nParallel_Line + nParallel_Tria + nParallel_Quad + nParallel_Tetr + - nParallel_Hexa + nParallel_Pris + nParallel_Pyra); - myElemStorage = (nParallel_Line*3 + nParallel_Tria*4 + nParallel_Quad*5 + nParallel_Tetr*5 + - nParallel_Hexa*9 + nParallel_Pris*7 + nParallel_Pyra*6); - - GlobalElem = (nTot_Line + nTot_Tria + nTot_Quad + nTot_Tetr + - nTot_Hexa + nTot_Pris + nTot_Pyra); - GlobalElemStorage = (nTot_Line*3 + nTot_Tria*4 + nTot_Quad*5 + nTot_Tetr*5 + - nTot_Hexa*9 + nTot_Pris*7 + nTot_Pyra*6); - - + + unsigned long nTot_Line = dataSorter->GetnElemGlobal(LINE), + nTot_Tria = dataSorter->GetnElemGlobal(TRIANGLE), + nTot_Quad = dataSorter->GetnElemGlobal(QUADRILATERAL), + nTot_Tetr = dataSorter->GetnElemGlobal(TETRAHEDRON), + nTot_Hexa = dataSorter->GetnElemGlobal(HEXAHEDRON), + nTot_Pris = dataSorter->GetnElemGlobal(PRISM), + nTot_Pyra = dataSorter->GetnElemGlobal(PYRAMID); + + myElem = dataSorter->GetnElem(); + + myElemStorage = (nParallel_Line*N_POINTS_LINE + + nParallel_Tria*N_POINTS_TRIANGLE + + nParallel_Quad*N_POINTS_QUADRILATERAL + + nParallel_Tetr*N_POINTS_TETRAHEDRON + + nParallel_Hexa*N_POINTS_HEXAHEDRON + + nParallel_Pris*N_POINTS_PRISM + + nParallel_Pyra*N_POINTS_PYRAMID); + + GlobalElem = dataSorter->GetnElemGlobal(); + GlobalElemStorage = (nTot_Line*N_POINTS_LINE + + nTot_Tria*N_POINTS_TRIANGLE + + nTot_Quad*N_POINTS_QUADRILATERAL + + nTot_Tetr*N_POINTS_TETRAHEDRON + + nTot_Hexa*N_POINTS_HEXAHEDRON + + nTot_Pris*N_POINTS_PRISM + + nTot_Pyra*N_POINTS_PYRAMID); /*--- Communicate the number of total cells/storage that will be written by each rank. After this communication, each proc knows how @@ -683,218 +206,63 @@ void CParaviewBinaryFileWriter::Write_Data(){ nElem_Cum[ii+1] += nElem_Cum[ii]; nElemStorage_Cum[ii+1] += nElemStorage_Cum[ii]; } - - /*--- Reset the file view before writing the next ASCII line for cells. ---*/ - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); + SPRINTF(str_buf, "\nCELLS %i %i\n", SU2_TYPE::Int(GlobalElem), SU2_TYPE::Int(GlobalElemStorage)); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - + WriteMPIString(str_buf, MASTER_NODE); + /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ - int *conn_buf = new int[myElemStorage]; - unsigned long iStorage = 0; - - for (iElem = 0; iElem < nParallel_Line; iElem++) { - conn_buf[iStorage+0] = N_POINTS_LINE; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(LINE, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(LINE, iElem, 1)-1; - iStorage += (N_POINTS_LINE+1); - } - - for (iElem = 0; iElem < nParallel_Tria; iElem++) { - conn_buf[iStorage+0] = N_POINTS_TRIANGLE; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 1)-1; - conn_buf[iStorage+3] = dataSorter->GetElem_Connectivity(TRIANGLE, iElem, 2)-1 ; - iStorage += (N_POINTS_TRIANGLE+1); - } - - for (iElem = 0; iElem < nParallel_Quad; iElem++) { - conn_buf[iStorage+0] = N_POINTS_QUADRILATERAL; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 1)-1; - conn_buf[iStorage+3] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 2)-1; - conn_buf[iStorage+4] = dataSorter->GetElem_Connectivity(QUADRILATERAL, iElem, 3)-1; - iStorage += (N_POINTS_QUADRILATERAL+1); - - } - - for (iElem = 0; iElem < nParallel_Tetr; iElem++) { - conn_buf[iStorage+0] = N_POINTS_TETRAHEDRON; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 1)-1; - conn_buf[iStorage+3] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 2)-1; - conn_buf[iStorage+4] = dataSorter->GetElem_Connectivity(TETRAHEDRON, iElem, 3)-1; - iStorage += (N_POINTS_TETRAHEDRON+1); - - } - - for (iElem = 0; iElem < nParallel_Hexa; iElem++) { - conn_buf[iStorage+0] = N_POINTS_HEXAHEDRON; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 1)-1; - conn_buf[iStorage+3] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 2)-1; - conn_buf[iStorage+4] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 3)-1; - conn_buf[iStorage+5] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 4)-1; - conn_buf[iStorage+6] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 5)-1; - conn_buf[iStorage+7] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 6)-1; - conn_buf[iStorage+8] = dataSorter->GetElem_Connectivity(HEXAHEDRON, iElem, 7)-1; - iStorage += (N_POINTS_HEXAHEDRON+1); - } - - for (iElem = 0; iElem < nParallel_Pris; iElem++) { - conn_buf[iStorage+0] = N_POINTS_PRISM; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(PRISM, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(PRISM, iElem, 1)-1; - conn_buf[iStorage+3] = dataSorter->GetElem_Connectivity(PRISM, iElem, 2)-1; - conn_buf[iStorage+4] = dataSorter->GetElem_Connectivity(PRISM, iElem, 3)-1; - conn_buf[iStorage+5] = dataSorter->GetElem_Connectivity(PRISM, iElem, 4)-1; - conn_buf[iStorage+6] = dataSorter->GetElem_Connectivity(PRISM, iElem, 5)-1; - iStorage += (N_POINTS_PRISM+1); - } - - for (iElem = 0; iElem < nParallel_Pyra; iElem++) { - conn_buf[iStorage+0] = N_POINTS_PYRAMID; - conn_buf[iStorage+1] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 0)-1; - conn_buf[iStorage+2] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 1)-1; - conn_buf[iStorage+3] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 2)-1; - conn_buf[iStorage+4] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 3)-1; - conn_buf[iStorage+5] = dataSorter->GetElem_Connectivity(PYRAMID, iElem, 4)-1; - iStorage += (N_POINTS_PYRAMID+1); - } - - - if (!BigEndian) SwapBytes((char *)conn_buf, sizeof(int), myElemStorage); - - /*--- We write the connectivity with MPI_INTs. ---*/ - - etype = MPI_INT; - - /*--- Define a derived datatype for this ranks contiguous - chunk of data that will be placed in the file. ---*/ - - MPI_Type_contiguous(myElemStorage, MPI_INT, &filetype); - MPI_Type_commit(&filetype); - - /*--- Compute the offset for this rank's linear partition of the - data in bytes. ---*/ - - disp2 = (disp + nElemStorage_Cum[rank]*sizeof(int)); - - /*--- Set the view for the MPI file write, i.e., describe the - location in the file that this rank "sees" for writing its - piece of the file. ---*/ - - MPI_File_set_view(fhw, disp2, etype, filetype, - (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write simultaneously. ---*/ - - MPI_File_write_all(fhw, conn_buf, myElemStorage, MPI_INT, &status); - - /*--- Update the displacement position for MPI IO. ---*/ - - disp += nElemStorage_Cum[size]*sizeof(int); - - fileSize += sizeof(int)*myElemStorage; - - /*--- Free the derived datatype. ---*/ - - MPI_Type_free(&filetype); - delete [] conn_buf; + vector connBuf(myElemStorage); + unsigned long iStorage = 0, iElemID = 0; + unsigned short iNode = 0; - /*--- Load/write the cell type for all elements in the file. ---*/ - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); + auto copyToBuffer = [&](GEO_TYPE type, unsigned long nElem, unsigned short nPoints){ + for (iElem = 0; iElem < nElem; iElem++) { + for (iNode = 0; iNode < nPoints; iNode++){ + connBuf[iStorage+iNode] = int(dataSorter->GetElem_Connectivity(type, iElem, iNode)-1); + } + iStorage += nPoints; + } + }; + + copyToBuffer(LINE, nParallel_Line, N_POINTS_LINE); + copyToBuffer(TRIANGLE, nParallel_Tria, N_POINTS_TRIANGLE); + copyToBuffer(QUADRILATERAL, nParallel_Quad, N_POINTS_QUADRILATERAL); + copyToBuffer(TETRAHEDRON, nParallel_Tetr, N_POINTS_TETRAHEDRON); + copyToBuffer(HEXAHEDRON, nParallel_Hexa, N_POINTS_HEXAHEDRON); + copyToBuffer(PRISM, nParallel_Pris, N_POINTS_PRISM); + copyToBuffer(PYRAMID, nParallel_Pyra, N_POINTS_PYRAMID); + + if (!bigEndian) SwapBytes((char *)connBuf.data(), sizeof(int), myElemStorage); + + WriteMPIBinaryDataAll(connBuf.data(), + myElemStorage*sizeof(int), + GlobalElemStorage*sizeof(int), + nElemStorage_Cum[rank]*sizeof(int)); + SPRINTF (str_buf, "\nCELL_TYPES %i\n", SU2_TYPE::Int(GlobalElem)); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - int *type_buf = new int[myElem]; - unsigned long jElem = 0; - - for (iElem = 0; iElem < nParallel_Line; iElem++) { - type_buf[jElem] = LINE; jElem++; - } - for (iElem = 0; iElem < nParallel_Tria; iElem++) { - type_buf[jElem] = TRIANGLE; jElem++; - } - for (iElem = 0; iElem < nParallel_Quad; iElem++) { - type_buf[jElem] = QUADRILATERAL; jElem++; - } - for (iElem = 0; iElem < nParallel_Tetr; iElem++) { - type_buf[jElem] = TETRAHEDRON; jElem++; - } - for (iElem = 0; iElem < nParallel_Hexa; iElem++) { - type_buf[jElem] = HEXAHEDRON; jElem++; - } - for (iElem = 0; iElem < nParallel_Pris; iElem++) { - type_buf[jElem] = PRISM; jElem++; - } - for (iElem = 0; iElem < nParallel_Pyra; iElem++) { - type_buf[jElem] = PYRAMID; jElem++; - } - - if (!BigEndian) SwapBytes((char *)type_buf, sizeof(int), myElem); - - /*--- We write the cell types with MPI_INTs. ---*/ - - etype = MPI_INT; - - /*--- Define a derived datatype for this ranks contiguous - chunk of data that will be placed in the file. ---*/ - - MPI_Type_contiguous(myElem, MPI_INT, &filetype); - MPI_Type_commit(&filetype); - - /*--- Compute the offset for this rank's linear partition of the - data in bytes. ---*/ + WriteMPIString(str_buf, MASTER_NODE); - disp2 = (disp + nElem_Cum[rank]*sizeof(int)); - - /*--- Set the view for the MPI file write, i.e., describe the - location in the file that this rank "sees" for writing its - piece of the file. ---*/ - - MPI_File_set_view(fhw, disp2, etype, filetype, - (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write simultaneously. ---*/ - - MPI_File_write_all(fhw, type_buf, myElem, MPI_INT, &status); - - /*--- Update the displacement position for MPI IO. ---*/ - - disp += nElem_Cum[size]*sizeof(int); - - fileSize += sizeof(int)*myElem; - - /*--- Free the derived datatype. ---*/ + /*--- Load/write the cell type for all elements in the file. ---*/ - MPI_Type_free(&filetype); - if (type_buf != NULL) delete [] type_buf; + vector typeBuf(myElem); + vector::iterator typeIter = typeBuf.begin(); - /*--- Now write the scalar and vector point data. ---*/ + std::fill(typeIter, typeIter+nParallel_Line, LINE); typeIter += nParallel_Line; + std::fill(typeIter, typeIter+nParallel_Tria, TRIANGLE); typeIter += nParallel_Tria; + std::fill(typeIter, typeIter+nParallel_Quad, QUADRILATERAL); typeIter += nParallel_Quad; + std::fill(typeIter, typeIter+nParallel_Tetr, TETRAHEDRON); typeIter += nParallel_Tetr; + std::fill(typeIter, typeIter+nParallel_Hexa, HEXAHEDRON); typeIter += nParallel_Hexa; + std::fill(typeIter, typeIter+nParallel_Pris, PRISM); typeIter += nParallel_Pris; + std::fill(typeIter, typeIter+nParallel_Pyra, PYRAMID); typeIter += nParallel_Pyra; + + if (!bigEndian) SwapBytes((char *)typeBuf.data(), sizeof(int), myElem); - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); - SPRINTF (str_buf, "\nPOINT_DATA %i\n", SU2_TYPE::Int(GlobalPoint)); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); + WriteMPIBinaryDataAll(typeBuf.data(), + myElem*sizeof(int), + GlobalElem*sizeof(int), + nElem_Cum[rank]*sizeof(int)); /*--- Adjust container start location to avoid point coords. ---*/ @@ -938,18 +306,9 @@ void CParaviewBinaryFileWriter::Write_Data(){ /*--- Adjust the string name to remove the leading "X-" ---*/ fieldname.erase(fieldname.end()-2,fieldname.end()); - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); + SPRINTF (str_buf, "\nVECTORS %s float\n", fieldname.c_str()); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *vec_buf = new float[myPoint*NCOORDS]; + WriteMPIString(str_buf, MASTER_NODE); /*--- Load up the buffer for writing this rank's vector data. ---*/ @@ -957,155 +316,46 @@ void CParaviewBinaryFileWriter::Write_Data(){ for (iPoint = 0; iPoint < myPoint; iPoint++) { for (iDim = 0; iDim < NCOORDS; iDim++) { if (nDim == 2 && iDim == 2) { - vec_buf[iPoint*NCOORDS + iDim] = 0.0; + dataBufferFloat[iPoint*NCOORDS + iDim] = 0.0; } else { val = (float)dataSorter->GetData(VarCounter+iDim,iPoint); - vec_buf[iPoint*NCOORDS + iDim] = val; + dataBufferFloat[iPoint*NCOORDS + iDim] = val; } } } - if (!BigEndian) - SwapBytes((char *)vec_buf, sizeof(float), myPoint*NCOORDS); - - /*--- We will write the point data as floats. ---*/ - - etype = MPI_FLOAT; - - /*--- Define a derived datatype for this ranks contiguous - chunk of data that will be placed in the file. ---*/ - - MPI_Type_contiguous(myPoint*NCOORDS, MPI_FLOAT, &filetype); - MPI_Type_commit(&filetype); - - /*--- Compute the offset for this rank's linear partition of the - data in bytes. ---*/ - - disp2 = disp + NCOORDS*nPoint_Cum[rank]*sizeof(float); - - /*--- Set the view for the MPI file write, i.e., describe the - location in the file that this rank "sees" for writing its - piece of the file. ---*/ - - MPI_File_set_view(fhw, disp2, etype, filetype, - (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write simultaneously. ---*/ - - MPI_File_write_all(fhw, vec_buf, myPoint*NCOORDS, MPI_FLOAT, &status); - - /*--- Update the displacement position for MPI IO. ---*/ - - disp += NCOORDS*nPoint_Cum[size]*sizeof(float); - - fileSize += sizeof(float)*myPoint*NCOORDS; - - /*--- Free the derived datatype and coordinate array. ---*/ - - MPI_Type_free(&filetype); - delete [] vec_buf; vec_buf = NULL; + if (!bigEndian) + SwapBytes((char *)dataBufferFloat.data(), sizeof(float), myPoint*NCOORDS); + WriteMPIBinaryDataAll(dataBufferFloat.data(), + myPoint*NCOORDS*sizeof(float), + GlobalPoint*NCOORDS*sizeof(float), + nPoint_Cum[rank]*NCOORDS*sizeof(float)); VarCounter++; } else if (output_variable) { - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); - SPRINTF (str_buf, "\nSCALARS %s float 1\n", fieldname.c_str()); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - MPI_File_set_view(fhw, 0, MPI_BYTE, MPI_BYTE, - (char*)"native", MPI_INFO_NULL); - SPRINTF (str_buf, "LOOKUP_TABLE default\n"); - if (rank == MASTER_NODE) - MPI_File_write_at(fhw, disp, str_buf, strlen(str_buf), - MPI_CHAR, MPI_STATUS_IGNORE); - disp += strlen(str_buf)*sizeof(char); - fileSize += sizeof(char)*strlen(str_buf); - - /*--- Prepare the 1D data buffer on this rank. ---*/ - - float *scalar_buf = new float[myPoint]; - /*--- For now, create a temp 1D buffer to load up the data for writing. This will be replaced with a derived data type most likely. ---*/ for (iPoint = 0; iPoint < myPoint; iPoint++) { float val = (float)dataSorter->GetData(VarCounter,iPoint); - scalar_buf[iPoint] = val; + dataBufferFloat[iPoint] = val; } - if (!BigEndian) SwapBytes((char *)scalar_buf, sizeof(float), myPoint); - - /*--- We will write the point data as floats. ---*/ - - etype = MPI_FLOAT; - - /*--- Define a derived datatype for this ranks contiguous - chunk of data that will be placed in the file. ---*/ - - MPI_Type_contiguous(myPoint, MPI_FLOAT, &filetype); - MPI_Type_commit(&filetype); - - /*--- Compute the offset for this rank's linear partition of the - data in bytes. ---*/ - - disp2 = disp + nPoint_Cum[rank]*sizeof(float); - - /*--- Set the view for the MPI file write, i.e., describe the - location in the file that this rank "sees" for writing its - piece of the file. ---*/ - - MPI_File_set_view(fhw, disp2, etype, filetype, - (char*)"native", MPI_INFO_NULL); - - /*--- Collective call for all ranks to write simultaneously. ---*/ - - MPI_File_write_all(fhw, scalar_buf, myPoint, MPI_FLOAT, &status); - - /*--- Update the displacement position for MPI IO. ---*/ - - disp += nPoint_Cum[size]*sizeof(float); - - fileSize += sizeof(float)*myPoint; - - /*--- Free the derived datatype and coordinate array. ---*/ - - MPI_Type_free(&filetype); - delete [] scalar_buf; scalar_buf = NULL; + + if (!bigEndian) + SwapBytes((char *)dataBufferFloat.data(), sizeof(float), myPoint); + + WriteMPIBinaryDataAll(dataBufferFloat.data(), + myPoint*sizeof(float), + GlobalPoint*sizeof(float), + nPoint_Cum[rank]*sizeof(float)); + VarCounter++; } } - /*--- All ranks close the file after writing. ---*/ - - MPI_File_close(&fhw); - - - /*--- Compute and store the write time. ---*/ - -#ifndef HAVE_MPI - StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - stopTime = MPI_Wtime(); -#endif - usedTime = stopTime-startTime; - - /*--- Communicate the total file size for the restart ---*/ - -#ifdef HAVE_MPI - su2double my_fileSize = fileSize; - SU2_MPI::Allreduce(&my_fileSize, &fileSize, 1, - MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); -#endif - - /*--- Compute and store the bandwidth ---*/ - - bandwidth = fileSize/(1.0e6)/usedTime; + CloseMPIFile(); /*--- Delete the offset counters that we needed for MPI IO. ---*/ @@ -1113,7 +363,6 @@ void CParaviewBinaryFileWriter::Write_Data(){ delete [] nElemStorage_Snd; delete [] nElemStorage_Cum; delete [] nPoint_Snd; delete [] nPoint_Cum; -#endif } From 4946d3b9a0af1bf1a10c342d1b6c5400dfd2a1b4 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 18:13:23 +0100 Subject: [PATCH 45/61] Updating paraview xml writer --- .../filewriter/CParaviewXMLFileWriter.cpp | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 65652af332a..5a852197bf4 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -87,9 +87,6 @@ void CParaviewXMLFileWriter::Write_Data(){ /*--- Compute our local number of elements, the required storage, and reduce the total number of elements and storage globally. ---*/ - unsigned long nTot_Line; - unsigned long nTot_Tria, nTot_Quad; - unsigned long nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; unsigned long myElem, myElemStorage, GlobalElem, GlobalElemStorage; unsigned long nParallel_Line = dataSorter->GetnElem(LINE), @@ -99,31 +96,33 @@ void CParaviewXMLFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); - - SU2_MPI::Allreduce(&nParallel_Line, &nTot_Line, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tria, &nTot_Tria, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Quad, &nTot_Quad, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tetr, &nTot_Tetr, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Hexa, &nTot_Hexa, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pris, &nTot_Pris, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pyra, &nTot_Pyra, 1, - MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - - myElem = (nParallel_Line + nParallel_Tria + nParallel_Quad + nParallel_Tetr + - nParallel_Hexa + nParallel_Pris + nParallel_Pyra); - myElemStorage = (nParallel_Line*2 + nParallel_Tria*3 + nParallel_Quad*4 + nParallel_Tetr*4 + - nParallel_Hexa*8 + nParallel_Pris*6 + nParallel_Pyra*5); - - GlobalElem = (nTot_Line + nTot_Tria + nTot_Quad + nTot_Tetr + - nTot_Hexa + nTot_Pris + nTot_Pyra); - GlobalElemStorage = (nTot_Line*2 + nTot_Tria*3 + nTot_Quad*4 + nTot_Tetr*4 + - nTot_Hexa*8 + nTot_Pris*6 + nTot_Pyra*5); + + unsigned long nTot_Line = dataSorter->GetnElemGlobal(LINE), + nTot_Tria = dataSorter->GetnElemGlobal(TRIANGLE), + nTot_Quad = dataSorter->GetnElemGlobal(QUADRILATERAL), + nTot_Tetr = dataSorter->GetnElemGlobal(TETRAHEDRON), + nTot_Hexa = dataSorter->GetnElemGlobal(HEXAHEDRON), + nTot_Pris = dataSorter->GetnElemGlobal(PRISM), + nTot_Pyra = dataSorter->GetnElemGlobal(PYRAMID); + + myElem = dataSorter->GetnElem(); + + myElemStorage = (nParallel_Line*N_POINTS_LINE + + nParallel_Tria*N_POINTS_TRIANGLE + + nParallel_Quad*N_POINTS_QUADRILATERAL + + nParallel_Tetr*N_POINTS_TETRAHEDRON + + nParallel_Hexa*N_POINTS_HEXAHEDRON + + nParallel_Pris*N_POINTS_PRISM + + nParallel_Pyra*N_POINTS_PYRAMID); + + GlobalElem = dataSorter->GetnElemGlobal(); + GlobalElemStorage = (nTot_Line*N_POINTS_LINE + + nTot_Tria*N_POINTS_TRIANGLE + + nTot_Quad*N_POINTS_QUADRILATERAL + + nTot_Tetr*N_POINTS_TETRAHEDRON + + nTot_Hexa*N_POINTS_HEXAHEDRON + + nTot_Pris*N_POINTS_PRISM + + nTot_Pyra*N_POINTS_PYRAMID); /* Write the ASCII XML header. Note that we use the appended format for the data, * which means that all data is appended at the end of the file in one binary blob. From ce99d3e081eabbc492650d74e619ce5de60eb7d2 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 18:31:25 +0100 Subject: [PATCH 46/61] Removing redundant member variables --- .../filewriter/CParaviewXMLFileWriter.hpp | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index 05644bf11a5..cf5e5baab33 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -42,29 +42,6 @@ class CParaviewXMLFileWriter final: public CFileWriter{ UINT8 }; -#ifdef HAVE_MPI - /*! - * \brief The displacement that every process has in the current file view - */ - MPI_Offset disp; - - /*! - * \brief The file handle for writing - */ - MPI_File fhw; -#else - - /*! - * \brief The displacement that every process has in the current file view - */ - unsigned long disp; - - /*! - * \brief The file handle for writing - */ - FILE* fhw; -#endif - /*! * \brief Boolean storing whether we are on a big or little endian machine */ From 8609172ca7e26ec49639bca061343908e1b9cc22 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 18:31:46 +0100 Subject: [PATCH 47/61] changing dyn. allocation to static --- SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index b52021646df..8d84f853c87 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -100,9 +100,8 @@ void CParaviewVTMFileWriter::AddDataset(string name, string file, CParallelDataS /*--- Create an XML writer and dump data into file ---*/ - CParaviewXMLFileWriter* XMLWriter = new CParaviewXMLFileWriter(fullFilename, dataSorter); - XMLWriter->Write_Data(); - delete XMLWriter; + CParaviewXMLFileWriter XMLWriter(fullFilename, dataSorter); + XMLWriter.Write_Data(); /*--- Add the dataset to the vtm file ---*/ From a84ce0bff95597ec7d4e4f773f4ee8a1568bbcfc Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 17 Jan 2020 20:12:10 +0100 Subject: [PATCH 48/61] small fix --- SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index 38dd50ac5bc..407fa669f81 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -96,8 +96,8 @@ bool CFileWriter::WriteMPIBinaryDataAll(const void *data, unsigned long sizeInBy /*--- Write binary data ---*/ - bytesWritte = fwrite(data, sizeof(char), sizeInBytes, fhw); - fileSize += byteSize; + bytesWritten = fwrite(data, sizeof(char), sizeInBytes, fhw); + fileSize += bytesWritten; return (bytesWritten == sizeInBytes); #endif @@ -128,7 +128,7 @@ bool CFileWriter::WriteMPIBinaryData(const void *data, unsigned long sizeInBytes /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ - bytesWritten = fwrite(&totalByteSize, sizeof(int),1, fhw); + bytesWritten = fwrite(data, sizeof(char), sizeInBytes, fhw); return (bytesWritten == sizeInBytes); @@ -161,7 +161,7 @@ bool CFileWriter::WriteMPIString(const string &str, unsigned short processor){ fileSize += bytesWritten; - return (bytesWritten == sizeInBytes); + return (bytesWritten == str.size()*sizeof(char)); #endif From 0750f38d09a7f520f2eae90dbaf2b2ec22b5a6b5 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 20 Jan 2020 14:06:50 +0100 Subject: [PATCH 49/61] Some refactoring and renaming of variables in data sorter --- .../output/filewriter/CParallelDataSorter.hpp | 96 ++++++++++++++----- .../src/output/filewriter/CFEMDataSorter.cpp | 16 ++-- .../src/output/filewriter/CFVMDataSorter.cpp | 64 ++++++------- .../output/filewriter/CParallelDataSorter.cpp | 88 ++++++++++++++--- .../filewriter/CSurfaceFEMDataSorter.cpp | 32 +++---- .../filewriter/CSurfaceFVMDataSorter.cpp | 51 ++++------ 6 files changed, 214 insertions(+), 133 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index dd3f425363a..69e45f27b3d 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -46,21 +46,20 @@ class CParallelDataSorter{ * \brief The MPI size, aka the number of processors. */ int size; - - unsigned long nGlobal_Poin_Par; //!< Global number of points without halos before sorting - unsigned long nGlobal_Elem_Par; //!< Global number of elems without halos before sorting - unsigned long nParallel_Poin; //!< Local number of points after sorting on this proc - int *Conn_Line_Par; //!< Local connectivity of line elements after sorting on this proc - int *Conn_Tria_Par; //!< Local connectivity of triangle elements after sorting on this proc - int *Conn_Quad_Par; //!< Local connectivity of quad elements after sorting on this proc - int *Conn_Tetr_Par; //!< Local connectivity of tetrahedral elements after sorting on this proc - int *Conn_Hexa_Par; //!< Local connectivity of hexahedral elements after sorting on this proc - int *Conn_Pris_Par; //!< Local connectivity of prism elements after sorting on this proc - int *Conn_Pyra_Par; //!< Local connectivity of pyramid elements after sorting on this proc - - array nGlobal_Elem; //!< Global number of elements after sorting on this proc - array nParallel_Elem; //!< Local number of elements after sorting on this proc + unsigned long nGlobalPointBeforeSort; //!< Global number of points without halos before sorting + unsigned long nLocalPointBeforeSort; //!< Local number of points without halos before sorting on this proc + + int *Conn_Line_Par; //!< Local connectivity of line elements + int *Conn_Tria_Par; //!< Local connectivity of triangle elements + int *Conn_Quad_Par; //!< Local connectivity of quad elements + int *Conn_Tetr_Par; //!< Local connectivity of tetrahedral elements + int *Conn_Hexa_Par; //!< Local connectivity of hexahedral elements + int *Conn_Pris_Par; //!< Local connectivity of prism elements + int *Conn_Pyra_Par; //!< Local connectivity of pyramid elements + + array nGlobalPerElem; //!< Global number of elements after sorting on this proc + array nLocalPerElem; //!< Local number of elements after sorting on this proc /*! * \brief Map that stores the index for each GEO_TYPE type where to find information @@ -68,10 +67,13 @@ class CParallelDataSorter{ */ static const map TypeMap; - unsigned long nGlobalPoint_Sort; //!< Global number of points without halos after sorting - unsigned long nLocalPoint_Sort; //!< Local number of points without halos after sorting on this proc - - + unsigned long nGlobalPoint; //!< Global number of points without halos + unsigned long nGlobalElem; //!< Global number of elems without halos + unsigned long nGlobalConn; //!< Global size of the connectivity array + unsigned long nLocalPoint; //!< Local number of points + unsigned long nLocalElem; //!< Local number of elements + unsigned long nLocalConn; //!< Local size of the connectivity array + CLinearPartitioner* linearPartitioner; //!< Linear partitioner based on the global number of points. unsigned short GlobalField_Counter; //!< Number of output fields @@ -80,6 +82,10 @@ class CParallelDataSorter{ int *nPoint_Send; //!< Number of points this processor has to send to other processors int *nPoint_Recv; //!< Number of points this processor receives from other processors + int *nElem_Send; //!< Number of elements this processor has to send to other processors + int *nElem_Cum; //!< Cumulative number of elements + int *nElemConn_Send; //!< Number of element connectivity this processor has to send to other processors + int *nElemConn_Cum; //!< Cumulative number of element connectivity entries unsigned long *Index; //!< Index each point has in the send buffer su2double *connSend; //!< Send buffer holding the data that will be send to other processors passivedouble *passiveDoubleBuffer; //!< Buffer holding the sorted, partitioned data as passivedouble types @@ -141,25 +147,25 @@ class CParallelDataSorter{ * \brief Get the number of points the local rank owns. * \return local number of points. */ - unsigned long GetnPoints() const {return nParallel_Poin;} + unsigned long GetnPoints() const {return nLocalPoint;} /*! * \brief Get the number of points to sort. * \return local number of points. */ - unsigned long GetnLocalPointSort() const {return nLocalPoint_Sort;} + unsigned long GetnLocalPointSort() const {return nLocalPointBeforeSort;} /*! * \brief Get the global number of points (accumulated from all ranks) * \return Global number of points. */ - unsigned long GetnPointsGlobal() const {return nGlobal_Poin_Par;} + unsigned long GetnPointsGlobal() const {return nGlobalPoint;} /*! * \brief Get the global of elements (accumulated from all ranks and element types) * \return Global number elements. */ - unsigned long GetnElem() const {return nGlobal_Elem_Par;} + unsigned long GetnElem() const {return nLocalElem;} /*! * \brief Get the local number of elements of a specific type that the current rank owns @@ -167,7 +173,7 @@ class CParallelDataSorter{ * \return Local number of elements of a specific type. */ unsigned long GetnElem(GEO_TYPE type) const { - return nParallel_Elem[TypeMap.at(type)]; + return nLocalPerElem[TypeMap.at(type)]; } /*! @@ -176,7 +182,7 @@ class CParallelDataSorter{ * \return global number of elements of a specific type. */ unsigned long GetnElemGlobal(GEO_TYPE type) const { - return nGlobal_Elem[TypeMap.at(type)]; + return nGlobalPerElem[TypeMap.at(type)]; } /*! @@ -184,7 +190,41 @@ class CParallelDataSorter{ * \return global number of elements. */ unsigned long GetnElemGlobal() const { - return nGlobal_Elem_Par; + return nGlobalElem; + } + + /*! + * \brief Get the global number entries of the connectivity array + * \return global number of entries of the connectivity array + */ + unsigned long GetnElemConnGlobal() const { + return nGlobalConn; + } + + /*! + * \brief Get the local number entries of the connectivity array + * \return local number of entries of the connectivity array + */ + unsigned long GetnElemConn() const { + return nLocalConn; + } + + /*! + * \brief Get the cumulated number of elements + * \input rank - the processor rank. + * \return The cumulated number of elements + */ + unsigned long GetnElemCumulative(unsigned short rank) const { + return nElem_Cum[rank]; + } + + /*! + * \brief Get the cumulated number of entries of the connectivity array + * \input rank - the processor rank. + * \return The cumulated number of entries of the connectivity array + */ + unsigned long GetnElemConnCumulative(unsigned short rank) const { + return nElemConn_Cum[rank]; } /*! @@ -282,4 +322,10 @@ class CParallelDataSorter{ unsigned short GetnDim() const { return nDim; } + + /*! + * \brief Set the total number of elements after sorting individual element types + */ + void SetTotalElements(); + }; diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index 0941964d4bc..d02387ab9b0 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -57,12 +57,12 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vecto const unsigned long globalIndex = volElem[l].offsetDOFsSolGlobal + j; globalID.push_back(globalIndex); - nLocalPoint_Sort++; + nLocalPointBeforeSort++; } } #ifdef HAVE_MPI - SU2_MPI::Allreduce(&nLocalPoint_Sort, &nGlobalPoint_Sort, 1, + SU2_MPI::Allreduce(&nLocalPointBeforeSort, &nGlobalPointBeforeSort, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #else nGlobalPoint_Sort = nLocalPoint_Sort; @@ -70,7 +70,7 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vecto /*--- Create a linear partition --- */ - linearPartitioner = new CLinearPartitioner(nGlobalPoint_Sort, 0); + linearPartitioner = new CLinearPartitioner(nGlobalPointBeforeSort, 0); /*--- Prepare the send buffers ---*/ @@ -103,13 +103,9 @@ void CFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool SortVolumetricConnectivity(config, geometry, HEXAHEDRON ); SortVolumetricConnectivity(config, geometry, PRISM ); SortVolumetricConnectivity(config, geometry, PYRAMID ); - - /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - - SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - - nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); + SetTotalElements(); + connectivitySorted = true; } @@ -211,7 +207,7 @@ void CFEMDataSorter::SortVolumetricConnectivity(CConfig *config, CGeometry *geom } } - nParallel_Elem[TypeMap.at(Elem_Type)] = nSubElem_Local; + nLocalPerElem[TypeMap.at(Elem_Type)] = nSubElem_Local; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index d91b58bc8c2..43196598e2e 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -36,8 +36,8 @@ CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vecto std::vector globalID; - nGlobalPoint_Sort = geometry->GetGlobal_nPointDomain(); - nLocalPoint_Sort = geometry->GetnPointDomain(); + nGlobalPointBeforeSort = geometry->GetGlobal_nPointDomain(); + nLocalPointBeforeSort = geometry->GetnPointDomain(); Local_Halo = new int[geometry->GetnPoint()](); @@ -60,7 +60,7 @@ CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vecto /*--- Create the linear partitioner --- */ - linearPartitioner = new CLinearPartitioner(nGlobalPoint_Sort, 0); + linearPartitioner = new CLinearPartitioner(nGlobalPointBeforeSort, 0); /*--- Prepare the send buffers ---*/ @@ -123,11 +123,7 @@ void CFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool SortVolumetricConnectivity(config, geometry, PRISM, val_sort); SortVolumetricConnectivity(config, geometry, PYRAMID, val_sort); - /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - - SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - - nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); + SetTotalElements(); connectivitySorted = true; @@ -186,16 +182,14 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, nodes, i.e., rank 0 holds the first nPoint()/nProcessors nodes. First, initialize a counter and flag. ---*/ - int *nElem_Send = new int[size+1](); nElem_Send[0] = 0; - int *nElem_Recv = new int[size+1](); nElem_Recv[0] = 0; int *nElem_Flag = new int[size](); for (int ii=0; ii < size; ii++) { nElem_Send[ii] = 0; - nElem_Recv[ii] = 0; + nElem_Cum[ii] = 0; nElem_Flag[ii]= -1; } - nElem_Send[size] = 0; nElem_Recv[size] = 0; + nElem_Send[size] = 0; nElem_Cum[size] = 0; for (int ii = 0; ii < (int)geometry->GetnElem(); ii++ ) { if (geometry->elem[ii]->GetVTK_Type() == Elem_Type) { @@ -246,7 +240,7 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, - &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); + &(nElem_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); #else nElem_Recv[1] = nElem_Send[1]; #endif @@ -261,10 +255,10 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, for (int ii = 0; ii < size; ii++) { if ((ii != rank) && (nElem_Send[ii+1] > 0)) nSends++; - if ((ii != rank) && (nElem_Recv[ii+1] > 0)) nRecvs++; + if ((ii != rank) && (nElem_Cum[ii+1] > 0)) nRecvs++; nElem_Send[ii+1] += nElem_Send[ii]; - nElem_Recv[ii+1] += nElem_Recv[ii]; + nElem_Cum[ii+1] += nElem_Cum[ii]; } /*--- Allocate memory to hold the connectivity that we are @@ -365,9 +359,9 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, directly copy our own data later. ---*/ unsigned long *connRecv = NULL; - connRecv = new unsigned long[NODES_PER_ELEMENT*nElem_Recv[size]](); + connRecv = new unsigned long[NODES_PER_ELEMENT*nElem_Cum[size]](); - unsigned short *haloRecv = new unsigned short[nElem_Recv[size]](); + unsigned short *haloRecv = new unsigned short[nElem_Cum[size]](); #ifdef HAVE_MPI @@ -378,9 +372,9 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, unsigned long iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { - int ll = NODES_PER_ELEMENT*nElem_Recv[ii]; - int kk = nElem_Recv[ii+1] - nElem_Recv[ii]; + if ((ii != rank) && (nElem_Cum[ii+1] > nElem_Cum[ii])) { + int ll = NODES_PER_ELEMENT*nElem_Cum[ii]; + int kk = nElem_Cum[ii+1] - nElem_Cum[ii]; int count = NODES_PER_ELEMENT*kk; int source = ii; int tag = ii + 1; @@ -410,9 +404,9 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, iMessage = 0; for (int ii=0; ii nElem_Recv[ii])) { - int ll = nElem_Recv[ii]; - int kk = nElem_Recv[ii+1] - nElem_Recv[ii]; + if ((ii != rank) && (nElem_Cum[ii+1] > nElem_Cum[ii])) { + int ll = nElem_Cum[ii]; + int kk = nElem_Cum[ii+1] - nElem_Cum[ii]; int count = kk; int source = ii; int tag = ii + 1; @@ -441,13 +435,13 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, /*--- Copy my own rank's data into the recv buffer directly. ---*/ - int mm = NODES_PER_ELEMENT*nElem_Recv[rank]; + int mm = NODES_PER_ELEMENT*nElem_Cum[rank]; int ll = NODES_PER_ELEMENT*nElem_Send[rank]; int kk = NODES_PER_ELEMENT*nElem_Send[rank+1]; for (int nn=ll; nn 0) Conn_Elem = new int[NODES_PER_ELEMENT*nElem_Recv[size]](); + if (nElem_Cum[size] > 0) Conn_Elem = new int[NODES_PER_ELEMENT*nElem_Cum[size]](); int count = 0; nElem_Total = 0; - for (int ii = 0; ii < nElem_Recv[size]; ii++) { + for (int ii = 0; ii < nElem_Cum[size]; ii++) { if (!haloRecv[ii]) { nElem_Total++; for (int jj = 0; jj < NODES_PER_ELEMENT; jj++) { @@ -485,7 +479,7 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, } } - nParallel_Elem[TypeMap.at(Elem_Type)] = nElem_Total; + nLocalPerElem[TypeMap.at(Elem_Type)] = nElem_Total; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ @@ -493,27 +487,27 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, switch (Elem_Type) { case TRIANGLE: if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; - if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Tria_Par = Conn_Elem; + Conn_Tria_Par = Conn_Elem; break; case QUADRILATERAL: if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; - if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Quad_Par = Conn_Elem; + Conn_Quad_Par = Conn_Elem; break; case TETRAHEDRON: if (Conn_Tetr_Par != NULL) delete [] Conn_Tetr_Par; - if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Tetr_Par = Conn_Elem; + Conn_Tetr_Par = Conn_Elem; break; case HEXAHEDRON: if (Conn_Hexa_Par != NULL) delete [] Conn_Hexa_Par; - if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Hexa_Par = Conn_Elem; + Conn_Hexa_Par = Conn_Elem; break; case PRISM: if (Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; - if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Pris_Par = Conn_Elem; + Conn_Pris_Par = Conn_Elem; break; case PYRAMID: if (Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; - if (nParallel_Elem[TypeMap.at(Elem_Type)] > 0) Conn_Pyra_Par = Conn_Elem; + Conn_Pyra_Par = Conn_Elem; break; default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); @@ -526,8 +520,6 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, delete [] connRecv; delete [] haloSend; delete [] haloRecv; - delete [] nElem_Recv; - delete [] nElem_Send; delete [] nElem_Flag; } diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index ddb4ffad9a8..407f00b0dfd 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -27,6 +27,8 @@ #include "../../../include/output/filewriter/CParallelDataSorter.hpp" #include +#include + const map CParallelDataSorter::TypeMap = { {LINE, 0}, @@ -65,16 +67,20 @@ CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector & nSends = 0; nRecvs = 0; - nLocalPoint_Sort = 0; - nGlobalPoint_Sort = 0; + nLocalPointBeforeSort = 0; + nGlobalPointBeforeSort = 0; nPoint_Send = new int[size+1](); nPoint_Recv = new int[size+1](); - + nElem_Send = new int[size+1](); + nElem_Cum = new int[size+1](); + nElemConn_Send = new int[size+1](); + nElemConn_Cum = new int[size+1](); + linearPartitioner = NULL; - nParallel_Elem.fill(0); - nGlobal_Elem.fill(0); + nLocalPerElem.fill(0); + nGlobalPerElem.fill(0); } @@ -82,7 +88,11 @@ CParallelDataSorter::~CParallelDataSorter(){ if (nPoint_Send != NULL) delete [] nPoint_Send; if (nPoint_Recv != NULL) delete [] nPoint_Recv; - + if (nElem_Send != NULL) delete [] nElem_Send; + if (nElem_Cum != NULL) delete [] nElem_Cum; + if (nElemConn_Send != NULL) delete [] nElemConn_Send; + if (nElemConn_Cum != NULL) delete [] nElemConn_Cum; + /*--- Deallocate memory for connectivity data on each processor. ---*/ if (GetnElem(LINE) > 0 && Conn_Line_Par != NULL) delete [] Conn_Line_Par; @@ -247,14 +257,14 @@ void CParallelDataSorter::SortOutputData() { /*--- Store the total number of local points my rank has for the current section after completing the communications. ---*/ - nParallel_Poin = nPoint_Recv[size]; + nLocalPoint = nPoint_Recv[size]; /*--- Reduce the total number of points we will write in the output files. ---*/ #ifndef HAVE_MPI nGlobal_Poin_Par = nParallel_Poin; #else - SU2_MPI::Allreduce(&nParallel_Poin, &nGlobal_Poin_Par, 1, + SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif @@ -277,7 +287,7 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector& globalI nodes, i.e., rank 0 holds the first ~ nGlobalPoint()/nProcessors nodes. First, initialize a counter and flag. ---*/ - for (iPoint = 0; iPoint < nLocalPoint_Sort; iPoint++ ) { + for (iPoint = 0; iPoint < nLocalPointBeforeSort; iPoint++ ) { iProcessor = linearPartitioner->GetRankContainingIndex(globalID[iPoint]); @@ -342,12 +352,12 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector& globalI unsigned long *idIndex = new unsigned long[size](); for (int ii=0; ii < size; ii++) idIndex[ii] = nPoint_Send[ii]; - Index = new unsigned long[nLocalPoint_Sort](); + Index = new unsigned long[nLocalPointBeforeSort](); /*--- Loop through our elements and load the elems and their additional data that we will send to the other procs. ---*/ - for (iPoint = 0; iPoint < nLocalPoint_Sort; iPoint++) { + for (iPoint = 0; iPoint < nLocalPointBeforeSort; iPoint++) { iProcessor = linearPartitioner->GetRankContainingIndex(globalID[iPoint]); @@ -408,3 +418,59 @@ unsigned long CParallelDataSorter::GetElem_Connectivity(GEO_TYPE type, unsigned return 0; } +void CParallelDataSorter::SetTotalElements(){ + + /*--- Reduce the total number of cells we will be writing in the output files. ---*/ + + SU2_MPI::Allreduce(nLocalPerElem.data(), nGlobalPerElem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + + nGlobalElem = std::accumulate(nGlobalPerElem.begin(), nGlobalPerElem.end(), 0); + nLocalElem = std::accumulate(nLocalPerElem.begin(), nLocalPerElem.end(), 0); + + nLocalConn = 0; + nGlobalConn = 0; + auto addConnectivitySize = [this](GEO_TYPE elem, unsigned short nPoints){ + nLocalConn += GetnElem(elem)*nPoints; + nGlobalConn += GetnElemGlobal(elem)*nPoints; + }; + + addConnectivitySize(LINE, N_POINTS_LINE); + addConnectivitySize(TRIANGLE, N_POINTS_TRIANGLE); + addConnectivitySize(QUADRILATERAL, N_POINTS_QUADRILATERAL); + addConnectivitySize(TETRAHEDRON, N_POINTS_TETRAHEDRON); + addConnectivitySize(HEXAHEDRON, N_POINTS_HEXAHEDRON); + addConnectivitySize(PRISM, N_POINTS_PRISM); + addConnectivitySize(PYRAMID, N_POINTS_PYRAMID); + + /*--- Communicate the number of total cells/storage that will be + written by each rank. After this communication, each proc knows how + many cells will be written before its location in the file and the + offsets can be correctly set. ---*/ + + nElem_Send[0] = 0; nElemConn_Send[0] = 0; + nElem_Cum[0] = 0; nElemConn_Cum[0] = 0; + for (int ii=1; ii <= size; ii++) { + nElem_Send[ii] = int(nLocalElem); + nElemConn_Send[ii] = int(nLocalConn); + nElem_Cum[ii] = 0; + nElemConn_Cum[ii] = 0; + } + + /*--- Communicate the local counts to all ranks for building offsets. ---*/ + + SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, + &(nElem_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); + + SU2_MPI::Alltoall(&(nElemConn_Send[1]), 1, MPI_INT, + &(nElemConn_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); + + /*--- Put the counters into cumulative storage format. ---*/ + + for (int ii = 0; ii < size; ii++) { + nElem_Cum[ii+1] += nElem_Cum[ii]; + nElemConn_Cum[ii+1] += nElemConn_Cum[ii]; + } + + +} + diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 77358c37229..3d01b5f7487 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -53,12 +53,12 @@ CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometr /* Count up the number of local points we have for allocating storage. */ for(unsigned short j=0; jGetCumulativeSizeBeforeRank(rank); for(int jj=0; jj nSurfaceDOFsRanks(size); - SU2_MPI::Allgather(&nParallel_Poin, 1, MPI_UNSIGNED_LONG, + SU2_MPI::Allgather(&nLocalPoint, 1, MPI_UNSIGNED_LONG, nSurfaceDOFsRanks.data(), 1, MPI_UNSIGNED_LONG, MPI_COMM_WORLD); @@ -272,7 +272,7 @@ void CSurfaceFEMDataSorter::SortOutputData() { /* Create the map from the global volume numbering to the new global surface numbering. */ map mapGlobalVol2Surf; - for(unsigned long i=0; iGetGlobal_nPointDomain(); - nLocalPoint_Sort = geometry->GetnPointDomain(); + nGlobalPointBeforeSort = geometry->GetGlobal_nPointDomain(); + nLocalPointBeforeSort = geometry->GetnPointDomain(); /*--- Create the linear partitioner --- */ - linearPartitioner = new CLinearPartitioner(nGlobalPoint_Sort, 0); + linearPartitioner = new CLinearPartitioner(nGlobalPointBeforeSort, 0); } @@ -402,7 +402,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- First, add up the number of surface points I have on my rank. ---*/ - nParallel_Poin = 0; + nLocalPoint = 0; Renumber2Global.clear(); for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) { @@ -410,11 +410,11 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Save the global index values for CSV output. ---*/ - Renumber2Global[nParallel_Poin] = surfPoint[iPoint]; + Renumber2Global[nLocalPoint] = surfPoint[iPoint]; /*--- Increment total number of surface points found locally. ---*/ - nParallel_Poin++; + nLocalPoint++; } } @@ -426,7 +426,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { int *nPoint_Send = new int[size+1](); nPoint_Send[0] = 0; int *nPoint_Recv = new int[size+1](); nPoint_Recv[0] = 0; - for (int ii=1; ii < size+1; ii++) nPoint_Send[ii]= (int)nParallel_Poin; + for (int ii=1; ii < size+1; ii++) nPoint_Send[ii]= (int)nLocalPoint; #ifdef HAVE_MPI SU2_MPI::Alltoall(&(nPoint_Send[1]), 1, MPI_INT, @@ -450,7 +450,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { delete [] passiveDoubleBuffer; } - passiveDoubleBuffer = new passivedouble[nParallel_Poin*VARS_PER_POINT]; + passiveDoubleBuffer = new passivedouble[nLocalPoint*VARS_PER_POINT]; for (int jj = 0; jj < VARS_PER_POINT; jj++) { count = 0; @@ -467,7 +467,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { #ifndef HAVE_MPI nGlobal_Poin_Par = nParallel_Poin; #else - SU2_MPI::Allreduce(&nParallel_Poin, &nGlobal_Poin_Par, 1, + SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif @@ -476,8 +476,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { create a new mapping using two arrays, which will need to be communicated. We use our mask again here. ---*/ - unsigned long *globalP = new unsigned long[nParallel_Poin](); - unsigned long *renumbP = new unsigned long[nParallel_Poin](); + unsigned long *globalP = new unsigned long[nLocalPoint](); + unsigned long *renumbP = new unsigned long[nLocalPoint](); count = 0; for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) { @@ -513,7 +513,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Loop through my local surface nodes, find which proc the global value lives on, then communicate the global ID and remumbered value. ---*/ - for (int ii = 0; ii < (int)nParallel_Poin; ii++) { + for (int ii = 0; ii < (int)nLocalPoint; ii++) { Global_Index = globalP[ii]; @@ -579,7 +579,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Loop back through and load up the buffers for the global IDs and their new renumbering values. ---*/ - for (int ii = 0; ii < (int)nParallel_Poin; ii++) { + for (int ii = 0; ii < (int)nLocalPoint; ii++) { Global_Index = globalP[ii]; @@ -976,7 +976,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { that they need to have their renumbering shared. ---*/ for (int ii = 0; ii < nElem_Recv[size]; ii++) { - for (iPoint = 0; iPoint < nParallel_Poin; iPoint++) { + for (iPoint = 0; iPoint < nLocalPoint; iPoint++) { if (idRecv[ii] == globalP[iPoint]) { idRecv[ii] = renumbP[iPoint]; } @@ -1124,11 +1124,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); - /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - - SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - - nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); + SetTotalElements(); connectivitySorted = true; @@ -1146,11 +1142,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); - /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - - SU2_MPI::Allreduce(nParallel_Elem.data(), nGlobal_Elem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - - nGlobal_Elem_Par = std::accumulate(nGlobal_Elem.begin(), nGlobal_Elem.end(), 0); + SetTotalElements(); connectivitySorted = true; @@ -1515,7 +1507,7 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * } } - nParallel_Elem[TypeMap.at(Elem_Type)] = nElem_Total; + nLocalPerElem[TypeMap.at(Elem_Type)] = nElem_Total; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ @@ -1523,18 +1515,15 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * switch (Elem_Type) { case LINE: if (Conn_Line_Par != NULL) delete [] Conn_Line_Par; - Conn_Line_Par = NULL; - if (GetnElem(LINE) > 0) Conn_Line_Par = Conn_Elem; + Conn_Line_Par = Conn_Elem; break; case TRIANGLE: if (Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; - Conn_Tria_Par = NULL; - if (GetnElem(TRIANGLE) > 0) Conn_Tria_Par = Conn_Elem; + Conn_Tria_Par = Conn_Elem; break; case QUADRILATERAL: if (Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; - Conn_Quad_Par = NULL; - if (GetnElem(QUADRILATERAL) > 0) Conn_Quad_Par = Conn_Elem; + Conn_Quad_Par = Conn_Elem; break; default: SU2_MPI::Error("Unrecognized element type", CURRENT_FUNCTION); From b60b84d71956d28d57d6c7c0fca610a5906ffa6f Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 20 Jan 2020 14:07:21 +0100 Subject: [PATCH 50/61] Adapting paraview binary writers --- .../filewriter/CParaviewBinaryFileWriter.cpp | 159 ++++++------------ .../filewriter/CParaviewXMLFileWriter.cpp | 108 ++---------- 2 files changed, 68 insertions(+), 199 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index bc88a291cdd..ece3942cf56 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -84,27 +84,6 @@ void CParaviewBinaryFileWriter::Write_Data(){ GlobalPoint = dataSorter->GetnPointsGlobal(); myPoint = dataSorter->GetnPoints(); - - int *nPoint_Snd = new int[size+1]; - int *nPoint_Cum = new int[size+1]; - - nPoint_Snd[0] = 0; nPoint_Cum[0] = 0; - for (int ii=1; ii < size; ii++) { - nPoint_Snd[ii] = myPoint; nPoint_Cum[ii] = 0; - } - nPoint_Snd[size] = myPoint; nPoint_Cum[size] = 0; - - /*--- Communicate the local counts to all ranks for building offsets. ---*/ - - SU2_MPI::Alltoall(&(nPoint_Snd[1]), 1, MPI_INT, - &(nPoint_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); - - /*--- Put the counters into cumulative storage format. ---*/ - - for (int ii = 0; ii < size; ii++) { - nPoint_Cum[ii+1] += nPoint_Cum[ii]; - } - SPRINTF(str_buf, "POINTS %i float\n", SU2_TYPE::Int(GlobalPoint)); WriteMPIString(string(str_buf), MASTER_NODE); @@ -147,82 +126,29 @@ void CParaviewBinaryFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); - - unsigned long nTot_Line = dataSorter->GetnElemGlobal(LINE), - nTot_Tria = dataSorter->GetnElemGlobal(TRIANGLE), - nTot_Quad = dataSorter->GetnElemGlobal(QUADRILATERAL), - nTot_Tetr = dataSorter->GetnElemGlobal(TETRAHEDRON), - nTot_Hexa = dataSorter->GetnElemGlobal(HEXAHEDRON), - nTot_Pris = dataSorter->GetnElemGlobal(PRISM), - nTot_Pyra = dataSorter->GetnElemGlobal(PYRAMID); - - myElem = dataSorter->GetnElem(); - - myElemStorage = (nParallel_Line*N_POINTS_LINE + - nParallel_Tria*N_POINTS_TRIANGLE + - nParallel_Quad*N_POINTS_QUADRILATERAL + - nParallel_Tetr*N_POINTS_TETRAHEDRON + - nParallel_Hexa*N_POINTS_HEXAHEDRON + - nParallel_Pris*N_POINTS_PRISM + - nParallel_Pyra*N_POINTS_PYRAMID); - - GlobalElem = dataSorter->GetnElemGlobal(); - GlobalElemStorage = (nTot_Line*N_POINTS_LINE + - nTot_Tria*N_POINTS_TRIANGLE + - nTot_Quad*N_POINTS_QUADRILATERAL + - nTot_Tetr*N_POINTS_TETRAHEDRON + - nTot_Hexa*N_POINTS_HEXAHEDRON + - nTot_Pris*N_POINTS_PRISM + - nTot_Pyra*N_POINTS_PYRAMID); - - /*--- Communicate the number of total cells/storage that will be - written by each rank. After this communication, each proc knows how - many cells will be written before its location in the file and the - offsets can be correctly set. ---*/ - - int *nElem_Snd = new int[size+1]; int *nElemStorage_Snd = new int[size+1]; - int *nElem_Cum = new int[size+1]; int *nElemStorage_Cum = new int[size+1]; - - nElem_Snd[0] = 0; nElemStorage_Snd[0] = 0; - nElem_Cum[0] = 0; nElemStorage_Cum[0] = 0; - for (int ii=1; ii < size; ii++) { - nElem_Snd[ii] = myElem; nElemStorage_Snd[ii] = myElemStorage; - nElem_Cum[ii] = 0; nElemStorage_Cum[ii] = 0; - } - nElem_Snd[size] = myElem; nElemStorage_Snd[size] = myElemStorage; - nElem_Cum[size] = 0; nElemStorage_Cum[size] = 0; - - /*--- Communicate the local counts to all ranks for building offsets. ---*/ - - SU2_MPI::Alltoall(&(nElem_Snd[1]), 1, MPI_INT, - &(nElem_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); - - SU2_MPI::Alltoall(&(nElemStorage_Snd[1]), 1, MPI_INT, - &(nElemStorage_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); - /*--- Put the counters into cumulative storage format. ---*/ + myElem = dataSorter->GetnElem(); + myElemStorage = dataSorter->GetnElemConn(); + GlobalElem = dataSorter->GetnElemGlobal(); + GlobalElemStorage = dataSorter->GetnElemConnGlobal(); - for (int ii = 0; ii < size; ii++) { - nElem_Cum[ii+1] += nElem_Cum[ii]; - nElemStorage_Cum[ii+1] += nElemStorage_Cum[ii]; - } - SPRINTF(str_buf, "\nCELLS %i %i\n", SU2_TYPE::Int(GlobalElem), - SU2_TYPE::Int(GlobalElemStorage)); + SU2_TYPE::Int(GlobalElemStorage+GlobalElem)); WriteMPIString(str_buf, MASTER_NODE); /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ - vector connBuf(myElemStorage); - unsigned long iStorage = 0, iElemID = 0; + vector connBuf(myElemStorage + myElem); + unsigned long iStorage = 0; unsigned short iNode = 0; auto copyToBuffer = [&](GEO_TYPE type, unsigned long nElem, unsigned short nPoints){ for (iElem = 0; iElem < nElem; iElem++) { + connBuf[iStorage+0] = nPoints; for (iNode = 0; iNode < nPoints; iNode++){ - connBuf[iStorage+iNode] = int(dataSorter->GetElem_Connectivity(type, iElem, iNode)-1); + connBuf[iStorage+iNode+1] = int(dataSorter->GetElem_Connectivity(type, iElem, iNode)-1); } - iStorage += nPoints; + iStorage += nPoints + 1; } }; @@ -234,12 +160,17 @@ void CParaviewBinaryFileWriter::Write_Data(){ copyToBuffer(PRISM, nParallel_Pris, N_POINTS_PRISM); copyToBuffer(PYRAMID, nParallel_Pyra, N_POINTS_PYRAMID); - if (!bigEndian) SwapBytes((char *)connBuf.data(), sizeof(int), myElemStorage); + if (!bigEndian) SwapBytes((char *)connBuf.data(), sizeof(int), myElemStorage+myElem); + + /*--- Compute various data sizes --- */ + + sizeInBytesPerPoint = sizeof(int); + sizeInBytesLocal = sizeInBytesPerPoint*(myElemStorage + myElem); + sizeInBytesGlobal = sizeInBytesPerPoint*(GlobalElemStorage + GlobalElem); + offsetInBytes = sizeInBytesPerPoint* + (dataSorter->GetnElemConnCumulative(rank) + dataSorter->GetnElemCumulative(rank)); - WriteMPIBinaryDataAll(connBuf.data(), - myElemStorage*sizeof(int), - GlobalElemStorage*sizeof(int), - nElemStorage_Cum[rank]*sizeof(int)); + WriteMPIBinaryDataAll(connBuf.data(), sizeInBytesLocal, sizeInBytesGlobal, offsetInBytes); SPRINTF (str_buf, "\nCELL_TYPES %i\n", SU2_TYPE::Int(GlobalElem)); WriteMPIString(str_buf, MASTER_NODE); @@ -258,12 +189,19 @@ void CParaviewBinaryFileWriter::Write_Data(){ std::fill(typeIter, typeIter+nParallel_Pyra, PYRAMID); typeIter += nParallel_Pyra; if (!bigEndian) SwapBytes((char *)typeBuf.data(), sizeof(int), myElem); + + /*--- Compute various data sizes --- */ + + sizeInBytesPerPoint = sizeof(int); + sizeInBytesLocal = sizeInBytesPerPoint*myElem; + sizeInBytesGlobal = sizeInBytesPerPoint*GlobalElem; + offsetInBytes = sizeInBytesPerPoint*dataSorter->GetnElemCumulative(rank); - WriteMPIBinaryDataAll(typeBuf.data(), - myElem*sizeof(int), - GlobalElem*sizeof(int), - nElem_Cum[rank]*sizeof(int)); + WriteMPIBinaryDataAll(typeBuf.data(), sizeInBytesLocal, sizeInBytesGlobal, offsetInBytes); + SPRINTF (str_buf, "\nPOINT_DATA %i\n", SU2_TYPE::Int(GlobalPoint)); + WriteMPIString(str_buf, MASTER_NODE); + /*--- Adjust container start location to avoid point coords. ---*/ unsigned short varStart = 2; @@ -326,13 +264,23 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!bigEndian) SwapBytes((char *)dataBufferFloat.data(), sizeof(float), myPoint*NCOORDS); - WriteMPIBinaryDataAll(dataBufferFloat.data(), - myPoint*NCOORDS*sizeof(float), - GlobalPoint*NCOORDS*sizeof(float), - nPoint_Cum[rank]*NCOORDS*sizeof(float)); + /*--- Compute various data sizes --- */ + + sizeInBytesPerPoint = sizeof(float)*NCOORDS; + sizeInBytesLocal = sizeInBytesPerPoint*myPoint; + sizeInBytesGlobal = sizeInBytesPerPoint*GlobalPoint; + offsetInBytes = sizeInBytesPerPoint*dataSorter->GetnPointCumulative(rank); + + WriteMPIBinaryDataAll(dataBufferFloat.data(), sizeInBytesLocal, sizeInBytesGlobal, offsetInBytes); + VarCounter++; } else if (output_variable) { + + SPRINTF (str_buf, "\nSCALARS %s float 1\n", fieldname.c_str()); + WriteMPIString(str_buf, MASTER_NODE); + WriteMPIString("LOOKUP_TABLE default\n", MASTER_NODE); + /*--- For now, create a temp 1D buffer to load up the data for writing. This will be replaced with a derived data type most likely. ---*/ @@ -344,11 +292,14 @@ void CParaviewBinaryFileWriter::Write_Data(){ if (!bigEndian) SwapBytes((char *)dataBufferFloat.data(), sizeof(float), myPoint); - WriteMPIBinaryDataAll(dataBufferFloat.data(), - myPoint*sizeof(float), - GlobalPoint*sizeof(float), - nPoint_Cum[rank]*sizeof(float)); + /*--- Compute various data sizes --- */ + sizeInBytesPerPoint = sizeof(float); + sizeInBytesLocal = sizeInBytesPerPoint*myPoint; + sizeInBytesGlobal = sizeInBytesPerPoint*GlobalPoint; + offsetInBytes = sizeInBytesPerPoint*dataSorter->GetnPointCumulative(rank); + + WriteMPIBinaryDataAll(dataBufferFloat.data(), sizeInBytesLocal, sizeInBytesGlobal, offsetInBytes); VarCounter++; } @@ -357,12 +308,6 @@ void CParaviewBinaryFileWriter::Write_Data(){ CloseMPIFile(); - /*--- Delete the offset counters that we needed for MPI IO. ---*/ - - delete [] nElem_Snd; delete [] nElem_Cum; - delete [] nElemStorage_Snd; delete [] nElemStorage_Cum; - delete [] nPoint_Snd; delete [] nPoint_Cum; - } diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 5a852197bf4..6a6a9f3e814 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -96,33 +96,11 @@ void CParaviewXMLFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); - - unsigned long nTot_Line = dataSorter->GetnElemGlobal(LINE), - nTot_Tria = dataSorter->GetnElemGlobal(TRIANGLE), - nTot_Quad = dataSorter->GetnElemGlobal(QUADRILATERAL), - nTot_Tetr = dataSorter->GetnElemGlobal(TETRAHEDRON), - nTot_Hexa = dataSorter->GetnElemGlobal(HEXAHEDRON), - nTot_Pris = dataSorter->GetnElemGlobal(PRISM), - nTot_Pyra = dataSorter->GetnElemGlobal(PYRAMID); - - myElem = dataSorter->GetnElem(); - - myElemStorage = (nParallel_Line*N_POINTS_LINE + - nParallel_Tria*N_POINTS_TRIANGLE + - nParallel_Quad*N_POINTS_QUADRILATERAL + - nParallel_Tetr*N_POINTS_TETRAHEDRON + - nParallel_Hexa*N_POINTS_HEXAHEDRON + - nParallel_Pris*N_POINTS_PRISM + - nParallel_Pyra*N_POINTS_PYRAMID); - - GlobalElem = dataSorter->GetnElemGlobal(); - GlobalElemStorage = (nTot_Line*N_POINTS_LINE + - nTot_Tria*N_POINTS_TRIANGLE + - nTot_Quad*N_POINTS_QUADRILATERAL + - nTot_Tetr*N_POINTS_TETRAHEDRON + - nTot_Hexa*N_POINTS_HEXAHEDRON + - nTot_Pris*N_POINTS_PRISM + - nTot_Pyra*N_POINTS_PYRAMID); + + myElem = dataSorter->GetnElem(); + myElemStorage = dataSorter->GetnElemConn(); + GlobalElem = dataSorter->GetnElemGlobal(); + GlobalElemStorage = dataSorter->GetnElemConnGlobal(); /* Write the ASCII XML header. Note that we use the appended format for the data, * which means that all data is appended at the end of the file in one binary blob. @@ -207,26 +185,6 @@ void CParaviewXMLFileWriter::Write_Data(){ WriteMPIString("\n", MASTER_NODE); WriteMPIString("\n", MASTER_NODE); - int *nPoint_Snd = new int[size+1]; - int *nPoint_Cum = new int[size+1]; - - nPoint_Snd[0] = 0; nPoint_Cum[0] = 0; - for (int ii=1; ii < size; ii++) { - nPoint_Snd[ii] = int(myPoint); nPoint_Cum[ii] = 0; - } - nPoint_Snd[size] = int(myPoint); nPoint_Cum[size] = 0; - - /*--- Communicate the local counts to all ranks for building offsets. ---*/ - - SU2_MPI::Alltoall(&(nPoint_Snd[1]), 1, MPI_INT, - &(nPoint_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); - - /*--- Put the counters into cumulative storage format. ---*/ - - for (int ii = 0; ii < size; ii++) { - nPoint_Cum[ii+1] += nPoint_Cum[ii]; - } - /*--- Now write all the data we have previously defined into the binary section of the file ---*/ WriteMPIString("\n_", MASTER_NODE); @@ -246,39 +204,8 @@ void CParaviewXMLFileWriter::Write_Data(){ } } - WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, NCOORDS*myPoint, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); - - /*--- Communicate the number of total cells/storage that will be - written by each rank. After this communication, each proc knows how - many cells will be written before its location in the file and the - offsets can be correctly set. ---*/ - - int *nElem_Snd = new int[size+1]; int *nElemStorage_Snd = new int[size+1]; - int *nElem_Cum = new int[size+1]; int *nElemStorage_Cum = new int[size+1]; - - nElem_Snd[0] = 0; nElemStorage_Snd[0] = 0; - nElem_Cum[0] = 0; nElemStorage_Cum[0] = 0; - for (int ii=1; ii < size; ii++) { - nElem_Snd[ii] = int(myElem); nElemStorage_Snd[ii] = int(myElemStorage); - nElem_Cum[ii] = 0; nElemStorage_Cum[ii] = 0; - } - nElem_Snd[size] = int(myElem); nElemStorage_Snd[size] = int(myElemStorage); - nElem_Cum[size] = 0; nElemStorage_Cum[size] = 0; - - /*--- Communicate the local counts to all ranks for building offsets. ---*/ - - SU2_MPI::Alltoall(&(nElem_Snd[1]), 1, MPI_INT, - &(nElem_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); - - SU2_MPI::Alltoall(&(nElemStorage_Snd[1]), 1, MPI_INT, - &(nElemStorage_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); - - /*--- Put the counters into cumulative storage format. ---*/ - - for (int ii = 0; ii < size; ii++) { - nElem_Cum[ii+1] += nElem_Cum[ii]; - nElemStorage_Cum[ii+1] += nElemStorage_Cum[ii]; - } + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, NCOORDS*myPoint, GlobalPoint*NCOORDS, + dataSorter->GetnPointCumulative(rank)*NCOORDS); /*--- Load/write 1D buffers for the connectivity of each element type. ---*/ @@ -293,7 +220,7 @@ void CParaviewXMLFileWriter::Write_Data(){ connBuf[iStorage+iNode] = int(dataSorter->GetElem_Connectivity(type, iElem, iNode)-1); } iStorage += nPoints; - offsetBuf[iElemID++] = int(iStorage + nElemStorage_Cum[rank]); + offsetBuf[iElemID++] = int(iStorage + dataSorter->GetnElemConnCumulative(rank)); } }; @@ -305,8 +232,9 @@ void CParaviewXMLFileWriter::Write_Data(){ copyToBuffer(PRISM, nParallel_Pris, N_POINTS_PRISM); copyToBuffer(PYRAMID, nParallel_Pyra, N_POINTS_PYRAMID); - WriteDataArray(connBuf.data(), VTKDatatype::INT32, myElemStorage, GlobalElemStorage, nElemStorage_Cum[rank]); - WriteDataArray(offsetBuf.data(), VTKDatatype::INT32, myElem, GlobalElem, nElem_Cum[rank]); + WriteDataArray(connBuf.data(), VTKDatatype::INT32, myElemStorage, GlobalElemStorage, + dataSorter->GetnElemConnCumulative(rank)); + WriteDataArray(offsetBuf.data(), VTKDatatype::INT32, myElem, GlobalElem, dataSorter->GetnElemCumulative(rank)); /*--- Load/write the cell type for all elements in the file. ---*/ @@ -321,7 +249,7 @@ void CParaviewXMLFileWriter::Write_Data(){ std::fill(typeIter, typeIter+nParallel_Pris, PRISM); typeIter += nParallel_Pris; std::fill(typeIter, typeIter+nParallel_Pyra, PYRAMID); typeIter += nParallel_Pyra; - WriteDataArray(typeBuf.data(), VTKDatatype::UINT8, myElem, GlobalElem, nElem_Cum[rank]); + WriteDataArray(typeBuf.data(), VTKDatatype::UINT8, myElem, GlobalElem, dataSorter->GetnElemCumulative(rank)); /*--- Loop over all variables that have been registered in the output. ---*/ @@ -367,7 +295,8 @@ void CParaviewXMLFileWriter::Write_Data(){ } } - WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint*NCOORDS, GlobalPoint*NCOORDS, nPoint_Cum[rank]*NCOORDS); + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint*NCOORDS, GlobalPoint*NCOORDS, + dataSorter->GetnPointCumulative(rank)*NCOORDS); VarCounter++; @@ -382,7 +311,8 @@ void CParaviewXMLFileWriter::Write_Data(){ dataBufferFloat[iPoint] = val; } - WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint, GlobalPoint, nPoint_Cum[rank]); + WriteDataArray(dataBufferFloat.data(), VTKDatatype::FLOAT32, myPoint, GlobalPoint, + dataSorter->GetnPointCumulative(rank)); VarCounter++; } @@ -394,12 +324,6 @@ void CParaviewXMLFileWriter::Write_Data(){ CloseMPIFile(); - /*--- Delete the offset counters that we needed for MPI IO. ---*/ - - delete [] nElem_Snd; delete [] nElem_Cum; - delete [] nElemStorage_Snd; delete [] nElemStorage_Cum; - delete [] nPoint_Snd; delete [] nPoint_Cum; - } void CParaviewXMLFileWriter::WriteDataArray(void* data, VTKDatatype type, unsigned long arraySize, From 73583dd9aaa9af02b51fca06c089435d6e83c64c Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 20 Jan 2020 15:03:42 +0100 Subject: [PATCH 51/61] Removing #ifdef HAVE_MPI for collective calls in datasorters --- .../src/output/filewriter/CFEMDataSorter.cpp | 4 --- .../src/output/filewriter/CFVMDataSorter.cpp | 4 --- .../output/filewriter/CParallelDataSorter.cpp | 8 ------ .../filewriter/CSurfaceFEMDataSorter.cpp | 12 --------- .../filewriter/CSurfaceFVMDataSorter.cpp | 26 +------------------ 5 files changed, 1 insertion(+), 53 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index d02387ab9b0..896d5977363 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -61,12 +61,8 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vecto } } -#ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPointBeforeSort, &nGlobalPointBeforeSort, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#else - nGlobalPoint_Sort = nLocalPoint_Sort; -#endif /*--- Create a linear partition --- */ diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index 43196598e2e..5590b3fe683 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -238,12 +238,8 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Cum[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nElem_Recv[1] = nElem_Send[1]; -#endif /*--- Prepare to send connectivities. First check how many messages we will be sending and receiving. Here we also put diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index 407f00b0dfd..ab6b3686830 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -261,12 +261,8 @@ void CParallelDataSorter::SortOutputData() { /*--- Reduce the total number of points we will write in the output files. ---*/ -#ifndef HAVE_MPI - nGlobal_Poin_Par = nParallel_Poin; -#else SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif /*--- Free temporary memory from communications ---*/ @@ -301,12 +297,8 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector& globalI all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nPoint_Send[1]), 1, MPI_INT, &(nPoint_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nPoint_Recv[1] = nPoint_Send[1]; -#endif /*--- Prepare to send coordinates. First check how many messages we will be sending and receiving. Here we also put diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 3d01b5f7487..19138b23bcd 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -57,12 +57,8 @@ CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometr } } -#ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPointBeforeSort, &nGlobalPointBeforeSort, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#else - nGlobalPoint_Sort = nLocalPoint_Sort; -#endif /*--- Create the linear partitioner --- */ @@ -157,12 +153,8 @@ void CSurfaceFEMDataSorter::SortOutputData() { /* Communicate nDOFSend using Alltoall. */ vector nDOFRecv(size); -#ifdef HAVE_MPI SU2_MPI::Alltoall(nDOFSend.data(), 1, MPI_UNSIGNED_LONG, nDOFRecv.data(), 1, MPI_UNSIGNED_LONG, MPI_COMM_WORLD); -#else - nDOFRecv[rank] = nDOFSend[rank]; -#endif /* Determine the number of messages this rank will receive. */ int nRankRecv = 0; @@ -245,12 +237,8 @@ void CSurfaceFEMDataSorter::SortOutputData() { /*--- Reduce the total number of surf points we have. This will be needed for writing the surface solution files later. ---*/ -#ifdef HAVE_MPI SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#else - nGlobal_Poin_Par = nParallel_Poin; -#endif /*-------------------------------------------------------------------*/ /*--- Step 3: Modify the surface connectivities, such that only ---*/ diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index beb5fb44ac9..9e73798a8d5 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -174,12 +174,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { all processors. After this communication, each proc knows how many nodes it will receive from each other processor. ---*/ -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nElem_Recv[1] = nElem_Send[1]; -#endif /*--- Prepare to send. First check how many messages we will be sending and receiving. Here we also put @@ -428,12 +424,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { for (int ii=1; ii < size+1; ii++) nPoint_Send[ii]= (int)nLocalPoint; -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nPoint_Send[1]), 1, MPI_INT, &(nPoint_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nPoint_Recv[1] = nPoint_Send[1]; -#endif /*--- Go to cumulative storage format to compute the offsets. ---*/ @@ -464,12 +456,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Reduce the total number of surf points we have. This will be needed for writing the surface solution files later. ---*/ -#ifndef HAVE_MPI - nGlobal_Poin_Par = nParallel_Poin; -#else SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#endif /*--- Now that we know every proc's global offset for the number of surface points, we can create the new global numbering. Here, we @@ -535,12 +523,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nElem_Recv[1] = nElem_Send[1]; -#endif /*--- Prepare to send. First check how many messages we will be sending and receiving. Here we also put @@ -840,13 +824,9 @@ void CSurfaceFVMDataSorter::SortOutputData() { all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nElem_Recv[1] = nElem_Send[1]; -#endif - + /*--- Prepare to send connectivities. First check how many messages we will be sending and receiving. Here we also put the counters into cumulative storage format to make the @@ -1255,12 +1235,8 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * all processors. After this communication, each proc knows how many cells it will receive from each other processor. ---*/ -#ifdef HAVE_MPI SU2_MPI::Alltoall(&(nElem_Send[1]), 1, MPI_INT, &(nElem_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); -#else - nElem_Recv[1] = nElem_Send[1]; -#endif /*--- Prepare to send connectivities. First check how many messages we will be sending and receiving. Here we also put From 36cbbb24766aca740ec1fc0b69c20cdc50f49c34 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 20 Jan 2020 15:20:47 +0100 Subject: [PATCH 52/61] Adapting tecplot output --- .../filewriter/CTecplotBinaryFileWriter.cpp | 27 ++++++------------- .../output/filewriter/CTecplotFileWriter.cpp | 27 ++++++------------- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp index 5ee46228e36..7ccf618460b 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp @@ -59,7 +59,6 @@ void CTecplotBinaryFileWriter::Write_Data(){ /*--- Reduce the total number of each element. ---*/ - unsigned long nTot_Line, nTot_Tria, nTot_Quad, nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; unsigned long nParallel_Line = dataSorter->GetnElem(LINE), nParallel_Tria = dataSorter->GetnElem(TRIANGLE), nParallel_Quad = dataSorter->GetnElem(QUADRILATERAL), @@ -67,24 +66,14 @@ void CTecplotBinaryFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); -#ifdef HAVE_MPI - SU2_MPI::Allreduce(&nParallel_Line, &nTot_Line, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tria, &nTot_Tria, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Quad, &nTot_Quad, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tetr, &nTot_Tetr, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Hexa, &nTot_Hexa, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pris, &nTot_Pris, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pyra, &nTot_Pyra, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#else - nTot_Line = nParallel_Line; - - nTot_Tria = nParallel_Tria; - nTot_Quad = nParallel_Quad; - nTot_Tetr = nParallel_Tetr; - nTot_Hexa = nParallel_Hexa; - nTot_Pris = nParallel_Pris; - nTot_Pyra = nParallel_Pyra; -#endif + + unsigned long nTot_Line = dataSorter->GetnElemGlobal(LINE), + nTot_Tria = dataSorter->GetnElemGlobal(TRIANGLE), + nTot_Quad = dataSorter->GetnElemGlobal(QUADRILATERAL), + nTot_Tetr = dataSorter->GetnElemGlobal(TETRAHEDRON), + nTot_Hexa = dataSorter->GetnElemGlobal(HEXAHEDRON), + nTot_Pris = dataSorter->GetnElemGlobal(PRISM), + nTot_Pyra = dataSorter->GetnElemGlobal(PYRAMID); string data_set_title = "Visualization of the solution"; diff --git a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp index 1b2cc4388f4..0aaecfd775f 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp @@ -63,7 +63,6 @@ void CTecplotFileWriter::Write_Data(){ /*--- Reduce the total number of each element. ---*/ - unsigned long nTot_Line, nTot_Tria, nTot_Quad, nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; unsigned long nParallel_Line = dataSorter->GetnElem(LINE), nParallel_Tria = dataSorter->GetnElem(TRIANGLE), nParallel_Quad = dataSorter->GetnElem(QUADRILATERAL), @@ -71,24 +70,14 @@ void CTecplotFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); -#ifdef HAVE_MPI - SU2_MPI::Allreduce(&nParallel_Line, &nTot_Line, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tria, &nTot_Tria, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Quad, &nTot_Quad, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Tetr, &nTot_Tetr, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Hexa, &nTot_Hexa, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pris, &nTot_Pris, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nParallel_Pyra, &nTot_Pyra, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); -#else - nTot_Line = nParallel_Line; - - nTot_Tria = nParallel_Tria; - nTot_Quad = nParallel_Quad; - nTot_Tetr = nParallel_Tetr; - nTot_Hexa = nParallel_Hexa; - nTot_Pris = nParallel_Pris; - nTot_Pyra = nParallel_Pyra; -#endif + + unsigned long nTot_Line = dataSorter->GetnElemGlobal(LINE), + nTot_Tria = dataSorter->GetnElemGlobal(TRIANGLE), + nTot_Quad = dataSorter->GetnElemGlobal(QUADRILATERAL), + nTot_Tetr = dataSorter->GetnElemGlobal(TETRAHEDRON), + nTot_Hexa = dataSorter->GetnElemGlobal(HEXAHEDRON), + nTot_Pris = dataSorter->GetnElemGlobal(PRISM), + nTot_Pyra = dataSorter->GetnElemGlobal(PYRAMID); /*--- Open Tecplot ASCII file and write the header. ---*/ From 98a7ef8ecff76bec884489a2982e19df78c4e768 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Wed, 22 Jan 2020 16:27:16 +0100 Subject: [PATCH 53/61] Another round of fixes --- .../src/output/filewriter/CFEMDataSorter.cpp | 2 ++ .../src/output/filewriter/CFVMDataSorter.cpp | 2 ++ .../output/filewriter/CParaviewFileWriter.cpp | 25 +++---------------- .../filewriter/CSurfaceFEMDataSorter.cpp | 4 +++ .../filewriter/CSurfaceFVMDataSorter.cpp | 4 +++ .../filewriter/CTecplotBinaryFileWriter.cpp | 2 +- .../output/filewriter/CTecplotFileWriter.cpp | 2 +- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index 896d5977363..3bbb5bf48ba 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -92,6 +92,8 @@ void CFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool across all processors based on the global index of the grid nodes. ---*/ /*--- Sort volumetric grid connectivity. ---*/ + + nLocalPerElem.fill(0); SortVolumetricConnectivity(config, geometry, TRIANGLE ); SortVolumetricConnectivity(config, geometry, QUADRILATERAL); diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index 5590b3fe683..7d848608a53 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -116,6 +116,8 @@ void CFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool In these routines, we sort the connectivity into a linear partitioning across all processors based on the global index of the grid nodes. ---*/ + nLocalPerElem.fill(0); + SortVolumetricConnectivity(config, geometry, TRIANGLE, val_sort); SortVolumetricConnectivity(config, geometry, QUADRILATERAL, val_sort); SortVolumetricConnectivity(config, geometry, TETRAHEDRON, val_sort); diff --git a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp index 9078cfa2e64..4801c13194f 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp @@ -109,7 +109,6 @@ void CParaviewFileWriter::Write_Data(){ /*--- Reduce the total number of each element. ---*/ - unsigned long nTot_Line, nTot_Tria, nTot_Quad, nTot_Tetr, nTot_Hexa, nTot_Pris, nTot_Pyra; unsigned long nParallel_Line = dataSorter->GetnElem(LINE), nParallel_Tria = dataSorter->GetnElem(TRIANGLE), nParallel_Quad = dataSorter->GetnElem(QUADRILATERAL), @@ -117,31 +116,13 @@ void CParaviewFileWriter::Write_Data(){ nParallel_Hexa = dataSorter->GetnElem(HEXAHEDRON), nParallel_Pris = dataSorter->GetnElem(PRISM), nParallel_Pyra = dataSorter->GetnElem(PYRAMID); -#ifdef HAVE_MPI - SU2_MPI::Reduce(&nParallel_Line, &nTot_Line, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Reduce(&nParallel_Tria, &nTot_Tria, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Reduce(&nParallel_Quad, &nTot_Quad, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Reduce(&nParallel_Tetr, &nTot_Tetr, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Reduce(&nParallel_Hexa, &nTot_Hexa, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Reduce(&nParallel_Pris, &nTot_Pris, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Reduce(&nParallel_Pyra, &nTot_Pyra, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); -#else - nTot_Line = nParallel_Line; - - nTot_Tria = nParallel_Tria; - nTot_Quad = nParallel_Quad; - nTot_Tetr = nParallel_Tetr; - nTot_Hexa = nParallel_Hexa; - nTot_Pris = nParallel_Pris; - nTot_Pyra = nParallel_Pyra; -#endif if (rank == MASTER_NODE) { /*--- Write the header ---*/ - nGlobal_Elem_Storage = nTot_Line*3 + nTot_Tria*4 + nTot_Quad*5 + nTot_Tetr*5 + nTot_Hexa*9 + nTot_Pris*7 + nTot_Pyra*6; + nGlobal_Elem_Storage = dataSorter->GetnElemGlobal() + dataSorter->GetnElemConnGlobal(); - Paraview_File << "\nCELLS " << dataSorter->GetnElem() << "\t" << nGlobal_Elem_Storage << "\n"; + Paraview_File << "\nCELLS " << dataSorter->GetnElemGlobal() << "\t" << nGlobal_Elem_Storage << "\n"; } @@ -226,7 +207,7 @@ void CParaviewFileWriter::Write_Data(){ if (rank == MASTER_NODE) { /*--- Write the header ---*/ - Paraview_File << "\nCELL_TYPES " << dataSorter->GetnElem() << "\n"; + Paraview_File << "\nCELL_TYPES " << dataSorter->GetnElemGlobal() << "\n"; } diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 19138b23bcd..de7e5479562 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -339,6 +339,8 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr markerList.push_back(config->GetMarker_All_TagBound(iMarker)); } } + + nLocalPerElem.fill(0); SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); @@ -352,6 +354,8 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, const vector &markerList) { + nLocalPerElem.fill(0); + SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 9e73798a8d5..84c377a15b5 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -1099,6 +1099,8 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr across all processors based on the global index of the grid nodes. ---*/ /*--- Sort volumetric grid connectivity. ---*/ + + nLocalPerElem.fill(0); SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); @@ -1118,6 +1120,8 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr /*--- Sort volumetric grid connectivity. ---*/ + nLocalPerElem.fill(0); + SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); diff --git a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp index 7ccf618460b..b17007558bb 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp @@ -101,7 +101,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ num_nodes = static_cast(dataSorter->GetnPointsGlobal()); - num_cells = static_cast(dataSorter->GetnElem()); + num_cells = static_cast(dataSorter->GetnElemGlobal()); if (dataSorter->GetnDim() == 3){ if ((nTot_Quad > 0 || nTot_Tria > 0) && (nTot_Hexa + nTot_Pris + nTot_Pyra + nTot_Tetr == 0)){ zone_type = ZONETYPE_FEQUADRILATERAL; diff --git a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp index 0aaecfd775f..5a26deccb3a 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotFileWriter.cpp @@ -100,7 +100,7 @@ void CTecplotFileWriter::Write_Data(){ Tecplot_File << "STRANDID="<SetAlign(PrintingToolbox::CTablePrinter::LEFT); + } delete fileWriter; diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index 407fa669f81..1b9e95af901 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -66,6 +66,8 @@ bool CFileWriter::WriteMPIBinaryDataAll(const void *data, unsigned long sizeInBy #ifdef HAVE_MPI + startTime = MPI_Wtime(); + MPI_Datatype filetype; /*--- Prepare to write the actual data ---*/ @@ -89,9 +91,15 @@ bool CFileWriter::WriteMPIBinaryDataAll(const void *data, unsigned long sizeInBy disp += totalSizeInBytes; fileSize += sizeInBytes; + stopTime = MPI_Wtime(); + + usedTime += stopTime - startTime; + return (ierr == MPI_SUCCESS); #else + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + unsigned long bytesWritten; /*--- Write binary data ---*/ @@ -99,15 +107,21 @@ bool CFileWriter::WriteMPIBinaryDataAll(const void *data, unsigned long sizeInBy bytesWritten = fwrite(data, sizeof(char), sizeInBytes, fhw); fileSize += bytesWritten; + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + + usedTime += stopTime - startTime; + return (bytesWritten == sizeInBytes); #endif - + } bool CFileWriter::WriteMPIBinaryData(const void *data, unsigned long sizeInBytes, unsigned short processor){ #ifdef HAVE_MPI + startTime = MPI_Wtime(); + int ierr = MPI_SUCCESS; /*--- Reset the file view. ---*/ @@ -121,15 +135,25 @@ bool CFileWriter::WriteMPIBinaryData(const void *data, unsigned long sizeInBytes disp += sizeInBytes; fileSize += sizeInBytes; + stopTime = MPI_Wtime(); + + usedTime += stopTime - startTime; + return (ierr == MPI_SUCCESS); #else + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + unsigned long bytesWritten = sizeInBytes; /*--- Write the total size in bytes at the beginning of the binary data blob ---*/ bytesWritten = fwrite(data, sizeof(char), sizeInBytes, fhw); + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + + usedTime += stopTime - startTime; + return (bytesWritten == sizeInBytes); #endif @@ -140,6 +164,8 @@ bool CFileWriter::WriteMPIString(const string &str, unsigned short processor){ #ifdef HAVE_MPI + startTime = MPI_Wtime(); + int ierr = MPI_SUCCESS; /*--- Reset the file view. ---*/ @@ -150,17 +176,29 @@ bool CFileWriter::WriteMPIString(const string &str, unsigned short processor){ if (SU2_MPI::GetRank() == processor) ierr = MPI_File_write_at(fhw, disp, str.c_str(), str.size(), MPI_CHAR, MPI_STATUS_IGNORE); + disp += str.size()*sizeof(char); fileSize += sizeof(char)*str.size(); + stopTime = MPI_Wtime(); + + usedTime += stopTime - startTime; + return (ierr == MPI_SUCCESS); #else + + startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + unsigned long bytesWritten; bytesWritten = fwrite(str.c_str(), sizeof(char), str.size(), fhw); fileSize += bytesWritten; + stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); + + usedTime += stopTime - startTime; + return (bytesWritten == str.size()*sizeof(char)); #endif @@ -208,13 +246,7 @@ bool CFileWriter::OpenMPIFile(){ disp = 0.0; fileSize = 0.0; - /*--- Set a timer for the file writing. ---*/ - -#ifndef HAVE_MPI - startTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - startTime = MPI_Wtime(); -#endif + usedTime = 0; return true; } @@ -228,14 +260,6 @@ bool CFileWriter::CloseMPIFile(){ #else fclose(fhw); #endif - /*--- Compute and store the write time. ---*/ - -#ifndef HAVE_MPI - stopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); -#else - stopTime = MPI_Wtime(); -#endif - usedTime = stopTime-startTime; /*--- Communicate the total file size for the restart ---*/ diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index 8d84f853c87..cfe2b0c0012 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -47,7 +47,9 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string valFileName, string valFol mkdir(this->folderName.c_str(), 0777); mkdir((this->folderName + "/zone_" + to_string(valiZone)).c_str(), 0777); #endif - + + nWrittenDatasets = 0; + accumulatedBandwidth = 0; } @@ -106,5 +108,12 @@ void CParaviewVTMFileWriter::AddDataset(string name, string file, CParallelDataS /*--- Add the dataset to the vtm file ---*/ AddDataset(name, fullFilename + CParaviewXMLFileWriter::fileExt); - + + /*--- Update the bandwidth ---*/ + + nWrittenDatasets++; + + accumulatedBandwidth += XMLWriter.Get_Bandwidth(); + + bandwidth = accumulatedBandwidth/nWrittenDatasets; } From 7bdbc1d554d9568d4300eca4422a95764593503c Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Fri, 24 Jan 2020 11:36:32 +0100 Subject: [PATCH 55/61] Removing some code duplication --- .../output/filewriter/CSurfaceFEMDataSorter.cpp | 10 ++-------- .../output/filewriter/CSurfaceFVMDataSorter.cpp | 16 ++-------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index d72c990bdae..30da91dcf48 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -341,15 +341,9 @@ void CSurfaceFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } } - nLocalPerElem.fill(0); - - SortSurfaceConnectivity(config, geometry, LINE , markerList); - SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); - SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); + /*--- Call the sort connectivity routine ---*/ - SetTotalElements(); - - connectivitySorted = true; + SortConnectivity(config, geometry, markerList); } diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 65c326c0713..892401b6a6e 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -1093,21 +1093,9 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr } } - /*--- Sort connectivity for each type of element (excluding halos). Note - In these routines, we sort the connectivity into a linear partitioning - across all processors based on the global index of the grid nodes. ---*/ - - /*--- Sort volumetric grid connectivity. ---*/ + /*--- Call the sort connectivity routine ---*/ - nLocalPerElem.fill(0); - - SortSurfaceConnectivity(config, geometry, LINE , markerList); - SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); - SortSurfaceConnectivity(config, geometry, QUADRILATERAL, markerList); - - SetTotalElements(); - - connectivitySorted = true; + SortConnectivity(config, geometry, markerList); } From a0568f740381ac05f1be3e56e13e9426a09c76f3 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 26 Jan 2020 14:43:03 +0100 Subject: [PATCH 56/61] Small fixes --- .../include/output/filewriter/CFileWriter.hpp | 5 ---- .../output/filewriter/CParallelDataSorter.hpp | 6 ++-- .../filewriter/CParaviewXMLFileWriter.hpp | 2 +- .../output/filewriter/CParallelDataSorter.cpp | 30 +++++++++---------- .../output/filewriter/CParallelFileWriter.cpp | 5 ++-- .../filewriter/CParaviewVTMFileWriter.cpp | 3 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CFileWriter.hpp b/SU2_CFD/include/output/filewriter/CFileWriter.hpp index 10ea94b29e4..0c8306070ae 100644 --- a/SU2_CFD/include/output/filewriter/CFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CFileWriter.hpp @@ -96,11 +96,6 @@ class CFileWriter{ MPI_File fhw; #else - /*! - * \brief The displacement that every process has in the current file view - */ - unsigned long disp; - /*! * \brief The file handle for writing */ diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index 304d3962e41..3cc12997f11 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -83,9 +83,9 @@ class CParallelDataSorter{ int *nPoint_Send; //!< Number of points this processor has to send to other processors int *nPoint_Recv; //!< Number of points this processor receives from other processors int *nElem_Send; //!< Number of elements this processor has to send to other processors - int *nElem_Cum; //!< Cumulative number of elements - int *nElemConn_Send; //!< Number of element connectivity this processor has to send to other processors - int *nElemConn_Cum; //!< Cumulative number of element connectivity entries + int *nElem_Cum; //!< Cumulative number of elements + int *nElemConn_Send; //!< Number of element connectivity this processor has to send to other processors + int *nElemConn_Cum; //!< Cumulative number of element connectivity entries unsigned long *Index; //!< Index each point has in the send buffer su2double *connSend; //!< Send buffer holding the data that will be send to other processors passivedouble *passiveDoubleBuffer; //!< Buffer holding the sorted, partitioned data as passivedouble types diff --git a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp index cf5e5baab33..8915238d641 100644 --- a/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp +++ b/SU2_CFD/include/output/filewriter/CParaviewXMLFileWriter.hpp @@ -104,7 +104,7 @@ class CParaviewXMLFileWriter final: public CFileWriter{ * \param[out] typeStr - The string name of the type * \param[out] typeSize - The size in bytes of the type */ - inline void GetTypeInfo(const VTKDatatype type, string &typeStr, unsigned long &typeSize){ + inline void GetTypeInfo(const VTKDatatype type, string &typeStr, unsigned long &typeSize) const { switch (type) { case VTKDatatype::FLOAT32: typeStr = "\"Float32\""; diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index ab6b3686830..ad8371062f3 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -86,26 +86,26 @@ CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector & CParallelDataSorter::~CParallelDataSorter(){ - if (nPoint_Send != NULL) delete [] nPoint_Send; - if (nPoint_Recv != NULL) delete [] nPoint_Recv; - if (nElem_Send != NULL) delete [] nElem_Send; - if (nElem_Cum != NULL) delete [] nElem_Cum; - if (nElemConn_Send != NULL) delete [] nElemConn_Send; - if (nElemConn_Cum != NULL) delete [] nElemConn_Cum; + delete [] nPoint_Send; + delete [] nPoint_Recv; + delete [] nElem_Send; + delete [] nElem_Cum; + delete [] nElemConn_Send; + delete [] nElemConn_Cum; /*--- Deallocate memory for connectivity data on each processor. ---*/ - if (GetnElem(LINE) > 0 && Conn_Line_Par != NULL) delete [] Conn_Line_Par; - if (GetnElem(TRIANGLE) > 0 && Conn_Tria_Par != NULL) delete [] Conn_Tria_Par; - if (GetnElem(QUADRILATERAL) > 0 && Conn_Quad_Par != NULL) delete [] Conn_Quad_Par; - if (GetnElem(TETRAHEDRON) > 0 && Conn_Tetr_Par != NULL) delete [] Conn_Tetr_Par; - if (GetnElem(HEXAHEDRON) > 0 && Conn_Hexa_Par != NULL) delete [] Conn_Hexa_Par; - if (GetnElem(PRISM) > 0 && Conn_Pris_Par != NULL) delete [] Conn_Pris_Par; - if (GetnElem(PYRAMID) > 0 && Conn_Pyra_Par != NULL) delete [] Conn_Pyra_Par; + delete [] Conn_Line_Par; + delete [] Conn_Tria_Par; + delete [] Conn_Quad_Par; + delete [] Conn_Tetr_Par; + delete [] Conn_Hexa_Par; + delete [] Conn_Pris_Par; + delete [] Conn_Pyra_Par; - if (connSend != NULL) delete [] connSend; + delete [] connSend; - if (dataBuffer != NULL) delete [] dataBuffer; + delete [] dataBuffer; } void CParallelDataSorter::SortOutputData() { diff --git a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp index 1b9e95af901..18c95c4d3cf 100644 --- a/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelFileWriter.cpp @@ -210,6 +210,9 @@ bool CFileWriter::OpenMPIFile(){ int ierr; #ifdef HAVE_MPI + + disp = 0.0; + /*--- All ranks open the file using MPI. Here, we try to open the file with exclusive so that an error is generated if the file exists. We always want to write a fresh output file, so we delete any existing files and create @@ -243,9 +246,7 @@ bool CFileWriter::OpenMPIFile(){ } #endif - disp = 0.0; fileSize = 0.0; - usedTime = 0; return true; diff --git a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp index cfe2b0c0012..91a1b6a0906 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewVTMFileWriter.cpp @@ -39,7 +39,7 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string valFileName, string valFol : CFileWriter(std::move(valFileName), fileExt), folderName(std::move(valFolderName)), iZone(valiZone), nZone(valnZone), curTime(valTime){ - if (rank == MASTER_NODE) + if (rank == MASTER_NODE){ #if defined(_WIN32) || defined(_WIN64) || defined (__WINDOWS__) _mkdir(this->folderName.c_str()); _mkdir((this->folderName + "/zone_" + to_string(iZone)).c_str()); @@ -47,6 +47,7 @@ CParaviewVTMFileWriter::CParaviewVTMFileWriter(string valFileName, string valFol mkdir(this->folderName.c_str(), 0777); mkdir((this->folderName + "/zone_" + to_string(valiZone)).c_str(), 0777); #endif + } nWrittenDatasets = 0; accumulatedBandwidth = 0; From b78b44391829bd22f062879ed30fd8c05d7849fc Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 26 Jan 2020 14:46:02 +0100 Subject: [PATCH 57/61] Fixed alignment --- SU2_DOT/src/meson.build | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index 70aa746bcd4..def27602727 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -4,28 +4,28 @@ if get_option('enable-normal') 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', - 'output/tools/CWindowingTools.cpp', + 'output/tools/CWindowingTools.cpp', 'output/output_structure_legacy.cpp', - 'output/CBaselineOutput.cpp', - 'output/filewriter/CParallelDataSorter.cpp', - 'output/filewriter/CParallelFileWriter.cpp', - 'output/filewriter/CFEMDataSorter.cpp', - 'output/filewriter/CSurfaceFEMDataSorter.cpp', - 'output/filewriter/CFVMDataSorter.cpp', - 'output/filewriter/CSurfaceFVMDataSorter.cpp', - 'output/filewriter/CCSVFileWriter.cpp', + 'output/CBaselineOutput.cpp', + 'output/filewriter/CParallelDataSorter.cpp', + 'output/filewriter/CParallelFileWriter.cpp', + 'output/filewriter/CFEMDataSorter.cpp', + 'output/filewriter/CSurfaceFEMDataSorter.cpp', + 'output/filewriter/CFVMDataSorter.cpp', + 'output/filewriter/CSurfaceFVMDataSorter.cpp', + 'output/filewriter/CCSVFileWriter.cpp', 'output/filewriter/CSTLFileWriter.cpp', - 'output/filewriter/CTecplotFileWriter.cpp', - 'output/filewriter/CTecplotBinaryFileWriter.cpp', - 'output/filewriter/CParaviewFileWriter.cpp', - 'output/filewriter/CParaviewBinaryFileWriter.cpp', - 'output/filewriter/CSU2FileWriter.cpp', - 'output/filewriter/CSU2BinaryFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CTecplotFileWriter.cpp', + 'output/filewriter/CTecplotBinaryFileWriter.cpp', + 'output/filewriter/CParaviewFileWriter.cpp', + 'output/filewriter/CParaviewBinaryFileWriter.cpp', + 'output/filewriter/CSU2FileWriter.cpp', + 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CSU2MeshFileWriter.cpp', 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot = executable('SU2_DOT', su2_dot_src, @@ -42,28 +42,28 @@ if get_option('enable-autodiff') 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', - 'output/tools/CWindowingTools.cpp', + 'output/tools/CWindowingTools.cpp', 'output/output_structure_legacy.cpp', - 'output/CBaselineOutput.cpp', - 'output/filewriter/CParallelDataSorter.cpp', - 'output/filewriter/CParallelFileWriter.cpp', - 'output/filewriter/CFEMDataSorter.cpp', - 'output/filewriter/CSurfaceFEMDataSorter.cpp', - 'output/filewriter/CFVMDataSorter.cpp', - 'output/filewriter/CSurfaceFVMDataSorter.cpp', - 'output/filewriter/CCSVFileWriter.cpp', + 'output/CBaselineOutput.cpp', + 'output/filewriter/CParallelDataSorter.cpp', + 'output/filewriter/CParallelFileWriter.cpp', + 'output/filewriter/CFEMDataSorter.cpp', + 'output/filewriter/CSurfaceFEMDataSorter.cpp', + 'output/filewriter/CFVMDataSorter.cpp', + 'output/filewriter/CSurfaceFVMDataSorter.cpp', + 'output/filewriter/CCSVFileWriter.cpp', 'output/filewriter/CSTLFileWriter.cpp', - 'output/filewriter/CTecplotFileWriter.cpp', - 'output/filewriter/CTecplotBinaryFileWriter.cpp', - 'output/filewriter/CParaviewFileWriter.cpp', - 'output/filewriter/CParaviewBinaryFileWriter.cpp', - 'output/filewriter/CSU2FileWriter.cpp', - 'output/filewriter/CSU2BinaryFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CTecplotFileWriter.cpp', + 'output/filewriter/CTecplotBinaryFileWriter.cpp', + 'output/filewriter/CParaviewFileWriter.cpp', + 'output/filewriter/CParaviewBinaryFileWriter.cpp', + 'output/filewriter/CSU2FileWriter.cpp', + 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CSU2MeshFileWriter.cpp', 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot_ad = executable('SU2_DOT_AD', su2_dot_src_ad, From b636f09e54197feb40d632942b9ba1ba8255cdb4 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Sun, 26 Jan 2020 15:23:39 +0100 Subject: [PATCH 58/61] Fixed memory leak --- SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 892401b6a6e..9db3a4b0d6d 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -419,8 +419,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { processors so that it can be used to create offsets for the new global numbering for the surface points. ---*/ - int *nPoint_Send = new int[size+1](); nPoint_Send[0] = 0; - nPoint_Recv = new int[size+1](); nPoint_Recv[0] = 0; + nPoint_Send[0] = 0; + nPoint_Recv[0] = 0; for (int ii=1; ii < size+1; ii++) nPoint_Send[ii]= (int)nLocalPoint; @@ -1079,7 +1079,6 @@ void CSurfaceFVMDataSorter::SortOutputData() { delete [] nElem_Send; delete [] nElem_Flag; delete [] Local_Halo; - delete [] nPoint_Send; } From 253fc16231eb5bbf5ae22e3da102deb11472340c Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 27 Jan 2020 16:31:56 +0100 Subject: [PATCH 59/61] Fixed some comments and renamed some variables --- .../output/filewriter/CParallelDataSorter.hpp | 42 +++++++++---------- .../filewriter/CSurfaceFEMDataSorter.hpp | 10 ++--- .../filewriter/CSurfaceFVMDataSorter.hpp | 7 ++-- SU2_CFD/src/output/COutput.cpp | 4 +- .../src/output/filewriter/CFEMDataSorter.cpp | 8 ++-- .../src/output/filewriter/CFVMDataSorter.cpp | 6 +-- .../output/filewriter/CParallelDataSorter.cpp | 34 +++++++-------- .../filewriter/CParaviewBinaryFileWriter.cpp | 4 +- .../output/filewriter/CParaviewFileWriter.cpp | 2 +- .../filewriter/CParaviewXMLFileWriter.cpp | 4 +- .../filewriter/CSurfaceFEMDataSorter.cpp | 20 ++++----- .../filewriter/CSurfaceFVMDataSorter.cpp | 28 ++++++------- 12 files changed, 85 insertions(+), 84 deletions(-) diff --git a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp index 3cc12997f11..88c28a9c209 100644 --- a/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp @@ -48,7 +48,7 @@ class CParallelDataSorter{ int size; unsigned long nGlobalPointBeforeSort; //!< Global number of points without halos before sorting - unsigned long nLocalPointBeforeSort; //!< Local number of points without halos before sorting on this proc + unsigned long nLocalPointsBeforeSort; //!< Local number of points without halos before sorting on this proc int *Conn_Line_Par; //!< Local connectivity of line elements int *Conn_Tria_Par; //!< Local connectivity of triangle elements @@ -58,8 +58,8 @@ class CParallelDataSorter{ int *Conn_Pris_Par; //!< Local connectivity of prism elements int *Conn_Pyra_Par; //!< Local connectivity of pyramid elements - array nGlobalPerElem; //!< Global number of elements after sorting on this proc - array nLocalPerElem; //!< Local number of elements after sorting on this proc + array nElemPerTypeGlobal; //!< Global number of elements after sorting on this proc + array nElemPerType; //!< Local number of elements after sorting on this proc /*! * \brief Map that stores the index for each GEO_TYPE type where to find information @@ -67,12 +67,12 @@ class CParallelDataSorter{ */ static const map TypeMap; - unsigned long nGlobalPoint; //!< Global number of points without halos - unsigned long nGlobalElem; //!< Global number of elems without halos - unsigned long nGlobalConn; //!< Global size of the connectivity array - unsigned long nLocalPoint; //!< Local number of points - unsigned long nLocalElem; //!< Local number of elements - unsigned long nLocalConn; //!< Local size of the connectivity array + unsigned long nPointsGlobal; //!< Global number of points without halos + unsigned long nElemGlobal; //!< Global number of elems without halos + unsigned long nConnGlobal; //!< Global size of the connectivity array + unsigned long nPoints; //!< Local number of points + unsigned long nElem; //!< Local number of elements + unsigned long nConn; //!< Local size of the connectivity array CLinearPartitioner* linearPartitioner; //!< Linear partitioner based on the global number of points. @@ -113,7 +113,7 @@ class CParallelDataSorter{ /*! * \brief Constructor * \param[in] config - Pointer to the current config structure - * \param[in] fieldNames - Vector containing the field names + * \param[in] valFieldNames - Vector containing the field names */ CParallelDataSorter(CConfig *config, const vector &valFieldNames); @@ -147,25 +147,25 @@ class CParallelDataSorter{ * \brief Get the number of points the local rank owns. * \return local number of points. */ - unsigned long GetnPoints() const {return nLocalPoint;} + unsigned long GetnPoints() const {return nPoints;} /*! * \brief Get the number of points to sort. * \return local number of points. */ - unsigned long GetnLocalPointSort() const {return nLocalPointBeforeSort;} + unsigned long GetnLocalPointsBeforeSort() const {return nLocalPointsBeforeSort;} /*! * \brief Get the global number of points (accumulated from all ranks) * \return Global number of points. */ - unsigned long GetnPointsGlobal() const {return nGlobalPoint;} + unsigned long GetnPointsGlobal() const {return nPointsGlobal;} /*! * \brief Get the global of elements (accumulated from all ranks and element types) * \return Global number elements. */ - unsigned long GetnElem() const {return nLocalElem;} + unsigned long GetnElem() const {return nElem;} /*! * \brief Get the local number of elements of a specific type that the current rank owns @@ -173,7 +173,7 @@ class CParallelDataSorter{ * \return Local number of elements of a specific type. */ unsigned long GetnElem(GEO_TYPE type) const { - return nLocalPerElem[TypeMap.at(type)]; + return nElemPerType[TypeMap.at(type)]; } /*! @@ -182,7 +182,7 @@ class CParallelDataSorter{ * \return global number of elements of a specific type. */ unsigned long GetnElemGlobal(GEO_TYPE type) const { - return nGlobalPerElem[TypeMap.at(type)]; + return nElemPerTypeGlobal[TypeMap.at(type)]; } /*! @@ -190,23 +190,23 @@ class CParallelDataSorter{ * \return global number of elements. */ unsigned long GetnElemGlobal() const { - return nGlobalElem; + return nElemGlobal; } /*! * \brief Get the global number entries of the connectivity array * \return global number of entries of the connectivity array */ - unsigned long GetnElemConnGlobal() const { - return nGlobalConn; + unsigned long GetnConnGlobal() const { + return nConnGlobal; } /*! * \brief Get the local number entries of the connectivity array * \return local number of entries of the connectivity array */ - unsigned long GetnElemConn() const { - return nLocalConn; + unsigned long GetnConn() const { + return nConn; } /*! diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp index a889d28cf0b..584cbc769f7 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFEMDataSorter.hpp @@ -32,9 +32,8 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ CFEMDataSorter* volumeSorter; //!< Pointer to the volume sorter instance - //! Structure to map the local sorted point ID to the global point ID - std::vector globalSurfaceDOFIDs; - vector nSurfaceDOFsRanks; + vector globalSurfaceDOFIDs; //!< Structure to map the local sorted point ID to the global point ID + vector nSurfaceDOFsRanks; //!< Number of points on each rank public: @@ -63,7 +62,7 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ * All markers in MARKER_PLOTTING will be sorted. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] surf - boolean controlling whether surface or volume connectivity should be sorted. + * \param[in] val_sort - boolean controlling whether surface or volume connectivity should be sorted. */ void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; @@ -114,7 +113,7 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ /*! * \brief Get the cumulated number of points - * \input rank - the processor rank. + * \param[in] rank - the processor rank. * \return The cumulated number of points up to certain processor rank. */ unsigned long GetnPointCumulative(unsigned short rank) const override { @@ -128,6 +127,7 @@ class CSurfaceFEMDataSorter final: public CParallelDataSorter{ * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] Elem_Type - VTK index of the element type being merged. + * \param[in] markerList - List of markers to sort */ void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, const vector &markerList); diff --git a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp index d377c1b026d..de8f72441c4 100644 --- a/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp +++ b/SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp @@ -60,7 +60,7 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * All markers in MARKER_PLOTTING will be sorted. * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] surf - boolean controlling whether surface or volume connectivity should be sorted. + * \param[in] val_sort - boolean controlling whether surface or volume connectivity should be sorted. */ void SortConnectivity(CConfig *config, CGeometry *geometry, bool val_sort) override; @@ -79,9 +79,9 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * \return Global index of a specific point. */ unsigned long GetGlobalIndex(unsigned long iPoint) const override{ - if (iPoint > nLocalPoint) + if (iPoint > nPoints) SU2_MPI::Error(string("Local renumbered iPoint ID ") + to_string(iPoint) + - string(" is larger than max number of nodes ") + to_string(nLocalPoint), CURRENT_FUNCTION); + string(" is larger than max number of nodes ") + to_string(nPoints), CURRENT_FUNCTION); return Renumber2Global.at(iPoint); } @@ -126,6 +126,7 @@ class CSurfaceFVMDataSorter final: public CParallelDataSorter{ * \param[in] config - Definition of the particular problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] Elem_Type - VTK index of the element type being merged. + * \param[in] markerList - List of markers to sort */ void SortSurfaceConnectivity(CConfig *config, CGeometry *geometry, unsigned short Elem_Type, const vector &markerList); diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index ca39c52aeb6..506e8e21893 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1172,7 +1172,7 @@ void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){ /*--- Open history file and print the header ---*/ if (!config->GetMultizone_Problem() || config->GetWrt_ZoneConv()) - PrepareHistoryFile(config); + PrepareHistoryFile(config); total_width = nRequestedScreenFields*fieldWidth + (nRequestedScreenFields-1); @@ -2019,7 +2019,7 @@ void COutput::LoadCommonHistoryData(CConfig *config){ SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref()); - /*--- Update the current time time only if the time iteration has changed ---*/ + /*--- Update the current time only if the time iteration has changed ---*/ if (SU2_TYPE::Int(GetHistoryFieldValue("TIME_ITER")) != curTimeIter){ SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); diff --git a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp index 3bbb5bf48ba..370180e7116 100644 --- a/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFEMDataSorter.cpp @@ -57,11 +57,11 @@ CFEMDataSorter::CFEMDataSorter(CConfig *config, CGeometry *geometry, const vecto const unsigned long globalIndex = volElem[l].offsetDOFsSolGlobal + j; globalID.push_back(globalIndex); - nLocalPointBeforeSort++; + nLocalPointsBeforeSort++; } } - SU2_MPI::Allreduce(&nLocalPointBeforeSort, &nGlobalPointBeforeSort, 1, + SU2_MPI::Allreduce(&nLocalPointsBeforeSort, &nGlobalPointBeforeSort, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); /*--- Create a linear partition --- */ @@ -93,7 +93,7 @@ void CFEMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool /*--- Sort volumetric grid connectivity. ---*/ - nLocalPerElem.fill(0); + nElemPerType.fill(0); SortVolumetricConnectivity(config, geometry, TRIANGLE ); SortVolumetricConnectivity(config, geometry, QUADRILATERAL); @@ -205,7 +205,7 @@ void CFEMDataSorter::SortVolumetricConnectivity(CConfig *config, CGeometry *geom } } - nLocalPerElem[TypeMap.at(Elem_Type)] = nSubElem_Local; + nElemPerType[TypeMap.at(Elem_Type)] = nSubElem_Local; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp index 7d848608a53..c76a6c84638 100644 --- a/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CFVMDataSorter.cpp @@ -37,7 +37,7 @@ CFVMDataSorter::CFVMDataSorter(CConfig *config, CGeometry *geometry, const vecto std::vector globalID; nGlobalPointBeforeSort = geometry->GetGlobal_nPointDomain(); - nLocalPointBeforeSort = geometry->GetnPointDomain(); + nLocalPointsBeforeSort = geometry->GetnPointDomain(); Local_Halo = new int[geometry->GetnPoint()](); @@ -116,7 +116,7 @@ void CFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometry, bool In these routines, we sort the connectivity into a linear partitioning across all processors based on the global index of the grid nodes. ---*/ - nLocalPerElem.fill(0); + nElemPerType.fill(0); SortVolumetricConnectivity(config, geometry, TRIANGLE, val_sort); SortVolumetricConnectivity(config, geometry, QUADRILATERAL, val_sort); @@ -477,7 +477,7 @@ void CFVMDataSorter::SortVolumetricConnectivity(CConfig *config, } } - nLocalPerElem[TypeMap.at(Elem_Type)] = nElem_Total; + nElemPerType[TypeMap.at(Elem_Type)] = nElem_Total; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp index ad8371062f3..620686774c5 100644 --- a/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CParallelDataSorter.cpp @@ -67,7 +67,7 @@ CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector & nSends = 0; nRecvs = 0; - nLocalPointBeforeSort = 0; + nLocalPointsBeforeSort = 0; nGlobalPointBeforeSort = 0; nPoint_Send = new int[size+1](); @@ -79,8 +79,8 @@ CParallelDataSorter::CParallelDataSorter(CConfig *config, const vector & linearPartitioner = NULL; - nLocalPerElem.fill(0); - nGlobalPerElem.fill(0); + nElemPerType.fill(0); + nElemPerTypeGlobal.fill(0); } @@ -257,11 +257,11 @@ void CParallelDataSorter::SortOutputData() { /*--- Store the total number of local points my rank has for the current section after completing the communications. ---*/ - nLocalPoint = nPoint_Recv[size]; + nPoints = nPoint_Recv[size]; /*--- Reduce the total number of points we will write in the output files. ---*/ - SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, + SU2_MPI::Allreduce(&nPoints, &nPointsGlobal, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); /*--- Free temporary memory from communications ---*/ @@ -283,7 +283,7 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector& globalI nodes, i.e., rank 0 holds the first ~ nGlobalPoint()/nProcessors nodes. First, initialize a counter and flag. ---*/ - for (iPoint = 0; iPoint < nLocalPointBeforeSort; iPoint++ ) { + for (iPoint = 0; iPoint < nLocalPointsBeforeSort; iPoint++ ) { iProcessor = linearPartitioner->GetRankContainingIndex(globalID[iPoint]); @@ -344,12 +344,12 @@ void CParallelDataSorter::PrepareSendBuffers(std::vector& globalI unsigned long *idIndex = new unsigned long[size](); for (int ii=0; ii < size; ii++) idIndex[ii] = nPoint_Send[ii]; - Index = new unsigned long[nLocalPointBeforeSort](); + Index = new unsigned long[nLocalPointsBeforeSort](); /*--- Loop through our elements and load the elems and their additional data that we will send to the other procs. ---*/ - for (iPoint = 0; iPoint < nLocalPointBeforeSort; iPoint++) { + for (iPoint = 0; iPoint < nLocalPointsBeforeSort; iPoint++) { iProcessor = linearPartitioner->GetRankContainingIndex(globalID[iPoint]); @@ -414,16 +414,16 @@ void CParallelDataSorter::SetTotalElements(){ /*--- Reduce the total number of cells we will be writing in the output files. ---*/ - SU2_MPI::Allreduce(nLocalPerElem.data(), nGlobalPerElem.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(nElemPerType.data(), nElemPerTypeGlobal.data(), N_ELEM_TYPES, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); - nGlobalElem = std::accumulate(nGlobalPerElem.begin(), nGlobalPerElem.end(), 0); - nLocalElem = std::accumulate(nLocalPerElem.begin(), nLocalPerElem.end(), 0); + nElemGlobal = std::accumulate(nElemPerTypeGlobal.begin(), nElemPerTypeGlobal.end(), 0); + nElem = std::accumulate(nElemPerType.begin(), nElemPerType.end(), 0); - nLocalConn = 0; - nGlobalConn = 0; + nConn = 0; + nConnGlobal = 0; auto addConnectivitySize = [this](GEO_TYPE elem, unsigned short nPoints){ - nLocalConn += GetnElem(elem)*nPoints; - nGlobalConn += GetnElemGlobal(elem)*nPoints; + nConn += GetnElem(elem)*nPoints; + nConnGlobal += GetnElemGlobal(elem)*nPoints; }; addConnectivitySize(LINE, N_POINTS_LINE); @@ -442,8 +442,8 @@ void CParallelDataSorter::SetTotalElements(){ nElem_Send[0] = 0; nElemConn_Send[0] = 0; nElem_Cum[0] = 0; nElemConn_Cum[0] = 0; for (int ii=1; ii <= size; ii++) { - nElem_Send[ii] = int(nLocalElem); - nElemConn_Send[ii] = int(nLocalConn); + nElem_Send[ii] = int(nElem); + nElemConn_Send[ii] = int(nConn); nElem_Cum[ii] = 0; nElemConn_Cum[ii] = 0; } diff --git a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp index ece3942cf56..a8fcdd86bfb 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewBinaryFileWriter.cpp @@ -128,9 +128,9 @@ void CParaviewBinaryFileWriter::Write_Data(){ nParallel_Pyra = dataSorter->GetnElem(PYRAMID); myElem = dataSorter->GetnElem(); - myElemStorage = dataSorter->GetnElemConn(); + myElemStorage = dataSorter->GetnConn(); GlobalElem = dataSorter->GetnElemGlobal(); - GlobalElemStorage = dataSorter->GetnElemConnGlobal(); + GlobalElemStorage = dataSorter->GetnConnGlobal(); SPRINTF(str_buf, "\nCELLS %i %i\n", SU2_TYPE::Int(GlobalElem), SU2_TYPE::Int(GlobalElemStorage+GlobalElem)); diff --git a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp index 4801c13194f..411b1362ecd 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewFileWriter.cpp @@ -120,7 +120,7 @@ void CParaviewFileWriter::Write_Data(){ if (rank == MASTER_NODE) { /*--- Write the header ---*/ - nGlobal_Elem_Storage = dataSorter->GetnElemGlobal() + dataSorter->GetnElemConnGlobal(); + nGlobal_Elem_Storage = dataSorter->GetnElemGlobal() + dataSorter->GetnConnGlobal(); Paraview_File << "\nCELLS " << dataSorter->GetnElemGlobal() << "\t" << nGlobal_Elem_Storage << "\n"; diff --git a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp index 6a6a9f3e814..0b248a5e897 100644 --- a/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CParaviewXMLFileWriter.cpp @@ -98,9 +98,9 @@ void CParaviewXMLFileWriter::Write_Data(){ nParallel_Pyra = dataSorter->GetnElem(PYRAMID); myElem = dataSorter->GetnElem(); - myElemStorage = dataSorter->GetnElemConn(); + myElemStorage = dataSorter->GetnConn(); GlobalElem = dataSorter->GetnElemGlobal(); - GlobalElemStorage = dataSorter->GetnElemConnGlobal(); + GlobalElemStorage = dataSorter->GetnConnGlobal(); /* Write the ASCII XML header. Note that we use the appended format for the data, * which means that all data is appended at the end of the file in one binary blob. diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp index 30da91dcf48..e4de4b201d3 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFEMDataSorter.cpp @@ -53,11 +53,11 @@ CSurfaceFEMDataSorter::CSurfaceFEMDataSorter(CConfig *config, CGeometry *geometr /* Count up the number of local points we have for allocating storage. */ for(unsigned short j=0; jGetCumulativeSizeBeforeRank(rank); for(int jj=0; jj mapGlobalVol2Surf; - for(unsigned long i=0; i &markerList) { - nLocalPerElem.fill(0); + nElemPerType.fill(0); SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); @@ -459,7 +459,7 @@ void CSurfaceFEMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * } } - nLocalPerElem[TypeMap.at(Elem_Type)] = nSubElem_Local; + nElemPerType[TypeMap.at(Elem_Type)] = nSubElem_Local; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ diff --git a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp index 9db3a4b0d6d..aab810a51cc 100644 --- a/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp +++ b/SU2_CFD/src/output/filewriter/CSurfaceFVMDataSorter.cpp @@ -39,7 +39,7 @@ CSurfaceFVMDataSorter::CSurfaceFVMDataSorter(CConfig *config, CGeometry *geometr connectivitySorted = false; nGlobalPointBeforeSort = geometry->GetGlobal_nPointDomain(); - nLocalPointBeforeSort = geometry->GetnPointDomain(); + nLocalPointsBeforeSort = geometry->GetnPointDomain(); /*--- Create the linear partitioner --- */ @@ -398,7 +398,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- First, add up the number of surface points I have on my rank. ---*/ - nLocalPoint = 0; + nPoints = 0; Renumber2Global.clear(); for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) { @@ -406,11 +406,11 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Save the global index values for CSV output. ---*/ - Renumber2Global[nLocalPoint] = surfPoint[iPoint]; + Renumber2Global[nPoints] = surfPoint[iPoint]; /*--- Increment total number of surface points found locally. ---*/ - nLocalPoint++; + nPoints++; } } @@ -422,7 +422,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { nPoint_Send[0] = 0; nPoint_Recv[0] = 0; - for (int ii=1; ii < size+1; ii++) nPoint_Send[ii]= (int)nLocalPoint; + for (int ii=1; ii < size+1; ii++) nPoint_Send[ii]= (int)nPoints; SU2_MPI::Alltoall(&(nPoint_Send[1]), 1, MPI_INT, &(nPoint_Recv[1]), 1, MPI_INT, MPI_COMM_WORLD); @@ -442,7 +442,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { delete [] passiveDoubleBuffer; } - passiveDoubleBuffer = new passivedouble[nLocalPoint*VARS_PER_POINT]; + passiveDoubleBuffer = new passivedouble[nPoints*VARS_PER_POINT]; for (int jj = 0; jj < VARS_PER_POINT; jj++) { count = 0; @@ -456,7 +456,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Reduce the total number of surf points we have. This will be needed for writing the surface solution files later. ---*/ - SU2_MPI::Allreduce(&nLocalPoint, &nGlobalPoint, 1, + SU2_MPI::Allreduce(&nPoints, &nPointsGlobal, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); /*--- Now that we know every proc's global offset for the number of @@ -464,8 +464,8 @@ void CSurfaceFVMDataSorter::SortOutputData() { create a new mapping using two arrays, which will need to be communicated. We use our mask again here. ---*/ - unsigned long *globalP = new unsigned long[nLocalPoint](); - unsigned long *renumbP = new unsigned long[nLocalPoint](); + unsigned long *globalP = new unsigned long[nPoints](); + unsigned long *renumbP = new unsigned long[nPoints](); count = 0; for (iPoint = 0; iPoint < volumeSorter->GetnPoints(); iPoint++) { @@ -501,7 +501,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Loop through my local surface nodes, find which proc the global value lives on, then communicate the global ID and remumbered value. ---*/ - for (int ii = 0; ii < (int)nLocalPoint; ii++) { + for (int ii = 0; ii < (int)nPoints; ii++) { Global_Index = globalP[ii]; @@ -563,7 +563,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { /*--- Loop back through and load up the buffers for the global IDs and their new renumbering values. ---*/ - for (int ii = 0; ii < (int)nLocalPoint; ii++) { + for (int ii = 0; ii < (int)nPoints; ii++) { Global_Index = globalP[ii]; @@ -956,7 +956,7 @@ void CSurfaceFVMDataSorter::SortOutputData() { that they need to have their renumbering shared. ---*/ for (int ii = 0; ii < nElem_Recv[size]; ii++) { - for (iPoint = 0; iPoint < nLocalPoint; iPoint++) { + for (iPoint = 0; iPoint < nPoints; iPoint++) { if (idRecv[ii] == globalP[iPoint]) { idRecv[ii] = renumbP[iPoint]; } @@ -1106,7 +1106,7 @@ void CSurfaceFVMDataSorter::SortConnectivity(CConfig *config, CGeometry *geometr /*--- Sort volumetric grid connectivity. ---*/ - nLocalPerElem.fill(0); + nElemPerType.fill(0); SortSurfaceConnectivity(config, geometry, LINE , markerList); SortSurfaceConnectivity(config, geometry, TRIANGLE , markerList); @@ -1473,7 +1473,7 @@ void CSurfaceFVMDataSorter::SortSurfaceConnectivity(CConfig *config, CGeometry * } } - nLocalPerElem[TypeMap.at(Elem_Type)] = nElem_Total; + nElemPerType[TypeMap.at(Elem_Type)] = nElem_Total; /*--- Store the particular global element count in the class data, and set the class data pointer to the connectivity array. ---*/ From a1dbcaa4b6b50c71b15cfb7f7dc9e0ac18502449 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 27 Jan 2020 16:32:07 +0100 Subject: [PATCH 60/61] Fixed alignment --- SU2_DOT/src/meson.build | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index def27602727..34c0eafdad7 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -4,28 +4,28 @@ if get_option('enable-normal') 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', - 'output/tools/CWindowingTools.cpp', + 'output/tools/CWindowingTools.cpp', 'output/output_structure_legacy.cpp', - 'output/CBaselineOutput.cpp', - 'output/filewriter/CParallelDataSorter.cpp', - 'output/filewriter/CParallelFileWriter.cpp', - 'output/filewriter/CFEMDataSorter.cpp', - 'output/filewriter/CSurfaceFEMDataSorter.cpp', - 'output/filewriter/CFVMDataSorter.cpp', - 'output/filewriter/CSurfaceFVMDataSorter.cpp', - 'output/filewriter/CCSVFileWriter.cpp', + 'output/CBaselineOutput.cpp', + 'output/filewriter/CParallelDataSorter.cpp', + 'output/filewriter/CParallelFileWriter.cpp', + 'output/filewriter/CFEMDataSorter.cpp', + 'output/filewriter/CSurfaceFEMDataSorter.cpp', + 'output/filewriter/CFVMDataSorter.cpp', + 'output/filewriter/CSurfaceFVMDataSorter.cpp', + 'output/filewriter/CCSVFileWriter.cpp', 'output/filewriter/CSTLFileWriter.cpp', - 'output/filewriter/CTecplotFileWriter.cpp', - 'output/filewriter/CTecplotBinaryFileWriter.cpp', - 'output/filewriter/CParaviewFileWriter.cpp', - 'output/filewriter/CParaviewBinaryFileWriter.cpp', - 'output/filewriter/CSU2FileWriter.cpp', - 'output/filewriter/CSU2BinaryFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CTecplotFileWriter.cpp', + 'output/filewriter/CTecplotBinaryFileWriter.cpp', + 'output/filewriter/CParaviewFileWriter.cpp', + 'output/filewriter/CParaviewBinaryFileWriter.cpp', + 'output/filewriter/CSU2FileWriter.cpp', + 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CSU2MeshFileWriter.cpp', 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot = executable('SU2_DOT', su2_dot_src, @@ -42,28 +42,28 @@ if get_option('enable-autodiff') 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', - 'output/tools/CWindowingTools.cpp', + 'output/tools/CWindowingTools.cpp', 'output/output_structure_legacy.cpp', - 'output/CBaselineOutput.cpp', - 'output/filewriter/CParallelDataSorter.cpp', - 'output/filewriter/CParallelFileWriter.cpp', - 'output/filewriter/CFEMDataSorter.cpp', - 'output/filewriter/CSurfaceFEMDataSorter.cpp', - 'output/filewriter/CFVMDataSorter.cpp', - 'output/filewriter/CSurfaceFVMDataSorter.cpp', - 'output/filewriter/CCSVFileWriter.cpp', + 'output/CBaselineOutput.cpp', + 'output/filewriter/CParallelDataSorter.cpp', + 'output/filewriter/CParallelFileWriter.cpp', + 'output/filewriter/CFEMDataSorter.cpp', + 'output/filewriter/CSurfaceFEMDataSorter.cpp', + 'output/filewriter/CFVMDataSorter.cpp', + 'output/filewriter/CSurfaceFVMDataSorter.cpp', + 'output/filewriter/CCSVFileWriter.cpp', 'output/filewriter/CSTLFileWriter.cpp', - 'output/filewriter/CTecplotFileWriter.cpp', - 'output/filewriter/CTecplotBinaryFileWriter.cpp', - 'output/filewriter/CParaviewFileWriter.cpp', - 'output/filewriter/CParaviewBinaryFileWriter.cpp', - 'output/filewriter/CSU2FileWriter.cpp', - 'output/filewriter/CSU2BinaryFileWriter.cpp', - 'output/filewriter/CSU2MeshFileWriter.cpp', + 'output/filewriter/CTecplotFileWriter.cpp', + 'output/filewriter/CTecplotBinaryFileWriter.cpp', + 'output/filewriter/CParaviewFileWriter.cpp', + 'output/filewriter/CParaviewBinaryFileWriter.cpp', + 'output/filewriter/CSU2FileWriter.cpp', + 'output/filewriter/CSU2BinaryFileWriter.cpp', + 'output/filewriter/CSU2MeshFileWriter.cpp', 'output/filewriter/CParaviewXMLFileWriter.cpp', 'output/filewriter/CParaviewVTMFileWriter.cpp', - 'variables/CBaselineVariable.cpp', - 'variables/CVariable.cpp']) + 'variables/CBaselineVariable.cpp', + 'variables/CVariable.cpp']) su2_dot_ad = executable('SU2_DOT_AD', su2_dot_src_ad, From afc203d931bef9d898fc555e3ec41e08ec446ebf Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 28 Jan 2020 09:30:47 +0100 Subject: [PATCH 61/61] Updating automake files --- Common/lib/Makefile.am | 38 +++++++++++++++++++++----------------- SU2_CFD/obj/Makefile.am | 2 ++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Common/lib/Makefile.am b/Common/lib/Makefile.am index de5a9c06edc..6dc410c0252 100644 --- a/Common/lib/Makefile.am +++ b/Common/lib/Makefile.am @@ -56,26 +56,17 @@ lib_sources = \ ../include/config_structure.hpp \ ../include/config_structure.inl \ ../include/blas_structure.hpp \ - ../include/dual_grid_structure.hpp \ - ../include/dual_grid_structure.inl \ ../include/fem_geometry_structure.hpp \ ../include/fem_geometry_structure.inl \ ../include/fem_standard_element.hpp \ ../include/fem_standard_element.inl \ ../include/CMultiGridQueue.hpp \ - ../include/CMeshReaderFVM.hpp \ - ../include/CSU2ASCIIMeshReaderFVM.hpp \ - ../include/CCGNSMeshReaderFVM.hpp \ - ../include/CRectangularMeshReaderFVM.hpp \ - ../include/CBoxMeshReaderFVM.hpp \ ../include/graph_coloring_structure.hpp \ ../include/grid_adaptation_structure.hpp \ ../include/grid_adaptation_structure.inl \ ../include/grid_movement_structure.hpp \ ../include/grid_movement_structure.inl \ ../include/option_structure.hpp \ - ../include/primal_grid_structure.hpp \ - ../include/primal_grid_structure.inl \ ../include/mpi_structure.hpp \ ../include/mpi_structure.inl \ ../include/datatype_structure.hpp \ @@ -113,23 +104,16 @@ lib_sources = \ ../src/fem_cgns_elements.cpp \ ../src/config_structure.cpp \ ../src/blas_structure.cpp \ - ../src/dual_grid_structure.cpp \ ../src/fem_geometry_structure.cpp \ ../src/fem_integration_rules.cpp \ ../src/fem_standard_element.cpp \ ../src/fem_wall_distance.cpp \ ../src/fem_work_estimate_metis.cpp \ ../src/CMultiGridQueue.cpp \ - ../src/CMeshReaderFVM.cpp \ - ../src/CSU2ASCIIMeshReaderFVM.cpp \ - ../src/CCGNSMeshReaderFVM.cpp \ - ../src/CRectangularMeshReaderFVM.cpp \ - ../src/CBoxMeshReaderFVM.cpp \ ../src/geometry_structure_fem_part.cpp \ ../src/graph_coloring_structure.cpp \ ../src/grid_adaptation_structure.cpp \ ../src/grid_movement_structure.cpp \ - ../src/primal_grid_structure.cpp \ ../src/mpi_structure.cpp \ ../src/ad_structure.cpp \ ../src/fem_gauss_jacobi_quadrature.cpp \ @@ -144,11 +128,31 @@ lib_sources = \ ../src/geometry/elements/CPYRAM5.cpp \ ../src/geometry/elements/CPRISM6.cpp \ ../src/geometry/elements/CHEXA8.cpp \ + ../src/geometry/dual_grid/CDualGrid.cpp \ + ../src/geometry/dual_grid/CEdge.cpp \ + ../src/geometry/dual_grid/CPoint.cpp \ + ../src/geometry/dual_grid/CTurboVertex.cpp \ + ../src/geometry/dual_grid/CVertex.cpp \ + ../src/geometry/primal_grid/CHexahedron.cpp \ + ../src/geometry/primal_grid/CLine.cpp \ + ../src/geometry/primal_grid/CPrimalGridBoundFEM.cpp \ + ../src/geometry/primal_grid/CPrimalGrid.cpp \ + ../src/geometry/primal_grid/CPrimalGridFEM.cpp \ + ../src/geometry/primal_grid/CPrism.cpp \ + ../src/geometry/primal_grid/CPyramid.cpp \ + ../src/geometry/primal_grid/CQuadrilateral.cpp \ + ../src/geometry/primal_grid/CTetrahedron.cpp \ + ../src/geometry/primal_grid/CTriangle.cpp \ + ../src/geometry/primal_grid/CVertexMPI.cpp \ + ../src/geometry/meshreader/CBoxMeshReaderFVM.cpp \ + ../src/geometry/meshreader/CCGNSMeshReaderFVM.cpp \ + ../src/geometry/meshreader/CMeshReaderFVM.cpp \ + ../src/geometry/meshreader/CRectangularMeshReaderFVM.cpp \ + ../src/geometry/meshreader/CSU2ASCIIMeshReaderFVM.cpp \ ../src/interpolation_structure.cpp \ ../src/adt_structure.cpp \ ../src/wall_model.cpp \ ../src/toolboxes/printing_toolbox.cpp \ - ../src/toolboxes/signal_processing_toolbox.cpp \ ../src/toolboxes/CLinearPartitioner.cpp \ ../src/toolboxes/MMS/CVerificationSolution.cpp \ ../src/toolboxes/MMS/CIncTGVSolution.cpp \ diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index ebbd9522101..16c9109a059 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -87,6 +87,8 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/output/filewriter/CParallelDataSorter.cpp \ ../src/output/filewriter/CParallelFileWriter.cpp \ ../src/output/filewriter/CParaviewBinaryFileWriter.cpp \ + ../src/output/filewriter/CParaviewXMLFileWriter.cpp \ + ../src/output/filewriter/CParaviewVTMFileWriter.cpp \ ../src/output/filewriter/CParaviewFileWriter.cpp \ ../src/output/filewriter/CSurfaceFEMDataSorter.cpp \ ../src/output/filewriter/CSurfaceFVMDataSorter.cpp \