diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/functionObjects/field/fieldMinMax/fieldMinMax.H index 6d34a105cb..8e1a9139dd 100644 --- a/src/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -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, diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C index dd7e86de56..f937a22f81 100644 --- a/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C +++ b/src/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C @@ -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 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 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 minVs(Pstream::nProcs()); + labelList minCells(Pstream::nProcs()); List 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 maxVs(Pstream::nProcs()); + labelList maxCells(Pstream::nProcs()); List maxCs(Pstream::nProcs()); label maxProci = findMax(field); maxVs[proci] = field[maxProci]; + maxCells[proci] = maxProci; maxCs[proci] = mesh_.C()[maxProci]; forAll(fieldBoundary, patchi) { const Field& 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,