Documentation 6b54b78464
Loading...
Searching...
No Matches
CInterpolator.hpp
Go to the documentation of this file.
1/*!
2 * \file CInterpolator.hpp
3 * \brief Base class for multiphysics interpolation.
4 * \author H. Kline
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#pragma once
28
29#include "../../include/basic_types/datatype_structure.hpp"
30#include "../../include/containers/C2DContainer.hpp"
31#include "../../include/containers/container_decorators.hpp"
32#include <vector>
33#include <algorithm>
34
35class CConfig;
36class CGeometry;
37
38using namespace std;
39
40/*!
41 * \class CInterpolator
42 * \ingroup Interfaces
43 * \brief Main class for defining the interpolator, it requires
44 * a child class for each particular interpolation method.
45 * \author H. Kline
46 */
48 protected:
49 const int rank; /*!< \brief MPI Rank. */
50 const int size; /*!< \brief MPI Size. */
51 const unsigned donorZone; /*!< \brief Index of donor zone. */
52 const unsigned targetZone; /*!< \brief Index of target zone. */
53
54 unsigned long MaxLocalVertex_Donor, /*!< \brief Maximum vertices per processor. */
55 Buffer_Send_nVertex_Donor[1], /*!< \brief Buffer to send number of vertices on the local processor. */
56 *Buffer_Receive_nVertex_Donor; /*!< \brief Buffer to store the number of vertices per processor on the Donor
57 domain. */
58
59 su2vector<unsigned long> Buffer_Send_GlobalPoint; /*!< \brief Buffer to send global point indices. */
60 su2vector<unsigned long> Buffer_Receive_GlobalPoint; /*!< \brief Buffer to receive global point indices. */
61
62 su2activematrix Buffer_Send_Coord; /*!< \brief Buffer to send coordinate values. */
63 su2activematrix Buffer_Receive_Coord; /*!< \brief Buffer to receive coordinate values. */
64
65 /*! \brief Buffer to receive the number of surface-connected edges, for each vertex. */
67 /*! \brief Buffer to receive the index of the Receive_LinkedNodes buffer where corresponding list of linked nodes
68 * begins. */
70 /*! \brief Buffer to receive the list of surface-connected nodes, for each vertex.
71 * \details The vertices are ordered as in Buffer_Receive_nLinkedNodes and Buffer_Receive_StartLinkedNodes, but for
72 * each*/
74 /*! \brief Buffer to receive the rank that owns the vertex. */
76
77 unsigned long nGlobalVertex_Target, /*!< \brief Global number of vertex of the target boundary. */
78 nLocalVertex_Target, /*!< \brief Number of vertex of the target boundary owned by the thread. */
79 nGlobalVertex_Donor, /*!< \brief Global number of vertex of the donor boundary. */
80 nLocalVertex_Donor, /*!< \brief Number of vertex of the donor boundary owned by the thread. */
81 nGlobalVertex, /*!< \brief Dummy variable to temporarily store the global number of vertex of a boundary. */
82 nLocalLinkedNodes; /*!< \brief Dummy variable to temporarily store the number of vertex of a boundary. */
83
84 CGeometry**** const Geometry; /*! \brief Vector which stores n zones of geometry. */
85 CGeometry* const donor_geometry; /*! \brief Donor geometry. */
86 CGeometry* const target_geometry; /*! \brief Target geometry. */
87
88 public:
89 struct CDonorInfo {
90 vector<int> processor;
91 vector<unsigned long> globalPoint;
92 vector<su2double> coefficient;
93
94 unsigned long nDonor() const { return processor.size(); }
95
96 void resize(size_t nDonor) {
97 processor.resize(nDonor);
98 globalPoint.resize(nDonor);
99 coefficient.resize(nDonor);
100 }
101 };
102 vector<vector<CDonorInfo>> targetVertices; /*! \brief Donor information per marker per vertex of the target. */
103
105 size_t donorSpan; // Refers to donor span
106 su2double coefficient; // Refers to coefficient
107 };
108 vector<vector<CSpanDonorInfo>> targetSpans; // <iMarkerInt<TargetSpan<CSpanDonorInfo>>
109
110 /*!
111 * \brief Constructor of the class.
112 * \param[in] geometry_container - Geometrical definition of the problem.
113 * \param[in] config - Definition of the particular problem.
114 * \param[in] iZone - index of the donor zone.
115 * \param[in] jZone - index of the target zone.
116 */
117 CInterpolator(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone);
118
119 /*!
120 * \brief No default construction allowed to force zones and geometry to always be set.
121 */
122 CInterpolator(void) = delete;
123
124 /*!
125 * \brief Destructor of the class, nothing is deleted, derived classes need to manage the MPI buffers.
126 */
127 virtual ~CInterpolator(void) = default;
128
129 /*!
130 * \brief Set up transfer matrix defining relation between two meshes
131 * \note Main method that derived classes must implement.
132 * \param[in] config - Definition of the particular problem.
133 */
134 virtual void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) = 0;
135
136 /*!
137 * \brief Print information about the interpolation.
138 */
139 virtual void PrintStatistics(void) const {}
140
141 /*!
142 * \brief Write mixing plane interpolation details to file
143 */
144 inline virtual void WriteInterpolationDetails(const string& filename, const CConfig* const* config){};
145
146 /*!
147 * \brief Check whether an interface should be processed or not, i.e. if it is part of the zones.
148 * \param[in] val_markDonor - Marker tag from donor zone.
149 * \param[in] val_markTarget - Marker tag from target zone.
150 */
151 static bool CheckInterfaceBoundary(int val_markDonor, int val_markTarget);
152
153 /*!
154 * \brief Check whether two zones have a common interface.
155 * \param[in] donor - Configuration of the donor zone.
156 * \param[in] target - Configuration of the target zone.
157 */
158 static bool CheckZonesInterface(const CConfig* donor, const CConfig* target);
159
160 protected:
161 /*!
162 * \brief Reconstruct the boundary connectivity from parallel partitioning and broadcasts it to all threads.
163 * \param[in] val_zone - index of the zone
164 * \param[in] val_marker - index of the marker
165 */
166 void ReconstructBoundary(unsigned long val_zone, int val_marker);
167
168 /*!
169 * \brief Determine array sizes used to collect and send coordinate and global point information.
170 * \param[in] markDonor - Index of the boundary on the donor domain.
171 * \param[in] markTarget - Index of the boundary on the target domain.
172 * \param[in] nVertexDonor - Number of vertices on the donor boundary.
173 * \param[in] nDim - number of physical dimensions.
174 */
175 void Determine_ArraySize(int markDonor, int markTarget, unsigned long nVertexDonor, unsigned short nDim);
176
177 /*!
178 * \brief Collect and communicate vertex info: coord, global point.
179 * \param[in] markDonor - Index of the boundary on the donor domain.
180 * \param[in] markTarget - Index of the boundary on the target domain.
181 * \param[in] nVertexDonor - Number of vertices on the donor boundary.
182 * \param[in] nDim - number of physical dimensions.
183 */
184 void Collect_VertexInfo(int markDonor, int markTarget, unsigned long nVertexDonor, unsigned short nDim);
185
186 /*!
187 * \brief Collect all donor elements in an interface pair.
188 * \param[in] markDonor - Index of the boundary on the donor domain.
189 * \param[in] nDim - number of physical dimensions.
190 * \param[in] compress - Squeeze the information (Allgatherv instead of Allgather).
191 * \param[out] allNumElem - Number of donor element per rank.
192 * \param[out] numNodes - Number of nodes for each element.
193 * \param[out] idxNodes - Index (global) of those nodes.
194 * \return Number of collected donor elements.
195 * \note The last two outputs are always sized for Allgather.
196 */
197 unsigned long Collect_ElementInfo(int markDonor, unsigned short nDim, bool compress,
198 vector<unsigned long>& allNumElem, vector<unsigned short>& numNodes,
199 su2matrix<long>& idxNodes) const;
200};
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
Main class for defining the interpolator, it requires a child class for each particular interpolation...
Definition CInterpolator.hpp:47
CGeometry ****const Geometry
Definition CInterpolator.hpp:84
const unsigned donorZone
Index of donor zone.
Definition CInterpolator.hpp:51
unsigned long nLocalVertex_Target
Number of vertex of the target boundary owned by the thread.
Definition CInterpolator.hpp:78
void ReconstructBoundary(unsigned long val_zone, int val_marker)
Reconstruct the boundary connectivity from parallel partitioning and broadcasts it to all threads.
Definition CInterpolator.cpp:155
su2vector< unsigned long > Buffer_Send_GlobalPoint
Buffer to send global point indices.
Definition CInterpolator.hpp:59
const int size
MPI Size.
Definition CInterpolator.hpp:50
virtual ~CInterpolator(void)=default
Destructor of the class, nothing is deleted, derived classes need to manage the MPI buffers.
unsigned long nLocalLinkedNodes
Dummy variable to temporarily store the number of vertex of a boundary.
Definition CInterpolator.hpp:82
unsigned long Collect_ElementInfo(int markDonor, unsigned short nDim, bool compress, vector< unsigned long > &allNumElem, vector< unsigned short > &numNodes, su2matrix< long > &idxNodes) const
Collect all donor elements in an interface pair.
Definition CInterpolator.cpp:102
unsigned long nGlobalVertex
Dummy variable to temporarily store the global number of vertex of a boundary.
Definition CInterpolator.hpp:81
su2vector< unsigned long > Buffer_Receive_StartLinkedNodes
Buffer to receive the index of the Receive_LinkedNodes buffer where corresponding list of linked node...
Definition CInterpolator.hpp:69
unsigned long MaxLocalVertex_Donor
Maximum vertices per processor.
Definition CInterpolator.hpp:54
const int rank
MPI Rank.
Definition CInterpolator.hpp:49
unsigned long Buffer_Send_nVertex_Donor[1]
Buffer to send number of vertices on the local processor.
Definition CInterpolator.hpp:55
CInterpolator(void)=delete
No default construction allowed to force zones and geometry to always be set.
su2vector< unsigned long > Buffer_Receive_Proc
Buffer to receive the rank that owns the vertex.
Definition CInterpolator.hpp:75
unsigned long nGlobalVertex_Target
Global number of vertex of the target boundary.
Definition CInterpolator.hpp:77
CGeometry *const target_geometry
Donor geometry.
Definition CInterpolator.hpp:86
su2activematrix Buffer_Receive_Coord
Buffer to receive coordinate values.
Definition CInterpolator.hpp:63
CGeometry *const donor_geometry
Vector which stores n zones of geometry.
Definition CInterpolator.hpp:85
virtual void WriteInterpolationDetails(const string &filename, const CConfig *const *config)
Write mixing plane interpolation details to file.
Definition CInterpolator.hpp:144
static bool CheckInterfaceBoundary(int val_markDonor, int val_markTarget)
Check whether an interface should be processed or not, i.e. if it is part of the zones.
Definition CInterpolator.cpp:45
virtual void SetTransferCoeff(CGeometry ****geometry, const CConfig *const *config)=0
Set up transfer matrix defining relation between two meshes.
void Collect_VertexInfo(int markDonor, int markTarget, unsigned long nVertexDonor, unsigned short nDim)
Collect and communicate vertex info: coord, global point.
Definition CInterpolator.cpp:79
unsigned long nGlobalVertex_Donor
Global number of vertex of the donor boundary.
Definition CInterpolator.hpp:79
su2vector< unsigned long > Buffer_Receive_LinkedNodes
Buffer to receive the list of surface-connected nodes, for each vertex.
Definition CInterpolator.hpp:73
static bool CheckZonesInterface(const CConfig *donor, const CConfig *target)
Check whether two zones have a common interface.
Definition CInterpolator.cpp:54
virtual void PrintStatistics(void) const
Print information about the interpolation.
Definition CInterpolator.hpp:139
void Determine_ArraySize(int markDonor, int markTarget, unsigned long nVertexDonor, unsigned short nDim)
Determine array sizes used to collect and send coordinate and global point information.
Definition CInterpolator.cpp:62
vector< vector< CSpanDonorInfo > > targetSpans
Definition CInterpolator.hpp:108
const unsigned targetZone
Index of target zone.
Definition CInterpolator.hpp:52
unsigned long nLocalVertex_Donor
Number of vertex of the donor boundary owned by the thread.
Definition CInterpolator.hpp:80
vector< vector< CDonorInfo > > targetVertices
Definition CInterpolator.hpp:102
su2activematrix Buffer_Send_Coord
Buffer to send coordinate values.
Definition CInterpolator.hpp:62
su2vector< unsigned long > Buffer_Receive_GlobalPoint
Buffer to receive global point indices.
Definition CInterpolator.hpp:60
su2vector< unsigned long > Buffer_Receive_nLinkedNodes
Buffer to receive the number of surface-connected edges, for each vertex.
Definition CInterpolator.hpp:66
unsigned long * Buffer_Receive_nVertex_Donor
Buffer to store the number of vertices per processor on the Donor domain.
Definition CInterpolator.hpp:56
passivedouble su2double
Definition code_config.hpp:181
Target geometry.
Definition CInterpolator.hpp:89
vector< unsigned long > globalPoint
Definition CInterpolator.hpp:91
vector< int > processor
Definition CInterpolator.hpp:90
void resize(size_t nDonor)
Definition CInterpolator.hpp:96
vector< su2double > coefficient
Definition CInterpolator.hpp:92
unsigned long nDonor() const
Definition CInterpolator.hpp:94
Donor information per marker per vertex of the target.
Definition CInterpolator.hpp:104
size_t donorSpan
Definition CInterpolator.hpp:105
su2double coefficient
Definition CInterpolator.hpp:106