From 49130c846782982093fedebef8d6e6ab8654a6e5 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 29 Oct 2012 14:31:23 +0000 Subject: [PATCH] ENH: Updated min/max function object to include boundary values --- .../field/fieldMinMax/fieldMinMaxTemplates.C | 95 ++++++++++++++----- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C index 64a03c43b1..33564024b1 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C @@ -45,31 +45,56 @@ void Foam::fieldMinMax::calcMinMaxFields const label procI = Pstream::myProcNo(); const fieldType& field = obr_.lookupObject(fieldName); + const fvMesh& mesh = field.mesh(); + + const volVectorField::GeometricBoundaryField& CfBoundary = + mesh.C().boundaryField(); + switch (mode) { case mdMag: { - const scalarField magField(mag(field)); + const volScalarField magField(mag(field)); + const volScalarField::GeometricBoundaryField& magFieldBoundary = + magField.boundaryField(); - labelList minIs(Pstream::nProcs()); scalarList minVs(Pstream::nProcs()); List minCs(Pstream::nProcs()); - minIs[procI] = findMin(magField); - minVs[procI] = magField[minIs[procI]]; - minCs[procI] = field.mesh().C()[minIs[procI]]; + label minProcI = findMin(magField); + minVs[procI] = magField[minProcI]; + minCs[procI] = field.mesh().C()[minProcI]; - Pstream::gatherList(minIs); - Pstream::gatherList(minVs); - Pstream::gatherList(minCs); labelList maxIs(Pstream::nProcs()); scalarList maxVs(Pstream::nProcs()); List maxCs(Pstream::nProcs()); - maxIs[procI] = findMax(magField); - maxVs[procI] = magField[maxIs[procI]]; - maxCs[procI] = field.mesh().C()[maxIs[procI]]; + label maxProcI = findMax(magField); + maxVs[procI] = magField[maxProcI]; + maxCs[procI] = field.mesh().C()[maxProcI]; + + forAll(magFieldBoundary, patchI) + { + const scalarField& mfp = magFieldBoundary[patchI]; + const vectorField& Cfp = CfBoundary[patchI]; + + label minPI = findMin(mfp); + if (mfp[minPI] < minVs[procI]) + { + minVs[procI] = mfp[minPI]; + minCs[procI] = Cfp[minPI]; + } + + label maxPI = findMax(mfp); + if (mfp[maxPI] > maxVs[procI]) + { + maxVs[procI] = mfp[maxPI]; + maxCs[procI] = Cfp[maxPI]; + } + } + + Pstream::gatherList(minVs); + Pstream::gatherList(minCs); - Pstream::gatherList(maxIs); Pstream::gatherList(maxVs); Pstream::gatherList(maxCs); @@ -127,25 +152,47 @@ void Foam::fieldMinMax::calcMinMaxFields } case mdCmpt: { - List minVs(Pstream::nProcs()); - labelList minIs(Pstream::nProcs()); - List minCs(Pstream::nProcs()); - minIs[procI] = findMin(field); - minVs[procI] = field[minIs[procI]]; - minCs[procI] = field.mesh().C()[minIs[procI]]; + const typename fieldType::GeometricBoundaryField& + fieldBoundary = field.boundaryField(); + + List minVs(Pstream::nProcs()); + List minCs(Pstream::nProcs()); + label minProcI = findMin(field); + minVs[procI] = field[minProcI]; + minCs[procI] = field.mesh().C()[minProcI]; - Pstream::gatherList(minIs); Pstream::gatherList(minVs); Pstream::gatherList(minCs); List maxVs(Pstream::nProcs()); - labelList maxIs(Pstream::nProcs()); List maxCs(Pstream::nProcs()); - maxIs[procI] = findMax(field); - maxVs[procI] = field[maxIs[procI]]; - maxCs[procI] = field.mesh().C()[maxIs[procI]]; + label maxProcI = findMax(field); + maxVs[procI] = field[maxProcI]; + maxCs[procI] = field.mesh().C()[maxProcI]; + + forAll(fieldBoundary, patchI) + { + const Field& fp = fieldBoundary[patchI]; + const vectorField& Cfp = CfBoundary[patchI]; + + label minPI = findMin(fp); + if (fp[minPI] < minVs[procI]) + { + minVs[procI] = fp[minPI]; + minCs[procI] = Cfp[minPI]; + } + + label maxPI = findMax(fp); + if (fp[maxPI] > maxVs[procI]) + { + maxVs[procI] = fp[maxPI]; + maxCs[procI] = Cfp[maxPI]; + } + } + + Pstream::gatherList(minVs); + Pstream::gatherList(minCs); - Pstream::gatherList(maxIs); Pstream::gatherList(maxVs); Pstream::gatherList(maxCs);