diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index e920b946b83dc1b94c83dc56a4e3551d8f40f302..6d072e280958283d91804960811ef36f0166b945 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,6 +58,9 @@ void Foam::probes::findElements(const fvMesh& mesh) faceList_.clear(); faceList_.setSize(size()); + processor_.setSize(size()); + processor_ = -1; + forAll(*this, probei) { const vector& location = operator[](probei); @@ -105,9 +108,12 @@ void Foam::probes::findElements(const fvMesh& mesh) label celli = elementList_[probei]; label facei = faceList_[probei]; + processor_[probei] = (celli != -1 ? Pstream::myProcNo() : -1); + // Check at least one processor with cell. reduce(celli, maxOp<label>()); reduce(facei, maxOp<label>()); + reduce(processor_[probei], maxOp<label>()); if (celli == -1) { @@ -240,8 +246,13 @@ Foam::label Foam::probes::prepare() forAll(*this, probei) { - fout<< "# Probe " << probei << ' ' << operator[](probei) - << endl; + fout<< "# Probe " << probei << ' ' << operator[](probei); + + if (processor_[probei] == -1) + { + fout<< " # Not Found"; + } + fout<< endl; } fout<< '#' << setw(IOstream::defaultPrecision() + 6) @@ -249,7 +260,10 @@ Foam::label Foam::probes::prepare() forAll(*this, probei) { - fout<< ' ' << setw(w) << probei; + if (includeOutOfBounds_ || processor_[probei] != -1) + { + fout<< ' ' << setw(w) << probei; + } } fout<< endl; @@ -288,7 +302,8 @@ Foam::probes::probes loadFromFiles_(loadFromFiles), fieldSelection_(), fixedLocations_(true), - interpolationScheme_("cell") + interpolationScheme_("cell"), + includeOutOfBounds_(true) { if (readFields) { @@ -320,6 +335,7 @@ bool Foam::probes::read(const dictionary& dict) << "entry will be ignored"; } } + dict.readIfPresent("includeOutOfBounds", includeOutOfBounds_); // Initialise cells to sample from supplied locations findElements(mesh_); diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H index 8feb83a229abdabd77f67577b47ecd80eacee9c9..a2a480a985596a09de230d977bcf6c9be9514a2b 100644 --- a/src/sampling/probes/probes.H +++ b/src/sampling/probes/probes.H @@ -62,6 +62,10 @@ Description (0.21 0.20999 0.01) // at outlet2 (0.21 0 0.01) // at central block ); + + // Optional: filter out points that haven't been found. Default + // is to include them (with value -VGREAT) + includeOutOfBounds true; } \endverbatim @@ -148,6 +152,9 @@ protected: // Note: only possible when fixedLocations_ is true word interpolationScheme_; + //- Include probes that were not found + bool includeOutOfBounds_; + // Calculated @@ -165,12 +172,16 @@ protected: fieldGroup<symmTensor> surfaceSymmTensorFields_; fieldGroup<tensor> surfaceTensorFields_; - // Cells to be probed (obtained from the locations) + //- Cells to be probed (obtained from the locations) labelList elementList_; - // Faces to be probed + //- Faces to be probed labelList faceList_; + //- Processor holding the cell or face (-1 if point not found + // on any processor) + labelList processor_; + //- Current open files HashPtrTable<OFstream> probeFilePtrs_; diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/probesTemplates.C index b5c469365774132a4c1c495e98d56e452622831b..463a0aeafa7a5afd385b11d0a6da43d712119365 100644 --- a/src/sampling/probes/probesTemplates.C +++ b/src/sampling/probes/probesTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,7 +80,10 @@ void Foam::probes::sampleAndWrite forAll(values, probei) { - os << ' ' << setw(w) << values[probei]; + if (includeOutOfBounds_ || processor_[probei] != -1) + { + os << ' ' << setw(w) << values[probei]; + } } os << endl; } @@ -104,7 +107,10 @@ void Foam::probes::sampleAndWrite forAll(values, probei) { - os << ' ' << setw(w) << values[probei]; + if (includeOutOfBounds_ || processor_[probei] != -1) + { + os << ' ' << setw(w) << values[probei]; + } } os << endl; } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 7f41fd7795f662d4ea0cdcbac32a395be89376d1..e2925cf9e672e067566945882934bf034910bc64 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,8 @@ Description // Fields to be sampled fields (p U); - // Interpolation scheme to use + // Interpolation scheme to use (only used if interpolate=true for + // the surfaces below) interpolationScheme cell; // Output surface format @@ -58,7 +59,12 @@ Description type sampledTriSurfaceMesh; surface f0surf.obj; source cells; + + // Optional: keep original regions keepIds true; + + // Optional: generate values on points instead of faces + interpolate true; } ); }