corrected patchIds

This commit is contained in:
andy
2009-06-30 19:02:25 +01:00
parent d0bb30e7ef
commit 4fee00d61f
3 changed files with 38 additions and 18 deletions

View File

@ -27,6 +27,26 @@ License
#include "PatchPostProcessing.H" #include "PatchPostProcessing.H"
#include "IOPtrList.H" #include "IOPtrList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class CloudType>
Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
(
const label globalPatchI
) const
{
forAll(patchIds_, patchI)
{
if (patchIds_[patchI] == globalPatchI)
{
return patchI;
}
}
return -1;
}
// * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * //
template<class CloudType> template<class CloudType>
@ -80,9 +100,8 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
mesh_(owner.mesh()), mesh_(owner.mesh()),
patchNames_(this->coeffDict().lookup("patches")), patchNames_(this->coeffDict().lookup("patches")),
patchData_(patchNames_.size()), patchData_(patchNames_.size()),
globalToLocalPatchIds_(patchNames_.size()) patchIds_(patchNames_.size())
{ {
labelList localToGlobal(patchNames_.size());
forAll(patchNames_, patchI) forAll(patchNames_, patchI)
{ {
label id = mesh_.boundaryMesh().findPatchID(patchNames_[patchI]); label id = mesh_.boundaryMesh().findPatchID(patchNames_[patchI]);
@ -99,12 +118,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
<< "Available patches are: " << mesh_.boundaryMesh().names() << nl << "Available patches are: " << mesh_.boundaryMesh().names() << nl
<< exit(FatalError); << exit(FatalError);
} }
localToGlobal[patchI] = id; patchIds_[patchI] = id;
}
forAll(localToGlobal, patchI)
{
globalToLocalPatchIds_[localToGlobal[patchI]] = patchI;
} }
} }
@ -132,8 +146,8 @@ void Foam::PatchPostProcessing<CloudType>::postPatch
const label patchI const label patchI
) )
{ {
label localPatchI = globalToLocalPatchIds_[patchI]; label localPatchI = applyToPatch(patchI);
if (patchData_[localPatchI].size() < maxStoredParcels_) if (localPatchI >= 0 && patchData_[localPatchI].size() < maxStoredParcels_)
{ {
patchData_[localPatchI].append(p.clone()); patchData_[localPatchI].append(p.clone());
} }

View File

@ -59,7 +59,7 @@ class PatchPostProcessing
//- Reference to the mesh //- Reference to the mesh
const polyMesh& mesh_; const polyMesh& mesh_;
//- Maximum number of parcels to store per patch //- Maximum number of parcels to store
label maxStoredParcels_; label maxStoredParcels_;
//- List of patch names //- List of patch names
@ -68,8 +68,14 @@ class PatchPostProcessing
//- List of parcel data per patch //- List of parcel data per patch
List<DynamicList<autoPtr<parcelType> > > patchData_; List<DynamicList<autoPtr<parcelType> > > patchData_;
//- Mapping from global to local patch ids //- Mapping from local to global patch ids
labelList globalToLocalPatchIds_; labelList patchIds_;
// Private member functions
//- Returns local patchI if patch is in patchIds_ list
label applyToPatch(const label globalPatchI) const;
protected: protected:
@ -109,8 +115,8 @@ public:
//- Return const access to the list of patch names //- Return const access to the list of patch names
inline const wordList& patchNames() const; inline const wordList& patchNames() const;
//- Return const mapping from global to local patch ids //- Return const mapping from local to global patch ids
inline const labelList& globalToLocalPatchIds() const; inline const labelList& patchIds() const;
// Evaluation // Evaluation

View File

@ -47,9 +47,9 @@ const Foam::wordList& Foam::PatchPostProcessing<CloudType>::patchNames() const
template<class CloudType> template<class CloudType>
const Foam::labelList& const Foam::labelList&
Foam::PatchPostProcessing<CloudType>::globalToLocalPatchIds() const Foam::PatchPostProcessing<CloudType>::patchIds() const
{ {
return globalToLocalPatchIds_; return patchIds_;
} }