3333CMixingPlane::CMixingPlane (CGeometry**** geometry_container, const CConfig* const * config, unsigned int iZone,
3434 unsigned int jZone)
3535 : CInterpolator(geometry_container, config, iZone, jZone) {
36- SetTransferCoeff (config);
36+ SetTransferCoeff (geometry_container, config);
3737}
3838
39- void CMixingPlane::SetTransferCoeff (const CConfig* const * config) {
39+ void CMixingPlane::SetTransferCoeff (CGeometry**** geometry, const CConfig* const * config) {
4040 const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface () / 2 ;
4141 const auto nDim = donor_geometry->GetnDim ();
4242
4343 const auto donor_config = config[donorZone];
4444 const auto target_config = config[targetZone];
4545
46+ const auto donor_geometry = geometry[donorZone][INST_0][MESH_0];
47+ const auto target_geometry = geometry[targetZone][INST_0][MESH_0];
48+
4649 // TODO turbo this approach only works if all the turboamchinery marker
4750 // of all zones have the same amount of span wise sections.
4851 // TODO turbo initialization needed for the MPI routine should be place somewhere else.
@@ -52,14 +55,14 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) {
5255 targetSpans.resize (config[donorZone]->GetnMarker_MixingPlaneInterface ());
5356
5457 /* --- On the donor side ---*/
55- for (auto iMarkerInt = 0 ; iMarkerInt < nMarkerInt; iMarkerInt++){
58+ for (auto iMarkerInt = 1 ; iMarkerInt < nMarkerInt + 1 ; iMarkerInt++){
5659 int markDonor = -1 , markTarget = -1 ;
57- unsigned short donorFlag = 0 , targetFlag = 0 ;
60+ short donorFlag = 0 , targetFlag = 0 ;
5861
59- markDonor = donor_config->FindMixingPlaneInterfaceMarker (donor_config-> GetnMarker_All () );
62+ markDonor = donor_config->FindMixingPlaneInterfaceMarker (donor_geometry-> GetnMarker (), iMarkerInt );
6063 donorFlag = (markDonor != -1 ) ? donor_config->GetMarker_All_MixingPlaneInterface (markDonor) : -1 ;
6164
62- markTarget = target_config->FindMixingPlaneInterfaceMarker (target_config-> GetnMarker_All () );
65+ markTarget = target_config->FindMixingPlaneInterfaceMarker (target_geometry-> GetnMarker (), iMarkerInt );
6366 targetFlag = (markTarget != -1 ) ? target_config->GetMarker_All_MixingPlaneInterface (markTarget) : -1 ;
6467
6568#ifdef HAVE_MPI
@@ -85,11 +88,17 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) {
8588 targetFlag= -1 ;
8689
8790 for (int iSize=0 ; iSize<size; iSize++) {
88- if (buffMarkerDonor[iSize] >= 0.0 ) {
91+ if (buffMarkerDonor[iSize] != - 1 ) {
8992 markDonor = buffMarkerDonor[iSize];
9093 donorFlag = buffDonorFlag[iSize];
91- markTarget = buffMarkerDonor[iSize];
92- targetFlag = buffDonorFlag[iSize];
94+ break ;
95+ }
96+ }
97+
98+ for (int iSize=0 ; iSize<size; iSize++) {
99+ if (buffMarkerTarget[iSize] != -1 ) {
100+ markTarget = buffMarkerTarget[iSize];
101+ targetFlag = buffTargetFlag[iSize];
93102 break ;
94103 }
95104 }
@@ -98,7 +107,6 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) {
98107 delete [] buffMarkerTarget;
99108 delete [] buffTargetFlag;
100109#endif
101-
102110 if (markTarget == -1 || markDonor == -1 ) continue ;
103111
104112 nSpanDonor = donor_config->GetnSpanWiseSections ();
@@ -115,9 +123,9 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) {
115123 if (nDim > 2 ) {
116124 targetSpans[iMarkerInt][nSpanTarget-1 ].donorSpan = nSpanDonor-1 ;
117125 targetSpans[iMarkerInt][nSpanTarget-1 ].coefficient = 0.0 ;
118- targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor;
119- targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0 ;
120126 }
127+ targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor;
128+ targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0 ;
121129
122130 for (auto iSpanTarget = 1 ; iSpanTarget < nSpanTarget - 1 ; iSpanTarget++){
123131 auto &targetSpan = targetSpans[iMarkerInt][iSpanTarget];
@@ -147,31 +155,46 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) {
147155 break ;
148156
149157 case LINEAR_INTERPOLATION:
150- // Find the donor span interval that brackets the target span
151- for (auto iSpanDonor = 1 ; iSpanDonor < nSpanDonor - 1 ; iSpanDonor++) {
152- const auto test = abs (spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]);
153- if (test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]){
154- kSpan = iSpanDonor;
155- minDist = test;
158+ {
159+ bool printWarning = false ;
160+ // Check if target span is within donor bound
161+ if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0 ]) {
162+ // Below hub - use hub value
163+ targetSpan.donorSpan = 0 ;
164+ targetSpan.coefficient = 0.0 ;
165+ printWarning = true ;
166+ }
167+ else if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1 ]) {
168+ // Above shroud - use shroud value
169+ targetSpan.donorSpan = nSpanDonor - 1 ;
170+ targetSpan.coefficient = 0.0 ;
171+ printWarning = true ;
172+ }
173+ else {
174+ // Find the donor span interval that brackets the target span
175+ for (auto iSpanDonor = 0 ; iSpanDonor < nSpanDonor - 1 ; iSpanDonor++) {
176+ const auto test = abs (spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]);
177+ if (test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]){
178+ kSpan = iSpanDonor;
179+ minDist = test;
180+ }
156181 }
182+ // Calculate interpolation coefficient
183+ coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan ]) /
184+ (spanValuesDonor[kSpan + 1 ] - spanValuesDonor[kSpan ]);
185+ targetSpan.donorSpan = kSpan ;
186+ targetSpan.coefficient = coeff;
157187 }
158- // Calculate interpolation coefficient
159- coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan ]) /
160- (spanValuesDonor[kSpan + 1 ] - spanValuesDonor[kSpan ]);
161- if ((coeff < 0 ) || (coeff > 1 )) {
188+ if (printWarning) {
162189 if (rank == MASTER_NODE) {
163- cout << " Warning! Target spans exist outside the bounds of donor spans!" << endl;
164- cout << " Target span " << iSpanTarget << " <- " << kSpan << " coeff = " << coeff << endl;
165- if (iSpanTarget < nSpanTarget/2 ) cout << " This is likely an issue at the hub." << endl;
166- if (iSpanTarget > nSpanTarget/2 ) cout << " This is likely an issue at the shroud." << endl;
167- cout << " Setting coeff = 0.0" << endl;
190+ cout << " Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl;
191+ if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0 ]) cout << " This is an issue at the hub." << endl;
192+ if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1 ]) cout << " This is an issue at the shroud." << endl;
193+ cout << " Setting coeff = 0.0 and transferring endwall value!" << endl;
168194 }
169- coeff = 0.0 ;
170195 }
171- targetSpan.donorSpan = kSpan ;
172- targetSpan.coefficient = coeff;
173196 break ;
174-
197+ }
175198 default :
176199 SU2_MPI::Error (" MixingPlane interface option not implemented yet" , CURRENT_FUNCTION);
177200 break ;
0 commit comments