diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 4d0dc8dafd4161b134ed34f928f859c8d611cc70..7e0900da8cf16c325c5ccc217ef9ed70e2140273 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 2b0925c30ddac214ac1593d8c939d08dce3ef410..94e14fc58cdf6c2ed7389ee118fa9c998301fd98 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C @@ -432,7 +432,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshAdder::add constructFaceMap, constructPointMap ); - + fvMeshAdder::MapDimFields<scalar>(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields<vector>(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields<sphericalTensor>(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields<symmTensor>(fvMeshes, constructCellMap); + fvMeshAdder::MapDimFields<tensor>(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 45db30ae6d3f83a428fe77e1b3dcbea728ff40d5..5f534e3d86e70161101c60158f72da60699f44cb 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<fldType&>(*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<fldType&>(*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<Type> oldInternalField(flds[0].primitiveField()); + const Field<Type> oldInternalField(flds[0]); // Modify internal field - Field<Type>& intFld = flds[0].primitiveFieldRef(); + Field<Type>& 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<Type>& addFld = flds[meshi].primitiveFieldRef(); + const Field<Type>& addFld = flds[meshi]; intFld.rmap(addFld, cellProcAddressing[meshi]); } } @@ -1174,6 +1174,7 @@ void Foam::fvMeshAdder::MapDimFields ) { typedef DimensionedField<Type, volMesh> fldType; + typedef GeometricField<Type, fvPatchField, volMesh> 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(); + if (!isA<excludeType>(*fld)) + { + const word& name0 = fld->name(); - DebugPout - << "MapDimFields : mapping " << name0 << endl; + DebugPout + << "MapDimFields : mapping " << name0 << endl; - UPtrList<fldType> meshToField(meshes.size()); - forAll(meshes, meshi) - { - if (meshes.set(meshi)) + UPtrList<fldType> meshToField(meshes.size()); + forAll(meshes, meshi) { - auto& meshFld = meshes[meshi]. - objectRegistry::lookupObjectRef<fldType>(name0); - meshToField.set(meshi, &meshFld); + if (meshes.set(meshi)) + { + auto& meshFld = meshes[meshi]. + objectRegistry::lookupObjectRef<fldType>(name0); + meshToField.set(meshi, &meshFld); + } } - } - MapDimField(meshToField, cellProcAddressing, fullyMapped); + 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 23c5799651cd876b417fe09d0bbd74cdf3df7519..f753211b1814c8522945f6fa1d74d435bbd9b085 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -2017,11 +2017,36 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute getFieldNames<surfaceSymmTensorField>(mesh_, allFieldNames); getFieldNames<surfaceTensorField>(mesh_, allFieldNames); - getFieldNames<volScalarField::Internal>(mesh_, allFieldNames); - getFieldNames<volVectorField::Internal>(mesh_, allFieldNames); - getFieldNames<volSphericalTensorField::Internal>(mesh_, allFieldNames); - getFieldNames<volSymmTensorField::Internal>(mesh_, allFieldNames); - getFieldNames<volTensorField::Internal>(mesh_, allFieldNames); + getFieldNames<volScalarField::Internal> + ( + mesh_, + allFieldNames, + volScalarField::typeName + ); + getFieldNames<volVectorField::Internal> + ( + mesh_, + allFieldNames, + volVectorField::typeName + ); + getFieldNames<volSphericalTensorField::Internal> + ( + mesh_, + allFieldNames, + volSphericalTensorField::typeName + ); + getFieldNames<volSymmTensorField::Internal> + ( + mesh_, + allFieldNames, + volSymmTensorField::typeName + ); + getFieldNames<volTensorField::Internal> + ( + mesh_, + allFieldNames, + volTensorField::typeName + ); // Find patch to temporarily put exposed and processor faces into. @@ -2072,6 +2097,11 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute printFieldInfo<surfaceSphericalTensorField>(mesh_); printFieldInfo<surfaceSymmTensorField>(mesh_); printFieldInfo<surfaceTensorField>(mesh_); + printIntFieldInfo<volScalarField::Internal>(mesh_); + printIntFieldInfo<volVectorField::Internal>(mesh_); + printIntFieldInfo<volSphericalTensorField::Internal>(mesh_); + printIntFieldInfo<volSymmTensorField::Internal>(mesh_); + printIntFieldInfo<volTensorField::Internal>(mesh_); Pout<< nl << endl; } @@ -2430,6 +2460,11 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute printFieldInfo<surfaceSphericalTensorField>(mesh_); printFieldInfo<surfaceSymmTensorField>(mesh_); printFieldInfo<surfaceTensorField>(mesh_); + printIntFieldInfo<volScalarField::Internal>(mesh_); + printIntFieldInfo<volVectorField::Internal>(mesh_); + printIntFieldInfo<volSphericalTensorField::Internal>(mesh_); + printIntFieldInfo<volSymmTensorField::Internal>(mesh_); + printIntFieldInfo<volTensorField::Internal>(mesh_); Pout<< nl << endl; } @@ -2804,6 +2839,11 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute printFieldInfo<surfaceSphericalTensorField>(mesh_); printFieldInfo<surfaceSymmTensorField>(mesh_); printFieldInfo<surfaceTensorField>(mesh_); + printIntFieldInfo<volScalarField::Internal>(mesh_); + printIntFieldInfo<volVectorField::Internal>(mesh_); + printIntFieldInfo<volSphericalTensorField::Internal>(mesh_); + printIntFieldInfo<volSymmTensorField::Internal>(mesh_); + printIntFieldInfo<volTensorField::Internal>(mesh_); Pout<< nl << endl; } @@ -2915,6 +2955,11 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute printFieldInfo<surfaceSphericalTensorField>(mesh_); printFieldInfo<surfaceSymmTensorField>(mesh_); printFieldInfo<surfaceTensorField>(mesh_); + printIntFieldInfo<volScalarField::Internal>(mesh_); + printIntFieldInfo<volVectorField::Internal>(mesh_); + printIntFieldInfo<volSphericalTensorField::Internal>(mesh_); + printIntFieldInfo<volSymmTensorField::Internal>(mesh_); + printIntFieldInfo<volTensorField::Internal>(mesh_); Pout<< nl << endl; } @@ -3000,6 +3045,11 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute printFieldInfo<surfaceSphericalTensorField>(mesh_); printFieldInfo<surfaceSymmTensorField>(mesh_); printFieldInfo<surfaceTensorField>(mesh_); + printIntFieldInfo<volScalarField::Internal>(mesh_); + printIntFieldInfo<volVectorField::Internal>(mesh_); + printIntFieldInfo<volSphericalTensorField::Internal>(mesh_); + printIntFieldInfo<volSymmTensorField::Internal>(mesh_); + printIntFieldInfo<volTensorField::Internal>(mesh_); Pout<< nl << endl; } diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H index bbdf6fe3dfa4d13dac13e94c49a88aa8313087cb..1c4c7d518a1863c390c99efdebafb4d5331eb6e5 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<class GeoField> - void correctBoundaryConditions(); + ////- Call correctBoundaryConditions on fields + //template<class GeoField> + //void correctBoundaryConditions(); //- Delete all processor patches. Move any processor faces into // patchi. @@ -306,6 +306,7 @@ class fvMeshDistribute ( const fvMesh& mesh, HashTable<wordList>& allFieldNames, + const word& excludeType = word::null, const bool syncPar = true ); @@ -384,6 +385,10 @@ public: const labelList& ); + //- Print some field info + template<class GeoField> + static void printIntFieldInfo(const fvMesh&); + //- Print some field info template<class GeoField> static void printFieldInfo(const fvMesh&); diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C index f735afd4e3f961816b12fb78756c88cbd40f3af9..ab7395d6651ad8f8ca625956a154a22e2424f0b9 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<class GeoField> +void Foam::fvMeshDistribute::printIntFieldInfo(const fvMesh& mesh) +{ + typedef GeometricField + < + typename GeoField::value_type, + fvPatchField, + volMesh + > excludeType; + + const HashTable<const GeoField*> flds + ( + mesh.objectRegistry::lookupClass<GeoField>() + ); + + forAllConstIters(flds, iter) + { + const GeoField& fld = *iter(); + if (!isA<excludeType>(fld)) + { + Pout<< "Field:" << iter.key() << " internalsize:" << fld.size() + //<< " value:" << fld + << endl; + } + } +} + + template<class GeoField> void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh) { - HashTable<const GeoField*> flds + const HashTable<const GeoField*> flds ( mesh.objectRegistry::lookupClass<GeoField>() ); @@ -270,22 +298,22 @@ void Foam::fvMeshDistribute::initPatchFields } -template<class GeoField> -void Foam::fvMeshDistribute::correctBoundaryConditions() -{ - // CorrectBoundaryConditions patch fields of certain type - - HashTable<GeoField*> flds - ( - mesh_.objectRegistry::lookupClass<GeoField>() - ); - - forAllIters(flds, iter) - { - GeoField& fld = *iter(); - fld.correctBoundaryConditions(); - } -} +//template<class GeoField> +//void Foam::fvMeshDistribute::correctBoundaryConditions() +//{ +// // CorrectBoundaryConditions patch fields of certain type +// +// HashTable<GeoField*> flds +// ( +// mesh_.objectRegistry::lookupClass<GeoField>() +// ); +// +// forAllIters(flds, iter) +// { +// GeoField& fld = *iter(); +// fld.correctBoundaryConditions(); +// } +//} template<class GeoField> @@ -293,12 +321,32 @@ void Foam::fvMeshDistribute::getFieldNames ( const fvMesh& mesh, HashTable<wordList>& allFieldNames, + const word& excludeType, const bool syncPar ) { wordList& list = allFieldNames(GeoField::typeName); list = mesh.sortedNames<GeoField>(); + if (!excludeType.empty()) + { + const wordList& excludeList = allFieldNames(excludeType); + + DynamicList<word> 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; }