Documentation 6b54b78464
Loading...
Searching...
No Matches
CInterface.hpp
Go to the documentation of this file.
1/*!
2 * \file CInterface.hpp
3 * \brief Declarations and inlines of the transfer structure.
4 * The subroutines and functions are in the physics folders.
5 * \author R. Sanchez
6 * \version 8.5.0 "Harrier"
7 *
8 * SU2 Project Website: https://su2code.github.io
9 *
10 * The SU2 Project is maintained by the SU2 Foundation
11 * (http://su2foundation.org)
12 *
13 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
14 *
15 * SU2 is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
19 *
20 * SU2 is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
27 */
28
29#pragma once
30
31#include "../../../Common/include/parallelization/mpi_structure.hpp"
32#include "../../../Common/include/containers/C2DContainer.hpp"
33#include "../../../Common/include/option_structure.hpp"
34
35#include <cmath>
36#include <string>
37#include <fstream>
38#include <sstream>
39#include <algorithm>
40#include <iostream>
41#include <vector>
42#include <stdlib.h>
43#include <stdio.h>
44
45class CConfig;
46class CGeometry;
47class CSolver;
48class CInterpolator;
49
50using namespace std;
51
52/*!
53 * \class CInterface
54 * \ingroup Interfaces
55 * \brief Main class for defining the physical transfer of information.
56 * \author R. Sanchez
57 * \version 8.5.0 "Harrier"
58 */
59
61protected:
62
63 const int rank; /*!< \brief MPI Rank. */
64 const int size; /*!< \brief MPI Size. */
65
69 bool valAggregated = false;
70
71 unsigned short InterfaceType; /*!< \brief The type of interface. */
72
73 /*--- Mixing Plane interface variable ---*/
75 unsigned short *SpanLevelDonor = nullptr;
76 unsigned short nSpanMaxAllZones = 0;
77
78 unsigned short nVar = 0;
79 static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */
80
81public:
82 /*!
83 * \brief Constructor of the class.
84 */
85 CInterface();
86
87 /*!
88 * \overload
89 * \param[in] val_nVar - Number of variables that need to be transferred.
90 * \param[in] val_nConst - Number of physical constants that need to be taken into account.
91 */
92 CInterface(unsigned short val_nVar, unsigned short val_nConst);
93
94 /*!
95 * \brief Destructor of the class.
96 */
97 virtual ~CInterface();
98
99 /*!
100 * \brief Interpolate data and broadcast it into all processors, for nonmatching meshes.
101 * \param[in] interpolator - Object defining the interpolation.
102 * \param[in] donor_solution - Solution from the donor mesh.
103 * \param[in] target_solution - Solution from the target mesh.
104 * \param[in] donor_geometry - Geometry of the donor mesh.
105 * \param[in] target_geometry - Geometry of the target mesh.
106 * \param[in] donor_config - Definition of the problem at the donor mesh.
107 * \param[in] target_config - Definition of the problem at the target mesh.
108 */
109 void BroadcastData(const CInterpolator& interpolator,
110 CSolver *donor_solution, CSolver *target_solution,
111 CGeometry *donor_geometry, CGeometry *target_geometry,
112 const CConfig *donor_config, const CConfig *target_config);
113
114protected:
115 /*!
116 * \brief A virtual member.
117 */
118 inline virtual void GetPhysical_Constants(CSolver *donor_solution, CSolver *target_solution,
119 CGeometry *donor_geometry, CGeometry *target_geometry,
120 const CConfig *donor_config, const CConfig *target_config) { }
121 /*!
122 * \brief A virtual member.
123 * \param[in] donor_solution - Solution from the donor mesh.
124 * \param[in] donor_geometry - Geometry of the donor mesh.
125 * \param[in] donor_config - Definition of the problem at the donor mesh.
126 * \param[in] Marker_Donor - Index of the donor marker.
127 * \param[in] Vertex_Donor - Index of the donor vertex.
128 */
129 virtual void GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry,
130 const CConfig *donor_config, unsigned long Marker_Donor,
131 unsigned long Vertex_Donor, unsigned long Point_Donor) = 0;
132
133 /*!
134 * \brief A virtual member.
135 * \param[in] donor_config - Definition of the problem at the donor mesh.
136 * \param[in] donor_geometry - Geometry of the donor mesh.
137 * \param[in] target_config - Definition of the problem at the target mesh.
138 * \param[in] target_geometry - Geometry of the target mesh.
139 */
140 inline virtual void GetDonor_Velocity_RotatingFrame(const CConfig *donor_config, CGeometry *donor_geometry,
141 const CConfig *target_config, CGeometry *target_geometry) {}
142
143 /*!
144 * \brief Initializes the target variable.
145 * \param[in] target_solution - Solution from the target mesh.
146 * \param[in] Marker_Target - Index of the target marker.
147 * \param[in] Vertex_Target - Index of the target vertex.
148 * \param[in] nDonorPoints - Number of donor points.
149 */
150 inline virtual void InitializeTarget_Variable(CSolver *target_solution, unsigned long Marker_Target,
151 unsigned long Vertex_Target, unsigned short nDonorPoints){
152 for (unsigned short iVar = 0; iVar < nVar; iVar++) Target_Variable[iVar] = 0.0;
153 }
154
155 /*!
156 * \brief Recovers the target variable from the buffer of su2doubles that was broadcast.
157 * \param[in] bcastVariable - Broadcast variable.
158 * \param[in] donorCoeff - value of the donor coefficient.
159 */
160 inline virtual void RecoverTarget_Variable(const su2double *bcastVariable, su2double donorCoeff) {
161 for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar];
162 }
163
164 /*!
165 * \brief Recovers the target variable at the endwall from the buffer of su2doubles that was broadcast for mixing plane interfaces.
166 * \param[in] bcastVariable - Broadcast variable.
167 * \param[in] idx - Index of the target point.
168 */
169 inline virtual void RecoverTarget_SpanEndwall(const su2activevector &bcastVariable, unsigned long idx) { }
170
171 /*!
172 * \brief Recovers the target variable at the span from the buffer of su2doubles that was broadcast for mixing plane interfaces.
173 * \param[in] bcastVariable - Broadcast variable.
174 * \param[in] idx - Index of the target point.
175 * \param[in] donorCoeff - value of the donor coefficient.
176 */
177 inline virtual void RecoverTarget_Span(const su2activevector &bcastVariable, unsigned long idx, su2double donorCoeff) { }
178
179 /*!
180 * \brief A virtual member.
181 * \param[in] target_solution - Solution from the target mesh.
182 * \param[in] target_geometry - Geometry of the target mesh.
183 * \param[in] target_config - Definition of the problem at the target mesh.
184 * \param[in] Marker_Target - Index of the target marker.
185 * \param[in] Vertex_Target - Index of the target vertex.
186 * \param[in] Point_Target - Index of the target point.
187 */
188 virtual void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry,
189 const CConfig *target_config, unsigned long Marker_Target,
190 unsigned long Vertex_Target, unsigned long Point_Target) = 0;
191
192 /*!
193 * \brief A virtual member.
194 * \param[in] donor_geometry - Geometry of the target mesh.
195 * \param[in] target_geometry - Geometry of the target mesh.
196 * \param[in] donor_zone - Index of the donorZone.
197 */
198 inline virtual void SetAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry,
199 unsigned short donorZone) { }
200
201public:
202 /*!
203 * \brief A virtual member.
204 * \param[in] donor_config - Definition of the problem at the donor mesh.
205 * \param[in] target_config - Definition of the problem at the target mesh.
206 */
207 inline virtual void SetSpanWiseLevels(const CConfig *donor_config, const CConfig *target_config) { }
208
209 /*!
210 * \brief Interpolate data and broadcast it into all processors, for nonmatching meshes.
211 * \param[in] interpolator - Object defining the interpolation.
212 * \param[in] donor_solution - Solution from the donor mesh.
213 * \param[in] target_solution - Solution from the target mesh.
214 * \param[in] donor_geometry - Geometry of the donor mesh.
215 * \param[in] target_geometry - Geometry of the target mesh.
216 * \param[in] donor_config - Definition of the problem at the donor mesh.
217 * \param[in] target_config - Definition of the problem at the target mesh.
218 */
219 inline virtual void BroadcastData_MixingPlane(const CInterpolator& interpolator,
220 CSolver *donor_solution, CSolver *target_solution,
221 CGeometry *donor_geometry, CGeometry *target_geometry,
222 const CConfig *donor_config, const CConfig *target_config) { };
223
224
225 /*!
226 * \brief Set the contact resistance value for the solid-to-solid heat transfer interface.
227 * \param[in] val_contact_resistance - Contact resistance value in m^2/W
228 */
229 inline virtual void SetContactResistance(su2double val_contact_resistance) {};
230
231 /*!
232 * \brief Set the type of an interface
233 * \param[in] interface_type - The type of interface
234 */
235 void SetInterfaceType(unsigned short interface_type) { InterfaceType = interface_type; }
236
237 /*!
238 * \brief Get the type of an interface
239 */
240 unsigned short GetInterfaceType(void) const { return InterfaceType; }
241
242 /*!
243 * \brief These can be used to chain interfaces between the same zones but for other variables,
244 * without having to mix physics in the interface classes. Currently this is used for FSI+CHT.
245 */
248};
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 physical transfer of information.
Definition CInterface.hpp:60
static constexpr size_t MAXNDIM
Max number of space dimensions, used in some static arrays.
Definition CInterface.hpp:79
CInterface * NextInterface
Definition CInterface.hpp:247
unsigned short GetInterfaceType(void) const
Get the type of an interface.
Definition CInterface.hpp:240
CInterface()
Constructor of the class.
Definition CInterface.cpp:34
const int rank
MPI Rank.
Definition CInterface.hpp:63
virtual void SetContactResistance(su2double val_contact_resistance)
Set the contact resistance value for the solid-to-solid heat transfer interface.
Definition CInterface.hpp:229
virtual void InitializeTarget_Variable(CSolver *target_solution, unsigned long Marker_Target, unsigned long Vertex_Target, unsigned short nDonorPoints)
Initializes the target variable.
Definition CInterface.hpp:150
virtual ~CInterface()
Destructor of the class.
Definition CInterface.cpp:52
virtual void RecoverTarget_Span(const su2activevector &bcastVariable, unsigned long idx, su2double donorCoeff)
Recovers the target variable at the span from the buffer of su2doubles that was broadcast for mixing ...
Definition CInterface.hpp:177
unsigned short nVar
Definition CInterface.hpp:78
virtual void GetDonor_Velocity_RotatingFrame(const CConfig *donor_config, CGeometry *donor_geometry, const CConfig *target_config, CGeometry *target_geometry)
A virtual member.
Definition CInterface.hpp:140
su2double * Physical_Constants
Definition CInterface.hpp:66
su2double * Donor_Variable
Definition CInterface.hpp:67
unsigned short InterfaceType
The type of interface.
Definition CInterface.hpp:71
virtual void GetPhysical_Constants(CSolver *donor_solution, CSolver *target_solution, CGeometry *donor_geometry, CGeometry *target_geometry, const CConfig *donor_config, const CConfig *target_config)
A virtual member.
Definition CInterface.hpp:118
virtual void SetAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry, unsigned short donorZone)
A virtual member.
Definition CInterface.hpp:198
unsigned short * SpanLevelDonor
Definition CInterface.hpp:75
ENUM_TRANSFER NextInterfaceType
These can be used to chain interfaces between the same zones but for other variables,...
Definition CInterface.hpp:246
su2double * SpanValueCoeffTarget
Definition CInterface.hpp:74
su2double * Target_Variable
Definition CInterface.hpp:68
virtual void RecoverTarget_SpanEndwall(const su2activevector &bcastVariable, unsigned long idx)
Recovers the target variable at the endwall from the buffer of su2doubles that was broadcast for mixi...
Definition CInterface.hpp:169
virtual void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long Vertex_Target, unsigned long Point_Target)=0
A virtual member.
virtual void GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry, const CConfig *donor_config, unsigned long Marker_Donor, unsigned long Vertex_Donor, unsigned long Point_Donor)=0
A virtual member.
virtual void BroadcastData_MixingPlane(const CInterpolator &interpolator, CSolver *donor_solution, CSolver *target_solution, CGeometry *donor_geometry, CGeometry *target_geometry, const CConfig *donor_config, const CConfig *target_config)
Interpolate data and broadcast it into all processors, for nonmatching meshes.
Definition CInterface.hpp:219
const int size
MPI Size.
Definition CInterface.hpp:64
unsigned short nSpanMaxAllZones
Definition CInterface.hpp:76
void BroadcastData(const CInterpolator &interpolator, CSolver *donor_solution, CSolver *target_solution, CGeometry *donor_geometry, CGeometry *target_geometry, const CConfig *donor_config, const CConfig *target_config)
Interpolate data and broadcast it into all processors, for nonmatching meshes.
Definition CInterface.cpp:64
virtual void RecoverTarget_Variable(const su2double *bcastVariable, su2double donorCoeff)
Recovers the target variable from the buffer of su2doubles that was broadcast.
Definition CInterface.hpp:160
bool valAggregated
Definition CInterface.hpp:69
void SetInterfaceType(unsigned short interface_type)
Set the type of an interface.
Definition CInterface.hpp:235
virtual void SetSpanWiseLevels(const CConfig *donor_config, const CConfig *target_config)
A virtual member.
Definition CInterface.hpp:207
Main class for defining the interpolator, it requires a child class for each particular interpolation...
Definition CInterpolator.hpp:47
Definition CSolver.hpp:71
passivedouble su2double
Definition code_config.hpp:181
ENUM_TRANSFER
types of (coupling) transfers between distinct physical zones
Definition option_structure.hpp:498
@ NO_TRANSFER
Zones may share a boundary, but still no coupling desired.
Definition option_structure.hpp:501