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

updated since origProc and origId are now stored on the particle

parent bbc404e5
Branches
Tags
No related merge requests found
...@@ -46,14 +46,17 @@ using namespace Foam; ...@@ -46,14 +46,17 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
# include "setRootCase.H" #include "setRootCase.H"
# include "createTime.H" #include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args); instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H" #include "createMesh.H"
# include "createFields.H" #include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
fileName vtkPath(runTime.path()/"VTK");
mkDir(vtkPath);
Info<< "Scanning times to determine track data" << nl << endl; Info<< "Scanning times to determine track data" << nl << endl;
...@@ -63,29 +66,28 @@ int main(int argc, char *argv[]) ...@@ -63,29 +66,28 @@ int main(int argc, char *argv[])
runTime.setTime(timeDirs[timeI], timeI); runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
IOobject origProcHeader IOobject positionsHeader
(
"origProc",
runTime.timeName(),
cloud::prefix/cloudName,
mesh,
IOobject::MUST_READ
);
IOobject idHeader
( (
"id", "positions",
runTime.timeName(), runTime.timeName(),
cloud::prefix/cloudName, cloud::prefix/cloudName,
mesh, mesh,
IOobject::MUST_READ IOobject::MUST_READ,
IOobject::NO_WRITE,
false
); );
if (idHeader.headerOk() && origProcHeader.headerOk())
if (positionsHeader.headerOk())
{ {
IOField<label> origProc(origProcHeader); Info<< " Reading particle positions" << endl;
IOField<label> id(idHeader); Cloud<passiveParticle> myCloud(mesh, cloudName, false);
forAll(id, i)
forAllConstIter(Cloud<passiveParticle>, myCloud, iter)
{ {
maxIds[origProc[i]] = max(maxIds[origProc[i]], id[i]); label origId = iter().origId();
label origProc = iter().origProc();
maxIds[origProc] = max(maxIds[origProc], origId);
} }
} }
} }
...@@ -124,60 +126,35 @@ int main(int argc, char *argv[]) ...@@ -124,60 +126,35 @@ int main(int argc, char *argv[])
false false
); );
IOobject origProcHeader if (positionsHeader.headerOk())
(
"origProc",
runTime.timeName(),
cloud::prefix/cloudName,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
IOobject idHeader
(
"id",
runTime.timeName(),
cloud::prefix/cloudName,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if
(
positionsHeader.headerOk()
&& origProcHeader.headerOk()
&& idHeader.headerOk()
)
{ {
Info<< " Reading particle positions" << endl; Info<< " Reading particle positions" << endl;
Cloud<passiveParticle> myCloud(mesh, cloudName, false); Cloud<passiveParticle> myCloud(mesh, cloudName, false);
Info<< " Reading particle id" << endl; // collect the track data on the master processor
IOField<label> id(idHeader); List<pointField> allPositions(Pstream::nProcs());
allPositions[Pstream::myProcNo()].setSize
(
myCloud.size(),
point::zero
);
Info<< " Reading particle origProc" << endl; List<labelField> allOrigIds(Pstream::nProcs());
IOField<label> origProc(origProcHeader); allOrigIds[Pstream::myProcNo()].setSize(myCloud.size(), 0);
List<labelField> allOrigProcs(Pstream::nProcs());
allOrigProcs[Pstream::myProcNo()].setSize(myCloud.size(), 0);
// collect the track data on the master processor
label i = 0; label i = 0;
List<pointField> allPositions(Pstream::nProcs());
allPositions[Pstream::myProcNo()].setSize(myCloud.size());
forAllConstIter(Cloud<passiveParticle>, myCloud, iter) forAllConstIter(Cloud<passiveParticle>, myCloud, iter)
{ {
allPositions[Pstream::myProcNo()][i++] = iter().position(); allPositions[Pstream::myProcNo()][i] = iter().position();
allOrigIds[Pstream::myProcNo()][i] = iter().origId();
allOrigProcs[Pstream::myProcNo()][i] = iter().origProc();
i++;
} }
Pstream::gatherList(allPositions); Pstream::gatherList(allPositions);
Pstream::gatherList(allOrigIds);
List<labelList> allIds(Pstream::nProcs());
allIds[Pstream::myProcNo()] = id;
Pstream::gatherList(allIds);
List<labelList> allOrigProcs(Pstream::nProcs());
allOrigProcs[Pstream::myProcNo()] = origProc;
Pstream::gatherList(allOrigProcs); Pstream::gatherList(allOrigProcs);
Info<< " Constructing tracks" << nl << endl; Info<< " Constructing tracks" << nl << endl;
...@@ -189,7 +166,7 @@ int main(int argc, char *argv[]) ...@@ -189,7 +166,7 @@ int main(int argc, char *argv[])
{ {
label globalId = label globalId =
startIds[allOrigProcs[procI][i]] startIds[allOrigProcs[procI][i]]
+ allIds[procI][i]; + allOrigIds[procI][i];
if (globalId % sampleFrequency == 0) if (globalId % sampleFrequency == 0)
{ {
...@@ -216,7 +193,7 @@ int main(int argc, char *argv[]) ...@@ -216,7 +193,7 @@ int main(int argc, char *argv[])
{ {
Info<< "\nWriting particle tracks" << nl << endl; Info<< "\nWriting particle tracks" << nl << endl;
OFstream vtkTracks("particleTracks.vtk"); OFstream vtkTracks(vtkPath/"particleTracks.vtk");
// Total number of points in tracks + 1 per track // Total number of points in tracks + 1 per track
label nPoints = 0; label nPoints = 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment