Changed resizing mechanism in load balancing topo change

This commit is contained in:
Hrvoje Jasak 2018-05-16 11:19:31 +01:00
parent 63c9311177
commit 737dee5705
3 changed files with 77 additions and 13 deletions

View file

@ -40,6 +40,8 @@ SourceFiles
#include "dynamicFvMesh.H"
#include "polyTopoChanger.H"
#include "mapPolyMesh.H"
#include "fvMeshMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -100,7 +102,7 @@ class topoChangerFvMesh
const HashTable<const GeoField*>& geoFields,
const Reconstructor& reconstructor,
const List<PtrList<GeoField> >& receivedFields,
const boolList& patchesToReplace
const mapPolyMesh& meshMap
) const;

View file

@ -28,10 +28,8 @@ License
#include "fvFieldDecomposer.H"
#include "processorMeshesReconstructor.H"
#include "fvFieldReconstructor.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "passiveProcessorPolyPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -543,6 +541,60 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
}
}
// Create mesh map. Note: map is dummy and it is used only for resizing
// HJ, 16/May/2018
const polyBoundaryMesh& patches = boundaryMesh();
labelList patchStarts(patches.size());
labelList oldPatchNMeshPoints(patches.size());
labelListList patchPointMap(patches.size());
forAll(patches, patchI)
{
patchStarts[patchI] = patches[patchI].start();
oldPatchNMeshPoints[patchI] = patches[patchI].nPoints();
patchPointMap[patchI].setSize(patches[patchI].nPoints(), -1);
}
mapPolyMesh meshMap
(
*this, // const polyMesh& mesh,
nPoints(), // nOldPoints,
nFaces(), // nOldFaces,
nCells(), // nOldCells,
labelList(reconMesh.nPoints(), -1), // pointMap,
List<objectMap>(0), // pointsFromPoints,
labelList(reconMesh.nFaces(), -1), // faceMap,
List<objectMap>(0), // facesFromPoints,
List<objectMap>(0), // facesFromEdges,
List<objectMap>(0), // facesFromFaces,
labelList(), // cellMap,
List<objectMap>(0), // cellsFromPoints,
List<objectMap>(0), // cellsFromEdges,
List<objectMap>(0), // cellsFromFaces,
List<objectMap>(0), // cellsFromCells,
labelList(nPoints(), -1), // reversePointMap,
labelList(nFaces(), -1), // reverseFaceMap,
labelList(nCells(), -1), // reverseCellMap,
labelHashSet(0), // flipFaceFlux,
labelListList(0), // patchPointMap,
labelListList(0), // pointZoneMap,
labelListList(0), // faceZonePointMap,
labelListList(0), // faceZoneFaceMap,
labelListList(0), // cellZoneMap,
resetFvPatchFlag, // resetPatchFlag
pointField(0), // preMotionPoints,
patchStarts, // oldPatchStarts,
oldPatchNMeshPoints // oldPatchNMeshPoints
);
// Reset fvMesh and patches
resetFvPrimitives
(
@ -573,7 +625,7 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
volScalarFields,
fieldReconstructor,
receivedVolScalarFields,
resetFvPatchFlag
meshMap
);
rebuildFields
@ -581,7 +633,7 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
volVectorFields,
fieldReconstructor,
receivedVolVectorFields,
resetFvPatchFlag
meshMap
);
rebuildFields
@ -589,7 +641,7 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
surfaceScalarFields,
fieldReconstructor,
receivedSurfaceScalarFields,
resetFvPatchFlag
meshMap
);
// Debug

View file

@ -157,11 +157,14 @@ void Foam::topoChangerFvMesh::rebuildFields
const HashTable<const GeoField*>& geoFields,
const Reconstructor& reconstructor,
const List<PtrList<GeoField> >& receivedFields,
const boolList& patchesToReplace
const mapPolyMesh& meshMap
) const
{
label fieldI = 0;
// Make an fvMesh mapper
const fvMeshMapper mapper(*this, meshMap);
forAllConstIter
(
typename HashTable<const GeoField*>,
@ -221,12 +224,17 @@ void Foam::topoChangerFvMesh::rebuildFields
" const HashTable<const GeoField*>& geoFields,\n"
" const Reconstructor& reconstructor,\n"
" const List<PtrList<GeoField> >& receivedFields,\n"
" const mapPolyMesh& meshMap,\n"
") const"
) << "Name mismatch when rebuilding field " << masterField.name()
<< abort(FatalError);
}
if (patchesToReplace.size() != masterField.mesh().boundary().size())
if
(
meshMap.resetPatchFlag().size()
!= masterField.mesh().boundary().size()
)
{
FatalErrorIn
(
@ -235,10 +243,11 @@ void Foam::topoChangerFvMesh::rebuildFields
" const HashTable<const GeoField*>& geoFields,\n"
" const Reconstructor& reconstructor,\n"
" const List<PtrList<GeoField> >& receivedFields,\n"
" const mapPolyMesh& meshMap,\n"
") const"
) << "Bad size of patches to replace. Boundary: "
<< masterField.mesh().boundary().size()
<< " patchesToReplace: " << patchesToReplace.size()
<< " resetPatchFlag: " << meshMap.resetPatchFlag().size()
<< abort(FatalError);
}
@ -280,7 +289,7 @@ void Foam::topoChangerFvMesh::rebuildFields
// Resize patch fields
forAll (patchFields, patchI)
{
if (patchesToReplace[patchI])
if (meshMap.resetPatchFlag()[patchI])
{
// Create a new constrained patch field
Pout<< "Inserting constrained patch field for patch "
@ -319,9 +328,10 @@ void Foam::topoChangerFvMesh::rebuildFields
<< masterField.mesh().boundary()[patchI].size()
<< endl;
patchFields[patchI].resetSize
// Reset patch field size
patchFields[patchI].autoMap
(
masterField.mesh().boundary()[patchI].size()
mapper.boundaryMap()[patchI]
);
}
}