Skip to content

Commit fd20657

Browse files
committed
Assorted MPI Fixes and updates of interpolation classes to account for MP.
1 parent 0d1ac6d commit fd20657

File tree

15 files changed

+86
-62
lines changed

15 files changed

+86
-62
lines changed

Common/include/interface_interpolation/CInterpolator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class CInterpolator {
131131
* \note Main method that derived classes must implement.
132132
* \param[in] config - Definition of the particular problem.
133133
*/
134-
virtual void SetTransferCoeff(const CConfig* const* config) = 0;
134+
virtual void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) = 0;
135135

136136
/*!
137137
* \brief Print information about the interpolation.

Common/include/interface_interpolation/CIsoparametric.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CIsoparametric final : public CInterpolator {
6464
* \brief Set up transfer matrix defining relation between two meshes
6565
* \param[in] config - Definition of the particular problem.
6666
*/
67-
void SetTransferCoeff(const CConfig* const* config) override;
67+
void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
6868

6969
/*!
7070
* \brief Print information about the interpolation.

Common/include/interface_interpolation/CMirror.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ class CMirror final : public CInterpolator {
5454
* \brief Set up transfer matrix defining relation between two meshes
5555
* \param[in] config - Definition of the particular problem.
5656
*/
57-
void SetTransferCoeff(const CConfig* const* config) override;
57+
void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
5858
};

Common/include/interface_interpolation/CMixingPlane.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CMixingPlane final : public CInterpolator {
3939
CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone,
4040
unsigned int jZone);
4141

42-
void SetTransferCoeff(const CConfig* const* config) override;
42+
void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
4343

4444
/*!
4545
* \brief Write interpolation details to file.

Common/include/interface_interpolation/CNearestNeighbor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CNearestNeighbor final : public CInterpolator {
6363
* \brief Set up transfer matrix defining relation between two meshes.
6464
* \param[in] config - Definition of the particular problem.
6565
*/
66-
void SetTransferCoeff(const CConfig* const* config) override;
66+
void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
6767

6868
/*!
6969
* \brief Print interpolation statistics.

Common/include/interface_interpolation/CRadialBasisFunction.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CRadialBasisFunction final : public CInterpolator {
5656
* \brief Set up transfer matrix defining relation between two meshes
5757
* \param[in] config - Definition of the particular problem.
5858
*/
59-
void SetTransferCoeff(const CConfig* const* config) override;
59+
void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
6060

6161
/*!
6262
* \brief Print information about the interpolation.

Common/include/interface_interpolation/CSlidingMesh.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CSlidingMesh final : public CInterpolator {
4949
* \brief Set up transfer matrix defining relation between two meshes
5050
* \param[in] config - Definition of the particular problem.
5151
*/
52-
void SetTransferCoeff(const CConfig* const* config) override;
52+
void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override;
5353

5454
private:
5555
/*!

Common/src/interface_interpolation/CIsoparametric.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using namespace GeometryToolbox;
3737
CIsoparametric::CIsoparametric(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone,
3838
unsigned int jZone)
3939
: CInterpolator(geometry_container, config, iZone, jZone) {
40-
SetTransferCoeff(config);
40+
SetTransferCoeff(geometry_container, config);
4141
}
4242

4343
void CIsoparametric::PrintStatistics() const {
@@ -46,7 +46,7 @@ void CIsoparametric::PrintStatistics() const {
4646
<< " Interpolation clipped for " << ErrorCounter << " (" << ErrorRate << "%) target vertices." << endl;
4747
}
4848

49-
void CIsoparametric::SetTransferCoeff(const CConfig* const* config) {
49+
void CIsoparametric::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) {
5050
const su2double matchingVertexTol = 1e-12; // 1um^2
5151

5252
const int nProcessor = size;

Common/src/interface_interpolation/CMirror.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ CMirror::CMirror(CGeometry**** geometry_container, const CConfig* const* config,
4040
to_string(iZone) + string(" and ") + to_string(jZone) + string("."),
4141
CURRENT_FUNCTION);
4242
}
43-
SetTransferCoeff(config);
43+
SetTransferCoeff(geometry_container, config);
4444
}
4545

46-
void CMirror::SetTransferCoeff(const CConfig* const* config) {
46+
void CMirror::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) {
4747
const int nProcessor = size;
4848

4949
vector<unsigned long> allNumVertexTarget(nProcessor);

Common/src/interface_interpolation/CMixingPlane.cpp

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@
3333
CMixingPlane::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

Comments
 (0)