Commit ff26b96a authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: use 'cloudObjects' instead of 'sprayObjects'

parent dd775c6e
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -461,13 +461,15 @@ int main(int argc, char *argv[])
// Do local scan for valid cloud objects
IOobjectList sprayObjs(runTime, runTime.timeName(), dir);
wordList cloudFields
(
IOobjectList(runTime, runTime.timeName(), dir).sortedNames()
);
// Combine with all other cloud objects
wordList sprayFields(sprayObjs.sortedToc());
combineReduce(sprayFields, uniqueEqOp<word>());
combineReduce(cloudFields, uniqueEqOp<word>());
for (const word& name : sprayFields)
for (const word& name : cloudFields)
{
// Note: try the various field types. Make sure to
// exit once successful conversion to avoid re-read
......
......@@ -807,7 +807,7 @@ int main(int argc, char *argv[])
for (const fileName& cloudDir : cloudDirs)
{
IOobjectList sprayObjs
IOobjectList cloudObjects
(
mesh,
runTime.timeName(),
......@@ -817,12 +817,12 @@ int main(int argc, char *argv[])
false
);
// Note: looking up "positions" for backwards compatibility
IOobject* positionsPtr =
sprayObjs.lookup(word("positions"));
IOobject* coordsPtr = sprayObjs.lookup(word("coordinates"));
if (positionsPtr || coordsPtr)
// Note: look up "positions" for backwards compatibility
if
(
cloudObjects.found("coordinates")
|| cloudObjects.found("positions")
)
{
// Read lagrangian particles
// ~~~~~~~~~~~~~~~~~~~~~~~~~
......
......@@ -538,7 +538,7 @@ int main(int argc, char *argv[])
if (!noLagrangian)
{
HashTable<IOobjectList> cloudObjects;
HashTable<IOobjectList> allCloudObjects;
forAll(databases, proci)
{
......@@ -566,39 +566,38 @@ int main(int argc, char *argv[])
{
// Check if we already have cloud objects for this
// cloudname
if (!cloudObjects.found(cloudDir))
if (!allCloudObjects.found(cloudDir))
{
// Do local scan for valid cloud objects
IOobjectList sprayObjs
IOobjectList localObjs
(
procMeshes.meshes()[proci],
databases[proci].timeName(),
cloud::prefix/cloudDir
);
IOobject* positionsPtr =
sprayObjs.lookup(word("positions"));
IOobject* coordsPtr =
sprayObjs.lookup(word("coordinates"));
if (coordsPtr || positionsPtr)
if
(
localObjs.found("coordinates")
|| localObjs.found("positions")
)
{
cloudObjects.insert(cloudDir, sprayObjs);
allCloudObjects.insert(cloudDir, localObjs);
}
}
}
}
if (cloudObjects.size())
if (allCloudObjects.size())
{
// Pass2: reconstruct the cloud
forAllConstIter(HashTable<IOobjectList>, cloudObjects, iter)
forAllConstIters(allCloudObjects, iter)
{
const word cloudName = word::validate(iter.key());
// Objects (on arbitrary processor)
const IOobjectList& sprayObjs = iter.object();
const IOobjectList& cloudObjs = iter.object();
Info<< "Reconstructing lagrangian fields for cloud "
<< cloudName << nl << endl;
......@@ -616,7 +615,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<label>
......@@ -624,7 +623,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<scalar>
......@@ -632,7 +631,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<scalar>
......@@ -640,7 +639,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<vector>
......@@ -648,7 +647,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<vector>
......@@ -656,7 +655,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<sphericalTensor>
......@@ -664,7 +663,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<sphericalTensor>
......@@ -672,7 +671,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<symmTensor>
......@@ -680,7 +679,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<symmTensor>
......@@ -688,7 +687,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFields<tensor>
......@@ -696,7 +695,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
reconstructLagrangianFieldFields<tensor>
......@@ -704,7 +703,7 @@ int main(int argc, char *argv[])
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -89,30 +89,30 @@ void Foam::parLagrangianRedistributor::findClouds
for (const fileName& localCloudName : localCloudDirs)
{
// Do local scan for valid cloud objects
IOobjectList sprayObjs
IOobjectList localObjs
(
mesh,
mesh.time().timeName(),
cloud::prefix/localCloudName
);
if (sprayObjs.found("coordinates") || sprayObjs.found("positions"))
bool isCloud = false;
if (localObjs.erase("coordinates"))
{
isCloud = true;
}
if (localObjs.erase("positions"))
{
isCloud = true;
}
if (isCloud)
{
// Has coordinates/positions - so must be a valid cloud
const label cloudI = cloudNames.find(localCloudName);
const label cloudi = cloudNames.find(localCloudName);
objectNames[cloudI].setSize(sprayObjs.size());
label objectI = 0;
forAllConstIters(sprayObjs, iter)
{
const word& name = iter.key();
if (name != "coordinates" && name != "positions")
{
objectNames[cloudI][objectI++] = name;
}
}
objectNames[cloudI].setSize(objectI);
objectNames[cloudi] = localObjs.sortedNames();
}
}
......
......@@ -1807,13 +1807,14 @@ void reconstructLagrangian
<< cloudName << nl << endl;
autoPtr<mapDistributeBase> lagrangianMapPtr =
lagrangianReconstructor.redistributeLagrangianPositions
(
cloudName
);
lagrangianReconstructor.redistributeLagrangianPositions
(
cloudName
);
const mapDistributeBase& lagrangianMap = *lagrangianMapPtr;
IOobjectList sprayObjs
IOobjectList cloudObjs
(
mesh,
mesh.time().timeName(),
......@@ -1824,42 +1825,42 @@ void reconstructLagrangian
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<label>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<scalar>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<scalar>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<vector>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<vector>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields
......@@ -1867,7 +1868,7 @@ void reconstructLagrangian
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields
......@@ -1875,14 +1876,14 @@ void reconstructLagrangian
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<symmTensor>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields
......@@ -1890,21 +1891,21 @@ void reconstructLagrangian
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<tensor>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<tensor>
(
lagrangianMap,
cloudName,
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
}
......@@ -1947,29 +1948,29 @@ void readLagrangian
//}
IOobjectList sprayObjs(clouds[i], clouds[i].time().timeName());
IOobjectList cloudObjs(clouds[i], clouds[i].time().timeName());
//Pout<< "Found clould objects:" << sprayObjs.names() << endl;
//Pout<< "Found clould objects:" << cloudObjs.names() << endl;
parLagrangianRedistributor::readLagrangianFields
<IOField<label>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<IOField<Field<label>>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<CompactIOField<Field<label>, label>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
......@@ -1978,21 +1979,21 @@ void readLagrangian
<IOField<scalar>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<IOField<Field<scalar>>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<CompactIOField<Field<scalar>, scalar>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
......@@ -2001,21 +2002,21 @@ void readLagrangian
<IOField<vector>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<IOField<Field<vector>>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<CompactIOField<Field<vector>, vector>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
......@@ -2024,21 +2025,21 @@ void readLagrangian
<IOField<sphericalTensor>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<IOField<Field<sphericalTensor>>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<CompactIOField<Field<sphericalTensor>, sphericalTensor>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
......@@ -2047,21 +2048,21 @@ void readLagrangian
<IOField<symmTensor>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<IOField<Field<symmTensor>>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<CompactIOField<Field<symmTensor>, symmTensor>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
......@@ -2070,21 +2071,21 @@ void readLagrangian
<IOField<tensor>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<IOField<Field<tensor>>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
parLagrangianRedistributor::readLagrangianFields
<CompactIOField<Field<tensor>, tensor>>
(
clouds[i],
sprayObjs,
cloudObjs,
selectedLagrangianFields
);
}
......
......@@ -37,7 +37,19 @@ if (timeDirs.size() && !noLagrangian)
// Clouds require "coordinates".
// The "positions" are for v1706 and lower.
if (cloudObjs.found("coordinates") || cloudObjs.found("positions"))
// - detect and remove since these are treated specially
bool isCloud = false;
if (cloudObjs.erase("coordinates"))
{
isCloud = true;
}
if (cloudObjs.erase("positions"))
{
isCloud = true;
}
if (isCloud)
{
// Save the cloud fields on a per cloud basis
auto& fieldsPerCloud = cloudFields(cloudName);
......@@ -53,13 +65,6 @@ if (timeDirs.size() && !noLagrangian)
}
}
// Prune out geometry again since it gets treated specially
forAllIters(cloudFields, cloudIter)
{
cloudIter().erase("coordinates");
cloudIter().erase("positions");
}
if (Pstream::parRun())
{
Pstream::mapCombineGather(cloudFields, HashTableOps::plusEqOp<word>());
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -55,17 +55,19 @@ vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::lagrangianVTKMesh
}
// the region name is already in the mesh db