Commit 87b1bbac authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: support writeLagrangianPositions in redistributePar (issue #702)

parent 0d3d895d
......@@ -152,7 +152,7 @@ public:
void reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const;
//- Read, reconstruct and write all/selected volume fields
......@@ -160,7 +160,7 @@ public:
void reconstructFvVolumeFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const;
//- Read, reconstruct and write all/selected surface fields
......@@ -168,7 +168,7 @@ public:
void reconstructFvSurfaceFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const;
//- Helper: reconstruct and write mesh points
......
......@@ -420,7 +420,7 @@ template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const
{
const word& fieldClassName = DimensionedField<Type, volMesh>::typeName;
......@@ -461,7 +461,7 @@ template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const
{
const word& fieldClassName =
......@@ -504,7 +504,7 @@ template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const
{
const word& fieldClassName =
......
......@@ -86,30 +86,25 @@ void Foam::parLagrangianRedistributor::findClouds
objectNames.setSize(cloudNames.size());
forAll(localCloudDirs, i)
for (const fileName& localCloudName : localCloudDirs)
{
// Do local scan for valid cloud objects
IOobjectList sprayObjs
(
mesh,
mesh.time().timeName(),
cloud::prefix/localCloudDirs[i]
cloud::prefix/localCloudName
);
if
(
sprayObjs.lookup(word("coordinates"))
|| sprayObjs.lookup(word("positions"))
)
if (sprayObjs.found("coordinates") || sprayObjs.found("positions"))
{
// One of the objects is coordinates/positions so must be valid
// cloud
// Has coordinates/positions - so must be a valid cloud
label cloudI = cloudNames.find(localCloudDirs[i]);
const label cloudI = cloudNames.find(localCloudName);
objectNames[cloudI].setSize(sprayObjs.size());
label objectI = 0;
forAllConstIter(IOobjectList, sprayObjs, iter)
forAllConstIters(sprayObjs, iter)
{
const word& name = iter.key();
if (name != "coordinates" && name != "positions")
......@@ -160,8 +155,8 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
{
passivePositionParticle& ppi = iter();
label destProcI = destinationProcID_[ppi.cell()];
label destCellI = destinationCell_[ppi.cell()];
const label destProcI = destinationProcID_[ppi.cell()];
const label destCellI = destinationCell_[ppi.cell()];
ppi.cell() = destCellI;
destProc[particleI++] = destProcI;
......@@ -211,7 +206,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
// Retrieve from receive buffers
forAll(allNTrans, procI)
{
label nRec = allNTrans[procI];
const label nRec = allNTrans[procI];
//Pout<< "From processor " << procI << " receiving bytes " << nRec
// << endl;
......@@ -240,9 +235,19 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
}
}
// Write coordinates file
IOPosition<passivePositionParticleCloud>(lagrangianPositions).write();
// Optionally write positions file in v1706 format and earlier
if (particle::writeLagrangianPositions)
{
IOPosition<passivePositionParticleCloud>
(
lagrangianPositions,
cloud::geometryType::POSITIONS
).write();
}
// Restore cloud name
lpi.rename(cloudName);
}
......@@ -262,7 +267,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
label constructSize = 0;
forAll(constructMap, procI)
{
label nRecv = sizes[procI][UPstream::myProcNo()];
const label nRecv = sizes[procI][UPstream::myProcNo()];
labelList& map = constructMap[procI];
......
......@@ -126,7 +126,7 @@ public:
static wordList filterObjects
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
);
//- Read, redistribute and write all/selected lagrangian fields
......@@ -136,7 +136,7 @@ public:
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const;
//- Read, redistribute and write all/selected lagrangian fieldFields
......@@ -146,7 +146,7 @@ public:
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const;
//- Read and store all fields of a cloud
......@@ -155,7 +155,7 @@ public:
(
const passivePositionParticleCloud& cloud,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
);
//- Redistribute and write stored lagrangian fields
......
......@@ -37,7 +37,7 @@ template<class Container>
Foam::wordList Foam::parLagrangianRedistributor::filterObjects
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
)
{
const word fieldClassName(Container::typeName);
......@@ -69,7 +69,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const
{
const wordList objectNames
......@@ -141,7 +141,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
) const
{
wordList objectNames
......@@ -225,7 +225,7 @@ void Foam::parLagrangianRedistributor::readLagrangianFields
(
const passivePositionParticleCloud& cloud,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
)
{
const wordList objectNames
......
......@@ -115,9 +115,9 @@ scalar getMergeDistance
{
FatalErrorInFunction
<< "Your current settings specify ASCII writing with "
<< IOstream::defaultPrecision() << " digits precision." << endl
<< IOstream::defaultPrecision() << " digits precision." << nl
<< "Your merging tolerance (" << mergeTol << ") is finer than this."
<< endl
<< nl
<< "Please change your writeFormat to binary"
<< " or increase the writePrecision" << endl
<< "or adjust the merge tolerance (-mergeTol)."
......@@ -168,9 +168,9 @@ void printMeshData(const polyMesh& mesh)
label totProcPatches = 0;
label maxProcFaces = 0;
for (label procI = 0; procI < Pstream::nProcs(); procI++)
for (label procI = 0; procI < Pstream::nProcs(); ++procI)
{
Info<< endl
Info<< nl
<< "Processor " << procI << nl
<< " Number of cells = " << globalCells.localSize(procI)
<< endl;
......@@ -312,9 +312,9 @@ void determineDecomposition
WarningInFunction
<< "You have selected decomposition method "
<< decomposer.typeName
<< " which does" << endl
<< " which does" << nl
<< "not synchronise the decomposition across"
<< " processor patches." << endl
<< " processor patches." << nl
<< " You might want to select a decomposition method"
<< " which is aware of this. Continuing."
<< endl;
......@@ -637,7 +637,7 @@ void readFields
{
FatalErrorInFunction
<< "differing fields of type " << GeoField::typeName
<< " on processors." << endl
<< " on processors." << nl
<< "Master has:" << masterNames << endl
<< Pstream::myProcNo() << " has:" << objectNames
<< abort(FatalError);
......@@ -662,7 +662,7 @@ void readFields
tmp<GeoField> tsubfld = subsetterPtr().interpolate(fields[i]);
// Send to all processors that don't have a mesh
for (label procI = 1; procI < Pstream::nProcs(); procI++)
for (label procI = 1; procI < Pstream::nProcs(); ++procI)
{
if (!haveMesh[procI])
{
......@@ -752,10 +752,8 @@ void correctCoupledBoundaryConditions(fvMesh& mesh)
forAll(bfld, patchi)
{
typename GeoField::Patch& pfld = bfld[patchi];
auto& pfld = bfld[patchi];
//if (pfld.coupled())
//if (isA<CoupledPatchType>(pfld))
if (pfld.patch().coupled())
{
pfld.initEvaluate(Pstream::defaultCommsType);
......@@ -772,12 +770,8 @@ void correctCoupledBoundaryConditions(fvMesh& mesh)
Pstream::waitRequests(nReq);
}
forAll(bfld, patchi)
for (auto& pfld : bfld)
{
typename GeoField::Patch& pfld = bfld[patchi];
//if (pfld.coupled())
//if (isA<CoupledPatchType>(pfld))
if (pfld.patch().coupled())
{
pfld.evaluate(Pstream::defaultCommsType);
......@@ -791,11 +785,9 @@ void correctCoupledBoundaryConditions(fvMesh& mesh)
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
typename GeoField::Patch& pfld = bfld[patchi];
const label patchi = patchSchedule[patchEvali].patch;
auto& pfld = bfld[patchi];
//if (pfld.coupled())
//if (isA<CoupledPatchType>(pfld))
if (pfld.patch().coupled())
{
if (patchSchedule[patchEvali].init)
......@@ -869,7 +861,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
{
// Create 0 sized mesh to do all the generation of zero sized
// fields on processors that have zero sized meshes. Note that this is
// only nessecary on master but since polyMesh construction with
// only necessary on master but since polyMesh construction with
// Pstream::parRun does parallel comms we have to do it on all
// processors
autoPtr<fvMeshSubset> subsetterPtr;
......@@ -1695,7 +1687,7 @@ void reconstructMeshFields
(
const parFvFieldReconstructor& fvReconstructor,
const IOobjectList& objects,
const HashSet<word>& selectedFields
const wordHashSet& selectedFields
)
{
// Dimensioned fields
......@@ -1792,7 +1784,7 @@ void reconstructLagrangian
const fvMesh& baseMesh,
const fvMesh& mesh,
const mapDistributePolyMesh& distMap,
const HashSet<word>& selectedLagrangianFields
const wordHashSet& selectedLagrangianFields
)
{
// Clouds (note: might not be present on all processors)
......@@ -1820,62 +1812,62 @@ void reconstructLagrangian
const parLagrangianRedistributor& lagrangianReconstructor =
lagrangianReconstructorPtr();
forAll(cloudNames, i)
for (const word& cloudName : cloudNames)
{
Info<< "Reconstructing lagrangian fields for cloud "
<< cloudNames[i] << nl << endl;
<< cloudName << nl << endl;
autoPtr<mapDistributeBase> lagrangianMap =
lagrangianReconstructor.redistributeLagrangianPositions
(
cloudNames[i]
cloudName
);
IOobjectList sprayObjs
(
mesh,
mesh.time().timeName(),
cloud::prefix/cloudNames[i]
cloud::prefix/cloudName
);
lagrangianReconstructor.redistributeLagrangianFields<label>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<label>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<scalar>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<scalar>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<vector>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<vector>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
......@@ -1883,7 +1875,7 @@ void reconstructLagrangian
<sphericalTensor>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
......@@ -1891,14 +1883,14 @@ void reconstructLagrangian
<sphericalTensor>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<symmTensor>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
......@@ -1906,21 +1898,21 @@ void reconstructLagrangian
<symmTensor>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFields<tensor>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
lagrangianReconstructor.redistributeLagrangianFieldFields<tensor>
(
lagrangianMap,
cloudNames[i],
cloudName,
sprayObjs,
selectedLagrangianFields
);
......@@ -1928,12 +1920,13 @@ void reconstructLagrangian
}
}
// Read clouds (note: might not be present on all processors)
void readLagrangian
(
const fvMesh& mesh,
const wordList& cloudNames,
const HashSet<word>& selectedLagrangianFields,
const wordHashSet& selectedLagrangianFields,
PtrList<unmappedPassivePositionParticleCloud>& clouds
)
{
......@@ -2313,8 +2306,8 @@ int main(int argc, char *argv[])
}
const HashSet<word> selectedFields(0);
const HashSet<word> selectedLagrangianFields(0);
const wordHashSet selectedFields(0);
const wordHashSet selectedLagrangianFields(0);
if (decompose)
......@@ -2462,7 +2455,7 @@ int main(int argc, char *argv[])
);
HashSet<word> masterTimeDirSet;
wordHashSet masterTimeDirSet;
if (newTimes)
{
instantList baseTimeDirs(baseRunTime.times());
......
......@@ -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) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -29,7 +29,7 @@ template<class CloudType>
Foam::IOPosition<CloudType>::IOPosition
(
const CloudType& c,
const cloud::geometryType& geomType
cloud::geometryType geomType
)
:
regIOobject
......
......@@ -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) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -25,7 +25,7 @@ Class
Foam::IOPosition
Description
Helper IO class to read and write particle positions
Helper IO class to read and write particle coordinates (positions).
SourceFiles
IOPosition.C
......@@ -77,8 +77,7 @@ public:
IOPosition
(
const CloudType& c,
const cloud::geometryType& geomType
= cloud::geometryType::COORDINATES
cloud::geometryType geomType = cloud::geometryType::COORDINATES
);
......
Markdown is supported
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