Skip to content
Snippets Groups Projects
Commit d7f72671 authored by Andrew Heather's avatar Andrew Heather
Browse files

Merge branch 'fix-2291-patchProbes' into 'develop'

ENH: patchProbes: output patch. Fixes #2291.

See merge request Development/openfoam!515
parents aaf4f40b f19883c0
No related branches found
No related tags found
1 merge request!515ENH: patchProbes: output patch. Fixes #2291.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -92,26 +92,26 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) ...@@ -92,26 +92,26 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
overallBb.min() -= point::uniform(ROOTVSMALL); overallBb.min() -= point::uniform(ROOTVSMALL);
overallBb.max() += point::uniform(ROOTVSMALL); overallBb.max() += point::uniform(ROOTVSMALL);
const indexedOctree<treeDataFace> boundaryTree const indexedOctree<treeDataFace> boundaryTree
( (
treeDataFace // all information needed to search faces treeDataFace // all information needed to search faces
( (
false, // do not cache bb false, // do not cache bb
mesh, mesh,
bndFaces // patch faces only bndFaces // patch faces only
), ),
overallBb, // overall search domain overallBb, // overall search domain
8, // maxLevel 8, // maxLevel
10, // leafsize 10, // leafsize
3.0 // duplicity 3.0 // duplicity
); );
forAll(probeLocations(), probei) forAll(probeLocations(), probei)
{ {
const point sample = probeLocations()[probei]; const point sample = probeLocations()[probei];
scalar span = boundaryTree.bb().mag(); const scalar span = boundaryTree.bb().mag();
pointIndexHit info = boundaryTree.findNearest pointIndexHit info = boundaryTree.findNearest
( (
...@@ -169,14 +169,15 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) ...@@ -169,14 +169,15 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp()); Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp());
Pstream::listCombineScatter(nearest); Pstream::listCombineScatter(nearest);
oldPoints_.resize(this->size());
// Update actual probe locations // Update actual probe locations and store old ones
forAll(nearest, samplei) forAll(nearest, samplei)
{ {
oldPoints_[samplei] = operator[](samplei);
operator[](samplei) = nearest[samplei].first().rawPoint(); operator[](samplei) = nearest[samplei].first().rawPoint();
} }
if (debug) if (debug)
{ {
InfoInFunction << nl; InfoInFunction << nl;
...@@ -193,29 +194,39 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) ...@@ -193,29 +194,39 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
} }
} }
// Extract any local faces to sample:
// Extract any local faces to sample // - operator[] : actual point to sample (=nearest point on patch)
// - oldPoints_ : original provided point (might be anywhere in the mesh)
// - elementList_ : cells, not used
// - faceList_ : faces (now patch faces)
// - patchIDList_ : patch corresponding to faceList
// - processor_ : processor
elementList_.setSize(nearest.size()); elementList_.setSize(nearest.size());
elementList_ = -1; elementList_ = -1;
faceList_.setSize(nearest.size()); faceList_.setSize(nearest.size());
faceList_ = -1; faceList_ = -1;
processor_.setSize(nearest.size()); processor_.setSize(nearest.size());
processor_ = -1; processor_ = -1;
patchIDList_.setSize(nearest.size());
processor_.setSize(size()); patchIDList_ = -1;
processor_ = -1;
forAll(nearest, sampleI) forAll(nearest, sampleI)
{ {
processor_[sampleI] = nearest[sampleI].second().second(); processor_[sampleI] = nearest[sampleI].second().second();
if (nearest[sampleI].second().second() == Pstream::myProcNo()) if (nearest[sampleI].second().second() == Pstream::myProcNo())
{ {
// Store the face to sample // Store the face to sample
faceList_[sampleI] = nearest[sampleI].first().index(); faceList_[sampleI] = nearest[sampleI].first().index();
label facei = faceList_[sampleI]; const label facei = faceList_[sampleI];
processor_[sampleI] = (facei != -1 ? Pstream::myProcNo() : -1); if (facei != -1)
{
processor_[sampleI] = Pstream::myProcNo();
patchIDList_[sampleI] = bm.whichPatch(facei);
}
} }
reduce(processor_[sampleI], maxOp<label>()); reduce(processor_[sampleI], maxOp<label>());
reduce(patchIDList_[sampleI], maxOp<label>());
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -251,6 +251,28 @@ Foam::label Foam::probes::prepare() ...@@ -251,6 +251,28 @@ Foam::label Foam::probes::prepare()
{ {
fout<< " # Not Found"; fout<< " # Not Found";
} }
// Only for patchProbes
else if (probei < patchIDList_.size())
{
const label patchi = patchIDList_[probei];
if (patchi != -1)
{
const polyBoundaryMesh& bm = mesh_.boundaryMesh();
if
(
patchi < bm.nNonProcessor()
|| processor_[probei] == Pstream::myProcNo()
)
{
fout<< " at patch " << bm[patchi].name();
}
fout<< " with a distance of "
<< mag(operator[](probei)-oldPoints_[probei])
<< " m to the original point "
<< oldPoints_[probei];
}
}
fout<< endl; fout<< endl;
} }
...@@ -325,7 +347,7 @@ bool Foam::probes::read(const dictionary& dict) ...@@ -325,7 +347,7 @@ bool Foam::probes::read(const dictionary& dict)
{ {
WarningInFunction WarningInFunction
<< "Only cell interpolation can be applied when " << "Only cell interpolation can be applied when "
<< "not using fixedLocations. InterpolationScheme " << "not using fixedLocations. InterpolationScheme "
<< "entry will be ignored" << "entry will be ignored"
<< endl; << endl;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -188,6 +188,14 @@ protected: ...@@ -188,6 +188,14 @@ protected:
//- Current open files //- Current open files
HashPtrTable<OFstream> probeFilePtrs_; HashPtrTable<OFstream> probeFilePtrs_;
// Additional fields for patchProbes
//- Patch IDs on which the new probes are located
labelList patchIDList_;
//- Original probes location (only used for patchProbes)
pointField oldPoints_;
// Protected Member Functions // Protected Member Functions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment