Documentation 6b54b78464
Loading...
Searching...
No Matches
CSTLFileWriter.hpp
Go to the documentation of this file.
1/*!
2 * \file CSTLFileWriter.hpp
3 * \brief Headers fo the STL file writer class.
4 * \author T. Kattmann, T. Albring
5 * \version 8.5.0 "Harrier"
6 *
7 * SU2 Project Website: https://su2code.github.io
8 *
9 * The SU2 Project is maintained by the SU2 Foundation
10 * (http://su2foundation.org)
11 *
12 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
13 *
14 * SU2 is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SU2 is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#pragma once
29
30#include "CFileWriter.hpp"
31
32/*!
33 * \class CSTLFileWriter
34 * \brief Class for writing STL output files.
35 * \author T. Kattmann, T. Albring
36 * \version 8.5.0 "Harrier"
37 */
38class CSTLFileWriter final : public CFileWriter{
39private:
40
41 /*--- Variables for reprocessing element connectivity. ---*/
42
43 vector<unsigned long> halo_nodes; /*!< \brief Set of global renumbered node numbers which the current rank refers to via an element, but does not own. Happens on process borders.
44 Only one process has the 'border' element so that it is not printed twice. */
45 unsigned long num_halo_nodes; /*!< \brief Total number of halo nodes this process should receive, i.e. number it needs to acces but doesn't know the data of. */
46 /*--- Fields for the first MPI::Alltoallv: Afterwards each process knows the global renumbered node ID's it has to send and to which proc to send. ---*/
47 vector<unsigned long> sorted_halo_nodes; /*!< \brief Holds same data as `halo_nodes` but as a vector instead of a set. */
48 vector<int> num_nodes_to_receive; /*!< \brief Number of points to receive from each process. */
49 vector<int> nodes_to_receive_displacements; /*!< \brief Displacements vector for MPI::AlltoAllv command. */
50 vector<unsigned long> nodes_to_send; /*!< \brief Vector of global renumbered node numbers which the current rank owns, and another rank needs for connectivity. */
51 vector<int> num_nodes_to_send; /*!< \brief Number of points to to send to each process. */
52 vector<int> nodes_to_send_displacements; /*!< \brief Displacements vector for MPI::AlltoAllv command. */
53 /*--- Fields for the second MPI::Alltoallv: Afterwards, `halo_var_data` holds the correct coordinate data of halo points of this process. ---*/
54 vector<passivedouble> data_to_send; /*!< \brief Holds the halo-point coordinates for other ranks which are owned by this rank. These are communicated. */
55 vector<int> num_values_to_send; /*!< \brief Number of Coord values to send to each process. */
56 vector<int> values_to_send_displacements; /*!< \brief Displacements vector for MPI::AlltoAllv command. */
57 vector<passivedouble> halo_var_data; /*!< \brief Holds the halo-point coordinates for this rank received from other ranks. */
58 vector<int> num_values_to_receive; /*!< \brief Number of Coord values to receive from each process. */
59 vector<int> values_to_receive_displacements; /*!< \brief Displacements vector for MPI::AlltoAllv command. */
60
61 /*--- Variables for gathering the triangle data in one array. ---*/
62 unsigned long *buffRecvTriaCount = nullptr; /*!< \brief Array with number of triangles which each processor has. (Note: Quads are split into two Tris) */
63 unsigned long max_nLocalTriaAll; /*!< \brief Largest Tri count of all processors. */
64 su2double *buffSendCoords = nullptr; /*!< \brief Array holding Coordinate data of one processor. 3 consecutive doubles make a point and 3 consecutive points make a Tri. */
65 su2double *buffRecvCoords = nullptr; /*!< \brief Array holding Coordinate data of all processors. 3 consecutive doubles make a point and 3 consecutive points make a Tri. */
66
67public:
68
69 const static string fileExt; /*!< \brief File extension ".stl". */
70
71private:
72
73 /*!
74 * \brief Recompute Tri/Quad element connectivity between processor borders.
75 */
76 void ReprocessElementConnectivity();
77
78 /*!
79 * \brief Create an array containing all coordinate data for the surface triangles.
80 */
81 void GatherCoordData();
82
83 /*!
84 * \brief Write element coordinate data into a send-buffer in 'triangle order' (i.e. 3 points with 3 coords consecutively).
85 * \param[in] elemType - Either TRIANGLE or QUADRILATERAL
86 * \param[in] nLocalElements - number of elements of elemType
87 * \param[in] startIndex - index to start writing into buffSendCoords
88 */
89 void StoreCoordData(enum GEO_TYPE elemType,
90 unsigned long nLocalElements,
91 unsigned long startIndex);
92
93 /*!
94 * \brief Get the halo-node value of a global renumbered Point for a specific variable.
95 * \param[in] global_node_number - global renumbered Point ID
96 * \param[in] iVar - Variable number
97 * \return Value of the halo-node variable
98 */
99 passivedouble GetHaloNodeValue(unsigned long global_node_number, unsigned short iVar);
100
101public:
102
103 /*!
104 * \brief Construct a file writer using field name and the data sorter.
105 * \param[in] valDataSorter - The parallel sorted data to write
106 */
107 CSTLFileWriter(CParallelDataSorter* valDataSorter);
108
109 /*!
110 * \brief Destructor
111 */
112 ~CSTLFileWriter() override;
113
114 /*!
115 * \brief Write sorted data to file in STL file format
116 * \param[in] val_filename - The name of the file
117 */
118 void WriteData(string val_filename) override ;
119
120};
121
Headers fo the file writer class.
Definition CFileWriter.hpp:42
Definition CParallelDataSorter.hpp:39
Class for writing STL output files.
Definition CSTLFileWriter.hpp:38
static const string fileExt
File extension ".stl".
Definition CSTLFileWriter.hpp:69
void WriteData(string val_filename) override
Write sorted data to file in STL file format.
Definition CSTLFileWriter.cpp:44
~CSTLFileWriter() override
Destructor.
double passivedouble
Definition code_config.hpp:129
passivedouble su2double
Definition code_config.hpp:181
GEO_TYPE
Types of geometric entities based on VTK nomenclature.
Definition option_structure.hpp:131