diff --git a/applications/solvers/incompressible/boundaryFoam/evaluateNearWall.H b/applications/solvers/incompressible/boundaryFoam/evaluateNearWall.H index b9683b9e68..8844f21e6e 100644 --- a/applications/solvers/incompressible/boundaryFoam/evaluateNearWall.H +++ b/applications/solvers/incompressible/boundaryFoam/evaluateNearWall.H @@ -7,8 +7,7 @@ scalar epsilon = turbulence->epsilon()()[cellId]; // scalar omega = turbulence->omega()()[cellId]; scalar k = turbulence->k()()[cellId]; - scalar Up = - flowDirection & (U[cellId] - U.boundaryField()[patchId][faceId]); + scalar magUp = mag(U[cellId] - U.boundaryField()[patchId][faceId]); scalar tauw = flowDirection & R & wallNormal; @@ -16,7 +15,7 @@ scalar yPlus = uTau*y[cellId]/(nu + ROOTVSMALL); - scalar uPlus = Up/(uTau + ROOTVSMALL); + scalar uPlus = magUp/(uTau + ROOTVSMALL); scalar nutPlus = nut/nu; @@ -26,7 +25,7 @@ // scalar omegaPlus = omega*nu/(sqr(uTau) + ROOTVSMALL); - scalar Rey = Up*y[cellId]/nu; + scalar Rey = magUp*y[cellId]/nu; Info<< "Rey = " << Rey << ", uTau = " << uTau << ", nut+ = " << nutPlus << ", y+ = " << yPlus << ", u+ = " << uPlus diff --git a/applications/solvers/incompressible/simpleFoam/UEqn.H b/applications/solvers/incompressible/simpleFoam/UEqn.H index 9f9d9f6dd4..eb40b7665b 100644 --- a/applications/solvers/incompressible/simpleFoam/UEqn.H +++ b/applications/solvers/incompressible/simpleFoam/UEqn.H @@ -14,4 +14,3 @@ ).initialResidual(); maxResidual = max(eqnResidual, maxResidual); - diff --git a/applications/solvers/multiphase/settlingFoam/createFields.H b/applications/solvers/multiphase/settlingFoam/createFields.H index 6acb19994a..a085aebb37 100644 --- a/applications/solvers/multiphase/settlingFoam/createFields.H +++ b/applications/solvers/multiphase/settlingFoam/createFields.H @@ -56,20 +56,11 @@ ); - dimensionedScalar rhoc - ( - transportProperties.lookup("rhoc") - ); + dimensionedScalar rhoc(transportProperties.lookup("rhoc")); - dimensionedScalar rhod - ( - transportProperties.lookup("rhod") - ); + dimensionedScalar rhod(transportProperties.lookup("rhod")); - dimensionedScalar muc - ( - transportProperties.lookup("muc") - ); + dimensionedScalar muc(transportProperties.lookup("muc")); dimensionedScalar plasticViscosityCoeff ( @@ -96,10 +87,7 @@ transportProperties.lookup("yieldStressOffset") ); - Switch BinghamPlastic - ( - transportProperties.lookup("BinghamPlastic") - ); + Switch BinghamPlastic(transportProperties.lookup("BinghamPlastic")); volScalarField rho ( @@ -147,8 +135,8 @@ IOobject::NO_READ, IOobject::AUTO_WRITE ), - muc + - plasticViscosity + muc + + plasticViscosity ( plasticViscosityCoeff, plasticViscosityExponent, @@ -176,10 +164,7 @@ Info<< "Selecting Drift-Flux model " << endl; - word VdjModel - ( - transportProperties.lookup("VdjModel") - ); + word VdjModel(transportProperties.lookup("VdjModel")); Info<< tab << VdjModel << " selected\n" << endl; @@ -188,26 +173,13 @@ transportProperties.subDict(VdjModel + "Coeffs") ); - dimensionedVector V0 - ( - VdjModelCoeffs.lookup("V0") - ); + dimensionedVector V0(VdjModelCoeffs.lookup("V0")); - dimensionedScalar a - ( - VdjModelCoeffs.lookup("a") - ); + dimensionedScalar a(VdjModelCoeffs.lookup("a")); - dimensionedScalar a1 - ( - VdjModelCoeffs.lookup("a1") - ); - - dimensionedScalar alphaMin - ( - VdjModelCoeffs.lookup("alphaMin") - ); + dimensionedScalar a1(VdjModelCoeffs.lookup("a1")); + dimensionedScalar alphaMin(VdjModelCoeffs.lookup("alphaMin")); IOdictionary RASProperties @@ -223,15 +195,9 @@ ); - Switch turbulence - ( - RASProperties.lookup("turbulence") - ); + Switch turbulence(RASProperties.lookup("turbulence")); - dictionary kEpsilonDict - ( - RASProperties.subDictPtr("kEpsilonCoeffs") - ); + dictionary kEpsilonDict(RASProperties.subDictPtr("kEpsilonCoeffs")); dimensionedScalar Cmu ( @@ -273,30 +239,27 @@ ) ); - dimensionedScalar alphak + dimensionedScalar sigmak ( dimensionedScalar::lookupOrAddToDict ( - "alphaEps", + "sigmak", kEpsilonDict, 1.0 ) ); - dimensionedScalar alphaEps + dimensionedScalar sigmaEps ( dimensionedScalar::lookupOrAddToDict ( - "alphaEps", + "sigmaEps", kEpsilonDict, - 0.76923 + 1.3 ) ); - dictionary wallFunctionDict - ( - RASProperties.subDictPtr("wallFunctionCoeffs") - ); + dictionary wallFunctionDict(RASProperties.subDictPtr("wallFunctionCoeffs")); dimensionedScalar kappa ( diff --git a/applications/solvers/multiphase/settlingFoam/kEpsilon.H b/applications/solvers/multiphase/settlingFoam/kEpsilon.H index 742fcde708..522a9afac7 100644 --- a/applications/solvers/multiphase/settlingFoam/kEpsilon.H +++ b/applications/solvers/multiphase/settlingFoam/kEpsilon.H @@ -1,4 +1,4 @@ -if(turbulence) +if (turbulence) { if (mesh.changing()) { @@ -15,9 +15,9 @@ if(turbulence) tgradU.clear(); volScalarField Gcoef = - alphak*Cmu*k*(g & fvc::grad(rho))/(epsilon + epsilon0); + Cmu*k/sigmak*(g & fvc::grad(rho))/(epsilon + epsilon0); -# include "wallFunctions.H" + #include "wallFunctions.H" // Dissipation equation fvScalarMatrix epsEqn @@ -26,7 +26,7 @@ if(turbulence) + fvm::div(phi, epsilon) - fvm::laplacian ( - alphaEps*mut + mul, epsilon, + mut/sigmaEps + mul, epsilon, "laplacian(DepsilonEff,epsilon)" ) == @@ -35,7 +35,7 @@ if(turbulence) - fvm::Sp(C2*rho*epsilon/k, epsilon) ); -# include "wallDissipation.H" + #include "wallDissipation.H" epsEqn.relax(); epsEqn.solve(); @@ -51,7 +51,7 @@ if(turbulence) + fvm::div(phi, k) - fvm::laplacian ( - alphak*mut + mul, k, + mut/sigmak + mul, k, "laplacian(DkEff,k)" ) == @@ -66,7 +66,7 @@ if(turbulence) //- Re-calculate viscosity mut = rho*Cmu*sqr(k)/(epsilon + epsilon0); -# include "wallViscosity.H" + #include "wallViscosity.H" } mu = mut + mul; diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H b/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H index 18b915b16b..c0daa0e7ca 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H @@ -12,6 +12,7 @@ - fvm::laplacian(muEff, U) - (fvc::grad(U) & fvc::grad(muEff)) //- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + //- fvc::div(rho*turbulence->nuEff()*dev(fvc::grad(U)().T())) ); if (oCorr == nOuterCorr-1) diff --git a/applications/test/extendedStencil/testExtendedStencil.C b/applications/test/extendedStencil/testExtendedStencil.C index b8db2b89bf..876576b29e 100644 --- a/applications/test/extendedStencil/testExtendedStencil.C +++ b/applications/test/extendedStencil/testExtendedStencil.C @@ -34,7 +34,7 @@ Description #include "fvMesh.H" #include "volFields.H" #include "Time.H" -#include "mapDistribute.H" +//#include "mapDistribute.H" #include "OFstream.H" #include "meshTools.H" //#include "FECCellToFaceStencil.H" diff --git a/applications/test/parallel/parallelTest.C b/applications/test/parallel/parallelTest.C index bf8440ece6..6120de31a5 100644 --- a/applications/test/parallel/parallelTest.C +++ b/applications/test/parallel/parallelTest.C @@ -23,19 +23,23 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - icoFoam + parallelTest Description - Incompressible laminar CFD code. + Test for various parallel routines. \*---------------------------------------------------------------------------*/ +#include "List.H" +#include "mapDistribute.H" #include "argList.H" #include "Time.H" #include "IPstream.H" #include "OPstream.H" #include "vector.H" #include "IOstreams.H" +#include "Random.H" +#include "Tuple2.H" using namespace Foam; @@ -47,6 +51,99 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" + + // Test mapDistribute + // ~~~~~~~~~~~~~~~~~~ + + if (false) + { + Random rndGen(43544*Pstream::myProcNo()); + + // Generate random data. + List > > complexData(100); + forAll(complexData, i) + { + complexData[i].first() = rndGen.integer(0, Pstream::nProcs()-1); + complexData[i].second().setSize(3); + complexData[i].second()[0] = 1; + complexData[i].second()[1] = 2; + complexData[i].second()[2] = 3; + } + + // Send all ones to processor indicated by .first() + + + // Count how many to send + labelList nSend(Pstream::nProcs(), 0); + forAll(complexData, i) + { + label procI = complexData[i].first(); + nSend[procI]++; + } + + // Sync how many to send + labelListList allNTrans(Pstream::nProcs()); + allNTrans[Pstream::myProcNo()] = nSend; + combineReduce(allNTrans, mapDistribute::listEq()); + + // Collect items to be sent + labelListList sendMap(Pstream::nProcs()); + forAll(sendMap, procI) + { + sendMap[procI].setSize(nSend[procI]); + } + nSend = 0; + forAll(complexData, i) + { + label procI = complexData[i].first(); + sendMap[procI][nSend[procI]++] = i; + } + + // Collect items to be received + labelListList recvMap(Pstream::nProcs()); + forAll(recvMap, procI) + { + recvMap[procI].setSize(allNTrans[procI][Pstream::myProcNo()]); + } + + label constructSize = 0; + // Construct with my own elements first + forAll(recvMap[Pstream::myProcNo()], i) + { + recvMap[Pstream::myProcNo()][i] = constructSize++; + } + // Construct from other processors + forAll(recvMap, procI) + { + if (procI != Pstream::myProcNo()) + { + forAll(recvMap[procI], i) + { + recvMap[procI][i] = constructSize++; + } + } + } + + + + // Construct distribute map (destructively) + mapDistribute map(constructSize, sendMap.xfer(), recvMap.xfer()); + + // Distribute complexData + mapDistribute::distribute + ( + Pstream::nonBlocking, + List(), + map.constructSize(), + map.subMap(), + map.constructMap(), + complexData + ); + + Pout<< "complexData:" << complexData << endl; + } + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Perr<< "\nStarting transfers\n" << endl; @@ -60,13 +157,13 @@ int main(int argc, char *argv[]) { Perr<< "slave sending to master " << Pstream::masterNo() << endl; - OPstream toMaster(Pstream::masterNo()); + OPstream toMaster(Pstream::blocking, Pstream::masterNo()); toMaster << data; } Perr<< "slave receiving from master " << Pstream::masterNo() << endl; - IPstream fromMaster(Pstream::masterNo()); + IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); fromMaster >> data; Perr<< data << endl; @@ -81,7 +178,7 @@ int main(int argc, char *argv[]) ) { Perr << "master receiving from slave " << slave << endl; - IPstream fromSlave(slave); + IPstream fromSlave(Pstream::blocking, slave); fromSlave >> data; Perr<< data << endl; @@ -95,7 +192,7 @@ int main(int argc, char *argv[]) ) { Perr << "master sending to slave " << slave << endl; - OPstream toSlave(slave); + OPstream toSlave(Pstream::blocking, slave); toSlave << data; } } diff --git a/applications/utilities/mesh/generation/blockMesh/createMergeList.C b/applications/utilities/mesh/generation/blockMesh/createMergeList.C index 551b9eec67..b46317652d 100644 --- a/applications/utilities/mesh/generation/blockMesh/createMergeList.C +++ b/applications/utilities/mesh/generation/blockMesh/createMergeList.C @@ -30,7 +30,7 @@ License Foam::labelList Foam::blockMesh::createMergeList() { - Info<< nl << "Creating merge list " << flush; + Info<< nl << "Creating merge list" << flush; labelList MergeList(nPoints_, -1); diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatchDict b/applications/utilities/mesh/manipulation/createPatch/createPatchDict index 2ab9a8b3cc..9704392a10 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatchDict +++ b/applications/utilities/mesh/manipulation/createPatch/createPatchDict @@ -53,18 +53,18 @@ patches name sidePatches; // Type of new patch - dictionary - { + dictionary + { type cyclic; - // Optional: explicitly set transformation tensor. + // Optional: explicitly set transformation tensor. // Used when matching and synchronising points. //transform translational; //separationVector (-2289 0 0); - transform rotational; - rotationAxis (1 0 0); + transform rotational; + rotationAxis (1 0 0); rotationCentre (0 0 0); - } + } // How to construct: either from 'patches' or 'set' constructFrom patches; @@ -80,10 +80,10 @@ patches name bottom; // Type of new patch - dictionary - { + dictionary + { type wall; - } + } constructFrom set; diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index 859ddf20a2..a5adac74e8 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -105,6 +105,8 @@ int main(int argc, char *argv[]) Foam::argList::validOptions.insert("overwrite", ""); + Foam::argList::validOptions.insert("toleranceDict", "file with tolerances"); + # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); @@ -168,6 +170,22 @@ int main(int argc, char *argv[]) << "If this is not the case use the -partial option" << nl << endl; } + // set up the tolerances for the sliding mesh + dictionary slidingTolerances; + if (args.options().found("toleranceDict")) + { + IOdictionary toleranceFile( + IOobject( + args.options()["toleranceDict"], + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + slidingTolerances += toleranceFile; + } + // Check for non-empty master and slave patches checkPatch(mesh.boundaryMesh(), masterPatchName); checkPatch(mesh.boundaryMesh(), slavePatchName); @@ -320,6 +338,11 @@ int main(int argc, char *argv[]) true // couple/decouple mode ) ); + static_cast(stitcher[0]).setTolerances + ( + slidingTolerances, + true + ); } diff --git a/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C b/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C index aa26a0e0c0..fcf090caa8 100644 --- a/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C +++ b/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - sigma.component(tensor::XX) + sigma.component(symmTensor::XX) ); sigmaxx.write(); @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - sigma.component(tensor::YY) + sigma.component(symmTensor::YY) ); sigmayy.write(); @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - sigma.component(tensor::ZZ) + sigma.component(symmTensor::ZZ) ); sigmazz.write(); @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - sigma.component(tensor::XY) + sigma.component(symmTensor::XY) ); sigmaxy.write(); @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - sigma.component(tensor::XZ) + sigma.component(symmTensor::XZ) ); sigmaxz.write(); @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - sigma.component(tensor::YZ) + sigma.component(symmTensor::YZ) ); sigmayz.write(); @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) mesh, IOobject::NO_READ ), - 0.0*sigma.component(tensor::YZ) + 0.0*sigma.component(symmTensor::YZ) ); forAll(sigmaUn.boundaryField(), patchI) diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index 6ff9bbce18..e8e441b165 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -72,10 +72,12 @@ namespace Foam int main(int argc, char *argv[]) { -# include "addRegionOption.H" -# include "setRootCase.H" -# include "createTime.H" -# include "createNamedMesh.H" + argList::validOptions.insert("instance", "instance"); + #include "addRegionOption.H" + + #include "setRootCase.H" + #include "createTime.H" + #include "createNamedMesh.H" fileName regionPrefix = ""; if (regionName != fvMesh::defaultRegion) @@ -83,6 +85,12 @@ int main(int argc, char *argv[]) regionPrefix = regionName; } + word instance = runTime.timeName(); + if (args.options().found("instance")) + { + instance = args.options()["instance"]; + } + // Get the replacement rules from a dictionary IOdictionary dict ( @@ -196,12 +204,13 @@ int main(int argc, char *argv[]) Info<< "Loading dictionary " << fieldName << endl; const word oldTypeName = IOdictionary::typeName; const_cast(IOdictionary::typeName) = word::null; + IOdictionary fieldDict ( IOobject ( fieldName, - runTime.timeName(), + instance, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, diff --git a/applications/utilities/surface/surfaceAdd/surfaceAdd.C b/applications/utilities/surface/surfaceAdd/surfaceAdd.C index 6441486cd1..587461d403 100644 --- a/applications/utilities/surface/surfaceAdd/surfaceAdd.C +++ b/applications/utilities/surface/surfaceAdd/surfaceAdd.C @@ -158,45 +158,33 @@ int main(int argc, char *argv[]) label trianglei = 0; - label maxRegion1 = labelMin; // Copy triangles1 into trianglesAll - // Determine max region. - forAll(surface1, faceI) { - facesAll[trianglei] = surface1[faceI]; - - maxRegion1 = max(maxRegion1, facesAll[trianglei].region()); - - trianglei++; + facesAll[trianglei++] = surface1[faceI]; } + label nRegions1 = surface1.patches().size(); - label nRegions1 = maxRegion1 + 1; if (!mergeRegions) { - Info<< "Surface " << inFileName1 << " has " << nRegions1 << " regions" + Info<< "Surface " << inFileName1 << " has " << nRegions1 + << " regions" << nl << "All region numbers in " << inFileName2 << " will be offset" << " by this amount" << nl << endl; } // Add (renumbered) surface2 triangles - label maxRegion2 = labelMin; - forAll(surface2, faceI) { const labelledTri& tri = surface2[faceI]; labelledTri& destTri = facesAll[trianglei++]; - destTri[0] = tri[0] + points1.size(); destTri[1] = tri[1] + points1.size(); destTri[2] = tri[2] + points1.size(); - - maxRegion2 = max(maxRegion2, tri.region()); - if (mergeRegions) { destTri.region() = tri.region(); @@ -207,7 +195,7 @@ int main(int argc, char *argv[]) } } - label nRegions2 = maxRegion2 + 1; + label nRegions2 = surface2.patches().size(); geometricSurfacePatchList newPatches; @@ -218,11 +206,11 @@ int main(int argc, char *argv[]) forAll(surface1.patches(), patchI) { - newPatches[patchI] = surface1.patches()[ patchI]; + newPatches[patchI] = surface1.patches()[patchI]; } forAll(surface2.patches(), patchI) { - newPatches[patchI] = surface2.patches()[ patchI]; + newPatches[patchI] = surface2.patches()[patchI]; } } else @@ -244,12 +232,12 @@ int main(int argc, char *argv[]) forAll(surface1.patches(), patchI) { - newPatches[newPatchI++] = surface1.patches()[ patchI]; + newPatches[newPatchI++] = surface1.patches()[patchI]; } forAll(surface2.patches(), patchI) { - newPatches[newPatchI++] = surface2.patches()[ patchI]; + newPatches[newPatchI++] = surface2.patches()[patchI]; } } diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubsetDict b/applications/utilities/surface/surfaceSubset/surfaceSubsetDict index ed06d0a39c..3a8db2cffd 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubsetDict +++ b/applications/utilities/surface/surfaceSubset/surfaceSubsetDict @@ -16,7 +16,7 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Select triangles by label -faces (); +faces #include "badFaces"; // Select triangles using given points (local point numbering) localPoints ( ); diff --git a/bin/foamLog b/bin/foamLog index 7490978c6e..06b2a2c5dc 100755 --- a/bin/foamLog +++ b/bin/foamLog @@ -58,9 +58,9 @@ cat <_, for every specified, for every occurrence inside @@ -69,7 +69,7 @@ a time step. For variables that are 'Solved for', the initial residual name will be , the final residual receive the name FinalRes, -The files are a simple xy format with the first column Time (default) +The files are output in a simple xy format with the first column Time (default) and the second the extracted values. Option -n creates single column files with the extracted data only. @@ -82,6 +82,7 @@ separated with '/' : The value taken will be the first (non-space)word after this column. The database ($PROGNAME.db) will taken from these locations: + . $HOME/.OpenFOAM/$WM_PROJECT_VERSION $HOME/.OpenFOAM $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION @@ -98,6 +99,7 @@ LABHELP # The various places to be searched: for i in \ + . \ $HOME/.OpenFOAM/$WM_PROJECT_VERSION \ $HOME/.OpenFOAM \ $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION \ @@ -114,7 +116,6 @@ do done - myEcho() { if [ "$VERBOSE" ] then @@ -171,6 +172,7 @@ getSolveQueryList() { done } + # getAllQueries dbFile logFile # Gets all queries from database and from logfile getAllQueries() { @@ -202,6 +204,7 @@ getAllQueries() { done | sort -u } + #----------------------------- # Main #----------------------------- @@ -314,8 +317,6 @@ myEcho "" # Generate Awk program #----------------------------- - - #-- header rm -f $AWKFILE; touch $AWKFILE @@ -355,9 +356,6 @@ function extract(inLine,columnSel,outVar, LABEL - - - #-- Generate code for iteration separator (increments 'Iteration') getQueries $DBFILE 'Separator' cat <> $AWKFILE @@ -418,6 +416,7 @@ cat <> $AWKFILE LABSOLVE + #-- generate code to process queries for queryName in $QUERYNAMES do @@ -438,7 +437,6 @@ do done - #----------------------------- # Run awk program on log #----------------------------- @@ -454,5 +452,6 @@ done #----------------------------- myEcho "Generated XY files for:" getAllQueries $DBFILE $LOG +myEcho "End" #------------------------------------------------------------------------------ diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index e608e4695b..7bff2143ec 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -345,6 +345,9 @@ $(globalMeshData)/globalIndex.C $(polyMesh)/syncTools/syncTools.C +zone = $(polyMesh)/zones/zone +$(zone)/zone.C + cellZone = $(polyMesh)/zones/cellZone $(cellZone)/cellZone.C $(cellZone)/newCellZone.C diff --git a/src/OpenFOAM/algorithms/MeshWave/MeshWave.C b/src/OpenFOAM/algorithms/MeshWave/MeshWave.C index 30538359ab..5049fe05a7 100644 --- a/src/OpenFOAM/algorithms/MeshWave/MeshWave.C +++ b/src/OpenFOAM/algorithms/MeshWave/MeshWave.C @@ -22,22 +22,10 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "MeshWave.H" #include "polyMesh.H" -#include "processorPolyPatch.H" -#include "cyclicPolyPatch.H" -#include "OPstream.H" -#include "IPstream.H" -#include "PstreamReduceOps.H" -#include "debug.H" -#include "typeInfo.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 08422fd9ba..fb6d9a0678 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -162,13 +162,14 @@ Foam::List::List(const UList& a, const unallocLabelList& map) { if (this->size_) { + // Note:cannot use List_ELEM since third argument has to be index. + this->v_ = new T[this->size_]; - List_ACCESS(T, (*this), vp); - List_CONST_ACCESS(T, a, ap); - List_FOR_ALL(map, i) - List_ELEM((*this), vp, i) = List_ELEM(a, ap, (map[i])); - List_END_FOR_ALL + forAll(*this, i) + { + this->v_[i] = a[map[i]]; + } } } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index 8f1ebc754d..d98d75d076 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C @@ -45,38 +45,44 @@ char Foam::ISstream::nextValid() // Return if stream is bad - ie, previous get() failed if (bad() || isspace(c)) { - return 0; + break; } // Is this the start of a C/C++ comment? if (c == '/') { - // If cannot get another character, return this one if (!get(c)) { + // cannot get another character - return this one return '/'; } if (c == '/') { - // This is the start of a C++ style one-line comment + // C++ style single-line comment - skip through past end-of-line while (get(c) && c != '\n') {} } else if (c == '*') { - // This is the start of a C style comment + // within a C-style comment while (true) { + // search for end of C-style comment - '*/' if (get(c) && c == '*') { - if (get(c) && c == '/') + if (get(c)) { - break; - } - else - { - putback(c); + if (c == '/') + { + // matched '*/' + break; + } + else if (c == '*') + { + // check again + putback(c); + } } } @@ -86,17 +92,21 @@ char Foam::ISstream::nextValid() } } } - else // A lone '/' so return it. + else { + // The '/' did not start a C/C++ comment - return it putback(c); return '/'; } } - else // c is a valid character so return it + else { + // a valid character - return it return c; } } + + return 0; } @@ -277,8 +287,8 @@ Foam::Istream& Foam::ISstream::read(token& t) // } } - // nothing converted (bad format), or trailing junk - if (endptr == buf || *endptr != '\0') + // not everything converted: bad format or trailing junk + if (*endptr) { t.setBad(); } @@ -289,7 +299,7 @@ Foam::Istream& Foam::ISstream::read(token& t) } - // Should be a word (which can be a single character) + // Should be a word (which can also be a single character) default: { putback(c); diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index fa9b3e6a91..f0c67306be 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -127,11 +127,10 @@ void Foam::Time::setControls() } else { - WarningIn("Time::setControls()") - << " expected startTime, firstTime or latestTime" - << " found '" << startFrom - << "' in dictionary " << controlDict_.name() << nl - << " Setting time to " << startTime_ << endl; + FatalIOErrorIn("Time::setControls()", controlDict_) + << "expected startTime, firstTime or latestTime" + << " found '" << startFrom << "'" + << exit(FatalIOError); } } @@ -151,10 +150,10 @@ void Foam::Time::setControls() > Pstream::nProcs()*deltaT_/10.0 ) { - FatalErrorIn("Time::setControls()") + FatalIOErrorIn("Time::setControls()", controlDict_) << "Start time is not the same for all processors" << nl << "processor " << Pstream::myProcNo() << " has startTime " - << startTime_ << exit(FatalError); + << startTime_ << exit(FatalIOError); } } diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 73a753157e..845b852e95 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -117,6 +117,10 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv) // get rootPath_ / globalCase_ from one of the following forms // * [-case dir] // * cwd +// +// Also export FOAM_CASE and FOAM_CASENAME environment variables +// so they can be used immediately (eg, in decomposeParDict) +// void Foam::argList::getRootCase() { fileName casePath; @@ -151,6 +155,26 @@ void Foam::argList::getRootCase() rootPath_ = casePath.path(); globalCase_ = casePath.name(); case_ = globalCase_; + + + // Set the case and case-name as an environment variable + if (rootPath_[0] == '/') + { + // absolute path - use as-is + setEnv("FOAM_CASE", rootPath_/globalCase_, true); + setEnv("FOAM_CASENAME", globalCase_, true); + } + else + { + // qualify relative path + fileName casePath = cwd()/rootPath_/globalCase_; + casePath.clean(); + + setEnv("FOAM_CASE", casePath, true); + setEnv("FOAM_CASENAME", casePath.name(), true); + } + + } @@ -531,24 +555,6 @@ Foam::argList::argList } jobInfo.write(); - - // Set the case and case-name as an environment variable - if (rootPath_[0] == '/') - { - // absolute path - use as-is - setEnv("FOAM_CASE", rootPath_/globalCase_, true); - setEnv("FOAM_CASENAME", globalCase_, true); - } - else - { - // qualify relative path - fileName casePath = cwd()/rootPath_/globalCase_; - casePath.clean(); - - setEnv("FOAM_CASE", casePath, true); - setEnv("FOAM_CASENAME", casePath.name(), true); - } - // Switch on signal trapping. We have to wait until after Pstream::init // since this sets up its own ones. sigFpe_.set(bannerEnabled); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index cc4278e221..e2c2dbf773 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -172,8 +172,8 @@ const Foam::List& Foam::mapDistribute::schedule() const Foam::mapDistribute::mapDistribute ( const label constructSize, - const labelListList& subMap, - const labelListList& constructMap + const Xfer& subMap, + const Xfer& constructMap ) : constructSize_(constructSize), @@ -183,22 +183,6 @@ Foam::mapDistribute::mapDistribute {} -//- (optionally destructively) construct from components -Foam::mapDistribute::mapDistribute -( - const label constructSize, - labelListList& subMap, - labelListList& constructMap, - const bool reUse // clone or reuse -) -: - constructSize_(constructSize), - subMap_(subMap, reUse), - constructMap_(constructMap, reUse), - schedulePtr_() -{} - - Foam::mapDistribute::mapDistribute ( const labelList& sendProcs, @@ -286,7 +270,7 @@ Foam::mapDistribute::mapDistribute(const mapDistribute& map) void Foam::mapDistribute::compact(const boolList& elemIsUsed) { - // 1. send back to sender. Have him delete the corresponding element + // 1. send back to sender. Have sender delete the corresponding element // from the submap and do the same to the constructMap locally // (and in same order). diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index d2cfe64ca5..c6962355fd 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -83,23 +83,36 @@ class mapDistribute public: + // Public classes + + //- combineReduce operator for lists. Used for counting. + class listEq + { + + public: + + template + void operator()(T& x, const T& y) const + { + forAll(y, i) + { + if (y[i].size()) + { + x[i] = y[i]; + } + } + } + }; + + // Constructors //- Construct from components mapDistribute ( const label constructSize, - const labelListList& subMap, - const labelListList& constructMap - ); - - //- (optionally destructively) construct from components - mapDistribute - ( - const label constructSize, - labelListList& subMap, - labelListList& constructMap, - const bool reUse // clone or reuse + const Xfer& subMap, + const Xfer& constructMap ); //- Construct from reverse addressing: per data item the send @@ -205,11 +218,7 @@ public: template void distribute(List& fld) const { - if - ( - Pstream::defaultCommsType == Pstream::nonBlocking - && contiguous() - ) + if (Pstream::defaultCommsType == Pstream::nonBlocking) { distribute ( diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeLagrangian.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeLagrangian.H index 5782308d19..ce05673908 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeLagrangian.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeLagrangian.H @@ -68,35 +68,15 @@ public: mapDistributeLagrangian ( const label nNewParticles, - const labelListList& subParticleMap, - const labelListList& constructParticleMap, - const labelListList& constructCellLabels + const Xfer& subParticleMap, + const Xfer& constructParticleMap, + const Xfer& constructCellLabels ) : particleMap_(nNewParticles, subParticleMap, constructParticleMap), constructCellLabels_(constructCellLabels) {} - //- Construct from components and steal storage - mapDistributeLagrangian - ( - const label nNewParticles, - labelListList& subParticleMap, - labelListList& constructParticleMap, - labelListList& constructCellLabels, - const bool reUse - ) - : - particleMap_ - ( - nNewParticles, - subParticleMap, - constructParticleMap, - reUse - ), - constructCellLabels_(constructCellLabels, reUse) - {} - // Member Functions diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.C index a5e4f16341..29649665b4 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.C @@ -66,27 +66,27 @@ Foam::mapDistributePolyMesh::mapDistributePolyMesh const label nOldPoints, const label nOldFaces, const label nOldCells, - const labelList& oldPatchStarts, - const labelList& oldPatchNMeshPoints, + const Xfer& oldPatchStarts, + const Xfer& oldPatchNMeshPoints, // how to subset pieces of mesh to send across - const labelListList& subPointMap, - const labelListList& subFaceMap, - const labelListList& subCellMap, - const labelListList& subPatchMap, + const Xfer& subPointMap, + const Xfer& subFaceMap, + const Xfer& subCellMap, + const Xfer& subPatchMap, // how to reconstruct received mesh - const labelListList& constructPointMap, - const labelListList& constructFaceMap, - const labelListList& constructCellMap, - const labelListList& constructPatchMap + const Xfer& constructPointMap, + const Xfer& constructFaceMap, + const Xfer& constructCellMap, + const Xfer& constructPatchMap ) : mesh_(mesh), nOldPoints_(nOldPoints), nOldFaces_(nOldFaces), nOldCells_(nOldCells), - oldPatchSizes_(oldPatchStarts.size()), + oldPatchSizes_(oldPatchStarts().size()), oldPatchStarts_(oldPatchStarts), oldPatchNMeshPoints_(oldPatchNMeshPoints), pointMap_(mesh.nPoints(), subPointMap, constructPointMap), @@ -98,44 +98,6 @@ Foam::mapDistributePolyMesh::mapDistributePolyMesh } -//- (optionally destructively) construct from components -Foam::mapDistributePolyMesh::mapDistributePolyMesh -( - const polyMesh& mesh, - const label nOldPoints, - const label nOldFaces, - const label nOldCells, - labelList& oldPatchStarts, - labelList& oldPatchNMeshPoints, - - labelListList& subPointMap, - labelListList& subFaceMap, - labelListList& subCellMap, - labelListList& subPatchMap, - labelListList& constructPointMap, - labelListList& constructFaceMap, - labelListList& constructCellMap, - labelListList& constructPatchMap, - const bool reUse // clone or reuse -) -: - mesh_(mesh), - nOldPoints_(nOldPoints), - nOldFaces_(nOldFaces), - nOldCells_(nOldCells), - oldPatchSizes_(oldPatchStarts.size()), - oldPatchStarts_(oldPatchStarts, reUse), - oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse), - - pointMap_(mesh.nPoints(), subPointMap, constructPointMap, reUse), - faceMap_(mesh.nFaces(), subFaceMap, constructFaceMap, reUse), - cellMap_(mesh.nCells(), subCellMap, constructCellMap, reUse), - patchMap_(mesh.boundaryMesh().size(), subPatchMap, constructPatchMap, reUse) -{ - calcPatchSizes(); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst) const diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.H index bf5857170b..8fdfe7e8fb 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributePolyMesh.H @@ -120,42 +120,20 @@ public: const label nOldPoints, const label nOldFaces, const label nOldCells, - const labelList& oldPatchStarts, - const labelList& oldPatchNMeshPoints, + const Xfer& oldPatchStarts, + const Xfer& oldPatchNMeshPoints, // how to subset pieces of mesh to send across - const labelListList& subPointMap, - const labelListList& subFaceMap, - const labelListList& subCellMap, - const labelListList& subPatchMap, + const Xfer& subPointMap, + const Xfer& subFaceMap, + const Xfer& subCellMap, + const Xfer& subPatchMap, // how to reconstruct received mesh - const labelListList& constructPointMap, - const labelListList& constructFaceMap, - const labelListList& constructCellMap, - const labelListList& constructPatchMap - ); - - //- (optionally destructively) construct from components - // Note that mesh has to be changed already! - mapDistributePolyMesh - ( - const polyMesh& mesh, - const label nOldPoints, - const label nOldFaces, - const label nOldCells, - labelList& oldPatchStarts, - labelList& oldPatchNMeshPoints, - - labelListList& subPointMap, - labelListList& subFaceMap, - labelListList& subCellMap, - labelListList& subPatchMap, - labelListList& constructPointMap, - labelListList& constructFaceMap, - labelListList& constructCellMap, - labelListList& constructPatchMap, - const bool reUse // clone or reuse + const Xfer& constructPointMap, + const Xfer& constructFaceMap, + const Xfer& constructCellMap, + const Xfer& constructPatchMap ); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 5f5d7a9fcf..da1ed19d1e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -25,6 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "Pstream.H" +#include "PstreamCombineReduceOps.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -184,138 +185,269 @@ void Foam::mapDistribute::distribute { if (!contiguous()) { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Non-blocking only supported for contiguous data." - << exit(FatalError); - } + // 1. convert to contiguous buffer + // 2. send buffer + // 3. receive buffer + // 4. read from buffer into List - // Set up sends to neighbours + List > sendFields(Pstream::nProcs()); + labelListList allNTrans(Pstream::nProcs()); + labelList& nsTransPs = allNTrans[Pstream::myProcNo()]; + nsTransPs.setSize(Pstream::nProcs(), 0); - List > sendFields(Pstream::nProcs()); - - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = subMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) + // Stream data into sendField buffers + for (label domain = 0; domain < Pstream::nProcs(); domain++) { - List& subField = sendFields[domain]; + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + // Put data into send buffer + OPstream toDomain(Pstream::nonBlocking, domain); + toDomain << UIndirectList(field, map); + + // Store the size + nsTransPs[domain] = toDomain.bufPosition(); + + // Transfer buffer out + sendFields[domain].transfer(toDomain.buf()); + toDomain.bufPosition() = 0; + + } + } + + // Send sizes across + combineReduce(allNTrans, listEq()); + + // Start sending buffers + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + OPstream::write + ( + Pstream::nonBlocking, + domain, + reinterpret_cast + ( + sendFields[domain].begin() + ), + nsTransPs[domain] + ); + } + } + + // Set up receives from neighbours + + PtrList fromSlave(Pstream::nProcs()); + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + // Start receiving + fromSlave.set + ( + domain, + new IPstream + ( + Pstream::nonBlocking, + domain, + allNTrans[domain][Pstream::myProcNo()] + ) + ); + } + } + + + { + // Set up 'send' to myself + const labelList& mySubMap = subMap[Pstream::myProcNo()]; + List mySubField(mySubMap.size()); + forAll(mySubMap, i) + { + mySubField[i] = field[mySubMap[i]]; + } + // Combine bits. Note that can reuse field storage + field.setSize(constructSize); + // Receive sub field from myself + { + const labelList& map = constructMap[Pstream::myProcNo()]; + + forAll(map, i) + { + field[map[i]] = mySubField[i]; + } + } + } + + + // Wait till all finished + IPstream::waitRequests(); + OPstream::waitRequests(); + + // Consume + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + List recvField(fromSlave[domain]); + + if (recvField.size() != map.size()) + { + FatalErrorIn + ( + "template\n" + "void mapDistribute::distribute\n" + "(\n" + " const Pstream::commsTypes commsType,\n" + " const List& schedule,\n" + " const label constructSize,\n" + " const labelListList& subMap,\n" + " const labelListList& constructMap,\n" + " List& field\n" + ")\n" + ) << "Expected from processor " << domain + << " " << map.size() << " but received " + << recvField.size() << " elements." + << abort(FatalError); + } + + forAll(map, i) + { + field[map[i]] = recvField[i]; + } + + // Delete receive buffer + fromSlave.set(domain, NULL); + } + } + } + else + { + // Set up sends to neighbours + + List > sendFields(Pstream::nProcs()); + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + List& subField = sendFields[domain]; + subField.setSize(map.size()); + forAll(map, i) + { + subField[i] = field[map[i]]; + } + + OPstream::write + ( + Pstream::nonBlocking, + domain, + reinterpret_cast(subField.begin()), + subField.byteSize() + ); + } + } + + // Set up receives from neighbours + + List > recvFields(Pstream::nProcs()); + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + recvFields[domain].setSize(map.size()); + IPstream::read + ( + Pstream::nonBlocking, + domain, + reinterpret_cast(recvFields[domain].begin()), + recvFields[domain].byteSize() + ); + } + } + + + // Set up 'send' to myself + + { + const labelList& map = subMap[Pstream::myProcNo()]; + + List& subField = sendFields[Pstream::myProcNo()]; subField.setSize(map.size()); forAll(map, i) { subField[i] = field[map[i]]; } - - OPstream::write - ( - Pstream::nonBlocking, - domain, - reinterpret_cast(subField.begin()), - subField.size()*sizeof(T) - ); } - } - // Set up receives from neighbours - List > recvFields(Pstream::nProcs()); + // Combine bits. Note that can reuse field storage - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = constructMap[domain]; + field.setSize(constructSize); - if (domain != Pstream::myProcNo() && map.size()) + + // Receive sub field from myself (sendFields[Pstream::myProcNo()]) { - recvFields[domain].setSize(map.size()); - IPstream::read - ( - Pstream::nonBlocking, - domain, - reinterpret_cast(recvFields[domain].begin()), - recvFields[domain].size()*sizeof(T) - ); - } - } - - - // Set up 'send' to myself - - { - const labelList& map = subMap[Pstream::myProcNo()]; - - List& subField = sendFields[Pstream::myProcNo()]; - subField.setSize(map.size()); - forAll(map, i) - { - subField[i] = field[map[i]]; - } - } - - - // Combine bits. Note that can reuse field storage - - field.setSize(constructSize); - - - // Receive sub field from myself (sendFields[Pstream::myProcNo()]) - { - const labelList& map = constructMap[Pstream::myProcNo()]; - const List& subField = sendFields[Pstream::myProcNo()]; - - forAll(map, i) - { - field[map[i]] = subField[i]; - } - } - - - // Wait for all to finish - - OPstream::waitRequests(); - IPstream::waitRequests(); - - // Collect neighbour fields - - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = constructMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) - { - if (recvFields[domain].size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << recvFields[domain].size() << " elements." - << abort(FatalError); - } + const labelList& map = constructMap[Pstream::myProcNo()]; + const List& subField = sendFields[Pstream::myProcNo()]; forAll(map, i) { - field[map[i]] = recvFields[domain][i]; + field[map[i]] = subField[i]; + } + } + + + // Wait for all to finish + + OPstream::waitRequests(); + IPstream::waitRequests(); + + // Collect neighbour fields + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + if (recvFields[domain].size() != map.size()) + { + FatalErrorIn + ( + "template\n" + "void mapDistribute::distribute\n" + "(\n" + " const Pstream::commsTypes commsType,\n" + " const List& schedule,\n" + " const label constructSize,\n" + " const labelListList& subMap,\n" + " const labelListList& constructMap,\n" + " List& field\n" + ")\n" + ) << "Expected from processor " << domain + << " " << map.size() << " but received " + << recvFields[domain].size() << " elements." + << abort(FatalError); + } + + forAll(map, i) + { + field[map[i]] = recvFields[domain][i]; + } } } } @@ -488,137 +620,263 @@ void Foam::mapDistribute::distribute { if (!contiguous()) { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Non-blocking only supported for contiguous data." - << exit(FatalError); - } + // 1. convert to contiguous buffer + // 2. send buffer + // 3. receive buffer + // 4. read from buffer into List - // Set up sends to neighbours + List > sendFields(Pstream::nProcs()); + labelListList allNTrans(Pstream::nProcs()); + labelList& nsTransPs = allNTrans[Pstream::myProcNo()]; + nsTransPs.setSize(Pstream::nProcs()); - List > sendFields(Pstream::nProcs()); - - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = subMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) + // Stream data into sendField buffers + for (label domain = 0; domain < Pstream::nProcs(); domain++) { - List& subField = sendFields[domain]; + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + // Put data into send buffer + OPstream toDomain(Pstream::nonBlocking, domain); + toDomain << UIndirectList(field, map); + + // Store the size + nsTransPs[domain] = toDomain.bufPosition(); + + // Transfer buffer out + sendFields[domain].transfer(toDomain.buf()); + toDomain.bufPosition() = 0; + } + } + + // Send sizes across + combineReduce(allNTrans, listEq()); + + // Start sending buffers + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + OPstream::write + ( + Pstream::nonBlocking, + domain, + reinterpret_cast + ( + sendFields[domain].begin() + ), + nsTransPs[domain] + ); + } + } + + // Set up receives from neighbours + + PtrList fromSlave(Pstream::nProcs()); + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + // Start receiving + fromSlave.set + ( + domain, + new IPstream + ( + Pstream::nonBlocking, + domain, + allNTrans[domain][Pstream::myProcNo()] + ) + ); + } + } + + + { + // Set up 'send' to myself + List mySubField(field, subMap[Pstream::myProcNo()]); + // Combine bits. Note that can reuse field storage + field.setSize(constructSize); + field = nullValue; + // Receive sub field from myself + { + const labelList& map = constructMap[Pstream::myProcNo()]; + + forAll(map, i) + { + cop(field[map[i]], mySubField[i]); + } + } + } + + + // Wait till all finished + IPstream::waitRequests(); + OPstream::waitRequests(); + + // Consume + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + List recvField(fromSlave[domain]); + + if (recvField.size() != map.size()) + { + FatalErrorIn + ( + "template\n" + "void mapDistribute::distribute\n" + "(\n" + " const Pstream::commsTypes commsType,\n" + " const List& schedule,\n" + " const label constructSize,\n" + " const labelListList& subMap,\n" + " const labelListList& constructMap,\n" + " List& field\n" + ")\n" + ) << "Expected from processor " << domain + << " " << map.size() << " but received " + << recvField.size() << " elements." + << abort(FatalError); + } + + forAll(map, i) + { + cop(field[map[i]], recvField[i]); + } + + // Delete receive buffer + fromSlave.set(domain, NULL); + } + } + } + else + { + // Set up sends to neighbours + + List > sendFields(Pstream::nProcs()); + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = subMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + List& subField = sendFields[domain]; + subField.setSize(map.size()); + forAll(map, i) + { + subField[i] = field[map[i]]; + } + + OPstream::write + ( + Pstream::nonBlocking, + domain, + reinterpret_cast(subField.begin()), + subField.size()*sizeof(T) + ); + } + } + + // Set up receives from neighbours + + List > recvFields(Pstream::nProcs()); + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + recvFields[domain].setSize(map.size()); + IPstream::read + ( + Pstream::nonBlocking, + domain, + reinterpret_cast(recvFields[domain].begin()), + recvFields[domain].size()*sizeof(T) + ); + } + } + + // Set up 'send' to myself + + { + const labelList& map = subMap[Pstream::myProcNo()]; + + List& subField = sendFields[Pstream::myProcNo()]; subField.setSize(map.size()); forAll(map, i) { subField[i] = field[map[i]]; } - - OPstream::write - ( - Pstream::nonBlocking, - domain, - reinterpret_cast(subField.begin()), - subField.size()*sizeof(T) - ); } - } - // Set up receives from neighbours - List > recvFields(Pstream::nProcs()); + // Combine bits. Note that can reuse field storage - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = constructMap[domain]; + field.setSize(constructSize); + field = nullValue; - if (domain != Pstream::myProcNo() && map.size()) + // Receive sub field from myself (subField) { - recvFields[domain].setSize(map.size()); - IPstream::read - ( - Pstream::nonBlocking, - domain, - reinterpret_cast(recvFields[domain].begin()), - recvFields[domain].size()*sizeof(T) - ); - } - } - - // Set up 'send' to myself - - { - const labelList& map = subMap[Pstream::myProcNo()]; - - List& subField = sendFields[Pstream::myProcNo()]; - subField.setSize(map.size()); - forAll(map, i) - { - subField[i] = field[map[i]]; - } - } - - - // Combine bits. Note that can reuse field storage - - field.setSize(constructSize); - field = nullValue; - - // Receive sub field from myself (subField) - { - const labelList& map = constructMap[Pstream::myProcNo()]; - const List& subField = sendFields[Pstream::myProcNo()]; - - forAll(map, i) - { - cop(field[map[i]], subField[i]); - } - } - - - // Wait for all to finish - - OPstream::waitRequests(); - IPstream::waitRequests(); - - // Collect neighbour fields - - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = constructMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) - { - if (recvFields[domain].size() != map.size()) - { - FatalErrorIn - ( - "template\n" - "void mapDistribute::distribute\n" - "(\n" - " const Pstream::commsTypes commsType,\n" - " const List& schedule,\n" - " const label constructSize,\n" - " const labelListList& subMap,\n" - " const labelListList& constructMap,\n" - " List& field\n" - ")\n" - ) << "Expected from processor " << domain - << " " << map.size() << " but received " - << recvFields[domain].size() << " elements." - << abort(FatalError); - } + const labelList& map = constructMap[Pstream::myProcNo()]; + const List& subField = sendFields[Pstream::myProcNo()]; forAll(map, i) { - cop(field[map[i]], recvFields[domain][i]); + cop(field[map[i]], subField[i]); + } + } + + + // Wait for all to finish + + OPstream::waitRequests(); + IPstream::waitRequests(); + + // Collect neighbour fields + + for (label domain = 0; domain < Pstream::nProcs(); domain++) + { + const labelList& map = constructMap[domain]; + + if (domain != Pstream::myProcNo() && map.size()) + { + if (recvFields[domain].size() != map.size()) + { + FatalErrorIn + ( + "template\n" + "void mapDistribute::distribute\n" + "(\n" + " const Pstream::commsTypes commsType,\n" + " const List& schedule,\n" + " const label constructSize,\n" + " const labelListList& subMap,\n" + " const labelListList& constructMap,\n" + " List& field\n" + ")\n" + ) << "Expected from processor " << domain + << " " << map.size() << " but received " + << recvFields[domain].size() << " elements." + << abort(FatalError); + } + + forAll(map, i) + { + cop(field[map[i]], recvFields[domain][i]); + } } } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 0b9c08b39e..265b61cc4b 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -1305,7 +1305,7 @@ bool Foam::cyclicPolyPatch::order { label baffleI = 0; - forAll(*this, faceI) + forAll(pp, faceI) { const face& f = pp.localFaces()[faceI]; const labelList& pFaces = pp.pointFaces()[f[0]]; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H index 5c98efd84a..b6800dceb6 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H @@ -114,6 +114,7 @@ public: return index_ > -1; } + // Edit //- Update diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C index ff8041fc60..a7672104da 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C @@ -22,9 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - A subset of mesh cells. - \*---------------------------------------------------------------------------*/ #include "cellZone.H" @@ -45,59 +42,9 @@ namespace Foam addToRunTimeSelectionTable(cellZone, cellZone, dictionary); } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -const Foam::Map& Foam::cellZone::cellLookupMap() const -{ - if (!cellLookupMapPtr_) - { - calcCellLookupMap(); - } - - return *cellLookupMapPtr_; -} - - -void Foam::cellZone::calcCellLookupMap() const -{ - if (debug) - { - Info<< "void cellZone::calcCellLookupMap() const : " - << "Calculating cell lookup map" - << endl; - } - - if (cellLookupMapPtr_) - { - FatalErrorIn - ( - "void cellZone::calcCellLookupMap() const" - ) << "cell lookup map already calculated" - << abort(FatalError); - } - - const labelList& addr = *this; - - cellLookupMapPtr_ = new Map