From 41829c7a5389fa42e6277649b72a941bbf7944aa Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 24 Apr 2018 19:04:02 +0100 Subject: [PATCH] Field mapping for patch reset --- .../manipulation/renumberMesh/renumberMesh.C | 9 ++ .../decomposePar/decomposePar.C | 1 + .../reconstructParMesh/reconstructParMesh.C | 1 + .../finiteVolume/decomposeMesh.C | 126 +++++++++--------- .../finiteVolume/domainDecomposition.C | 8 +- .../directTopoChange/directTopoChange.C | 12 ++ .../layerAdditionRemoval/addCellLayer.C | 4 +- .../layerAdditionRemoval.C | 31 ++++- .../layerAdditionRemoval.H | 14 +- .../polyTopoChangerChangeMesh.C | 6 + .../dynamicTopoFvMesh/dynamicTopoFvMesh.C | 16 ++- .../fieldMapping/topoMapper.C | 1 + .../fieldMapping/topoMapper.H | 19 ++- .../loadBalanceFvMesh/loadBalanceFvMesh.C | 16 +-- .../linearValveLayersFvMesh.C | 4 +- .../faMesh/faMeshMapper/faMeshMapper.C | 3 +- .../faMesh/faMeshMapper/faMeshMapper.H | 11 ++ src/finiteVolume/fvMesh/fvMesh.C | 11 +- .../fvMesh/fvMeshMapper/fvMeshMapper.H | 9 ++ .../GeometricField/MapGeometricFields.H | 72 ++++++++-- .../pointMeshMapper/pointMeshMapper.H | 13 +- .../meshes/polyMesh/mapPolyMesh/mapPolyMesh.C | 4 + .../meshes/polyMesh/mapPolyMesh/mapPolyMesh.H | 33 +++++ src/foam/meshes/polyMesh/polyMesh.C | 59 +------- .../polyPatches/polyPatch/polyPatch.C | 2 - .../MapTetFemFields/tetPolyMeshMapper.H | 23 +++- 26 files changed, 335 insertions(+), 173 deletions(-) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 1eef9c952..3d4d18a49 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -342,26 +342,35 @@ autoPtr reorderMesh mesh.nPoints(), // nOldPoints, mesh.nFaces(), // nOldFaces, mesh.nCells(), // nOldCells, + identity(mesh.nPoints()), // pointMap, List(0), // pointsFromPoints, + faceOrder, // faceMap, List(0), // facesFromPoints, List(0), // facesFromEdges, List(0), // facesFromFaces, + cellOrder, // cellMap, List(0), // cellsFromPoints, List(0), // cellsFromEdges, List(0), // cellsFromFaces, List(0), // cellsFromCells, + identity(mesh.nPoints()), // reversePointMap, reverseFaceOrder, // reverseFaceMap, reverseCellOrder, // reverseCellMap, + labelHashSet(0), // flipFaceFlux, + patchPointMap, // patchPointMap, labelListList(0), // pointZoneMap, labelListList(0), // faceZonePointMap, labelListList(0), // faceZoneFaceMap, labelListList(0), // cellZoneMap, + + boolList(mesh.boundaryMesh().size(), false), // resetPatchFlag + pointField(0), // preMotionPoints, patchStarts, // oldPatchStarts, oldPatchNMeshPoints // oldPatchNMeshPoints diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 6d7430682..42071d39a 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -651,6 +651,7 @@ int main(int argc, char *argv[]) processorDb ) ); + procMesh.syncUpdateMesh(); labelIOList cellProcAddressing ( diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index cb931aed1..342d4c129 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -142,6 +142,7 @@ int main(int argc, char *argv[]) regionName ); + // Get reconstructed mesh autoPtr meshPtr = procMeshes.reconstructMesh(runTime); diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/decomposeMesh.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/decomposeMesh.C index bd385b835..9cc673e28 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/decomposeMesh.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/decomposeMesh.C @@ -272,24 +272,9 @@ void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches) ); } } - else - { - // Owner and neighbour processor index are the same - // across the processor boundary. This face will be - // re-merged into internal faces in load balancing - // and therefore remains in the processor patch - Pout<< "Preserved proc[" << patchFaceI << "]: " - << ownerProc << " " << neighbourProc << endl; - - // Add the face - procFaceList[ownerProc].append - ( - patchStart + patchFaceI - ); - - // Increment the number of faces for this patch - procPatchSize_[ownerProc][patchI]++; - } + // Note: cannot insert regular faces here, because + // they are out of sequence. + // HJ, 24/Apr/2018 } } } @@ -516,24 +501,9 @@ void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches) ); } } - else - { - // Owner and neighbour processor index are the same - // across the processor boundary. This face will be - // re-merged into internal faces in load balancing - // and therefore remains in the processor patch - Pout<< "Preserved proc[" << patchFaceI << "]: " - << ownerProc << " " << neighbourProc << endl; - - // Add the face - procFaceList[ownerProc].append - ( - patchStart + patchFaceI - ); - - // Increment the number of faces for this patch - procPatchSize_[ownerProc][patchI]++; - } + // Note: cannot insert regular faces here, because + // they are out of sequence. + // HJ, 24/Apr/2018 } } } @@ -555,35 +525,53 @@ void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches) const label patchStart = patches[patchI].patch().start(); // Do normal patches. Note that processor patches - // have already been done and need to be skipped - // For all other patches patchNbrCellToProc_ will be empty - if (!patchNbrCellToProc_[patchI].empty()) + // have already been partially done and need special treatment + if + ( + isA(patches[patchI]) + && !patchNbrCellToProc_[patchI].empty() + ) { + // Only collect faces where the owner and neighbour processor + // index are the same. + // If owner and neighbour processor index are different, + // the face was already collected into a separate patch + // HJ, 23/Apr/2018 + + const unallocLabelList& fc = patches[patchI].faceCells(); + + // Get neighbour cellToProc addressing across the interface + const labelList& curNbrPtc = patchNbrCellToProc_[patchI]; + + forAll (fc, patchFaceI) + { + // Local owner proc is looked up using faceCells + const label ownerProc = cellToProc_[fc[patchFaceI]]; + + // Neighbour proc is looked up directly + const label neighbourProc = curNbrPtc[patchFaceI]; + + // If the owner and neighbour processor index is the same, + // the face remains in the processor patch + // In load balancing, it will be re-merged on reconstruction + // HJ, 23/Apr/2018 + if (ownerProc == neighbourProc) + { + // Add the face + procFaceList[ownerProc].append(patchStart + patchFaceI); + Pout<< "Add proc face to proc patch. Face " + << patchStart + patchFaceI + << endl; + // Increment the number of faces for this patch + procPatchSize_[ownerProc][patchI]++; + } + } + // Processor patch. Skip it continue; } - if (!isA(patches[patchI])) - { - // Normal patch. Add faces to processor where the cell - // next to the face lives - - const unallocLabelList& patchFaceCells = - patches[patchI].faceCells(); - - forAll (patchFaceCells, patchFaceI) - { - const label curProc = - cellToProc_[patchFaceCells[patchFaceI]]; - - // add the face - procFaceList[curProc].append(patchStart + patchFaceI); - - // increment the number of faces for this patch - procPatchSize_[curProc][patchI]++; - } - } - else + else if (isA(patches[patchI])) { // Cyclic patch special treatment @@ -785,6 +773,24 @@ void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches) } } } + else + { + // Normal patch. Add faces to processor where the cell + // next to the face lives + + const unallocLabelList& fc = patches[patchI].faceCells(); + + forAll (fc, patchFaceI) + { + const label curProc = cellToProc_[fc[patchFaceI]]; + + // add the face + procFaceList[curProc].append(patchStart + patchFaceI); + + // increment the number of faces for this patch + procPatchSize_[curProc][patchI]++; + } + } } // Face zone treatment. HJ, 27/Mar/2009 diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C index 44cc03ba7..67b12dd0f 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C @@ -207,7 +207,13 @@ Foam::autoPtr Foam::domainDecomposition::processorMesh } // Create processor mesh without a boundary - + Pout<< "RAW MESH: points: " << procPoints.size() + << " faces: " << procFaces.size() + << " owner: " << procOwner.size() + << " procNeighbour: " << procNeighbour.size() << nl + << "curPatchSizes: " << procPatchSize_[procI] << nl + << " curPatchStarts: " << procPatchStartIndex_[procI] << nl + << endl; // Create the mesh autoPtr procMeshPtr ( diff --git a/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directTopoChange.C b/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directTopoChange.C index 062366906..b7be6d38f 100644 --- a/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directTopoChange.C +++ b/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directTopoChange.C @@ -3162,6 +3162,10 @@ Foam::autoPtr Foam::directTopoChange::changeMesh calcFaceZonePointMap(mesh, oldFaceZoneMeshPointMaps, faceZonePointMap); + // Patch reset map is currently dummy + // HJ, 23/Apr/2018 + boolList resetPatchFlag(mesh.boundaryMesh().size(), false); + return autoPtr ( new mapPolyMesh @@ -3199,6 +3203,8 @@ Foam::autoPtr Foam::directTopoChange::changeMesh faceZoneFaceMap, cellZoneMap, + resetPatchFlag, + newPoints, // if empty signals no inflation. oldPatchStarts, oldPatchNMeshPoints, @@ -3470,6 +3476,10 @@ Foam::autoPtr Foam::directTopoChange::makeMesh writeMeshStats(mesh, Pout); } + // Patch reset map is currently dummy + // HJ, 23/Apr/2018 + boolList resetPatchFlag(mesh.boundaryMesh().size(), false); + return autoPtr ( new mapPolyMesh @@ -3507,6 +3517,8 @@ Foam::autoPtr Foam::directTopoChange::makeMesh faceZoneFaceMap, cellZoneMap, + resetPatchFlag, + newPoints, // if empty signals no inflation. oldPatchStarts, oldPatchNMeshPoints, diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C index b1ea2c9b3..81dc957a9 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/addCellLayer.C @@ -87,7 +87,7 @@ void Foam::layerAdditionRemoval::addCellLayer { extrusionDir[mpI] = points[ptc[mpI]] - points[mp[mpI]]; } - extrusionDir *= addDelta_*maxLayerThickness_; + extrusionDir *= addDelta_()*maxLayerThickness_; } else { @@ -118,7 +118,7 @@ void Foam::layerAdditionRemoval::addCellLayer polyAddPoint ( points[mp[pointI]] // point -// + addDelta_*maxLayerThickness_*extrusionDir[pointI], +// + addDelta_()*maxLayerThickness_*extrusionDir[pointI], + extrusionDir[pointI], mp[pointI], // master point -1, // zone for point diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C index e15066faa..47443b8de 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.C @@ -48,8 +48,19 @@ namespace Foam } -const Foam::scalar Foam::layerAdditionRemoval::addDelta_ = 0.3; -const Foam::scalar Foam::layerAdditionRemoval::removeDelta_ = 0.1; +const Foam::debug::tolerancesSwitch +Foam::layerAdditionRemoval::motionDelta_ +( + "layerAdditionRemoval::motionDelta", + 0.01 +); + +const Foam::debug::tolerancesSwitch +Foam::layerAdditionRemoval::addDelta_ +( + "layerAdditionRemoval::addDelta", + 0.3 +); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -354,7 +365,12 @@ bool Foam::layerAdditionRemoval::changeTopology() const topologicalChange = false; } - else if (avgDelta < oldLayerThickness_) + // New criterion to avoid round-off triggering layer addition/removal + // HJ, 30/Mar/2018 + else if + ( + (oldLayerThickness_ - avgDelta) > motionDelta_()*minLayerThickness_ + ) { // Layers moving towards removal if (minDelta < minLayerThickness_) @@ -397,7 +413,12 @@ bool Foam::layerAdditionRemoval::changeTopology() const oldLayerThickness_ = avgDelta; } } - else + // New criterion to avoid round-off triggering layer addition/removal + // HJ, 30/Mar/2018 + else if + ( + (avgDelta - oldLayerThickness_) > motionDelta_()*minLayerThickness_ + ) { // Layers moving towards addition if (maxDelta > maxLayerThickness_) @@ -422,6 +443,8 @@ bool Foam::layerAdditionRemoval::changeTopology() const oldLayerThickness_ = avgDelta; } } + // else the motion change is smaller than the tolerance and the layer + // interface is practically static. HJ, 30/Mar/2018 return topologicalChange; } diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H index 566ddf551..56497d60d 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H @@ -40,6 +40,7 @@ SourceFiles #include "polyMeshModifier.H" #include "primitiveFacePatch.H" #include "ZoneIDs.H" +#include "tolerancesSwitch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -128,13 +129,14 @@ class layerAdditionRemoval // Static data members - //- Thickness insertion fraction for the pre-motion - static const scalar addDelta_; + //- Motion detection fraction: if the motion is smaller than + // motionDelta*minLayerThickness_, it is assumed that the mesh is + // not layering + static const debug::tolerancesSwitch motionDelta_; + + //- Thickness insertion fraction for the pre-motion + static const debug::tolerancesSwitch addDelta_; - //- Thickness removal fraction for the cell collapse - // Note: the cell will be collapsed to this relative - // thickness before the layer is removed. - static const scalar removeDelta_; public: diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C index e91b4800b..11e1e689d 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C @@ -2416,6 +2416,10 @@ Foam::autoPtr Foam::polyTopoChanger::changeMesh List facesFromFaces; List cellsFromCells; + // Patch reset map is currently dummy: does not support change in number + // of boundary patches + // HJ, 23/Apr/2018 + boolList resetPatchFlag(boundary.size(), false); autoPtr topoChangeMap ( @@ -2453,6 +2457,8 @@ Foam::autoPtr Foam::polyTopoChanger::changeMesh fzFaceRenumber, czRenumber, + resetPatchFlag, + newPointsMotion, oldPatchStarts, oldPatchNMeshPoints, diff --git a/src/dynamicMesh/dynamicTopoFvMesh/dynamicTopoFvMesh.C b/src/dynamicMesh/dynamicTopoFvMesh/dynamicTopoFvMesh.C index eae20af74..af045652c 100644 --- a/src/dynamicMesh/dynamicTopoFvMesh/dynamicTopoFvMesh.C +++ b/src/dynamicMesh/dynamicTopoFvMesh/dynamicTopoFvMesh.C @@ -4253,6 +4253,11 @@ bool dynamicTopoFvMesh::resetMesh() } } + // Patch reset map is currently dummy: does not support change + // in number of boundary patches + // HJ, 23/Apr/2018 + boolList resetPatchFlag(boundaryMesh().size(), false); + // Generate new mesh mapping information mapPolyMesh mpm ( @@ -4260,30 +4265,39 @@ bool dynamicTopoFvMesh::resetMesh() nOldPoints_, nOldFaces_, nOldCells_, + pointMap_, pointsFromPoints_, + faceMap_, facesFromPoints_, facesFromEdges_, facesFromFaces_, + cellMap_, cellsFromPoints_, cellsFromEdges_, cellsFromFaces_, cellsFromCells_, + reversePointMap_, reverseFaceMap_, reverseCellMap_, + flipFaces_, + patchPointMap, pointZoneMap, faceZonePointMap, faceZoneFaceMap, cellZoneMap, + + resetPatchFlag, + preMotionPoints, oldPatchStarts, oldPatchNMeshPoints, - true + true // Re-use storage ); // Update the underlying mesh, and map all related fields diff --git a/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.C b/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.C index b35a9a42e..ae20ecfb9 100644 --- a/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.C +++ b/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.C @@ -192,6 +192,7 @@ topoMapper::topoMapper cellMap_(NULL), surfaceMap_(NULL), boundaryMap_(NULL), + resetPatchFlag_(mesh.boundaryMesh().size(), false), // Disabled fluxCorrector_(fluxCorrector::New(mesh, dict)), cellVolumesPtr_(NULL), cellCentresPtr_(NULL) diff --git a/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.H b/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.H index 106604ebb..9ce7a25eb 100644 --- a/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.H +++ b/src/dynamicMesh/dynamicTopoFvMesh/fieldMapping/topoMapper.H @@ -69,6 +69,7 @@ class topoMapper typedef Tuple2 GradientMap; typedef HashTable GradientTable; + // Private data //- Reference to fvMesh @@ -77,6 +78,7 @@ class topoMapper //- Reference to the options dictionary const dictionary& dict_; + // Demand-driven private data //- Cell mapper @@ -88,6 +90,10 @@ class topoMapper //- Boundary mapper mutable autoPtr boundaryMap_; + //- Reset patch flag. Set true for the rebuilt patch (no mapping) + // Disabled. HJ, 24/Apr/2018 + boolList resetPatchFlag_; + //- Flux corrector mutable autoPtr fluxCorrector_; @@ -118,6 +124,7 @@ class topoMapper mutable labelListList patchSizes_; mutable labelListList patchStarts_; + // Private Member Functions //- Disallow default bitwise copy construct @@ -141,6 +148,7 @@ class topoMapper //- Set geometric information void storeGeometry() const; + public: // Constructors @@ -148,9 +156,10 @@ public: //- Construct from mesh and dictionary topoMapper(const fvMesh& mesh, const dictionary& dict); - // Destructor - ~topoMapper(); + //- Destructor + ~topoMapper(); + // Member Functions @@ -256,6 +265,12 @@ public: //- Return boundary mapper const topoBoundaryMeshMapper& boundaryMap() const; + //- Return reset patch flag + const boolList& resetPatchFlag() const + { + return resetPatchFlag_; + } + //- Return flux-corrector const fluxCorrector& surfaceFluxCorrector() const; diff --git a/src/dynamicMesh/loadBalanceFvMesh/loadBalanceFvMesh/loadBalanceFvMesh.C b/src/dynamicMesh/loadBalanceFvMesh/loadBalanceFvMesh/loadBalanceFvMesh.C index 8964a6e29..56d5f484d 100644 --- a/src/dynamicMesh/loadBalanceFvMesh/loadBalanceFvMesh/loadBalanceFvMesh.C +++ b/src/dynamicMesh/loadBalanceFvMesh/loadBalanceFvMesh/loadBalanceFvMesh.C @@ -279,9 +279,6 @@ bool Foam::loadBalanceFvMesh::update() // Insert own mesh if there is a piece to insert if (curMigratedCells[Pstream::myProcNo()] > 0) { - Pout<< "Inserting local mesh piece, proc " << Pstream::myProcNo() - << endl; - procMeshes.set ( Pstream::myProcNo(), @@ -293,9 +290,7 @@ bool Foam::loadBalanceFvMesh::update() true // Create passive processor patches ) ); - Pout<< "Local proc mesh: " << Pstream::myProcNo() << nl - << procMeshes[Pstream::myProcNo()].boundaryMesh() - << endl; + // Set local fields } @@ -334,9 +329,7 @@ bool Foam::loadBalanceFvMesh::update() false // Do not sync ) ); - Pout<< "Received boundary: " << nl - << procMeshes[procI].boundaryMesh() - << endl; + // Receive the fields } } @@ -564,10 +557,13 @@ bool Foam::loadBalanceFvMesh::update() resetFvPatchFlag, true // Valid boundary ); - Pout<< "BMESH: " << boundaryMesh() << endl; // To Do: build a reconstructor from addressing data + Pout<< nl << nl + << "FINISHED CYCLE" << nl << nl << nl + << endl; + write(); // Create field reconstructor // fvFieldReconstructor fieldReconstructor diff --git a/src/dynamicMesh/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C b/src/dynamicMesh/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C index 58172e0b1..82842fc51 100644 --- a/src/dynamicMesh/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C +++ b/src/dynamicMesh/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C @@ -75,7 +75,6 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers() ) { // Zones found. Check topo changer - if (topoChanger_.empty()) { FatalErrorIn @@ -138,7 +137,6 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers() } - // Do face zones for slider // Inner slider @@ -242,7 +240,7 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers() fz.setSize(nFz); // Cell zones remain unchanged - Info << "Adding point and face zones" << endl; + Info<< "Adding point and face zones" << endl; removeZones(); addZones(pz, fz, cz); diff --git a/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.C b/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.C index 632f27aa3..065330357 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.C +++ b/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.C @@ -46,7 +46,8 @@ Foam::faMeshMapper::faMeshMapper oldPatchEdgeFaces_(mesh.boundary().size()), areaMap_(mesh, mpm), edgeMap_(mesh, mpm), - boundaryMap_(mesh, mpm) + boundaryMap_(mesh, mpm), + resetPatchFlag_(mesh.boundary().size(), false) // Disabled { // Capture old patch information const faBoundaryMesh& patches = mesh.boundary(); diff --git a/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.H b/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.H index 87dce1f20..6fe57e3a8 100644 --- a/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.H +++ b/src/finiteArea/faMesh/faMeshMapper/faMeshMapper.H @@ -103,6 +103,10 @@ class faMeshMapper //- Boundary mapper faBoundaryMeshMapper boundaryMap_; + //- Reset patch flag. Set true for the rebuilt patch (no mapping) + //- Disabled. HJ, 24/Apr/2018 + boolList resetPatchFlag_; + // Private Member Functions @@ -201,6 +205,13 @@ public: { return boundaryMap_; } + + //- Return reset patch flag + //- Disabled. HJ, 24/Apr/2018 + const boolList& resetPatchFlag() const + { + return resetPatchFlag_; + } }; diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 713cfc919..adeab5068 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -422,16 +422,11 @@ void Foam::fvMesh::resetFvPrimitives validBoundary ); + // Reset fvPatches HJ, 16/Apr/2018 boundary_.resetFvPatches(resetFvPatchFlag); - surfaceInterpolation::clearOut(); - clearGeomNotOldVol(); - // Reset fvPatches? HJ, 16/Apr/2018 - - // Clear LDU - clearAddressing(); - - // Clear cell volumes? + // Clear all mesh data + clearOut(); } diff --git a/src/finiteVolume/fvMesh/fvMeshMapper/fvMeshMapper.H b/src/finiteVolume/fvMesh/fvMeshMapper/fvMeshMapper.H index 067591095..57b7037fd 100644 --- a/src/finiteVolume/fvMesh/fvMeshMapper/fvMeshMapper.H +++ b/src/finiteVolume/fvMesh/fvMeshMapper/fvMeshMapper.H @@ -73,6 +73,9 @@ class fvMeshMapper //- Boundary mapper fvBoundaryMeshMapper boundaryMap_; + //- Reset patch flag. Set true for the rebuilt patch (no mapping) + boolList resetPatchFlag_; + // Private Member Functions @@ -130,6 +133,12 @@ public: { return boundaryMap_; } + + //- Return reset patch flag + const boolList& resetPatchFlag() const + { + return resetPatchFlag_; + } }; diff --git a/src/foam/fields/GeometricFields/GeometricField/MapGeometricFields.H b/src/foam/fields/GeometricFields/GeometricField/MapGeometricFields.H index 1b7c8c726..77cce7070 100644 --- a/src/foam/fields/GeometricFields/GeometricField/MapGeometricFields.H +++ b/src/foam/fields/GeometricFields/GeometricField/MapGeometricFields.H @@ -23,6 +23,7 @@ License Class Foam::MapInternalField + Foam::MapGeometricFields Description Generic internal field mapper. For "real" mapping, add template @@ -131,17 +132,72 @@ void MapGeometricFields mapper ); - // Map the patch fields - forAll (field.boundaryField(), patchi) + // Repatch boundary if needed + if + ( + field.boundaryField().size() + != mapper.mesh().boundary().size() + ) { - // Cannot check sizes for patch fields because of - // empty fields in FV and because point fields get their size - // from the patch which has already been resized + if (polyMesh::debug) + { + InfoIn("void MapGeometricFields(const MeshMapper& mapper)") + << "Resizing boundary field for " + << field.typeName << ' ' << field.name() + << endl; + } - field.boundaryField()[patchi].autoMap + field.boundaryField().setSize(mapper.mesh().boundary().size()); + } + + // Get repatch flag + const boolList& resetPatchFlag = mapper.resetPatchFlag(); + + if (resetPatchFlag.size() != field.boundaryField().size()) + { + FatalErrorIn ( - mapper.boundaryMap()[patchi] - ); + "void MapGeometricFields(const MeshMapper& mapper)" + ) << "Incorrect resetPatchFlag array size. Boundary: " + << field.boundaryField().size() << " flag: " + << resetPatchFlag.size() + << abort(FatalError); + } + + // Map the patch fields + forAll (field.boundaryField(), patchI) + { + // Flag reset can only take place for the constrained patches + // such as empty or processor + if (resetPatchFlag[patchI]) + { + // Build a new patchField if reset is true + field.boundaryField().set + ( + patchI, + PatchField::New + ( + mapper.mesh().boundary()[patchI].type(), + field.mesh().boundary()[patchI], + field.dimensionedInternalField() + ) + ); + + // Set to zero to avoid NaNs? + } + else + { + // No reset: auto-map + + // Cannot check sizes for patch fields because of + // empty fields in FV and because point fields get + // their size from the patch which has already been resized + + field.boundaryField()[patchI].autoMap + ( + mapper.boundaryMap()[patchI] + ); + } } field.instance() = field.time().timeName(); diff --git a/src/foam/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H b/src/foam/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H index 3aa734ebb..389335e32 100644 --- a/src/foam/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H +++ b/src/foam/meshes/pointMesh/pointMeshMapper/pointMeshMapper.H @@ -36,6 +36,7 @@ SourceFiles #ifndef pointMeshMapper_H #define pointMeshMapper_H +#include "mapPolyMesh.H" #include "pointMapper.H" #include "pointBoundaryMeshMapper.H" @@ -65,6 +66,9 @@ class pointMeshMapper //- Boundary mapper pointBoundaryMeshMapper boundaryMap_; + //- Reset patch flag. Set true for the rebuilt patch (no mapping) + boolList resetPatchFlag_; + // Private Member Functions @@ -84,7 +88,8 @@ public: : mesh_(mesh), pointMap_(mpm), - boundaryMap_(mesh, pointMap_, mpm) + boundaryMap_(mesh, pointMap_, mpm), + resetPatchFlag_(mpm.resetPatchFlag()) {} @@ -115,6 +120,12 @@ public: { return boundaryMap_; } + + //- Return reset patch flag + const boolList& resetPatchFlag() const + { + return resetPatchFlag_; + } }; diff --git a/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C b/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C index 1fd53638b..5eca023b0 100644 --- a/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C +++ b/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C @@ -69,6 +69,7 @@ Foam::mapPolyMesh::mapPolyMesh const labelListList& faceZonePointMap, const labelListList& faceZoneFaceMap, const labelListList& cellZoneMap, + const boolList& resetPatchFlag, const pointField& preMotionPoints, const labelList& oldPatchStarts, const labelList& oldPatchNMeshPoints @@ -99,6 +100,7 @@ Foam::mapPolyMesh::mapPolyMesh faceZonePointMap_(faceZonePointMap), faceZoneFaceMap_(faceZoneFaceMap), cellZoneMap_(cellZoneMap), + resetPatchFlag_(resetPatchFlag), preMotionPoints_(preMotionPoints), oldPatchSizes_(oldPatchStarts.size()), oldPatchStarts_(oldPatchStarts), @@ -155,6 +157,7 @@ Foam::mapPolyMesh::mapPolyMesh labelListList& faceZonePointMap, labelListList& faceZoneFaceMap, labelListList& cellZoneMap, + boolList& resetPatchFlag, pointField& preMotionPoints, labelList& oldPatchStarts, labelList& oldPatchNMeshPoints, @@ -186,6 +189,7 @@ Foam::mapPolyMesh::mapPolyMesh faceZonePointMap_(faceZonePointMap, reUse), faceZoneFaceMap_(faceZoneFaceMap, reUse), cellZoneMap_(cellZoneMap, reUse), + resetPatchFlag_(resetPatchFlag, reUse), preMotionPoints_(preMotionPoints, reUse), oldPatchSizes_(oldPatchStarts.size()), oldPatchStarts_(oldPatchStarts, reUse), diff --git a/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H b/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H index fdac9df25..1c9daeb58 100644 --- a/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H +++ b/src/foam/meshes/polyMesh/mapPolyMesh/mapPolyMesh.H @@ -139,6 +139,7 @@ SourceFiles #ifndef mapPolyMesh_H #define mapPolyMesh_H +#include "boolList.H" #include "labelList.H" #include "objectMap.H" #include "pointField.H" @@ -259,6 +260,10 @@ class mapPolyMesh // For added cells, the index is set to -1 const labelListList cellZoneMap_; + //- Reset patch flag + // True for the rebuilt patch (no mapping) + boolList resetPatchFlag_; + //- Pre-motion point positions. // This specifies the correct way of blowing up zero-volume objects const pointField preMotionPoints_; @@ -296,26 +301,36 @@ public: const label nOldPoints, const label nOldFaces, const label nOldCells, + const labelList& pointMap, const List& pointsFromPoints, + const labelList& faceMap, const List& facesFromPoints, const List& facesFromEdges, const List& facesFromFaces, + const labelList& cellMap, const List& cellsFromPoints, const List& cellsFromEdges, const List& cellsFromFaces, const List& cellsFromCells, + const labelList& reversePointMap, const labelList& reverseFaceMap, const labelList& reverseCellMap, + const labelHashSet& flipFaceFlux, + const labelListList& patchPointMap, + const labelListList& pointZoneMap, const labelListList& faceZonePointMap, const labelListList& faceZoneFaceMap, const labelListList& cellZoneMap, + + const boolList& resetPatchFlag, + const pointField& preMotionPoints, const labelList& oldPatchStarts, const labelList& oldPatchNMeshPoints @@ -328,26 +343,36 @@ public: const label nOldPoints, const label nOldFaces, const label nOldCells, + labelList& pointMap, List& pointsFromPoints, + labelList& faceMap, List& facesFromPoints, List& facesFromEdges, List& facesFromFaces, + labelList& cellMap, List& cellsFromPoints, List& cellsFromEdges, List& cellsFromFaces, List& cellsFromCells, + labelList& reversePointMap, labelList& reverseFaceMap, labelList& reverseCellMap, + labelHashSet& flipFaceFlux, + labelListList& patchPointMap, + labelListList& pointZoneMap, labelListList& faceZonePointMap, labelListList& faceZoneFaceMap, labelListList& cellZoneMap, + + boolList& resetPatchFlag, + pointField& preMotionPoints, labelList& oldPatchStarts, labelList& oldPatchNMeshPoints, @@ -616,6 +641,14 @@ public: return cellZoneMap_; } + //- Reset patch flag + // True for the rebuilt patch (no mapping) + const boolList& resetPatchFlag() const + { + return resetPatchFlag_; + } + + //- Pre-motion point positions. // This specifies the correct way of blowing up // zero-volume objects diff --git a/src/foam/meshes/polyMesh/polyMesh.C b/src/foam/meshes/polyMesh/polyMesh.C index cf4b48c07..90fffb0e1 100644 --- a/src/foam/meshes/polyMesh/polyMesh.C +++ b/src/foam/meshes/polyMesh/polyMesh.C @@ -751,7 +751,6 @@ void Foam::polyMesh::resetPrimitives // Reset patch sizes and starts - Pout<< "Resetting patches: starts: " << patchStarts << endl; forAll (boundary_, patchI) { boundary_[patchI].resetPatch @@ -1294,65 +1293,9 @@ const Foam::globalMeshData& Foam::polyMesh::globalData() const << "Constructing parallelData from processor topology" << endl; } + // Construct globalMeshData using processorPatch information only. globalMeshDataPtr_ = new globalMeshData(*this); - - // Old method. HJ, 6/Dec/2006 - -// // Check for parallel boundaries -// bool parBoundaries = false; - -// forAll (boundaryMesh(), patchI) -// { -// if -// ( -// typeid(boundaryMesh()[patchI]) -// == typeid(processorPolyPatch) -// ) -// { -// parBoundaries = true; -// break; -// } -// } - -// if (parBoundaries) -// { -// // All is well - read the parallel data - -// globalDataPtr_ = -// new globalMeshData -// ( -// IOobject -// ( -// "globalData", -// time().findInstance(meshDir(), "globalData"), -// meshSubDir, -// *this, -// IOobject::MUST_READ, -// IOobject::NO_WRITE -// ), -// *this -// ); -// } -// else -// { -// // The mesh has no parallel boundaries. Create and hook a -// // "non-parallel" parallel info -// globalDataPtr_ = -// new globalMeshData -// ( -// *this, -// false, -// false, // cyclicParallel. Remove when fixed -// nPoints(), -// nFaces(), -// nCells(), -// 0, -// labelList(0), -// labelList(0), -// labelList(0) -// ); -// } } return *globalMeshDataPtr_; diff --git a/src/foam/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/foam/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index df7ad82f8..5031e61a3 100644 --- a/src/foam/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/foam/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -604,8 +604,6 @@ void Foam::polyPatch::resetPatch boundaryMesh_.mesh().allPoints() ) ); - - Pout<< "Patch reset: faceCells: " << faceCells() << endl; } diff --git a/src/tetFiniteElement/tetPolyMesh/MapTetFemFields/tetPolyMeshMapper.H b/src/tetFiniteElement/tetPolyMesh/MapTetFemFields/tetPolyMeshMapper.H index d710f78e3..d5b8fbb73 100644 --- a/src/tetFiniteElement/tetPolyMesh/MapTetFemFields/tetPolyMeshMapper.H +++ b/src/tetFiniteElement/tetPolyMesh/MapTetFemFields/tetPolyMeshMapper.H @@ -36,6 +36,7 @@ SourceFiles #define tetPolyMeshMapper_H #include "tetPointMapper.H" +#include "mapPolyMesh.H" #include "pointMapper.H" #include "faceMapper.H" #include "cellMapper.H" @@ -76,6 +77,9 @@ class tetPolyMeshMapper //- Boundary mapper tetPolyBoundaryMapper boundaryMap_; + //- Reset patch flag. Set true for the rebuilt patch (no mapping) + boolList resetPatchFlag_; + // Private Member Functions @@ -94,15 +98,16 @@ public: tetPolyMeshMapper ( const tetPolyMesh& mesh, - const mapPolyMesh& meshMap + const mapPolyMesh& mpm ) : mesh_(mesh), - pointMap_(meshMap), - faceMap_(meshMap), - cellMap_(meshMap), - tetPointMap_(mesh, meshMap, pointMap_, faceMap_, cellMap_), - boundaryMap_(mesh, meshMap, pointMap_, faceMap_) + pointMap_(mpm), + faceMap_(mpm), + cellMap_(mpm), + tetPointMap_(mesh, mpm, pointMap_, faceMap_, cellMap_), + boundaryMap_(mesh, mpm, pointMap_, faceMap_), + resetPatchFlag_(mpm.resetPatchFlag()) {} @@ -138,6 +143,12 @@ public: { return boundaryMap_; } + + //- Return reset patch flag + const boolList& resetPatchFlag() const + { + return resetPatchFlag_; + } };