From 4da55e853fec1c4aaf68d871ff2607b5f12b6eac Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 10 Dec 2010 13:14:45 +0000 Subject: [PATCH 01/30] BUG: master-only-reading : did not transfer headerClassName --- .../redistributeMeshPar/redistributeMeshPar.C | 4 ---- .../db/IOobjects/IOdictionary/IOdictionary.C | 6 ++++++ src/OpenFOAM/db/regIOobject/regIOobjectRead.C | 6 ++++++ src/OpenFOAM/matrices/solution/solution.C | 15 +++++++++++++-- .../finiteVolume/fvSchemes/fvSchemes.C | 15 +++++++++++++-- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C b/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C index b870e9efab..f51ebafb87 100644 --- a/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C +++ b/applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C @@ -561,10 +561,6 @@ int main(int argc, char *argv[]) mkDir(args.path()); } - // Switch timeStamp checking to one which does not do any - // parallel sync for same reason - regIOobject::fileModificationChecking = regIOobject::timeStamp; - # include "createTime.H" diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C index 65276015fe..7192eb7f61 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C @@ -66,6 +66,11 @@ void Foam::IOdictionary::readFile(const bool masterOnly) : Pstream::treeCommunication() ); + // Master reads headerclassname from file. Make sure this gets + // transfered as well as contents. + word masterClassName = headerClassName(); + Pstream::scatter(comms, masterClassName); + // Get my communication order const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; @@ -89,6 +94,7 @@ void Foam::IOdictionary::readFile(const bool masterOnly) IOstream::ASCII ); IOdictionary::readData(fromAbove); + const_cast(headerClassName()) = masterClassName; } // Send to my downstairs neighbours diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index fcf53b985f..5802fec85f 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -201,6 +201,11 @@ bool Foam::regIOobject::read() : Pstream::treeCommunication() ); + // Master reads headerclassname from file. Make sure this gets + // transfered as well as contents. + word masterClassName = headerClassName(); + Pstream::scatter(comms, masterClassName); + // Get my communication order const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; @@ -226,6 +231,7 @@ bool Foam::regIOobject::read() IOstream::ASCII ); ok = readData(fromAbove); + const_cast(headerClassName()) = masterClassName; } // Send to my downstairs neighbours diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 610df5b8dd..c24ed33a60 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -84,7 +84,11 @@ Foam::solution::solution dictName, obr.time().system(), obr, - IOobject::MUST_READ_IF_MODIFIED, + ( + obr.readOpt() == IOobject::MUST_READ + ? IOobject::MUST_READ_IF_MODIFIED + : obr.readOpt() + ), IOobject::NO_WRITE ) ), @@ -94,7 +98,14 @@ Foam::solution::solution defaultRelaxationFactor_(0), solvers_(ITstream("solvers", tokenList())()) { - read(solutionDict()); + if + ( + readOpt() == IOobject::MUST_READ + || readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + { + read(solutionDict()); + } } diff --git a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C index cd786d09fa..a489b8c935 100644 --- a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C +++ b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C @@ -256,7 +256,11 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr) "fvSchemes", obr.time().system(), obr, - IOobject::MUST_READ_IF_MODIFIED, + ( + obr.readOpt() == IOobject::MUST_READ + ? IOobject::MUST_READ_IF_MODIFIED + : obr.readOpt() + ), IOobject::NO_WRITE ) ), @@ -364,7 +368,14 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr) // persistent settings across reads is incorrect clear(); - read(schemesDict()); + if + ( + readOpt() == IOobject::MUST_READ + || readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + { + read(schemesDict()); + } } From 572be798a6d64221fe1a5210b348206ac958676f Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 10 Dec 2010 13:17:06 +0000 Subject: [PATCH 02/30] ENH: snappyHexMesh : correct mesh instance --- .../autoHexMeshDriver/autoLayerDriver.C | 30 +------------------ .../meshRefinement/meshRefinement.C | 18 ++++++----- .../meshRefinement/meshRefinementBaffles.C | 20 ------------- .../meshRefinement/meshRefinementMerge.C | 10 ------- .../meshRefinement/meshRefinementRefine.C | 5 ---- 5 files changed, 12 insertions(+), 71 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 1d3219972c..68d1762993 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -159,11 +159,6 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo mesh.clearOut(); } - if (meshRefiner_.overwrite()) - { - mesh.setInstance(meshRefiner_.oldInstance()); - } - faceCombiner.updateMesh(map); meshRefiner_.updateMesh(map, labelList(0)); @@ -324,11 +319,6 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo mesh.clearOut(); } - if (meshRefiner_.overwrite()) - { - mesh.setInstance(meshRefiner_.oldInstance()); - } - faceCombiner.updateMesh(map); // Renumber restore maps @@ -396,11 +386,6 @@ Foam::autoPtr Foam::autoLayerDriver::doRemovePoints mesh.clearOut(); } - if (meshRefiner_.overwrite()) - { - mesh.setInstance(meshRefiner_.oldInstance()); - } - pointRemover.updateMesh(map); meshRefiner_.updateMesh(map, labelList(0)); @@ -454,11 +439,6 @@ Foam::autoPtr Foam::autoLayerDriver::doRestorePoints mesh.clearOut(); } - if (meshRefiner_.overwrite()) - { - mesh.setInstance(meshRefiner_.oldInstance()); - } - pointRemover.updateMesh(map); meshRefiner_.updateMesh(map, labelList(0)); @@ -3100,10 +3080,7 @@ void Foam::autoLayerDriver::addLayers //?neccesary? Update fields newMesh.updateMesh(map); - if (meshRefiner_.overwrite()) - { - newMesh.setInstance(meshRefiner_.oldInstance()); - } + newMesh.setInstance(meshRefiner_.timeName()); // Update numbering on addLayer: // - cell/point labels to be newMesh. @@ -3229,11 +3206,6 @@ void Foam::autoLayerDriver::addLayers mesh.clearOut(); } - if (meshRefiner_.overwrite()) - { - mesh.setInstance(meshRefiner_.oldInstance()); - } - meshRefiner_.updateMesh(map, labelList(0)); diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 512c651449..bcc98f1dff 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -481,11 +481,6 @@ Foam::autoPtr Foam::meshRefinement::doRemoveCells mesh_.clearOut(); } - if (overwrite_) - { - mesh_.setInstance(oldInstance_); - } - // Update local mesh data cellRemover.updateMesh(map); @@ -1903,9 +1898,14 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map) pointMap.clear(); } } + + // If necessary reset the instance + mesh_.setInstance(timeName()); + setInstance(mesh_.facesInstance()); } +// Update local data for a mesh change void Foam::meshRefinement::updateMesh ( const mapPolyMesh& map, @@ -2027,6 +2027,10 @@ void Foam::meshRefinement::updateMesh data.transfer(newFaceData); } } + + // If necessary reset the instance + mesh_.setInstance(timeName()); + setInstance(mesh_.facesInstance()); } @@ -2137,7 +2141,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const IOobject ( "cellLevel", - timeName(), + mesh_.time().timeName(),// Dump to current time, not to mesh inst mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE, @@ -2165,7 +2169,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const IOobject ( "pointLevel", - timeName(), + mesh_.time().timeName(),// Dump to current time, not to mesh inst mesh_, IOobject::NO_READ, IOobject::NO_WRITE, diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index a445ebf699..f43e4ab7e2 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -517,11 +517,6 @@ Foam::autoPtr Foam::meshRefinement::createBaffles mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - //- Redo the intersections on the newly create baffle faces. Note that // this changes also the cell centre positions. faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles); @@ -965,11 +960,6 @@ Foam::autoPtr Foam::meshRefinement::mergeBaffles mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - // Update intersections. Recalculate intersections on merged faces since // this seems to give problems? Note: should not be nessecary since // baffles preserve intersections from when they were created. @@ -2249,11 +2239,6 @@ Foam::autoPtr Foam::meshRefinement::dupNonManifoldPoints() mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - // Update intersections. Is mapping only (no faces created, positions stay // same) so no need to recalculate intersections. updateMesh(map, labelList(0)); @@ -2783,11 +2768,6 @@ Foam::autoPtr Foam::meshRefinement::zonify mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - // Print some stats (note: zones are synchronised) if (mesh_.cellZones().size() > 0) { diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C index 98dfe5aed5..c32446d3a2 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C @@ -103,11 +103,6 @@ Foam::label Foam::meshRefinement::mergePatchFaces mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - faceCombiner.updateMesh(map); // Get the kept faces that need to be recalculated. @@ -203,11 +198,6 @@ Foam::autoPtr Foam::meshRefinement::mergeEdges mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - pointRemover.updateMesh(map); // Get the kept faces that need to be recalculated. diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C index 98b0a34ae7..76c27d7d2b 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C @@ -1236,11 +1236,6 @@ Foam::autoPtr Foam::meshRefinement::refine mesh_.clearOut(); } - if (overwrite()) - { - mesh_.setInstance(oldInstance()); - } - // Update intersection info updateMesh(map, getChangedFaces(map, cellsToRefine)); From c025f7e0b282e9092f24e9246be1a47df4a034b1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 10 Dec 2010 13:17:56 +0000 Subject: [PATCH 03/30] STYLE: Particle interactionLists : added comment --- src/lagrangian/basic/InteractionLists/InteractionLists.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index 511fcc74d5..9fc4285f12 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -86,7 +86,8 @@ void Foam::InteractionLists::buildInteractionLists() // referred cells that they interact with. PackedBoolList cellInRangeOfCoupledPatch(mesh_.nCells(), false); - // IAndT: index and transform + // IAndT: index (=local cell index) and transform (from + // globalIndexAndTransform) DynamicList cellIAndTToExchange; DynamicList cellBbsToExchange; From 123de44f513db3597b9c2aea14ae119921cd294c Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 10 Dec 2010 16:04:13 +0000 Subject: [PATCH 04/30] ENH: windSimpleFoam tutorial update --- .../simpleFoam/windTurbineTerrain/0/U | 6 +- .../simpleFoam/windTurbineTerrain/0/epsilon | 2 +- .../simpleFoam/windTurbineTerrain/0/k | 5 +- .../simpleFoam/windTurbineTerrain/0/p | 5 +- .../simpleFoam/windTurbineTerrain/Allrun | 25 ++- .../simpleFoam/windTurbineTerrain/makeZones | 4 +- .../system/changeDictionaryDict | 201 ++++++++++++++++++ .../system/decomposeParDict | 28 +-- .../windTurbineTerrain/system/fvSolution | 60 +++--- 9 files changed, 270 insertions(+), 66 deletions(-) create mode 100644 tutorials/incompressible/simpleFoam/windTurbineTerrain/system/changeDictionaryDict diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/U b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/U index f23d0ce783..601a696b75 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/U +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/U @@ -46,13 +46,15 @@ boundaryField "terrain_.*" { - type fixedValue; + type uniformFixedValue; + uniformValue (0 0 0); value uniform (0 0 0); } ground { - type fixedValue; + type uniformFixedValue; + uniformValue (0 0 0); value uniform (0 0 0); } diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/epsilon b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/epsilon index a49793464e..2cbcbd2268 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/epsilon +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/epsilon @@ -23,7 +23,7 @@ internalField uniform $turbulentEpsilon; boundaryField { - #include "include/ABLConditions" + #include "include/ABLConditions" "terrain_.*" { diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/k b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/k index b42f64236c..79b7c087e8 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/k +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/k @@ -32,8 +32,9 @@ boundaryField } inlet { - type fixedValue; - value uniform $turbulentKE; + type uniformFixedValue; + uniformValue $turbulentKE; + value $turbulentKE; } "terrain_.*" { diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/p b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/p index 1449474a5e..add79aad34 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/p +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/0/p @@ -29,8 +29,9 @@ boundaryField outlet { - type fixedValue; - value $internalField; + type uniformFixedValue; + value uniform $pressure; + uniformValue $pressure; } "terrain_.*" diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/Allrun b/tutorials/incompressible/simpleFoam/windTurbineTerrain/Allrun index 7cd2a91b26..fbbdf2c04a 100755 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/Allrun +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/Allrun @@ -4,10 +4,27 @@ cd ${0%/*} || exit 1 # run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions +compileApplication windSimpleFoam + runApplication blockMesh -runApplication snappyHexMesh -overwrite -runApplication setSet -batch makeZones -runApplication setsToZones -noFlipMap -runApplication windSimpleFoam +runApplication decomposePar + +#runApplication snappyHexMesh -overwrite +#runApplication setSet -batch makeZones +#runApplication setsToZones -noFlipMap +#runApplication windSimpleFoam + +runParallel snappyHexMesh 2 -overwrite + +# Add wildcard entries for meshes patches since not preserved +# by decomposePar. Notice -literalRE option to add wildcard itself +# without evaluation. +runParallel changeDictionary 2 -literalRE + +runParallel setSet 2 -batch makeZones +runParallel windSimpleFoam 2 + +runApplication reconstructParMesh -constant +runApplication reconstructPar # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/makeZones b/tutorials/incompressible/simpleFoam/windTurbineTerrain/makeZones index dac135f004..e1f6bbc4c9 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/makeZones +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/makeZones @@ -1,2 +1,4 @@ cellSet actuationDisk1 new boxToCell (581850.5 4785805 1061) (581850.8 4785815 1071) -cellSet actuationDisk2 new boxToCell (581754 4785658 1065) (581754.4 4785668 1075) \ No newline at end of file +cellZoneSet actuationDisk1 new setToCellZone actuationDisk1 +cellSet actuationDisk2 new boxToCell (581754 4785658 1065) (581754.4 4785668 1075) +cellZoneSet actuationDisk2 new setToCellZone actuationDisk2 diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/changeDictionaryDict b/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/changeDictionaryDict new file mode 100644 index 0000000000..09a5e24c6a --- /dev/null +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/changeDictionaryDict @@ -0,0 +1,201 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Use absolute path to make sure it also works in parallel +#include "$FOAM_CASE/0/include/initialConditions" + +dictionaryReplacement +{ + + // Specify + // - all fvPatchFields with potential non-uniform values + // - all fvPatchFields originating from meshing + // - all fvPatchFields originating from mesh-redistribution + + p + { + boundaryField + { + outlet + { + type uniformFixedValue; + value $pressure; + uniformValue $pressure; + } + inlet + { + type zeroGradient; + } + "terrain_.*" + { + type zeroGradient; + } + ground + { + type zeroGradient; + } + #include "$FOAM_CASE/0/include/sideAndTopPatches" + "procBoundary.*" + { + type processor; + } + } + } + + k + { + boundaryField + { + outlet + { + type inletOutlet; + inletValue uniform 0.0; + value uniform $turbulentKE; + } + inlet + { + type uniformFixedValue; + uniformValue $turbulentKE; + } + "terrain_.*" + { + type kqRWallFunction; + value uniform 0.0; + } + ground + { + type zeroGradient; + } + #include "$FOAM_CASE/0/include/sideAndTopPatches" + "procBoundary.*" + { + type processor; + } + } + } + + U + { + boundaryField + { + outlet + { + type inletOutlet; + inletValue uniform (0 0 0); + value uniform $flowVelocity; + } + inlet + { + type atmBoundaryLayerInletVelocity; + Uref 10.0; + Href 20; + n (1 0 0); + z (0 0 1); + z0 0.1; + zGround 935.0; + value uniform $flowVelocity; + } + "terrain_.*" + { + type uniformFixedValue; + uniformValue $flowVelocity; + } + ground + { + type uniformFixedValue; + uniformValue $flowVelocity; + } + #include "$FOAM_CASE/0/include/sideAndTopPatches" + "procBoundary.*" + { + type processor; + } + } + } + + nut + { + boundaryField + { + outlet + { + type calculated; + value uniform 0; + } + inlet + { + type calculated; + value uniform 0; + } + "terrain_.*" + { + type nutkRoughWallFunction; + Ks uniform 0.2; //Ks = 20 Z0 + Cs uniform 0.5; + value uniform 0.0; + } + ground + { + type calculated; + value uniform 0; + } + #include "$FOAM_CASE/0/include/sideAndTopPatches" + "procBoundary.*" + { + type processor; + } + } + } + + epsilon + { + boundaryField + { + outlet + { + type zeroGradient; + } + inlet + { + type atmBoundaryLayerInletEpsilon; + Ustar 0.82; + z (0 0 1); + z0 0.1; + value uniform $turbulentEpsilon; + zGround 935.0; + } + "terrain_.*" + { + type epsilonWallFunction; + Cmu 0.09; + kappa 0.4; + E 9.8; + value uniform $turbulentEpsilon; + } + ground + { + type zeroGradient; + } + #include "$FOAM_CASE/0/include/sideAndTopPatches" + "procBoundary.*" + { + type processor; + } + } + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/decomposeParDict b/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/decomposeParDict index ede2ec0462..f45f2839e1 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/decomposeParDict +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/decomposeParDict @@ -15,35 +15,15 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 1; +numberOfSubdomains 2; method hierarchical; -// method metis; -// method ptscotch; - -simpleCoeffs -{ - n (4 1 1); - delta 0.001; -} hierarchicalCoeffs { - n (1 1 1); - delta 0.001; - order xyz; + n (2 1 1); + delta 0.001; + order xyz; } -manualCoeffs -{ - dataFile "cellDecomposition"; -} - -metisCoeffs -{ - //n (5 1 1); - //cellWeightsFile "constant/cellWeightsFile"; -} - - // ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/fvSolution b/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/fvSolution index 5bcf8d9898..ec738df41a 100644 --- a/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/fvSolution +++ b/tutorials/incompressible/simpleFoam/windTurbineTerrain/system/fvSolution @@ -18,49 +18,49 @@ solvers { p { - solver smoothSolver; - smoother GaussSeidel; - tolerance 1e-6; - relTol 0.01; - maxIter 300; - }; + solver GAMG; + tolerance 1e-7; + relTol 0.1; + smoother GaussSeidel; + nPreSweeps 0; + nPostSweeps 2; + cacheAgglomeration on; + agglomerator faceAreaPair; + nCellsInCoarsestLevel 10; + mergeLevels 1; + } U { - solver smoothSolver; - smoother GaussSeidel; - tolerance 1e-6; - relTol 0.01; - }; + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-8; + relTol 0.1; + nSweeps 1; + } k { - solver smoothSolver; - smoother GaussSeidel; - tolerance 1e-6; - relTol 0.01; - }; + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-8; + relTol 0.1; + nSweeps 1; + } epsilon { - solver smoothSolver; - smoother GaussSeidel; - tolerance 1e-6; - relTol 0.01; - }; - - omega - { - solver smoothSolver; - smoother GaussSeidel; - tolerance 1e-6; - relTol 0.1; - }; + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-8; + relTol 0.1; + nSweeps 1; + } } SIMPLE { - nNonOrthogonalCorrectors 1; + nNonOrthogonalCorrectors 0; convergence 1e-3; } From bb81cc9f07a2066192f0516cac124735baa50d40 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 13 Dec 2010 16:08:25 +0000 Subject: [PATCH 05/30] BUG: interpolationTable : allow for min != 0 --- .../interpolationTable/interpolationTable.C | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C index 6699b6349b..be8a2b71ba 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C @@ -284,10 +284,8 @@ Type Foam::interpolationTable::rateOfChange(const scalar value) const case interpolationTable::REPEAT: { // adjust lookupValue to >= minLimit - while (lookupValue < minLimit) - { - lookupValue += maxLimit; - } + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } @@ -325,10 +323,8 @@ Type Foam::interpolationTable::rateOfChange(const scalar value) const case interpolationTable::REPEAT: { // adjust lookupValue <= maxLimit - while (lookupValue > maxLimit) - { - lookupValue -= maxLimit; - } + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } @@ -540,11 +536,9 @@ Type Foam::interpolationTable::operator()(const scalar value) const } case interpolationTable::REPEAT: { - // adjust lookupValue to >= minLimin - while (lookupValue < minLimit) - { - lookupValue += maxLimit; - } + // adjust lookupValue to >= minLimit + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } @@ -582,10 +576,8 @@ Type Foam::interpolationTable::operator()(const scalar value) const case interpolationTable::REPEAT: { // adjust lookupValue <= maxLimit - while (lookupValue > maxLimit) - { - lookupValue -= maxLimit; - } + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } From c7560ad8b66feda7cf1ccf288653a78bd558479a Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 13 Dec 2010 16:09:08 +0000 Subject: [PATCH 06/30] ENH: cyclicPolyPatch : disallow non-uniform rotational cyclic --- .../constraint/cyclic/cyclicPolyPatch.C | 54 ++++++++----------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index e7d1991fb9..2ac0dc517c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -273,6 +273,28 @@ void Foam::cyclicPolyPatch::calcTransforms half1Normals, half0Tols ); + + if (transform_ == ROTATIONAL && !parallel() && forwardT().size() > 1) + { + const_cast(forwardT()).setSize(1); + const_cast(reverseT()).setSize(1); + const_cast(collocated()).setSize(1); + + WarningIn + ( + "cyclicPolyPatch::calcTransforms\n" + " (\n" + " const primitivePatch&,\n" + " const UList&,\n" + " const UList&,\n" + " const UList&,\n" + " const UList&\n" + " )" + ) << "For transform " << transformTypeNames[transform_] + << " found non-uniform transform." + << " Setting the transformation to be a uniform rotation." + << endl; + } } } @@ -851,22 +873,6 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledPoints() const str<< "l " << vertI-1 << ' ' << vertI << nl; } } - - // Remove any addressing calculated for the coupled edges calculation - const_cast - ( - static_cast - ( - *this - ) - ).clearOut(); - const_cast - ( - static_cast - ( - neighbPatch() - ) - ).clearOut(); } return *coupledPointsPtr_; } @@ -1006,22 +1012,6 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const str<< "l " << vertI-1 << ' ' << vertI << nl; } } - - // Remove any addressing calculated for the coupled edges calculation - const_cast - ( - static_cast - ( - *this - ) - ).clearOut(); - const_cast - ( - static_cast - ( - neighbPatch - ) - ).clearOut(); } return *coupledEdgesPtr_; } From 3fe4d6a55fc24ac88a90ac2163fc1a5005ee134c Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 13 Dec 2010 16:09:44 +0000 Subject: [PATCH 07/30] STYLE: processorPolyPatch : updated comment --- .../polyPatches/constraint/processor/processorPolyPatch.C | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index cd913267af..47425f1a8c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -409,6 +409,7 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs) } // Remove any addressing used for shared points/edges calculation + // since mostly not needed. primitivePatch::clearOut(); } } From e9b8f0a3ac0d768f539088eb2cbe0b9b0e5032b7 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 13 Dec 2010 16:10:11 +0000 Subject: [PATCH 08/30] STYLE: processorCyclic : removed extraneous printiing --- .../constraint/processorCyclic/processorCyclicPolyPatch.C | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C index 6bc517ec25..33264fc0d3 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C @@ -174,8 +174,6 @@ void Foam::processorCyclicPolyPatch::calcGeometry(PstreamBuffers& pBufs) // Update underlying cyclic coupledPolyPatch& pp = const_cast(referPatch()); - Pout<< "updating geometry on refered patch:" << pp.name() << endl; - pp.calcGeometry ( *this, From 6a7a0b6bcda5b37053e993db73e17b1669e2320f Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 14 Dec 2010 09:57:17 +0000 Subject: [PATCH 09/30] STYLE: FaceCellWave : return number of iterations --- .../algorithms/MeshWave/FaceCellWave.C | 30 +++++++++---------- .../algorithms/MeshWave/FaceCellWave.H | 9 ++---- src/OpenFOAM/algorithms/MeshWave/MeshWave.H | 4 +-- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C b/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C index 060666e02f..95539965ce 100644 --- a/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C +++ b/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.C @@ -40,8 +40,7 @@ const Foam::scalar Foam::FaceCellWave::geomTol_ = 1e-6; template -const Foam::scalar -Foam::FaceCellWave::propagationTol_ = 0.01; +Foam::scalar Foam::FaceCellWave::propagationTol_ = 0.01; template Foam::label Foam::FaceCellWave::dummyTrackData_ = 12345; @@ -516,8 +515,8 @@ void Foam::FaceCellWave::handleProcPatches() refCast(patch); // Allocate buffers - labelList receiveFaces(patch.size()); - List receiveFacesInfo(patch.size()); + labelList receiveFaces; + List receiveFacesInfo; { UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs); @@ -675,8 +674,7 @@ Foam::FaceCellWave::FaceCellWave hasCyclicPatches_(hasCyclicPatch()), nEvals_(0), nUnvisitedCells_(mesh_.nCells()), - nUnvisitedFaces_(mesh_.nFaces()), - iter_(0) + nUnvisitedFaces_(mesh_.nFaces()) {} @@ -707,16 +705,15 @@ Foam::FaceCellWave::FaceCellWave hasCyclicPatches_(hasCyclicPatch()), nEvals_(0), nUnvisitedCells_(mesh_.nCells()), - nUnvisitedFaces_(mesh_.nFaces()), - iter_(0) + nUnvisitedFaces_(mesh_.nFaces()) { // Copy initial changed faces data setFaceInfo(changedFaces, changedFacesInfo); // Iterate until nothing changes - iterate(maxIter); + label iter = iterate(maxIter); - if ((maxIter > 0) && (iter_ >= maxIter)) + if ((maxIter > 0) && (iter >= maxIter)) { FatalErrorIn ( @@ -796,7 +793,7 @@ Foam::label Foam::FaceCellWave::faceToCell() ); } - // Neighbour. Hack for check if face has neighbour. + // Neighbour. if (faceI < nInternalFaces) { cellI = neighbour[faceI]; @@ -927,11 +924,13 @@ Foam::label Foam::FaceCellWave::iterate(const label maxIter) handleProcPatches(); } - while (iter_ < maxIter) + label iter = 0; + + while (iter < maxIter) { if (debug) { - Pout<< " Iteration " << iter_ << endl; + Pout<< " Iteration " << iter << endl; } nEvals_ = 0; @@ -963,10 +962,11 @@ Foam::label Foam::FaceCellWave::iterate(const label maxIter) break; } - ++iter_; + ++iter; } - return nUnvisitedCells_; + return iter; } + // ************************************************************************* // diff --git a/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.H b/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.H index 6ad8a1ae32..2824d8e13a 100644 --- a/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.H +++ b/src/OpenFOAM/algorithms/MeshWave/FaceCellWave.H @@ -114,9 +114,6 @@ class FaceCellWave label nUnvisitedCells_; label nUnvisitedFaces_; - //- Iteration counter - label iter_; - // Private Member Functions @@ -232,7 +229,7 @@ class FaceCellWave // Private static data static const scalar geomTol_; - static const scalar propagationTol_; + static scalar propagationTol_; //- Used as default trackdata value to satisfy default template // argument. @@ -340,8 +337,8 @@ public: // counted double) label cellToFace(); - //- Iterate until no changes or maxIter reached. Returns number of - // unset cells (see getUnsetCells) + //- Iterate until no changes or maxIter reached. Returns actual + // number of iterations. label iterate(const label maxIter); }; diff --git a/src/OpenFOAM/algorithms/MeshWave/MeshWave.H b/src/OpenFOAM/algorithms/MeshWave/MeshWave.H index a93d01cfab..d48f3c69aa 100644 --- a/src/OpenFOAM/algorithms/MeshWave/MeshWave.H +++ b/src/OpenFOAM/algorithms/MeshWave/MeshWave.H @@ -134,8 +134,8 @@ public: return calc_.data(); } - //- Iterate until no changes or maxIter reached. Returns number of - // unset cells (see getUnsetCells) + //- Iterate until no changes or maxIter reached. Returns actual + // number of iterations. label iterate(const label maxIter) { return calc_.iterate(maxIter); From 20de9437ec201512b287d4aa6bc854fd284578d0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 14 Dec 2010 09:57:52 +0000 Subject: [PATCH 10/30] STYLE: cyclicPolyPatch : indentation --- .../polyPatches/constraint/cyclic/cyclicPolyPatch.C | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 2ac0dc517c..0010c5ecc4 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -290,9 +290,11 @@ void Foam::cyclicPolyPatch::calcTransforms " const UList&,\n" " const UList&\n" " )" - ) << "For transform " << transformTypeNames[transform_] - << " found non-uniform transform." - << " Setting the transformation to be a uniform rotation." + ) << "For patch " << name() + << " calculated non-uniform transform tensor even though" + << " the transform type is " << transformTypeNames[transform_] + << ". Setting the transformation tensor to be a uniform" + << " rotation." << endl; } } From 8a355a6332e80d96ec86bb724da2d243181b6522 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 14 Dec 2010 10:09:24 +0000 Subject: [PATCH 11/30] ENH: PointEdgeWave with trackData template argument. Using nonBlocking comms. --- .../layeredSolver/pointEdgeStructuredWalk.H | 55 +- .../layeredSolver/pointEdgeStructuredWalkI.H | 63 ++- .../inversePointDistanceDiffusivity.C | 8 +- .../autoHexMeshDriver/autoLayerDriverShrink.C | 13 +- .../autoHexMeshDriver/pointData/pointData.C | 7 +- .../autoHexMeshDriver/pointData/pointData.H | 109 +--- .../autoHexMeshDriver/pointData/pointDataI.H | 310 +++-------- src/meshTools/PointEdgeWave/PointEdgeWave.C | 513 ++++++++---------- src/meshTools/PointEdgeWave/PointEdgeWave.H | 100 ++-- src/meshTools/PointEdgeWave/pointEdgePoint.H | 60 +- src/meshTools/PointEdgeWave/pointEdgePointI.H | 88 +-- 11 files changed, 584 insertions(+), 742 deletions(-) diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H index 55d003a16a..e6852dffa2 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalk.H @@ -37,11 +37,7 @@ SourceFiles #define pointEdgeStructuredWalk_H #include "point.H" -#include "label.H" -#include "scalar.H" #include "tensor.H" -#include "pTraits.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,10 +71,12 @@ class pointEdgeStructuredWalk // Private Member Functions //- Evaluate distance to point. + template inline bool update ( const pointEdgeStructuredWalk& w2, - const scalar tol + const scalar tol, + TrackingData& td ); public: @@ -111,80 +109,105 @@ public: // Needed by meshWave - //- Check whether still contains original (invalid) value. - inline bool valid() const; + //- Check whether origin has been changed at all or + // still contains original (invalid) value. + template + inline bool valid(TrackingData& td) const; //- Check for identical geometrical data. Used for cyclics checking. + template inline bool sameGeometry ( const pointEdgeStructuredWalk&, - const scalar tol + const scalar tol, + TrackingData& td ) const; //- Convert origin to relative vector to leaving point // (= point coordinate) + template inline void leaveDomain ( const polyPatch& patch, const label patchPointI, - const point& pos + const point& pos, + TrackingData& td ); //- Convert relative origin to absolute by adding entering point + template inline void enterDomain ( const polyPatch& patch, const label patchPointI, - const point& pos + const point& pos, + TrackingData& td ); //- Apply rotation matrix to origin - inline void transform(const tensor& rotTensor); + template + inline void transform + ( + const tensor& rotTensor, + TrackingData& td + ); //- Influence of edge on point + template inline bool updatePoint ( const polyMesh& mesh, const label pointI, const label edgeI, const pointEdgeStructuredWalk& edgeInfo, - const scalar tol + const scalar tol, + TrackingData& td ); //- Influence of different value on same point. // Merge new and old info. + template inline bool updatePoint ( const polyMesh& mesh, const label pointI, const pointEdgeStructuredWalk& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ); //- Influence of different value on same point. // No information about current position whatsoever. + template inline bool updatePoint ( const pointEdgeStructuredWalk& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ); //- Influence of point on edge. + template inline bool updateEdge ( const polyMesh& mesh, const label edgeI, const label pointI, const pointEdgeStructuredWalk& pointInfo, - const scalar tol + const scalar tol, + TrackingData& td ); + //- Same (like operator==) + template + inline bool equal(const pointEdgeStructuredWalk&, TrackingData&) + const; + // Member Operators //Note: Used to determine whether to call update. inline bool operator==(const pointEdgeStructuredWalk&) const; - inline bool operator!=(const pointEdgeStructuredWalk&) const; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H index d60e9b52f7..47adcdb775 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/layeredSolver/pointEdgeStructuredWalkI.H @@ -29,13 +29,15 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Update this with w2. +template inline bool Foam::pointEdgeStructuredWalk::update ( const pointEdgeStructuredWalk& w2, - const scalar tol + const scalar tol, + TrackingData& td ) { - if (!valid()) + if (!valid(td)) { // current not yet set. Walked from w2 to here (=point0) dist_ = w2.dist_ + mag(point0_-w2.previousPoint_); @@ -105,17 +107,20 @@ inline const Foam::vector& Foam::pointEdgeStructuredWalk::data() const } -inline bool Foam::pointEdgeStructuredWalk::valid() const +template +inline bool Foam::pointEdgeStructuredWalk::valid(TrackingData& td) const { return previousPoint_ != vector::max; } // Checks for cyclic points +template inline bool Foam::pointEdgeStructuredWalk::sameGeometry ( const pointEdgeStructuredWalk& w2, - const scalar tol + const scalar tol, + TrackingData& td ) const { scalar diff = Foam::mag(dist() - w2.dist()); @@ -138,18 +143,25 @@ inline bool Foam::pointEdgeStructuredWalk::sameGeometry } +template inline void Foam::pointEdgeStructuredWalk::leaveDomain ( const polyPatch& patch, const label patchPointI, - const point& coord + const point& coord, + TrackingData& td ) { previousPoint_ -= coord; } -inline void Foam::pointEdgeStructuredWalk::transform(const tensor& rotTensor) +template +inline void Foam::pointEdgeStructuredWalk::transform +( + const tensor& rotTensor, + TrackingData& td +) { previousPoint_ = Foam::transform(rotTensor, previousPoint_); } @@ -157,11 +169,13 @@ inline void Foam::pointEdgeStructuredWalk::transform(const tensor& rotTensor) // Update absolute geometric quantities. Note that distance (dist_) // is not affected by leaving/entering domain. +template inline void Foam::pointEdgeStructuredWalk::enterDomain ( const polyPatch& patch, const label patchPointI, - const point& coord + const point& coord, + TrackingData& td ) { // back to absolute form @@ -170,18 +184,20 @@ inline void Foam::pointEdgeStructuredWalk::enterDomain // Update this with information from connected edge +template inline bool Foam::pointEdgeStructuredWalk::updatePoint ( const polyMesh& mesh, const label pointI, const label edgeI, const pointEdgeStructuredWalk& edgeInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { if (inZone()) { - return update(edgeInfo, tol); + return update(edgeInfo, tol, td); } else { @@ -191,17 +207,19 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint // Update this with new information on same point +template inline bool Foam::pointEdgeStructuredWalk::updatePoint ( const polyMesh& mesh, const label pointI, const pointEdgeStructuredWalk& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { if (inZone()) { - return update(newPointInfo, tol); + return update(newPointInfo, tol, td); } else { @@ -211,29 +229,33 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint // Update this with new information on same point. No extra information. +template inline bool Foam::pointEdgeStructuredWalk::updatePoint ( const pointEdgeStructuredWalk& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { - return update(newPointInfo, tol); + return update(newPointInfo, tol, td); } // Update this with information from connected point +template inline bool Foam::pointEdgeStructuredWalk::updateEdge ( const polyMesh& mesh, const label edgeI, const label pointI, const pointEdgeStructuredWalk& pointInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { if (inZone()) { - return update(pointInfo, tol); + return update(pointInfo, tol, td); } else { @@ -242,6 +264,17 @@ inline bool Foam::pointEdgeStructuredWalk::updateEdge } +template +inline bool Foam::pointEdgeStructuredWalk::equal +( + const pointEdgeStructuredWalk& rhs, + TrackingData& td +) const +{ + return operator==(rhs); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline bool Foam::pointEdgeStructuredWalk::operator== diff --git a/src/fvMotionSolver/motionDiffusivity/inversePointDistance/inversePointDistanceDiffusivity.C b/src/fvMotionSolver/motionDiffusivity/inversePointDistance/inversePointDistanceDiffusivity.C index 7ed2a34bba..486052b9db 100644 --- a/src/fvMotionSolver/motionDiffusivity/inversePointDistance/inversePointDistanceDiffusivity.C +++ b/src/fvMotionSolver/motionDiffusivity/inversePointDistance/inversePointDistanceDiffusivity.C @@ -91,6 +91,9 @@ void Foam::inversePointDistanceDiffusivity::correct() List pointWallDist(mesh.nPoints()); List edgeWallDist(mesh.nEdges()); + int dummyTrackData = 0; + + { // Seeds List seedInfo(nPatchEdges); @@ -108,7 +111,7 @@ void Foam::inversePointDistanceDiffusivity::correct() { label pointI = meshPoints[i]; - if (!pointWallDist[pointI].valid()) + if (!pointWallDist[pointI].valid(dummyTrackData)) { // Not yet seeded seedInfo[nPatchEdges] = pointEdgePoint @@ -135,7 +138,8 @@ void Foam::inversePointDistanceDiffusivity::correct() pointWallDist, edgeWallDist, - mesh.globalData().nTotalPoints() // max iterations + mesh.globalData().nTotalPoints(),// max iterations + dummyTrackData ); } diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 292ec5d142..d7abe804f7 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -756,6 +756,9 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo // Distance to wall List pointWallDist(mesh.nPoints()); + // Dummy additional info for PointEdgeWave + int dummyTrackData = 0; + // 1. Calculate distance to points where displacement is specified. { @@ -783,7 +786,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo wallInfo, pointWallDist, edgeWallDist, - mesh.globalData().nTotalPoints() // max iterations + mesh.globalData().nTotalPoints(), // max iterations + dummyTrackData ); } @@ -813,7 +817,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo { label pointI = e[ep]; - if (!pointMedialDist[pointI].valid()) + if (!pointMedialDist[pointI].valid(dummyTrackData)) { maxPoints.append(pointI); maxInfo.append @@ -857,7 +861,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo { label pointI = meshPoints[i]; - if (!pointMedialDist[pointI].valid()) + if (!pointMedialDist[pointI].valid(dummyTrackData)) { maxPoints.append(pointI); maxInfo.append @@ -888,7 +892,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo pointMedialDist, edgeMedialDist, - mesh.globalData().nTotalPoints() // max iterations + mesh.globalData().nTotalPoints(), // max iterations + dummyTrackData ); // Extract medial axis distance as pointScalarField diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.C index 6d97d1cd00..1d7f5090ae 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.C @@ -32,19 +32,20 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const pointData& wDist) if (os.format() == IOstream::ASCII) { return os - << wDist.origin() << token::SPACE << wDist.distSqr() + << static_cast(wDist) << token::SPACE << wDist.s() << token::SPACE << wDist.v(); } else { return os - << wDist.origin() << wDist.distSqr() << wDist.s() << wDist.v(); + << static_cast(wDist) + << wDist.s() << wDist.v(); } } Foam::Istream& Foam::operator>>(Istream& is, pointData& wDist) { - return is >> wDist.origin_ >> wDist.distSqr_ >> wDist.s_ >> wDist.v_; + return is >> static_cast(wDist) >> wDist.s_ >> wDist.v_; } // ************************************************************************* // diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H index 050b9d92c7..7719079821 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointData.H @@ -25,10 +25,10 @@ Class Foam::pointData Description - Holds information regarding nearest wall point. Used in pointEdgeWave. - (so not standard meshWave) - - To be used in wall distance calculation. + Variant of pointEdgePoint with some transported additional data. + WIP - should be templated on data like wallDistData. + Passive vector v_ is not a coordinate (so no enterDomain/leaveDomain + transformation needed) SourceFiles pointDataI.H @@ -39,9 +39,10 @@ SourceFiles #ifndef pointData_H #define pointData_H -#include "point.H" -#include "label.H" -#include "tensor.H" +#include "pointEdgePoint.H" +//#include "point.H" +//#include "label.H" +//#include "tensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,51 +50,22 @@ SourceFiles namespace Foam { -// Class forward declarations -class polyPatch; -class polyMesh; - /*---------------------------------------------------------------------------*\ Class pointData Declaration \*---------------------------------------------------------------------------*/ class pointData +: + public pointEdgePoint { // Private data - //- position of nearest wall center - point origin_; - - //- normal distance (squared) from point to origin - scalar distSqr_; - //- additional information. scalar s_; //- additional information. vector v_; - - // Private Member Functions - - //- Evaluate distance to point. Update distSqr, origin from whomever - // is nearer pt. Return true if w2 is closer to point, - // false otherwise. - inline bool update - ( - const point&, - const pointData& w2, - const scalar tol - ); - - //- Combine current with w2. Update distSqr, origin if w2 has smaller - // quantities and returns true. - inline bool update - ( - const pointData& w2, - const scalar tol - ); - public: // Constructors @@ -118,10 +90,6 @@ public: // Access - inline const point& origin() const; - - inline scalar distSqr() const; - inline scalar s() const; inline const vector& v() const; @@ -129,81 +97,60 @@ public: // Needed by meshWave - //- Check whether origin has been changed at all or - // still contains original (invalid) value. - inline bool valid() const; - - //- Check for identical geometrical data. Used for cyclics checking. - inline bool sameGeometry(const pointData&, const scalar tol) - const; - - //- Convert origin to relative vector to leaving point - // (= point coordinate) - inline void leaveDomain - ( - const polyPatch& patch, - const label patchPointI, - const point& pos - ); - - //- Convert relative origin to absolute by adding entering point - inline void enterDomain - ( - const polyPatch& patch, - const label patchPointI, - const point& pos - ); - //- Apply rotation matrix to origin - inline void transform(const tensor& rotTensor); + template + inline void transform + ( + const tensor& rotTensor, + TrackingData& td + ); //- Influence of edge on point + template inline bool updatePoint ( const polyMesh& mesh, const label pointI, const label edgeI, const pointData& edgeInfo, - const scalar tol + const scalar tol, + TrackingData& td ); //- Influence of different value on same point. // Merge new and old info. + template inline bool updatePoint ( const polyMesh& mesh, const label pointI, const pointData& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ); //- Influence of different value on same point. // No information about current position whatsoever. + template inline bool updatePoint ( const pointData& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ); //- Influence of point on edge. + template inline bool updateEdge ( const polyMesh& mesh, const label edgeI, const label pointI, const pointData& pointInfo, - const scalar tol + const scalar tol, + TrackingData& td ); - - // Member Operators - - //Note: Used to determine whether to call update. - inline bool operator==(const pointData&) const; - - inline bool operator!=(const pointData&) const; - - // IOstream Operators friend Ostream& operator<<(Ostream&, const pointData&); diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointDataI.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointDataI.H index a04038c247..c2228eca82 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointDataI.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/pointData/pointDataI.H @@ -26,118 +26,12 @@ License #include "polyMesh.H" #include "transform.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// Update this with w2 if w2 nearer to pt. -inline bool Foam::pointData::update -( - const point& pt, - const pointData& w2, - const scalar tol -) -{ - scalar dist2 = magSqr(pt - w2.origin()); - - if (!valid()) - { - distSqr_ = dist2; - origin_ = w2.origin(); - s_ = w2.s(); - v_ = w2.v(); - - return true; - } - - -// if (v_ != w2.v()) -// { -// return false; -// } - - - scalar diff = distSqr_ - dist2; - - if (diff < 0) - { - // already nearer to pt - return false; - } - - if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol))) - { - // don't propagate small changes - return false; - } - else - { - // update with new values - distSqr_ = dist2; - origin_ = w2.origin(); - s_ = w2.s(); - v_ = w2.v(); - - return true; - } -} - - -// Update this with w2 (information on same point) -inline bool Foam::pointData::update -( - const pointData& w2, - const scalar tol -) -{ - if (!valid()) - { - // current not yet set so use any value - distSqr_ = w2.distSqr(); - origin_ = w2.origin(); - s_ = w2.s(); - v_ = w2.v(); - return true; - } - - -// if (v_ != w2.v()) -// { -// return false; -// } - - - scalar diff = distSqr_ - w2.distSqr(); - - if (diff < 0) - { - // already nearer to pt - return false; - } - - if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol))) - { - // don't propagate small changes - return false; - } - else - { - // update with new values - distSqr_ = w2.distSqr(); - origin_ = w2.origin(); - s_ = w2.s(); - v_ = w2.v(); - - return true; - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Null constructor inline Foam::pointData::pointData() : - origin_(point::max), - distSqr_(GREAT), + pointEdgePoint(), s_(GREAT), v_(point::max) {} @@ -152,8 +46,7 @@ inline Foam::pointData::pointData const vector& v ) : - origin_(origin), - distSqr_(distSqr), + pointEdgePoint(origin, distSqr), s_(s), v_(v) {} @@ -162,8 +55,7 @@ inline Foam::pointData::pointData // Construct as copy inline Foam::pointData::pointData(const pointData& wpt) : - origin_(wpt.origin()), - distSqr_(wpt.distSqr()), + pointEdgePoint(wpt), s_(wpt.s()), v_(wpt.v()) {} @@ -171,18 +63,6 @@ inline Foam::pointData::pointData(const pointData& wpt) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline const Foam::point& Foam::pointData::origin() const -{ - return origin_; -} - - -inline Foam::scalar Foam::pointData::distSqr() const -{ - return distSqr_; -} - - inline Foam::scalar Foam::pointData::s() const { return s_; @@ -195,157 +75,143 @@ inline const Foam::vector& Foam::pointData::v() const } -inline bool Foam::pointData::valid() const -{ - return origin_ != point::max; -} - - -// Checks for cyclic points -inline bool Foam::pointData::sameGeometry +template +inline void Foam::pointData::transform ( - const pointData& w2, - const scalar tol -) const -{ - scalar diff = Foam::mag(distSqr() - w2.distSqr()); - - if (diff < SMALL) - { - return true; - } - else - { - if ((distSqr() > SMALL) && ((diff/distSqr()) < tol)) - { - return true; - } - else - { - return false; - } - } -} - - -inline void Foam::pointData::leaveDomain -( - const polyPatch& patch, - const label patchPointI, - const point& coord + const tensor& rotTensor, + TrackingData& td ) { - origin_ -= coord; -} - - -inline void Foam::pointData::transform(const tensor& rotTensor) -{ - origin_ = Foam::transform(rotTensor, origin_); -} - - -// Update absolute geometric quantities. Note that distance (distSqr_) -// is not affected by leaving/entering domain. -inline void Foam::pointData::enterDomain -( - const polyPatch& patch, - const label patchPointI, - const point& coord -) -{ - // back to absolute form - origin_ += coord; + pointEdgePoint::transform(rotTensor, td); + v_ = Foam::transform(rotTensor, v_); } // Update this with information from connected edge +template inline bool Foam::pointData::updatePoint ( const polyMesh& mesh, const label pointI, const label edgeI, const pointData& edgeInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { - return - update + if + ( + pointEdgePoint::updatePoint ( - mesh.points()[pointI], + mesh, + pointI, + edgeI, edgeInfo, - tol - ); + tol, + td + ) + ) + { + s_ = edgeInfo.s_; + v_ = edgeInfo.v_; + return true; } - + else + { + return false; + } +} // Update this with new information on same point +template inline bool Foam::pointData::updatePoint ( const polyMesh& mesh, const label pointI, const pointData& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { - return - update + if + ( + pointEdgePoint::updatePoint ( - mesh.points()[pointI], + mesh, + pointI, newPointInfo, - tol - ); + tol, + td + ) + ) + { + s_ = newPointInfo.s_; + v_ = newPointInfo.v_; + return true; + } + else + { + return false; + } } // Update this with new information on same point. No extra information. +template inline bool Foam::pointData::updatePoint ( const pointData& newPointInfo, - const scalar tol + const scalar tol, + TrackingData& td ) { - return update(newPointInfo, tol); + if (pointEdgePoint::updatePoint(newPointInfo, tol, td)) + { + s_ = newPointInfo.s_; + v_ = newPointInfo.v_; + return true; + } + else + { + return false; + } } // Update this with information from connected point +template inline bool Foam::pointData::updateEdge ( const polyMesh& mesh, const label edgeI, const label pointI, const pointData& pointInfo, - const scalar tol + const scalar tol, + TrackingData& td + ) { - const pointField& points = mesh.points(); - - const edge& e = mesh.edges()[edgeI]; - - const point edgeMid(0.5*(points[e[0]] + points[e[1]])); - - return - update + if + ( + pointEdgePoint::updateEdge ( - edgeMid, + mesh, + edgeI, + pointI, pointInfo, - tol - ); -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -inline bool Foam::pointData::operator==(const pointData& rhs) const -{ - return origin() == rhs.origin(); -} - - -inline bool Foam::pointData::operator!=(const pointData& rhs) const -{ - return !(*this == rhs); + tol, + td + ) + ) + { + s_ = pointInfo.s_; + v_ = pointInfo.v_; + return true; + } + else + { + return false; + } } diff --git a/src/meshTools/PointEdgeWave/PointEdgeWave.C b/src/meshTools/PointEdgeWave/PointEdgeWave.C index 304675d71f..a11d6601be 100644 --- a/src/meshTools/PointEdgeWave/PointEdgeWave.C +++ b/src/meshTools/PointEdgeWave/PointEdgeWave.C @@ -32,36 +32,25 @@ License #include "PstreamCombineReduceOps.H" #include "debug.H" #include "typeInfo.H" +#include "globalMeshData.H" +#include "pointFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -template -Foam::scalar Foam::PointEdgeWave::propagationTol_ = 0.01; +template +Foam::scalar Foam::PointEdgeWave::propagationTol_ = 0.01; - -// Offset labelList. Used for transferring from one cyclic half to the other. -template -void Foam::PointEdgeWave::offset(const label val, labelList& elems) -{ - forAll(elems, i) - { - elems[i] += val; - } -} +template +Foam::label Foam::PointEdgeWave::dummyTrackData_ = 12345; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Gets point-point correspondence. Is -// - list of halfA points (in cyclic patch points) -// - list of halfB points (can overlap with A!) -// - for every patchPoint its corresponding point // Handle leaving domain. Implementation referred to Type -template -void Foam::PointEdgeWave::leaveDomain +template +void Foam::PointEdgeWave::leaveDomain ( - const polyPatch& meshPatch, - const primitivePatch& patch, + const polyPatch& patch, const labelList& patchPointLabels, List& pointInfo ) const @@ -74,17 +63,16 @@ void Foam::PointEdgeWave::leaveDomain const point& pt = patch.points()[meshPoints[patchPointI]]; - pointInfo[i].leaveDomain(meshPatch, patchPointI, pt); + pointInfo[i].leaveDomain(patch, patchPointI, pt, td_); } } // Handle entering domain. Implementation referred to Type -template -void Foam::PointEdgeWave::enterDomain +template +void Foam::PointEdgeWave::enterDomain ( - const polyPatch& meshPatch, - const primitivePatch& patch, + const polyPatch& patch, const labelList& patchPointLabels, List& pointInfo ) const @@ -97,15 +85,16 @@ void Foam::PointEdgeWave::enterDomain const point& pt = patch.points()[meshPoints[patchPointI]]; - pointInfo[i].enterDomain(meshPatch, patchPointI, pt); + pointInfo[i].enterDomain(patch, patchPointI, pt, td_); } } // Transform. Implementation referred to Type -template -void Foam::PointEdgeWave::transform +template +void Foam::PointEdgeWave::transform ( + const polyPatch& patch, const tensorField& rotTensor, List& pointInfo ) const @@ -116,19 +105,22 @@ void Foam::PointEdgeWave::transform forAll(pointInfo, i) { - pointInfo[i].transform(T); + pointInfo[i].transform(T, td_); } } else { FatalErrorIn ( - "PointEdgeWave::transform(const tensorField&, List&)" - ) << "Parallel cyclics not supported" << abort(FatalError); + "PointEdgeWave::transform" + "(const tensorField&, List&)" + ) << "Non-uniform transformation on patch " << patch.name() + << " not supported for point fields" + << abort(FatalError); forAll(pointInfo, i) { - pointInfo[i].transform(rotTensor[i]); + pointInfo[i].transform(rotTensor[i], td_); } } } @@ -139,19 +131,18 @@ void Foam::PointEdgeWave::transform // Updates: // - changedPoint_, changedPoints_, nChangedPoints_, // - statistics: nEvals_, nUnvisitedPoints_ -template -bool Foam::PointEdgeWave::updatePoint +template +bool Foam::PointEdgeWave::updatePoint ( const label pointI, const label neighbourEdgeI, const Type& neighbourInfo, - const scalar tol, Type& pointInfo ) { nEvals_++; - bool wasValid = pointInfo.valid(); + bool wasValid = pointInfo.valid(td_); bool propagate = pointInfo.updatePoint @@ -160,7 +151,8 @@ bool Foam::PointEdgeWave::updatePoint pointI, neighbourEdgeI, neighbourInfo, - tol + propagationTol_, + td_ ); if (propagate) @@ -172,7 +164,7 @@ bool Foam::PointEdgeWave::updatePoint } } - if (!wasValid && pointInfo.valid()) + if (!wasValid && pointInfo.valid(td_)) { --nUnvisitedPoints_; } @@ -186,18 +178,17 @@ bool Foam::PointEdgeWave::updatePoint // Updates: // - changedPoint_, changedPoints_, nChangedPoints_, // - statistics: nEvals_, nUnvisitedPoints_ -template -bool Foam::PointEdgeWave::updatePoint +template +bool Foam::PointEdgeWave::updatePoint ( const label pointI, const Type& neighbourInfo, - const scalar tol, Type& pointInfo ) { nEvals_++; - bool wasValid = pointInfo.valid(); + bool wasValid = pointInfo.valid(td_); bool propagate = pointInfo.updatePoint @@ -205,7 +196,8 @@ bool Foam::PointEdgeWave::updatePoint mesh_, pointI, neighbourInfo, - tol + propagationTol_, + td_ ); if (propagate) @@ -217,7 +209,7 @@ bool Foam::PointEdgeWave::updatePoint } } - if (!wasValid && pointInfo.valid()) + if (!wasValid && pointInfo.valid(td_)) { --nUnvisitedPoints_; } @@ -231,19 +223,18 @@ bool Foam::PointEdgeWave::updatePoint // Updates: // - changedEdge_, changedEdges_, nChangedEdges_, // - statistics: nEvals_, nUnvisitedEdge_ -template -bool Foam::PointEdgeWave::updateEdge +template +bool Foam::PointEdgeWave::updateEdge ( const label edgeI, const label neighbourPointI, const Type& neighbourInfo, - const scalar tol, Type& edgeInfo ) { nEvals_++; - bool wasValid = edgeInfo.valid(); + bool wasValid = edgeInfo.valid(td_); bool propagate = edgeInfo.updateEdge @@ -252,7 +243,8 @@ bool Foam::PointEdgeWave::updateEdge edgeI, neighbourPointI, neighbourInfo, - tol + propagationTol_, + td_ ); if (propagate) @@ -264,7 +256,7 @@ bool Foam::PointEdgeWave::updateEdge } } - if (!wasValid && edgeInfo.valid()) + if (!wasValid && edgeInfo.valid(td_)) { --nUnvisitedEdges_; } @@ -274,9 +266,9 @@ bool Foam::PointEdgeWave::updateEdge // Check if patches of given type name are present -template +template template -Foam::label Foam::PointEdgeWave::countPatchType() const +Foam::label Foam::PointEdgeWave::countPatchType() const { label nPatches = 0; @@ -291,199 +283,110 @@ Foam::label Foam::PointEdgeWave::countPatchType() const } -// Collect changed patch points -template -void Foam::PointEdgeWave::getChangedPatchPoints -( - const primitivePatch& patch, - - DynamicList& patchInfo, - DynamicList