BUG: Lagrangian post-processing model not outputting in chronological order - mantis #357

This commit is contained in:
andy 2012-01-30 17:39:37 +00:00
parent 9c8e2fa709
commit 04e512140c
2 changed files with 33 additions and 6 deletions

View File

@ -26,6 +26,7 @@ License
#include "PatchPostProcessing.H"
#include "Pstream.H"
#include "stringListOps.H"
#include "ListOps.H"
#include "ListListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -55,9 +56,12 @@ void Foam::PatchPostProcessing<CloudType>::write()
{
forAll(patchData_, i)
{
List<List<scalar> > procTimes(Pstream::nProcs());
procTimes[Pstream::myProcNo()] = times_[i];
Pstream::gatherList(procTimes);
List<List<string> > procData(Pstream::nProcs());
procData[Pstream::myProcNo()] = patchData_[i];
Pstream::gatherList(procData);
if (Pstream::master())
@ -100,18 +104,33 @@ void Foam::PatchPostProcessing<CloudType>::write()
procData,
accessOp<List<string> >()
);
sort(globalData);
List<scalar> globalTimes;
globalTimes = ListListOps::combine<List<scalar> >
(
procTimes,
accessOp<List<scalar> >()
);
labelList indices;
sortedOrder(globalTimes, indices);
string header("# Time currentProc " + parcelType::propHeader);
patchOutFile<< header.c_str() << nl;
forAll(globalData, dataI)
forAll(globalTimes, i)
{
patchOutFile<< globalData[dataI].c_str() << nl;
label dataI = indices[i];
patchOutFile
<< globalTimes[dataI] << ' '
<< globalData[dataI].c_str()
<< nl;
}
}
patchData_[i].clearStorage();
times_[i].clearStorage();
}
}
@ -128,6 +147,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
CloudFunctionObject<CloudType>(dict, owner, typeName),
maxStoredParcels_(readScalar(this->coeffDict().lookup("maxStoredParcels"))),
patchIDs_(),
times_(),
patchData_()
{
const wordList allPatchNames = owner.mesh().boundaryMesh().names();
@ -167,6 +187,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
}
patchData_.setSize(patchIDs_.size());
times_.setSize(patchIDs_.size());
}
@ -179,6 +200,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
CloudFunctionObject<CloudType>(ppm),
maxStoredParcels_(ppm.maxStoredParcels_),
patchIDs_(ppm.patchIDs_),
times_(ppm.times_),
patchData_(ppm.patchData_)
{}
@ -203,9 +225,11 @@ void Foam::PatchPostProcessing<CloudType>::postPatch
const label localPatchI = applyToPatch(patchI);
if (localPatchI != -1 && patchData_[localPatchI].size() < maxStoredParcels_)
{
times_[localPatchI].append(this->owner().time().value());
OStringStream data;
data<< this->owner().time().timeName() << ' ' << Pstream::myProcNo()
<< ' ' << p;
data<< Pstream::myProcNo() << ' ' << p;
patchData_[localPatchI].append(data.str());
}
}

View File

@ -61,6 +61,9 @@ class PatchPostProcessing
//- List of patch indices to post-process
labelList patchIDs_;
//- List of time for each data record
List<DynamicList<scalar> > times_;
//- List of output data per patch
List<DynamicList<string> > patchData_;