Slight refactorisation in processorMeshesReconstructor::reconstructMesh
This commit is contained in:
parent
f1c714eabf
commit
028cafdb32
2 changed files with 70 additions and 69 deletions
|
@ -437,15 +437,13 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare patch reconstruction
|
// Get first boundary mesh size
|
||||||
HashTable<label, word> patchNameLookup
|
const label firstBndryMeshSize =
|
||||||
(
|
meshes_[firstValidMesh()].boundaryMesh().size();
|
||||||
meshes_[firstValidMesh()].boundaryMesh().size()
|
|
||||||
);
|
// Prepare patch reconstruction. Note: default key type is word in HashTable
|
||||||
DynamicList<word> patchTypeLookup
|
HashTable<label> patchNameLookup(firstBndryMeshSize);
|
||||||
(
|
DynamicList<word> patchTypeLookup(firstBndryMeshSize);
|
||||||
meshes_[firstValidMesh()].boundaryMesh().size()
|
|
||||||
);
|
|
||||||
|
|
||||||
label nReconPatches = 0;
|
label nReconPatches = 0;
|
||||||
|
|
||||||
|
@ -459,35 +457,37 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
{
|
{
|
||||||
if (!isA<processorPolyPatch>(procPatches[patchI]))
|
if (!isA<processorPolyPatch>(procPatches[patchI]))
|
||||||
{
|
{
|
||||||
const word& patchName = procPatches[patchI].name();
|
// Regular patch, get the patch and the name
|
||||||
|
const polyPatch& patch = procPatches[patchI];
|
||||||
|
const word& patchName = patch.name();
|
||||||
|
|
||||||
// Regular patch. Try to find it in a list
|
// Insert the pair into the hash table
|
||||||
if (!patchNameLookup.found(patchName))
|
if (patchNameLookup.insert(patchName, nReconPatches))
|
||||||
{
|
{
|
||||||
// Patch not found. Add it
|
// This is the first time we're inserting this patch,
|
||||||
patchNameLookup.insert(patchName, nReconPatches);
|
// add its type into the list and increment the counter
|
||||||
patchTypeLookup.append(procPatches[patchI].type());
|
patchTypeLookup.append(patch.type());
|
||||||
nReconPatches++;
|
++nReconPatches;
|
||||||
}
|
}
|
||||||
|
// else already present in the table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in patch names and types
|
// Fill in patch names
|
||||||
wordList reconPatchNames(patchNameLookup.size());
|
wordList reconPatchNames(patchNameLookup.size());
|
||||||
wordList reconPatchTypes(patchNameLookup.size());
|
|
||||||
|
|
||||||
wordList patchNameToc = patchNameLookup.toc();
|
// Loop through all the patch names and collect names and types
|
||||||
|
forAllConstIter(HashTable<label>, patchNameLookup, iter)
|
||||||
forAll (patchNameToc, pnI)
|
|
||||||
{
|
{
|
||||||
const label pnIndex = patchNameLookup.find(patchNameToc[pnI])();
|
reconPatchNames[iter()] = iter.key();
|
||||||
|
|
||||||
reconPatchNames[pnIndex] = patchNameToc[pnI];
|
|
||||||
reconPatchTypes[pnIndex] = patchTypeLookup[pnIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transfer the contents of the patchTypeLookup dynamic list into the
|
||||||
|
// ordinary list. Note: the ordering remains the same
|
||||||
|
const wordList reconPatchTypes(patchTypeLookup.xfer());
|
||||||
|
|
||||||
// Prepare point, face and patch reconstruction
|
// Prepare point, face and patch reconstruction
|
||||||
label nReconPoints = 0;
|
label nReconPoints = 0;
|
||||||
label nReconFaces = 0;
|
label nReconFaces = 0;
|
||||||
|
@ -498,30 +498,31 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
{
|
{
|
||||||
if (meshes_.set(procI))
|
if (meshes_.set(procI))
|
||||||
{
|
{
|
||||||
// Count total number of points and faces
|
// Get current mesh
|
||||||
nReconPoints += meshes_[procI].nPoints();
|
const fvMesh& procMesh = meshes_[procI];
|
||||||
nReconFaces += meshes_[procI].allFaces().size();
|
|
||||||
nReconCells += meshes_[procI].nCells();
|
|
||||||
|
|
||||||
const polyBoundaryMesh& procPatches = meshes_[procI].boundaryMesh();
|
// Count total number of points and faces
|
||||||
|
nReconPoints += procMesh.nPoints();
|
||||||
|
nReconFaces += procMesh.allFaces().size();
|
||||||
|
nReconCells += procMesh.nCells();
|
||||||
|
|
||||||
|
const polyBoundaryMesh& procPatches = procMesh.boundaryMesh();
|
||||||
|
|
||||||
forAll (procPatches, patchI)
|
forAll (procPatches, patchI)
|
||||||
{
|
{
|
||||||
if (!isA<processorPolyPatch>(procPatches[patchI]))
|
if (!isA<processorPolyPatch>(procPatches[patchI]))
|
||||||
{
|
{
|
||||||
|
// Get current patch
|
||||||
|
const polyPatch& patch = procPatches[patchI];
|
||||||
|
|
||||||
// Find processor patch index in reconstructed boundary
|
// Find processor patch index in reconstructed boundary
|
||||||
const label pnIndex = patchNameLookup.find
|
const label pnIndex = patchNameLookup.find(patch.name())();
|
||||||
(
|
|
||||||
procPatches[patchI].name()
|
|
||||||
)();
|
|
||||||
|
|
||||||
// Check patch name and type
|
// Check patch name and type
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
procPatches[patchI].name()
|
patch.name() != reconPatchNames[pnIndex]
|
||||||
!= reconPatchNames[pnIndex]
|
|| patch.type() != reconPatchTypes[pnIndex]
|
||||||
|| procPatches[patchI].type()
|
|
||||||
!= reconPatchTypes[pnIndex]
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
|
@ -530,13 +531,12 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
"reconstructMesh(const Time& db)"
|
"reconstructMesh(const Time& db)"
|
||||||
) << "Patch name and type does not match "
|
) << "Patch name and type does not match "
|
||||||
<< "across processors for patch "
|
<< "across processors for patch "
|
||||||
<< procPatches[patchI].name() << " type: "
|
<< patch.name() << " type: " << patch.type()
|
||||||
<< procPatches[patchI].type()
|
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record number of faces in patch
|
// Record number of faces in patch
|
||||||
reconPatchSizes[pnIndex] += procPatches[patchI].size();
|
reconPatchSizes[pnIndex] += patch.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,10 +553,11 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
|
|
||||||
forAll (reconPatchFaces, patchI)
|
forAll (reconPatchFaces, patchI)
|
||||||
{
|
{
|
||||||
|
// Set size of reconstructed patch faces
|
||||||
reconPatchFaces[patchI].setSize(reconPatchSizes[patchI]);
|
reconPatchFaces[patchI].setSize(reconPatchSizes[patchI]);
|
||||||
|
|
||||||
reconPatchOwner[patchI].setSize(reconPatchSizes[patchI]);
|
// Set size of reconstructed patch face owners with default value of -1
|
||||||
reconPatchOwner[patchI] = -1;
|
reconPatchOwner[patchI].setSize(reconPatchSizes[patchI], -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Size the mapping arrays
|
// Size the mapping arrays
|
||||||
|
@ -894,14 +895,14 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get sorting order. Note make a copy of indices because
|
// Get sorting order. Note: make a copy of indices because
|
||||||
// sortable list will be deleted
|
// sortable list will be deleted
|
||||||
labelList procVisitOrder =
|
const labelList procVisitOrder =
|
||||||
SortableList<label>(nrbProcIndex).indices();
|
SortableList<label>(nrbProcIndex).indices();
|
||||||
|
|
||||||
forAll (procVisitOrder, pvoI)
|
forAll (procVisitOrder, pvoI)
|
||||||
{
|
{
|
||||||
const label patchI = procVisitOrder[pvoI];
|
const label& patchI = procVisitOrder[pvoI];
|
||||||
|
|
||||||
if (isA<processorPolyPatch>(procPatches[patchI]))
|
if (isA<processorPolyPatch>(procPatches[patchI]))
|
||||||
{
|
{
|
||||||
|
@ -964,15 +965,14 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
|
|
||||||
forAll (indices, i)
|
forAll (indices, i)
|
||||||
{
|
{
|
||||||
// Location in reconstructed patch where the face
|
// Location in reconstructed patch where the face is
|
||||||
// is inserted
|
// inserted
|
||||||
const label insertSlot = indices[i];
|
const label& insertSlot = indices[i];
|
||||||
|
|
||||||
// Calculate face index depending on the ordering
|
// Calculate face index depending on the ordering
|
||||||
const label faceI = patchStart + i;
|
const label faceI = patchStart + i;
|
||||||
|
|
||||||
face newFace = curFaces[faceI];
|
face newFace = curFaces[faceI];
|
||||||
|
|
||||||
inplaceRenumber(ppAddr, newFace);
|
inplaceRenumber(ppAddr, newFace);
|
||||||
|
|
||||||
// Insert into correct slot
|
// Insert into correct slot
|
||||||
|
@ -1035,7 +1035,9 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
cpAddr[cellI] = cellI; // + cellOffset[firstValidMesh()];
|
cpAddr[cellI] = cellI; // + cellOffset[firstValidMesh()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set cell offset for the next mesh
|
// Set cell offset for the next mesh. Note: if the next mesh is not
|
||||||
|
// valid, the cell offset is propagated to the next one in the processor
|
||||||
|
// loop below.
|
||||||
if (cellOffset.size() > firstValidMesh() + 1)
|
if (cellOffset.size() > firstValidMesh() + 1)
|
||||||
{
|
{
|
||||||
cellOffset[firstValidMesh() + 1] =
|
cellOffset[firstValidMesh() + 1] =
|
||||||
|
@ -1045,11 +1047,19 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
|
|
||||||
|
|
||||||
// Dump all other meshes, merging the processor boundaries
|
// Dump all other meshes, merging the processor boundaries
|
||||||
|
|
||||||
for (label procI = firstValidMesh() + 1; procI < meshes_.size(); procI++)
|
for (label procI = firstValidMesh() + 1; procI < meshes_.size(); procI++)
|
||||||
{
|
{
|
||||||
if (meshes_.set(procI))
|
if (!meshes_.set(procI))
|
||||||
{
|
{
|
||||||
|
// Next mesh is not valid: simply propagate cell offset
|
||||||
|
if (cellOffset.size() > procI + 1)
|
||||||
|
{
|
||||||
|
cellOffset[procI + 1] = cellOffset[procI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Valid mesh, combine it
|
||||||
Pout<< "Dump mesh " << procI
|
Pout<< "Dump mesh " << procI
|
||||||
<< " cell offset: " << cellOffset[procI]
|
<< " cell offset: " << cellOffset[procI]
|
||||||
<< endl;
|
<< endl;
|
||||||
|
@ -1190,7 +1200,7 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
}
|
}
|
||||||
} // End of "is neighbour"
|
} // End of "is neighbour"
|
||||||
} // End of "is processor"
|
} // End of "is processor"
|
||||||
}
|
} // End for all patches
|
||||||
|
|
||||||
// Dump unmarked points into the global point list
|
// Dump unmarked points into the global point list
|
||||||
label nMergedPoints = 0;
|
label nMergedPoints = 0;
|
||||||
|
@ -1294,7 +1304,7 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
|
|
||||||
// Get sorting order. Note make a copy of indices because
|
// Get sorting order. Note make a copy of indices because
|
||||||
// sortable list will be deleted
|
// sortable list will be deleted
|
||||||
labelList procVisitOrder =
|
const labelList procVisitOrder =
|
||||||
SortableList<label>(nrbProcIndex).indices();
|
SortableList<label>(nrbProcIndex).indices();
|
||||||
|
|
||||||
forAll (procVisitOrder, pvoI)
|
forAll (procVisitOrder, pvoI)
|
||||||
|
@ -1367,13 +1377,14 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
faceI++
|
faceI++
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label faceInPatch = faceI - patchStart;
|
const label faceInPatch = faceI - patchStart;
|
||||||
|
|
||||||
// Calculate master index
|
// Calculate master index
|
||||||
label masterIndex = masterProcPatch.start()
|
const label masterIndex =
|
||||||
+ faceInPatch;
|
masterProcPatch.start() + faceInPatch;
|
||||||
|
|
||||||
label masterFp = masterFaceAddr[masterIndex] - 1;
|
const label masterFp =
|
||||||
|
masterFaceAddr[masterIndex] - 1;
|
||||||
|
|
||||||
// Record face-cells for the neighbour
|
// Record face-cells for the neighbour
|
||||||
fpAddr[faceI] = -masterFaceAddr[masterIndex];
|
fpAddr[faceI] = -masterFaceAddr[masterIndex];
|
||||||
|
@ -1490,14 +1501,6 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db)
|
||||||
cellOffset[procI + 1] = cellOffset[procI] + meshes_[procI].nCells();
|
cellOffset[procI + 1] = cellOffset[procI] + meshes_[procI].nCells();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// No valid mesh. Propagate cell offset
|
|
||||||
if (cellOffset.size() > procI + 1)
|
|
||||||
{
|
|
||||||
cellOffset[procI + 1] = cellOffset[procI];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize the lists
|
// Resize the lists
|
||||||
|
|
|
@ -29,8 +29,6 @@ Description
|
||||||
matching processor boundaries and build a single combined mesh by
|
matching processor boundaries and build a single combined mesh by
|
||||||
matching processor patches to each other.
|
matching processor patches to each other.
|
||||||
|
|
||||||
In order to
|
|
||||||
|
|
||||||
Author
|
Author
|
||||||
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
||||||
|
|
||||||
|
|
Reference in a new issue