-
Notifications
You must be signed in to change notification settings - Fork 910
WIP: SU2 Binary grid format #2535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vdweide
wants to merge
5
commits into
develop
Choose a base branch
from
feature_binary_su2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,164
−90
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
Common/include/geometry/meshreader/CSU2BinaryMeshReaderBase.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /*! | ||
| * \file CSU2BinaryMeshReaderBase.hpp | ||
| * \brief Header file for the class CSU2BinaryMeshReaderBase. | ||
| * The implementations are in the <i>CSU2BinaryMeshReaderBase.cpp</i> file. | ||
| * \author T. Economon, E. van der Weide | ||
| * \version 8.2.0 "Harrier" | ||
| * | ||
| * SU2 Project Website: https://su2code.github.io | ||
| * | ||
| * The SU2 Project is maintained by the SU2 Foundation | ||
| * (http://su2foundation.org) | ||
| * | ||
| * Copyright 2012-2025, 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 <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "CSU2MeshReaderBase.hpp" | ||
| #include "../../../include/toolboxes/SwapBytes.hpp" | ||
|
|
||
| /*! | ||
| * \class CSU2BinaryMeshReaderBase | ||
| * \brief Base class for the reading of a native SU2 binary grid. | ||
| * \author T. Economon, E. van der Weide | ||
| */ | ||
| class CSU2BinaryMeshReaderBase : public CSU2MeshReaderBase { | ||
| protected: | ||
| constexpr static int SU2_STRING_SIZE = 33; /*!< \brief Size of the strings in the SU2 binary mesh file. */ | ||
|
|
||
| FILE* mesh_file; /*!< \brief File object for the SU2 binary mesh file. */ | ||
| bool swap_bytes; /*!< \brief Whether or not byte swapping must be used. */ | ||
| int size_conn_type; /*!< \brief Size, in bytes of the connectivity type. */ | ||
|
|
||
| /*! | ||
| * \brief Reads the connectivity type used in the binary file and check if | ||
| * byte swapping must be applied. | ||
| */ | ||
| void ReadConnectivityType(); | ||
|
|
||
| /*! | ||
| * \brief Reads all SU2 binary mesh metadata and checks for errors. | ||
| * \param[in,out] config - Problem configuration where some metadata is updated (e.g. AoA). | ||
| */ | ||
| void ReadMetadata(CConfig* config); | ||
|
|
||
| /*! | ||
| * \brief Reads the grid points from an SU2 zone into linear partitions across all ranks. | ||
| */ | ||
| virtual void ReadPointCoordinates(); | ||
|
|
||
| /*! | ||
| * \brief Reads the interior volume elements from one section of an SU2 zone into linear partitions across all ranks. | ||
| */ | ||
| virtual void ReadVolumeElementConnectivity(); | ||
|
|
||
| /*! | ||
| * \brief Reads the surface (boundary) elements from the SU2 zone. | ||
| */ | ||
| virtual void ReadSurfaceElementConnectivity(); | ||
|
|
||
| /*! | ||
| * \brief Helper function to find the current zone in an SU2 binary mesh object. | ||
| */ | ||
| void FastForwardToMyZone(); | ||
|
|
||
| /*! | ||
| * \brief Function to read one entity of the connectivity type from the binary file. | ||
| * \return uint64_t version of the the data. | ||
| */ | ||
| uint64_t ReadBinaryNEntities(); | ||
|
|
||
| /*! | ||
| * \brief Template function to read data from the binary file. | ||
| */ | ||
| template <typename T> | ||
| void ReadBinaryData(T* data, const size_t nItems) { | ||
| /*--- Read the actual data. ---*/ | ||
| auto ret = fread(data, sizeof(T), nItems, mesh_file); | ||
| if (ret != nItems) SU2_MPI::Error(string("Error while reading the file ") + meshFilename, CURRENT_FUNCTION); | ||
|
|
||
| /*--- Apply byte swapping, if needed. ---*/ | ||
| if (swap_bytes) SwapBytes((char*)data, sizeof(T), nItems); | ||
| } | ||
|
|
||
| private: | ||
| /*! | ||
| * \brief Read the meta data for a zone. | ||
| */ | ||
| void ReadMetadataZone(); | ||
|
|
||
| public: | ||
| /*! | ||
| * \brief Constructor of the CSU2BinaryMeshReaderBase class. | ||
| */ | ||
| CSU2BinaryMeshReaderBase(CConfig* val_config, unsigned short val_iZone, unsigned short val_nZone); | ||
|
|
||
| /*! | ||
| * \brief Destructor of the CSU2BinaryMeshReaderBase class. | ||
| */ | ||
| ~CSU2BinaryMeshReaderBase(void) override; | ||
| }; | ||
66 changes: 66 additions & 0 deletions
66
Common/include/geometry/meshreader/CSU2BinaryMeshReaderFEM.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /*! | ||
| * \file CSU2BinaryMeshReaderFEM.hpp | ||
| * \brief Header file for the class CSU2BinaryMeshReaderFEM. | ||
| * The implementations are in the <i>CSU2BinaryMeshReaderFEM.cpp</i> file. | ||
| * \author T. Economon, E. van der Weide | ||
| * \version 8.2.0 "Harrier" | ||
| * | ||
| * SU2 Project Website: https://su2code.github.io | ||
| * | ||
| * The SU2 Project is maintained by the SU2 Foundation | ||
| * (http://su2foundation.org) | ||
| * | ||
| * Copyright 2012-2025, 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 <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "CSU2BinaryMeshReaderBase.hpp" | ||
|
|
||
| /*! | ||
| * \class CSU2BinaryMeshReaderFEM | ||
| * \brief Reads a native SU2 binary grid into linear partitions for the finite element solver (FEM). | ||
| * \author T. Economon, E. van der Weide | ||
| */ | ||
| class CSU2BinaryMeshReaderFEM : public CSU2BinaryMeshReaderBase { | ||
| private: | ||
| /*! | ||
| * \brief Reads the grid points from an SU2 zone into linear partitions across all ranks. | ||
| */ | ||
| void ReadPointCoordinates(); | ||
|
|
||
| /*! | ||
| * \brief Reads the interior volume elements from one section of an SU2 zone into linear partitions across all ranks. | ||
| */ | ||
| void ReadVolumeElementConnectivity(); | ||
|
|
||
| /*! | ||
| * \brief Reads the surface (boundary) elements from one section of an SU2 zone into linear partitions across all | ||
| * ranks. | ||
| */ | ||
| void ReadSurfaceElementConnectivity(); | ||
|
|
||
| public: | ||
| /*! | ||
| * \brief Constructor of the CSU2BinaryMeshReaderFEM class. | ||
| */ | ||
| CSU2BinaryMeshReaderFEM(CConfig* val_config, unsigned short val_iZone, unsigned short val_nZone); | ||
|
|
||
| /*! | ||
| * \brief Destructor of the CSU2BinaryMeshReaderFEM class. | ||
| */ | ||
| ~CSU2BinaryMeshReaderFEM(void) override; | ||
|
Comment on lines
+62
to
+65
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Omit destructors if you don't need them to do something custom. |
||
| }; | ||
55 changes: 55 additions & 0 deletions
55
Common/include/geometry/meshreader/CSU2BinaryMeshReaderFVM.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /*! | ||
| * \file CSU2BinaryMeshReaderFVM.hpp | ||
| * \brief Header file for the class CSU2BinaryMeshReaderFVM. | ||
| * The implementations are in the <i>CSU2BinaryMeshReaderFVM.cpp</i> file. | ||
| * \author T. Econonmon, E. van der Weide | ||
| * \version 8.2.0 "Harrier" | ||
| * | ||
| * SU2 Project Website: https://su2code.github.io | ||
| * | ||
| * The SU2 Project is maintained by the SU2 Foundation | ||
| * (http://su2foundation.org) | ||
| * | ||
| * Copyright 2012-2025, 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 <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "CSU2BinaryMeshReaderBase.hpp" | ||
|
|
||
| /*! | ||
| * \class CSU2BinaryMeshReaderFVM | ||
| * \brief Reads a native SU2 binary grid into linear partitions for the finite volume solver (FVM). | ||
| * \author T. Econonmon, E. van der Weide | ||
| */ | ||
| class CSU2BinaryMeshReaderFVM : public CSU2BinaryMeshReaderBase { | ||
| private: | ||
| /*! | ||
| * \brief Splits a single surface actuator disk boundary into two separate markers (repeated points). | ||
| */ | ||
| void SplitActuatorDiskSurface(); | ||
|
|
||
| public: | ||
| /*! | ||
| * \brief Constructor of the CSU2BinaryMeshReaderFVM class. | ||
| */ | ||
| CSU2BinaryMeshReaderFVM(CConfig* val_config, unsigned short val_iZone, unsigned short val_nZone); | ||
|
|
||
| /*! | ||
| * \brief Destructor of the CSU2BinaryMeshReaderFVM class. | ||
| */ | ||
| ~CSU2BinaryMeshReaderFVM(void) override; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /*! | ||
| * \file CSU2MeshReaderBase.hpp | ||
| * \brief Header file for the class CSU2MeshReaderBase. | ||
| * The implementations are in the <i>CSU2MeshReaderBase.cpp</i> file. | ||
| * \author T. Economon | ||
| * \version 8.2.0 "Harrier" | ||
| * | ||
| * SU2 Project Website: https://su2code.github.io | ||
| * | ||
| * The SU2 Project is maintained by the SU2 Foundation | ||
| * (http://su2foundation.org) | ||
| * | ||
| * Copyright 2012-2025, 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 <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <array> | ||
|
|
||
| #include "CMeshReaderBase.hpp" | ||
|
|
||
| /*! | ||
| * \class CSU2MeshReaderBase | ||
| * \brief Base class for the reading of a native SU2 grid. | ||
| * \author T. Economon | ||
| */ | ||
| class CSU2MeshReaderBase : public CMeshReaderBase { | ||
| protected: | ||
| const unsigned short myZone; /*!< \brief Current SU2 zone index. */ | ||
| const unsigned short nZones; /*!< \brief Total number of zones in the SU2 file. */ | ||
|
|
||
| const string meshFilename; /*!< \brief Name of the SU2 ASCII mesh file being read. */ | ||
|
|
||
| bool actuator_disk; /*!< \brief Boolean for whether we have an actuator disk to split. */ | ||
|
|
||
| unsigned long ActDiskNewPoints = | ||
| 0; /*!< \brief Total number of new grid points to add due to actuator disk splitting. */ | ||
|
|
||
| su2double Xloc = 0.0; /*!< \brief X-coordinate of the CG of the actuator disk surface. */ | ||
| su2double Yloc = 0.0; /*!< \brief X-coordinate of the CG of the actuator disk surface. */ | ||
| su2double Zloc = 0.0; /*!< \brief X-coordinate of the CG of the actuator disk surface. */ | ||
|
|
||
| vector<bool> ActDisk_Bool; /*!< \brief Flag to identify the grid points on the actuator disk. */ | ||
|
|
||
| vector<unsigned long> ActDiskPoint_Back; /*!< \brief Vector containing the global index for the new grid points added | ||
| to the back of the actuator disk. */ | ||
| vector<unsigned long> VolumePoint_Inv; /*!< \brief Vector containing the inverse mapping from the global index to the | ||
| added point index for the actuator disk. */ | ||
|
|
||
| vector<su2double> CoordXActDisk; /*!< \brief X-coordinates of the new grid points added by splitting the actuator disk | ||
| (size = ActDiskNewPoints). */ | ||
| vector<su2double> CoordYActDisk; /*!< \brief Y-coordinates of the new grid points added by splitting the actuator disk | ||
| (size = ActDiskNewPoints). */ | ||
| vector<su2double> CoordZActDisk; /*!< \brief Z-coordinates of the new grid points added by splitting the actuator disk | ||
| (size = ActDiskNewPoints). */ | ||
|
|
||
| vector<su2double> CoordXVolumePoint; /*!< \brief X-coordinates of the volume elements touching the actuator disk. */ | ||
| vector<su2double> CoordYVolumePoint; /*!< \brief Y-coordinates of the volume elements touching the actuator disk. */ | ||
| vector<su2double> CoordZVolumePoint; /*!< \brief Z-coordinates of the volume elements touching the actuator disk. */ | ||
|
|
||
| public: | ||
| /*! | ||
| * \brief Constructor of the CSU2MeshReaderBase class. | ||
| */ | ||
| CSU2MeshReaderBase(CConfig* val_config, unsigned short val_iZone, unsigned short val_nZone); | ||
|
|
||
| /*! | ||
| * \brief Destructor of the CSU2MeshReaderBase class. | ||
| */ | ||
| ~CSU2MeshReaderBase(void) override; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason behind the small-ish limit? Can it be relaxed? I remember some of the CRM meshes having quite long names padded with spaces.