BUG: patchProbes: clear found cells before finding faces

This commit is contained in:
mattijs
2011-09-02 10:54:43 +01:00
parent 37c85aaad6
commit fb7e68dac1
2 changed files with 61 additions and 63 deletions

View File

@ -92,10 +92,6 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
); );
if (elementList_.empty())
{
elementList_.setSize(probeLocations().size());
forAll(probeLocations(), probeI) forAll(probeLocations(), probeI)
{ {
const point sample = probeLocations()[probeI]; const point sample = probeLocations()[probeI];
@ -153,7 +149,6 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
} }
} }
} }
}
// Find nearest. // Find nearest.
@ -171,25 +166,21 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
Info<< " " << sampleI << " coord:"<< operator[](sampleI) Info<< " " << sampleI << " coord:"<< operator[](sampleI)
<< " found on processor:" << procI << " found on processor:" << procI
<< " in local cell/face:" << localI << " in local cell/face:" << localI
<< " with cc:" << nearest[sampleI].first().rawPoint() << endl; << " with fc:" << nearest[sampleI].first().rawPoint() << endl;
} }
} }
// Check if all patchProbes have been found.
// Extract any local faces to sample
elementList_.setSize(nearest.size(), -1);
forAll(nearest, sampleI) forAll(nearest, sampleI)
{ {
label localI = -1;
if (nearest[sampleI].second().second() == Pstream::myProcNo()) if (nearest[sampleI].second().second() == Pstream::myProcNo())
{ {
localI = nearest[sampleI].first().index(); // Store the face to sample
elementList_[sampleI] = nearest[sampleI].first().index();
} }
if (elementList_.empty())
{
elementList_.setSize(probeLocations().size());
}
elementList_[sampleI] = localI;
} }
} }
@ -206,6 +197,12 @@ Foam::patchProbes::patchProbes
: :
probes(name, obr, dict, loadFromFiles) probes(name, obr, dict, loadFromFiles)
{ {
// When constructing probes above it will have called the
// probes::findElements (since the virtual mechanism not yet operating).
// Not easy to workaround (apart from feeding through flag into constructor)
// so clear out any cells found for now.
elementList_.clear();
read(dict); read(dict);
} }
@ -230,6 +227,7 @@ void Foam::patchProbes::write()
void Foam::patchProbes::read(const dictionary& dict) void Foam::patchProbes::read(const dictionary& dict)
{ {
dict.lookup("patchName") >> patchName_;
probes::read(dict); probes::read(dict);
} }

View File

@ -206,7 +206,7 @@ public:
} }
//- Cells to be probed (obtained from the locations) //- Cells to be probed (obtained from the locations)
const labelList& elemets() const const labelList& elements() const
{ {
return elementList_; return elementList_;
} }