fieldMinMax: Added cell index to output

e.g.

fieldMinMax fieldMinMax write:
    min(T) = 291 in cell 255535 at location (-0.262546 -0.538933 1.00574) on processor 9
    max(T) = 336.298 in cell 419031 at location (1.7468 0.758405 8.10989) on processor 1
    min(mag(U)) = 0 in cell 14990 at location (-0.0824383 1.68479 1.5349) on processor 0
    max(mag(U)) = 652.341 in cell 218284 at location (0.609849 0.167247 1.00091) on processor 12
This commit is contained in:
Henry Weller
2017-01-13 14:10:04 +00:00
parent 78f6aebb99
commit 67e9cf81e0
2 changed files with 43 additions and 11 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -131,6 +131,8 @@ protected:
(
const word& fieldName,
const word& outputName,
const label minCell,
const label maxCell,
const vector& minC,
const vector& maxC,
const label minProci,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,6 +33,8 @@ void Foam::functionObjects::fieldMinMax::output
(
const word& fieldName,
const word& outputName,
const label minCell,
const label maxCell,
const vector& minC,
const vector& maxC,
const label minProci,
@ -68,6 +70,7 @@ void Foam::functionObjects::fieldMinMax::output
file<< endl;
Log << " min(" << outputName << ") = " << minValue
<< " in cell " << minCell
<< " at location " << minC;
if (Pstream::parRun())
@ -76,6 +79,7 @@ void Foam::functionObjects::fieldMinMax::output
}
Log << nl << " max(" << outputName << ") = " << maxValue
<< " in cell " << maxCell
<< " at location " << maxC;
if (Pstream::parRun())
@ -122,17 +126,19 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
magField.boundaryField();
scalarList minVs(Pstream::nProcs());
labelList minCells(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(magField);
minVs[proci] = magField[minProci];
minCells[proci] = minProci;
minCs[proci] = mesh_.C()[minProci];
labelList maxIs(Pstream::nProcs());
scalarList maxVs(Pstream::nProcs());
labelList maxCells(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(magField);
maxVs[proci] = magField[maxProci];
maxCells[proci] = maxProci;
maxCs[proci] = mesh_.C()[maxProci];
forAll(magFieldBoundary, patchi)
@ -142,10 +148,14 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
{
const vectorField& Cfp = CfBoundary[patchi];
const labelList& faceCells =
magFieldBoundary[patchi].patch().faceCells();
label minPI = findMin(mfp);
if (mfp[minPI] < minVs[proci])
{
minVs[proci] = mfp[minPI];
minCells[proci] = faceCells[minPI];
minCs[proci] = Cfp[minPI];
}
@ -153,31 +163,38 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
if (mfp[maxPI] > maxVs[proci])
{
maxVs[proci] = mfp[maxPI];
maxCells[proci] = faceCells[maxPI];
maxCs[proci] = Cfp[maxPI];
}
}
}
Pstream::gatherList(minVs);
Pstream::gatherList(minCells);
Pstream::gatherList(minCs);
Pstream::gatherList(maxVs);
Pstream::gatherList(maxCells);
Pstream::gatherList(maxCs);
if (Pstream::master())
{
label minI = findMin(minVs);
scalar minValue = minVs[minI];
const label minI = findMin(minVs);
const scalar minValue = minVs[minI];
const label minCell = minCells[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
scalar maxValue = maxVs[maxI];
const label maxI = findMax(maxVs);
const scalar maxValue = maxVs[maxI];
const label maxCell = maxCells[maxI];
const vector& maxC = maxCs[maxI];
output
(
fieldName,
word("mag(" + fieldName + ")"),
minCell,
maxCell,
minC,
maxC,
minI,
@ -194,31 +211,37 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
fieldBoundary = field.boundaryField();
List<Type> minVs(Pstream::nProcs());
labelList minCells(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(field);
minVs[proci] = field[minProci];
minCells[proci] = minProci;
minCs[proci] = mesh_.C()[minProci];
Pstream::gatherList(minVs);
Pstream::gatherList(minCs);
List<Type> maxVs(Pstream::nProcs());
labelList maxCells(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(field);
maxVs[proci] = field[maxProci];
maxCells[proci] = maxProci;
maxCs[proci] = mesh_.C()[maxProci];
forAll(fieldBoundary, patchi)
{
const Field<Type>& fp = fieldBoundary[patchi];
if (fp.size())
{
const vectorField& Cfp = CfBoundary[patchi];
const labelList& faceCells =
fieldBoundary[patchi].patch().faceCells();
label minPI = findMin(fp);
if (fp[minPI] < minVs[proci])
{
minVs[proci] = fp[minPI];
minCells[proci] = faceCells[minPI];
minCs[proci] = Cfp[minPI];
}
@ -226,31 +249,38 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
if (fp[maxPI] > maxVs[proci])
{
maxVs[proci] = fp[maxPI];
maxCells[proci] = faceCells[maxPI];
maxCs[proci] = Cfp[maxPI];
}
}
}
Pstream::gatherList(minVs);
Pstream::gatherList(minCells);
Pstream::gatherList(minCs);
Pstream::gatherList(maxVs);
Pstream::gatherList(maxCells);
Pstream::gatherList(maxCs);
if (Pstream::master())
{
label minI = findMin(minVs);
Type minValue = minVs[minI];
const label minCell = minCells[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
Type maxValue = maxVs[maxI];
const label maxCell = maxCells[maxI];
const vector& maxC = maxCs[maxI];
output
(
fieldName,
fieldName,
minCell,
maxCell,
minC,
maxC,
minI,