Documentation 6b54b78464
Loading...
Searching...
No Matches
CMixingPlane.hpp
Go to the documentation of this file.
1/*!
2 * \file CMixingPlane.hpp
3 * \brief Header of mixing plane interpolation methods.
4 * \author J. Kelly
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#include "CInterpolator.hpp"
30#include "../option_structure.hpp"
31
32/*!
33 * \brief Mixing plane interpolation.
34 * \note This contains several interpolation methods used in the mixing plane interpolation
35 * and enables the mixing state class structure for proper recording in AD mode
36 * \ingroup Interfaces
37 */
38class CMixingPlane final : public CInterpolator {
39 public:
40 CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone);
41
42 void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
43
44 inline CSpanDonorInfo MapMatchingSpan(unsigned short iSpanTarget) { return {iSpanTarget, 0.0}; }
45
46 inline CSpanDonorInfo MapNearestSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor,
47 unsigned long nSpanDonor) {
48 unsigned short tSpan = 0; // Nearest donor span index
49 auto minDist = std::numeric_limits<su2double>::max();
50
51 for (auto iSpanDonor = 0u; iSpanDonor < nSpanDonor - 1; iSpanDonor++) {
52 const auto dist = abs(iSpanTargetValue - spanValuesDonor[iSpanDonor]);
53 if (dist < minDist) {
54 minDist = dist;
55 tSpan = iSpanDonor;
56 }
57 }
58 return {tSpan, 0.0};
59 };
60
61 inline CSpanDonorInfo MapLinearInterpolationSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor,
62 unsigned long nSpanDonor, int rank) {
63 unsigned short kSpan = 0; // Lower bound donor span for interpolation
64 auto minDist = std::numeric_limits<su2double>::max();
65 su2double coeff = 0.0; // Interpolation coefficient
66
67 if (iSpanTargetValue <= spanValuesDonor[0]) {
69 return {0, 0.0};
70 }
71
72 if (iSpanTargetValue >= spanValuesDonor[nSpanDonor - 1]) {
74 return {nSpanDonor - 1, 0.0};
75 }
76
77 for (auto iSpanDonor = 0u; iSpanDonor < nSpanDonor - 1; iSpanDonor++) {
78 const auto dist = abs(iSpanTargetValue - spanValuesDonor[iSpanDonor]);
79 if (dist < minDist && iSpanTargetValue >= spanValuesDonor[iSpanDonor]) {
80 kSpan = iSpanDonor;
81 minDist = dist;
82 }
83 }
84 coeff = (iSpanTargetValue - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]);
85 return {kSpan, coeff};
86 };
87
88 inline void PrintClampingWarning(int rank, bool atHub) {
89 if (rank != MASTER_NODE) return;
90 cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl;
91 cout << (atHub ? "This is an issue at the hub." : "This is an issue at the shroud.") << endl;
92 cout << "Setting coeff = 0.0 and transferring endwall value!" << endl;
93 };
94
95 /*!
96 * \brief Write interpolation details to file.
97 * \param[in] filename - Name of output file.
98 * \param[in] config - Configuration for all zones.
99 */
100 void WriteInterpolationDetails(const string& filename, const CConfig* const* config) override;
101};
Base class for multiphysics interpolation.
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
const int rank
MPI Rank.
Definition CInterpolator.hpp:49
Mixing plane interpolation.
Definition CMixingPlane.hpp:38
void WriteInterpolationDetails(const string &filename, const CConfig *const *config) override
Write interpolation details to file.
Definition CMixingPlane.cpp:154
void PrintClampingWarning(int rank, bool atHub)
Definition CMixingPlane.hpp:88
CSpanDonorInfo MapMatchingSpan(unsigned short iSpanTarget)
Definition CMixingPlane.hpp:44
void SetTransferCoeff(CGeometry ****geometry, const CConfig *const *config) override
Set up transfer matrix defining relation between two meshes.
Definition CMixingPlane.cpp:39
CSpanDonorInfo MapLinearInterpolationSpan(const su2double iSpanTargetValue, const su2double *spanValuesDonor, unsigned long nSpanDonor, int rank)
Definition CMixingPlane.hpp:61
CSpanDonorInfo MapNearestSpan(const su2double iSpanTargetValue, const su2double *spanValuesDonor, unsigned long nSpanDonor)
Definition CMixingPlane.hpp:46
passivedouble su2double
Definition code_config.hpp:181
FORCEINLINE ARRAY_T abs(const ARRAY_T &x)
Definition special_vectorization.hpp:117
const int MASTER_NODE
Master node for MPI parallelization.
Definition option_structure.hpp:112
Donor information per marker per vertex of the target.
Definition CInterpolator.hpp:104