ENH: use findMinMax instead of findMin, findMax separately
This commit is contained in:
parent
e8fa46230a
commit
e5916fd9ba
@ -576,8 +576,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
label minIndex = findMin(triQ);
|
labelPair minMaxIds = findMinMax(triQ);
|
||||||
label maxIndex = findMax(triQ);
|
|
||||||
|
const label minIndex = minMaxIds.first();
|
||||||
|
const label maxIndex = minMaxIds.second();
|
||||||
|
|
||||||
Info<< " min " << triQ[minIndex] << " for triangle " << minIndex
|
Info<< " min " << triQ[minIndex] << " for triangle " << minIndex
|
||||||
<< nl
|
<< nl
|
||||||
@ -656,8 +658,10 @@ int main(int argc, char *argv[])
|
|||||||
edgeMag[edgei] = edges[edgei].mag(localPoints);
|
edgeMag[edgei] = edges[edgei].mag(localPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
label minEdgei = findMin(edgeMag);
|
labelPair minMaxIds = findMinMax(edgeMag);
|
||||||
label maxEdgei = findMax(edgeMag);
|
|
||||||
|
const label minEdgei = minMaxIds.first();
|
||||||
|
const label maxEdgei = minMaxIds.second();
|
||||||
|
|
||||||
const edge& minE = edges[minEdgei];
|
const edge& minE = edges[minEdgei];
|
||||||
const edge& maxE = edges[maxEdgei];
|
const edge& maxE = edges[maxEdgei];
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2017 OpenCFD Ltd.
|
Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -122,45 +122,36 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
|
|||||||
{
|
{
|
||||||
const label proci = Pstream::myProcNo();
|
const label proci = Pstream::myProcNo();
|
||||||
|
|
||||||
// Find min internal field value info
|
// Find min/max internal field value info
|
||||||
List<Type> minVs(Pstream::nProcs());
|
|
||||||
labelList minCells(Pstream::nProcs());
|
|
||||||
List<vector> minCs(Pstream::nProcs());
|
|
||||||
|
|
||||||
label minProci = findMin(field);
|
List<Type> minVs(Pstream::nProcs(), pTraits<Type>::max);
|
||||||
if (minProci != -1)
|
labelList minCells(Pstream::nProcs(), Zero);
|
||||||
|
List<vector> minCs(Pstream::nProcs(), Zero);
|
||||||
|
|
||||||
|
List<Type> maxVs(Pstream::nProcs(), pTraits<Type>::min);
|
||||||
|
labelList maxCells(Pstream::nProcs(), Zero);
|
||||||
|
List<vector> maxCs(Pstream::nProcs(), Zero);
|
||||||
|
|
||||||
|
labelPair minMaxIds = findMinMax(field);
|
||||||
|
|
||||||
|
label minId = minMaxIds.first();
|
||||||
|
if (minId != -1)
|
||||||
{
|
{
|
||||||
minVs[proci] = field[minProci];
|
minVs[proci] = field[minId];
|
||||||
minCells[proci] = minProci;
|
minCells[proci] = minId;
|
||||||
minCs[proci] = mesh_.C()[minProci];
|
minCs[proci] = mesh_.C()[minId];
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
minVs[proci] = pTraits<Type>::max;
|
|
||||||
minCells[proci] = -1;
|
|
||||||
minCs[proci] = vector::max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find max internal field value info
|
label maxId = minMaxIds.second();
|
||||||
List<Type> maxVs(Pstream::nProcs());
|
if (maxId != -1)
|
||||||
labelList maxCells(Pstream::nProcs());
|
|
||||||
List<vector> maxCs(Pstream::nProcs());
|
|
||||||
|
|
||||||
label maxProci = findMax(field);
|
|
||||||
if (maxProci != -1)
|
|
||||||
{
|
{
|
||||||
maxVs[proci] = field[maxProci];
|
maxVs[proci] = field[maxId];
|
||||||
maxCells[proci] = maxProci;
|
maxCells[proci] = maxId;
|
||||||
maxCs[proci] = mesh_.C()[maxProci];
|
maxCs[proci] = mesh_.C()[maxId];
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
maxVs[proci] = pTraits<Type>::min;
|
|
||||||
maxCells[proci] = -1;
|
|
||||||
maxCs[proci] = vector::max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find min and max boundary field info
|
|
||||||
|
// Find min/max boundary field info
|
||||||
const auto& fieldBoundary = field.boundaryField();
|
const auto& fieldBoundary = field.boundaryField();
|
||||||
const auto& CfBoundary = mesh_.C().boundaryField();
|
const auto& CfBoundary = mesh_.C().boundaryField();
|
||||||
|
|
||||||
@ -174,20 +165,22 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
|
|||||||
const labelList& faceCells =
|
const labelList& faceCells =
|
||||||
fieldBoundary[patchi].patch().faceCells();
|
fieldBoundary[patchi].patch().faceCells();
|
||||||
|
|
||||||
label minPi = findMin(fp);
|
minMaxIds = findMinMax(fp);
|
||||||
if (fp[minPi] < minVs[proci])
|
|
||||||
|
minId = minMaxIds.first();
|
||||||
|
if (minVs[proci] > fp[minId])
|
||||||
{
|
{
|
||||||
minVs[proci] = fp[minPi];
|
minVs[proci] = fp[minId];
|
||||||
minCells[proci] = faceCells[minPi];
|
minCells[proci] = faceCells[minId];
|
||||||
minCs[proci] = Cfp[minPi];
|
minCs[proci] = Cfp[minId];
|
||||||
}
|
}
|
||||||
|
|
||||||
label maxPi = findMax(fp);
|
maxId = minMaxIds.second();
|
||||||
if (fp[maxPi] > maxVs[proci])
|
if (maxVs[proci] < fp[maxId])
|
||||||
{
|
{
|
||||||
maxVs[proci] = fp[maxPi];
|
maxVs[proci] = fp[maxId];
|
||||||
maxCells[proci] = faceCells[maxPi];
|
maxCells[proci] = faceCells[maxId];
|
||||||
maxCs[proci] = Cfp[maxPi];
|
maxCs[proci] = Cfp[maxId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,15 +200,15 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
|
|||||||
Pstream::gatherList(maxCs);
|
Pstream::gatherList(maxCs);
|
||||||
Pstream::scatterList(maxCs);
|
Pstream::scatterList(maxCs);
|
||||||
|
|
||||||
label mini = findMin(minVs);
|
minId = findMin(minVs);
|
||||||
const Type& minValue = minVs[mini];
|
const Type& minValue = minVs[minId];
|
||||||
const label minCell = minCells[mini];
|
const label minCell = minCells[minId];
|
||||||
const vector& minC = minCs[mini];
|
const vector& minC = minCs[minId];
|
||||||
|
|
||||||
label maxi = findMax(maxVs);
|
maxId = findMax(maxVs);
|
||||||
const Type& maxValue = maxVs[maxi];
|
const Type& maxValue = maxVs[maxId];
|
||||||
const label maxCell = maxCells[maxi];
|
const label maxCell = maxCells[maxId];
|
||||||
const vector& maxC = maxCs[maxi];
|
const vector& maxC = maxCs[maxId];
|
||||||
|
|
||||||
output
|
output
|
||||||
(
|
(
|
||||||
@ -225,8 +218,8 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
|
|||||||
maxCell,
|
maxCell,
|
||||||
minC,
|
minC,
|
||||||
maxC,
|
maxC,
|
||||||
mini,
|
minId,
|
||||||
maxi,
|
maxId,
|
||||||
minValue,
|
minValue,
|
||||||
maxValue
|
maxValue
|
||||||
);
|
);
|
||||||
|
@ -211,7 +211,7 @@ void Foam::searchableCone::findNearestAndNormal
|
|||||||
dist[2] = magSqr(disk2Point-sample);
|
dist[2] = magSqr(disk2Point-sample);
|
||||||
dist[3] = magSqr(iCnearCone-sample);
|
dist[3] = magSqr(iCnearCone-sample);
|
||||||
|
|
||||||
label minI = findMin(dist);
|
const label minI = findMin(dist);
|
||||||
|
|
||||||
|
|
||||||
// Snap the point to the corresponding surface
|
// Snap the point to the corresponding surface
|
||||||
|
Loading…
Reference in New Issue
Block a user