Documentation 6b54b78464
Loading...
Searching...
No Matches
CTecplotBinaryFileWriter.hpp
Go to the documentation of this file.
1/*!
2 * \file CTecplotBinaryFileWriter.hpp
3 * \brief Headers fo the tecplot binary writer class.
4 * \author 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 <assert.h>
31#include <cstdint>
32
33#include "CFileWriter.hpp"
34
35
37
38 unsigned long timeIter; //!< Current value of the time iteration
39 su2double timeStep; //!< Current value of the time step
40
41public:
42
43 /*!
44 * \brief File extension
45 */
46 const static string fileExt;
47
48 /*!
49 * \brief Construct a file writer using field names and the data sorter.
50 * \param[in] valDataSorter - The parallel sorted data to write
51 * \param[in] valTimeIter - The current time iteration
52 * \param[in] valTimeStep - The current physical time step value
53 */
55 unsigned long valTimeIter, su2double valTimeStep);
56
57 /*!
58 * \brief Destructor
59 */
61
62 /*!
63 * \brief Write sorted data to file in tecplot binary file format
64 * \param[in] val_filename - The name of the file
65 */
66 void WriteData(string val_filename) override ;
67
68 /*!
69 * \brief Calculate the partitioning of nodes to determine:
70 * (a) For a given global node number, to which partition does it belong and what is its local node number; and
71 * (b) How many nodes are held by each partition.
72 */
74 public:
75 /*!
76 * \param[in] global_num_nodes - The total number of nodes being output
77 * \param[in] num_ranks - The number of MPI ranks involved in the output
78 */
79 NodePartitioner(unsigned long global_num_nodes, int num_ranks)
80 : m_num_ranks(num_ranks) {
81 /* rank i has (1-based) global nodes m_node_range[i] + 1 through m_node_range[i + 1] */
82 unsigned long nodes_per_rank = global_num_nodes / num_ranks;
83 unsigned long num_extra_nodes = global_num_nodes - nodes_per_rank * num_ranks;
84 m_node_range.resize(num_ranks + 1);
85 m_node_range[0] = 0;
86 for (int ii = 1; ii <= num_ranks; ii++) {
87 m_node_range[ii] = m_node_range[ii - 1] + nodes_per_rank;
88 if (num_extra_nodes > 0) {
89 ++m_node_range[ii];
90 --num_extra_nodes;
91 }
92 }
93 assert(m_node_range[num_ranks] == global_num_nodes);
94 }
95
96 /*!
97 * \brief Determine the MPI rank that owns a global node number and its corresponding local node number.
98 * \param global_node_number[in] - The global node number; global node numbers are sequential across all MPI ranks.
99 * \param owning_rank[out] - The MPI rank that owns (will output) the global node
100 * \param node_number[out] - The rank-local node number for the given global node number
101 */
102 void GetOwningRankAndNodeNumber(unsigned long global_node_number, int &owning_rank, unsigned long &node_number)
103 {
104 owning_rank = static_cast<int>(global_node_number / m_node_range[1]);
105 if (owning_rank >= m_num_ranks)
106 owning_rank = m_num_ranks - 1;
107 while(global_node_number > m_node_range[owning_rank + 1])
108 ++owning_rank;
109 while(global_node_number <= m_node_range[owning_rank])
110 --owning_rank;
111 node_number = global_node_number - m_node_range[owning_rank];
112 }
113
114 /*!
115 * \brief Determine the number of nodes to be output by a particular rank
116 * \param which_rank[in] - The MPI rank
117 * \ret - The number of nodes that will be output by the give MPI rank.
118 */
119 int64_t GetRankNumNodes(int which_rank)
120 {
121 return static_cast<int64_t>(m_node_range[which_rank + 1] - m_node_range[which_rank]);
122 }
123
124 private:
125 int m_num_ranks;
126 vector<unsigned long> m_node_range;
127 };
128
129 int64_t GetHaloNodeNumber(unsigned long global_node_number, unsigned long last_local_node, vector<unsigned long> const &halo_node_list);
130
131};
132
Headers fo the file writer class.
Definition CFileWriter.hpp:42
Definition CParallelDataSorter.hpp:39
Calculate the partitioning of nodes to determine: (a) For a given global node number,...
Definition CTecplotBinaryFileWriter.hpp:73
NodePartitioner(unsigned long global_num_nodes, int num_ranks)
Definition CTecplotBinaryFileWriter.hpp:79
void GetOwningRankAndNodeNumber(unsigned long global_node_number, int &owning_rank, unsigned long &node_number)
Determine the MPI rank that owns a global node number and its corresponding local node number.
Definition CTecplotBinaryFileWriter.hpp:102
int64_t GetRankNumNodes(int which_rank)
Determine the number of nodes to be output by a particular rank.
Definition CTecplotBinaryFileWriter.hpp:119
Definition CTecplotBinaryFileWriter.hpp:36
static const string fileExt
File extension.
Definition CTecplotBinaryFileWriter.hpp:46
int64_t GetHaloNodeNumber(unsigned long global_node_number, unsigned long last_local_node, vector< unsigned long > const &halo_node_list)
Definition CTecplotBinaryFileWriter.cpp:609
~CTecplotBinaryFileWriter() override
Destructor.
void WriteData(string val_filename) override
Write sorted data to file in tecplot binary file format.
Definition CTecplotBinaryFileWriter.cpp:48
passivedouble su2double
Definition code_config.hpp:181