Skip to content
Snippets Groups Projects
Commit 04e51214 authored by andy's avatar andy
Browse files

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

parent 9c8e2fa7
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ License ...@@ -26,6 +26,7 @@ License
#include "PatchPostProcessing.H" #include "PatchPostProcessing.H"
#include "Pstream.H" #include "Pstream.H"
#include "stringListOps.H" #include "stringListOps.H"
#include "ListOps.H"
#include "ListListOps.H" #include "ListListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...@@ -55,9 +56,12 @@ void Foam::PatchPostProcessing<CloudType>::write() ...@@ -55,9 +56,12 @@ void Foam::PatchPostProcessing<CloudType>::write()
{ {
forAll(patchData_, i) forAll(patchData_, i)
{ {
List<List<scalar> > procTimes(Pstream::nProcs());
procTimes[Pstream::myProcNo()] = times_[i];
Pstream::gatherList(procTimes);
List<List<string> > procData(Pstream::nProcs()); List<List<string> > procData(Pstream::nProcs());
procData[Pstream::myProcNo()] = patchData_[i]; procData[Pstream::myProcNo()] = patchData_[i];
Pstream::gatherList(procData); Pstream::gatherList(procData);
if (Pstream::master()) if (Pstream::master())
...@@ -100,18 +104,33 @@ void Foam::PatchPostProcessing<CloudType>::write() ...@@ -100,18 +104,33 @@ void Foam::PatchPostProcessing<CloudType>::write()
procData, procData,
accessOp<List<string> >() 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); string header("# Time currentProc " + parcelType::propHeader);
patchOutFile<< header.c_str() << nl; 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(); patchData_[i].clearStorage();
times_[i].clearStorage();
} }
} }
...@@ -128,6 +147,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing ...@@ -128,6 +147,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
CloudFunctionObject<CloudType>(dict, owner, typeName), CloudFunctionObject<CloudType>(dict, owner, typeName),
maxStoredParcels_(readScalar(this->coeffDict().lookup("maxStoredParcels"))), maxStoredParcels_(readScalar(this->coeffDict().lookup("maxStoredParcels"))),
patchIDs_(), patchIDs_(),
times_(),
patchData_() patchData_()
{ {
const wordList allPatchNames = owner.mesh().boundaryMesh().names(); const wordList allPatchNames = owner.mesh().boundaryMesh().names();
...@@ -167,6 +187,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing ...@@ -167,6 +187,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
} }
patchData_.setSize(patchIDs_.size()); patchData_.setSize(patchIDs_.size());
times_.setSize(patchIDs_.size());
} }
...@@ -179,6 +200,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing ...@@ -179,6 +200,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
CloudFunctionObject<CloudType>(ppm), CloudFunctionObject<CloudType>(ppm),
maxStoredParcels_(ppm.maxStoredParcels_), maxStoredParcels_(ppm.maxStoredParcels_),
patchIDs_(ppm.patchIDs_), patchIDs_(ppm.patchIDs_),
times_(ppm.times_),
patchData_(ppm.patchData_) patchData_(ppm.patchData_)
{} {}
...@@ -203,9 +225,11 @@ void Foam::PatchPostProcessing<CloudType>::postPatch ...@@ -203,9 +225,11 @@ void Foam::PatchPostProcessing<CloudType>::postPatch
const label localPatchI = applyToPatch(patchI); const label localPatchI = applyToPatch(patchI);
if (localPatchI != -1 && patchData_[localPatchI].size() < maxStoredParcels_) if (localPatchI != -1 && patchData_[localPatchI].size() < maxStoredParcels_)
{ {
times_[localPatchI].append(this->owner().time().value());
OStringStream data; OStringStream data;
data<< this->owner().time().timeName() << ' ' << Pstream::myProcNo() data<< Pstream::myProcNo() << ' ' << p;
<< ' ' << p;
patchData_[localPatchI].append(data.str()); patchData_[localPatchI].append(data.str());
} }
} }
......
...@@ -61,6 +61,9 @@ class PatchPostProcessing ...@@ -61,6 +61,9 @@ class PatchPostProcessing
//- List of patch indices to post-process //- List of patch indices to post-process
labelList patchIDs_; labelList patchIDs_;
//- List of time for each data record
List<DynamicList<scalar> > times_;
//- List of output data per patch //- List of output data per patch
List<DynamicList<string> > patchData_; List<DynamicList<string> > patchData_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment