@@ -854,7 +854,7 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry
854854
855855 /* --- Build ADT for probe nearest neighbor search if heuristic suggests it. ---*/
856856 std::unique_ptr<CADTPointsOnlyClass> probeADT;
857- if (useADT ) {
857+ auto BuildADT = [&]( ) {
858858 const unsigned long nPointDomain = geometry->GetnPointDomain ();
859859 vector<su2double> coords (nDim * nPointDomain);
860860 vector<unsigned long > pointIDs (nPointDomain);
@@ -868,7 +868,7 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry
868868
869869 /* --- Build global ADT to find nearest nodes across all ranks. ---*/
870870 probeADT = std::make_unique<CADTPointsOnlyClass>(nDim, nPointDomain, coords.data (), pointIDs.data (), true );
871- }
871+ };
872872
873873 for (auto & output : customOutputs) {
874874 if (output.skip ) continue ;
@@ -907,6 +907,8 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry
907907 int rank;
908908 SU2_MPI::Comm_rank (SU2_MPI::GetComm (), &rank);
909909
910+ if (useADT && !probeADT) BuildADT ();
911+
910912 if (useADT && probeADT && !probeADT->IsEmpty ()) {
911913 /* --- Use ADT to find the nearest node efficiently (O(log n) instead of O(n)). ---*/
912914 probeADT->DetermineNearestNode (coord, minDist, minPoint, rankID);
@@ -1794,11 +1796,11 @@ void CFlowOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver
17941796 SetVolumeOutputValue (" SKIN_FRICTION-Z" , iPoint, solver[FLOW_SOL ]->GetCSkinFriction (iMarker, iVertex, 2 ));
17951797 SetVolumeOutputValue (" HEAT_FLUX" , iPoint, solver[heat_sol]->GetHeatFlux (iMarker, iVertex));
17961798 SetVolumeOutputValue (" Y_PLUS" , iPoint, solver[FLOW_SOL ]->GetYPlus (iMarker, iVertex));
1797-
1799+
17981800 if (config->GetTime_Domain ()) {
17991801 SetAvgVolumeOutputValue (" MEAN_SKIN_FRICTION-X" , iPoint, solver[FLOW_SOL ]->GetCSkinFriction (iMarker, iVertex, 0 ));
18001802 SetAvgVolumeOutputValue (" MEAN_SKIN_FRICTION-Y" , iPoint, solver[FLOW_SOL ]->GetCSkinFriction (iMarker, iVertex, 1 ));
1801- if (nDim == 3 )
1803+ if (nDim == 3 )
18021804 SetAvgVolumeOutputValue (" MEAN_SKIN_FRICTION-Z" , iPoint, solver[FLOW_SOL ]->GetCSkinFriction (iMarker, iVertex, 2 ));
18031805 }
18041806}
0 commit comments