diff --git a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructor.H b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructor.H index 29e3673127..9c0d0617b9 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructor.H +++ b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructor.H @@ -152,7 +152,7 @@ public: void reconstructFvVolumeInternalFields ( const IOobjectList& objects, - const HashSet& 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& 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& selectedFields + const wordHashSet& selectedFields ) const; //- Helper: reconstruct and write mesh points diff --git a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C index c561dc7183..4ea05d956a 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C +++ b/applications/utilities/parallelProcessing/redistributePar/parFvFieldReconstructorReconstructFields.C @@ -420,7 +420,7 @@ template void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields ( const IOobjectList& objects, - const HashSet& selectedFields + const wordHashSet& selectedFields ) const { const word& fieldClassName = DimensionedField::typeName; @@ -461,7 +461,7 @@ template void Foam::parFvFieldReconstructor::reconstructFvVolumeFields ( const IOobjectList& objects, - const HashSet& selectedFields + const wordHashSet& selectedFields ) const { const word& fieldClassName = @@ -504,7 +504,7 @@ template void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields ( const IOobjectList& objects, - const HashSet& selectedFields + const wordHashSet& selectedFields ) const { const word& fieldClassName = diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C index ed6c7579b2..9407439476 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C @@ -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(lagrangianPositions).write(); + // Optionally write positions file in v1706 format and earlier + if (particle::writeLagrangianPositions) + { + IOPosition + ( + 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]; diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H index f7d1c226cb..3dc1e85ce0 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H @@ -126,7 +126,7 @@ public: static wordList filterObjects ( const IOobjectList& objects, - const HashSet& 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& 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& 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& selectedFields + const wordHashSet& selectedFields ); //- Redistribute and write stored lagrangian fields diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C index 6dc7e5dbe2..2e34a71a60 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C @@ -37,7 +37,7 @@ template Foam::wordList Foam::parLagrangianRedistributor::filterObjects ( const IOobjectList& objects, - const HashSet& 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& 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& selectedFields + const wordHashSet& selectedFields ) const { wordList objectNames @@ -225,7 +225,7 @@ void Foam::parLagrangianRedistributor::readLagrangianFields ( const passivePositionParticleCloud& cloud, const IOobjectList& objects, - const HashSet& selectedFields + const wordHashSet& selectedFields ) { const wordList objectNames diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 42ebadb05c..b082a260de 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -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 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(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(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(pfld)) if (pfld.patch().coupled()) { if (patchSchedule[patchEvali].init) @@ -869,7 +861,7 @@ autoPtr 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 subsetterPtr; @@ -1695,7 +1687,7 @@ void reconstructMeshFields ( const parFvFieldReconstructor& fvReconstructor, const IOobjectList& objects, - const HashSet& selectedFields + const wordHashSet& selectedFields ) { // Dimensioned fields @@ -1792,7 +1784,7 @@ void reconstructLagrangian const fvMesh& baseMesh, const fvMesh& mesh, const mapDistributePolyMesh& distMap, - const HashSet& 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 lagrangianMap = lagrangianReconstructor.redistributeLagrangianPositions ( - cloudNames[i] + cloudName ); IOobjectList sprayObjs ( mesh, mesh.time().timeName(), - cloud::prefix/cloudNames[i] + cloud::prefix/cloudName ); lagrangianReconstructor.redistributeLagrangianFields