diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 4d0dc8dafd..7e0900da8c 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -2407,9 +2407,12 @@ int main(int argc, char *argv[]) else { // Directory does not exist. If this happens on master -> decompose mode - decompose = true; - Info<< "No processor directories; switching on decompose mode" - << nl << endl; + if (Pstream::master()) + { + decompose = true; + Info<< "No processor directories; switching on decompose mode" + << nl << endl; + } } // If master changed to decompose mode make sure all nodes know about it Pstream::scatter(decompose); @@ -2421,20 +2424,19 @@ int main(int argc, char *argv[]) // e.g. latestTime will pick up a different time (which causes createTime.H // to abort). So for now make sure to have master times on all // processors - if (!procDir.empty()) { Info<< "Creating time directories on all processors" << nl << endl; instantList timeDirs; if (Pstream::master()) { const bool oldParRun = Pstream::parRun(false); - timeDirs = Time::findTimes(procDir, "constant"); + timeDirs = Time::findTimes(args.path(), "constant"); Pstream::parRun(oldParRun); // Restore parallel state } Pstream::scatter(timeDirs); for (const instant& t : timeDirs) { - mkDir(procDir/t.name()); + mkDir(args.path()/t.name()); } } diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C index 2b0925c30d..94e14fc58c 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C @@ -432,7 +432,11 @@ Foam::autoPtr Foam::fvMeshAdder::add constructFaceMap, constructPointMap ); - + fvMeshAdder::MapDimFields(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields(fvMeshes, constructCellMap); // Swap returned data back to processor order if (myProci != 0) diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C index 45db30ae6d..5f534e3d86 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C @@ -292,8 +292,7 @@ void Foam::fvMeshAdder::MapVolFields fldType& fld = const_cast(*fieldIter()); DebugPout - << "MapVolFields : Storing old time for " << fld.name() - << endl; + << "MapVolFields : Storing old time for " << fld.name() << endl; fld.storeOldTimes(); } @@ -317,8 +316,7 @@ void Foam::fvMeshAdder::MapVolFields { WarningInFunction << "Not mapping field " << fld.name() - << " since not present on mesh to add" - << endl; + << " since not present on mesh to add" << endl; } } } @@ -604,8 +602,7 @@ void Foam::fvMeshAdder::MapSurfaceFields fldType& fld = const_cast(*fieldIter()); DebugPout - << "MapSurfaceFields : Storing old time for " - << fld.name() << endl; + << "MapSurfaceFields : Storing old time for " << fld.name() << endl; fld.storeOldTimes(); } @@ -629,8 +626,7 @@ void Foam::fvMeshAdder::MapSurfaceFields { WarningInFunction << "Not mapping field " << fld.name() - << " since not present on mesh to add" - << endl; + << " since not present on mesh to add" << endl; } } } @@ -697,8 +693,7 @@ void Foam::fvMeshAdder::MapDimFields { WarningInFunction << "Not mapping field " << fld.name() - << " since not present on mesh to add" - << endl; + << " since not present on mesh to add" << endl; } } } @@ -717,7 +712,12 @@ void Foam::fvMeshAdder::MapDimField // Add fields to fields[0] after adding the meshes to meshes[0]. // Mesh[0] is the sum of all meshes. Fields are not yet mapped. - if (flds.size() == 0 || !flds.set(0)) + if + ( + flds.size() == 0 + || !flds.set(0) + || cellProcAddressing.size() != flds.size() + ) { FatalErrorInFunction << "Not valid field at element 0" << " in field list of size " << flds.size() << exit(FatalError); @@ -729,10 +729,10 @@ void Foam::fvMeshAdder::MapDimField { // Store old internal field - const Field oldInternalField(flds[0].primitiveField()); + const Field oldInternalField(flds[0]); // Modify internal field - Field& intFld = flds[0].primitiveFieldRef(); + Field& intFld = flds[0]; // Set to new mesh size intFld.setSize(flds[0].mesh().nCells()); @@ -743,7 +743,7 @@ void Foam::fvMeshAdder::MapDimField { if (flds.set(meshi)) { - const Field& addFld = flds[meshi].primitiveFieldRef(); + const Field& addFld = flds[meshi]; intFld.rmap(addFld, cellProcAddressing[meshi]); } } @@ -1174,6 +1174,7 @@ void Foam::fvMeshAdder::MapDimFields ) { typedef DimensionedField fldType; + typedef GeometricField excludeType; if (meshes.size() == 0 || !meshes.set(0)) { @@ -1190,23 +1191,31 @@ void Foam::fvMeshAdder::MapDimFields for (const auto& fld : fields) { - const word& name0 = fld->name(); - - DebugPout - << "MapDimFields : mapping " << name0 << endl; - - UPtrList meshToField(meshes.size()); - forAll(meshes, meshi) + if (!isA(*fld)) { - if (meshes.set(meshi)) - { - auto& meshFld = meshes[meshi]. - objectRegistry::lookupObjectRef(name0); - meshToField.set(meshi, &meshFld); - } - } + const word& name0 = fld->name(); - MapDimField(meshToField, cellProcAddressing, fullyMapped); + DebugPout + << "MapDimFields : mapping " << name0 << endl; + + UPtrList meshToField(meshes.size()); + forAll(meshes, meshi) + { + if (meshes.set(meshi)) + { + auto& meshFld = meshes[meshi]. + objectRegistry::lookupObjectRef(name0); + meshToField.set(meshi, &meshFld); + } + } + + MapDimField(meshToField, cellProcAddressing, fullyMapped); + } + else + { + DebugPout + << "MapDimFields : ignoring " << fld->name() << endl; + } } } diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C index 23c5799651..f753211b18 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -2017,11 +2017,36 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute getFieldNames(mesh_, allFieldNames); getFieldNames(mesh_, allFieldNames); - getFieldNames(mesh_, allFieldNames); - getFieldNames(mesh_, allFieldNames); - getFieldNames(mesh_, allFieldNames); - getFieldNames(mesh_, allFieldNames); - getFieldNames(mesh_, allFieldNames); + getFieldNames + ( + mesh_, + allFieldNames, + volScalarField::typeName + ); + getFieldNames + ( + mesh_, + allFieldNames, + volVectorField::typeName + ); + getFieldNames + ( + mesh_, + allFieldNames, + volSphericalTensorField::typeName + ); + getFieldNames + ( + mesh_, + allFieldNames, + volSymmTensorField::typeName + ); + getFieldNames + ( + mesh_, + allFieldNames, + volTensorField::typeName + ); // Find patch to temporarily put exposed and processor faces into. @@ -2072,6 +2097,11 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute printFieldInfo(mesh_); printFieldInfo(mesh_); printFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); Pout<< nl << endl; } @@ -2430,6 +2460,11 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute printFieldInfo(mesh_); printFieldInfo(mesh_); printFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); Pout<< nl << endl; } @@ -2804,6 +2839,11 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute printFieldInfo(mesh_); printFieldInfo(mesh_); printFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); Pout<< nl << endl; } @@ -2915,6 +2955,11 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute printFieldInfo(mesh_); printFieldInfo(mesh_); printFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); Pout<< nl << endl; } @@ -3000,6 +3045,11 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute printFieldInfo(mesh_); printFieldInfo(mesh_); printFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); + printIntFieldInfo(mesh_); Pout<< nl << endl; } diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H index bbdf6fe3df..1c4c7d518a 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H @@ -137,9 +137,9 @@ class fvMeshDistribute const typename GeoField::value_type& initVal ); - //- Call correctBoundaryConditions on fields - template - void correctBoundaryConditions(); + ////- Call correctBoundaryConditions on fields + //template + //void correctBoundaryConditions(); //- Delete all processor patches. Move any processor faces into // patchi. @@ -306,6 +306,7 @@ class fvMeshDistribute ( const fvMesh& mesh, HashTable& allFieldNames, + const word& excludeType = word::null, const bool syncPar = true ); @@ -384,6 +385,10 @@ public: const labelList& ); + //- Print some field info + template + static void printIntFieldInfo(const fvMesh&); + //- Print some field info template static void printFieldInfo(const fvMesh&); diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C index f735afd4e3..ab7395d665 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,10 +30,38 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +template +void Foam::fvMeshDistribute::printIntFieldInfo(const fvMesh& mesh) +{ + typedef GeometricField + < + typename GeoField::value_type, + fvPatchField, + volMesh + > excludeType; + + const HashTable flds + ( + mesh.objectRegistry::lookupClass() + ); + + forAllConstIters(flds, iter) + { + const GeoField& fld = *iter(); + if (!isA(fld)) + { + Pout<< "Field:" << iter.key() << " internalsize:" << fld.size() + //<< " value:" << fld + << endl; + } + } +} + + template void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh) { - HashTable flds + const HashTable flds ( mesh.objectRegistry::lookupClass() ); @@ -270,22 +298,22 @@ void Foam::fvMeshDistribute::initPatchFields } -template -void Foam::fvMeshDistribute::correctBoundaryConditions() -{ - // CorrectBoundaryConditions patch fields of certain type - - HashTable flds - ( - mesh_.objectRegistry::lookupClass() - ); - - forAllIters(flds, iter) - { - GeoField& fld = *iter(); - fld.correctBoundaryConditions(); - } -} +//template +//void Foam::fvMeshDistribute::correctBoundaryConditions() +//{ +// // CorrectBoundaryConditions patch fields of certain type +// +// HashTable flds +// ( +// mesh_.objectRegistry::lookupClass() +// ); +// +// forAllIters(flds, iter) +// { +// GeoField& fld = *iter(); +// fld.correctBoundaryConditions(); +// } +//} template @@ -293,12 +321,32 @@ void Foam::fvMeshDistribute::getFieldNames ( const fvMesh& mesh, HashTable& allFieldNames, + const word& excludeType, const bool syncPar ) { wordList& list = allFieldNames(GeoField::typeName); list = mesh.sortedNames(); + if (!excludeType.empty()) + { + const wordList& excludeList = allFieldNames(excludeType); + + DynamicList newList(list.size()); + for(const auto& name : list) + { + if (!excludeList.found(name)) + { + newList.append(name); + } + } + if (newList.size() < list.size()) + { + list = std::move(newList); + } + } + + // Check all procs have same names if (syncPar) { @@ -363,7 +411,8 @@ void Foam::fvMeshDistribute::sendFields { if (debug) { - Pout<< "Subsetting field " << fieldName + Pout<< "Subsetting " << GeoField::typeName + << " field " << fieldName << " for domain:" << domain << endl; } @@ -406,7 +455,8 @@ void Foam::fvMeshDistribute::receiveFields if (debug) { - Pout<< "Receiving fields " << fieldNames + Pout<< "Receiving:" << GeoField::typeName + << " fields:" << fieldNames << " from domain:" << domain << endl; } @@ -417,7 +467,8 @@ void Foam::fvMeshDistribute::receiveFields { if (debug) { - Pout<< "Constructing field " << fieldName + Pout<< "Constructing type:" << GeoField::typeName + << " field:" << fieldName << " from domain:" << domain << endl; }