mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: probes: filter out points that cannot be found. Fixes #492.
This commit is contained in:
@ -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_);
|
||||
|
||||
@ -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_;
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user