mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add primitiveMesh cellBb()
- the boundBox for a given cell, using the cheapest calculation:
- cellPoints if already available, since this will involve the
fewest number of min/max comparisions.
- otherwise walk the cell faces: via the cell box() method
to avoid creating demand-driven cellPoints etc.
This commit is contained in:
committed by
Andrew Heather
parent
27c2cdc040
commit
0ba458fdbc
@ -54,23 +54,20 @@ Foam::labelList Foam::meshToMeshMethod::maskCells() const
|
||||
|
||||
intersectBb.inflate(0.01);
|
||||
|
||||
const cellList& srcCells = src_.cells();
|
||||
const faceList& srcFaces = src_.faces();
|
||||
const pointField& srcPts = src_.points();
|
||||
|
||||
DynamicList<label> cells(src_.nCells());
|
||||
forAll(srcCells, srcI)
|
||||
|
||||
for (label srcCelli = 0; srcCelli < src_.nCells(); ++srcCelli)
|
||||
{
|
||||
boundBox cellBb(srcCells[srcI].points(srcFaces, srcPts), false);
|
||||
boundBox cellBb(src_.cellBb(srcCelli));
|
||||
if (intersectBb.overlaps(cellBb))
|
||||
{
|
||||
cells.append(srcI);
|
||||
cells.append(srcCelli);
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "participating source mesh cells: " << cells.size() << endl;
|
||||
Pout<< "participating source mesh cells: " << src_.nCells() << endl;
|
||||
}
|
||||
|
||||
return cells;
|
||||
@ -87,14 +84,7 @@ bool Foam::meshToMeshMethod::intersect
|
||||
|
||||
tetOverlapVolume overlapEngine;
|
||||
|
||||
// Note: avoid demand-driven construction of cellPoints
|
||||
// treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
|
||||
const UList<label>& cellFaces = tgt_.cells()[tgtCelli];
|
||||
treeBoundBox bbTgtCell(tgt_.points(), tgt_.faces()[cellFaces[0]]);
|
||||
for (label i = 1; i < cellFaces.size(); ++i)
|
||||
{
|
||||
bbTgtCell.add(tgt_.points(), tgt_.faces()[cellFaces[i]]);
|
||||
}
|
||||
treeBoundBox bbTgtCell(tgt_.cellBb(tgtCelli));
|
||||
|
||||
return overlapEngine.cellCellOverlapMinDecomp
|
||||
(
|
||||
@ -116,14 +106,7 @@ Foam::scalar Foam::meshToMeshMethod::interVol
|
||||
{
|
||||
tetOverlapVolume overlapEngine;
|
||||
|
||||
// Note: avoid demand-driven construction of cellPoints
|
||||
// treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
|
||||
const UList<label>& cellFaces = tgt_.cells()[tgtCelli];
|
||||
treeBoundBox bbTgtCell(tgt_.points(), tgt_.faces()[cellFaces[0]]);
|
||||
for (label i = 1; i < cellFaces.size(); ++i)
|
||||
{
|
||||
bbTgtCell.add(tgt_.points(), tgt_.faces()[cellFaces[i]]);
|
||||
}
|
||||
treeBoundBox bbTgtCell(tgt_.cellBb(tgtCelli));
|
||||
|
||||
scalar vol = overlapEngine.cellCellOverlapVolumeMinDecomp
|
||||
(
|
||||
@ -147,14 +130,7 @@ Foam::meshToMeshMethod::interVolAndCentroid
|
||||
{
|
||||
tetOverlapVolume overlapEngine;
|
||||
|
||||
// Note: avoid demand-driven construction of cellPoints
|
||||
// treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
|
||||
const UList<label>& cellFaces = tgt_.cells()[tgtCelli];
|
||||
treeBoundBox bbTgtCell(tgt_.points(), tgt_.faces()[cellFaces[0]]);
|
||||
for (label i = 1; i < cellFaces.size(); ++i)
|
||||
{
|
||||
bbTgtCell.add(tgt_.points(), tgt_.faces()[cellFaces[i]]);
|
||||
}
|
||||
treeBoundBox bbTgtCell(tgt_.cellBb(tgtCelli));
|
||||
|
||||
Tuple2<scalar, point> volAndInertia =
|
||||
overlapEngine.cellCellOverlapMomentMinDecomp
|
||||
|
||||
@ -178,12 +178,8 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
|
||||
}
|
||||
|
||||
|
||||
// determine which cells of tgt mesh overlaps src mesh per proc
|
||||
const cellList& cells = tgt.cells();
|
||||
const faceList& faces = tgt.faces();
|
||||
const pointField& points = tgt.points();
|
||||
|
||||
labelListList sendMap;
|
||||
// Determine which cells of tgt mesh overlaps src mesh per proc
|
||||
labelListList sendMap(Pstream::nProcs());
|
||||
|
||||
{
|
||||
// per processor indices into all segments to send
|
||||
@ -198,20 +194,11 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
|
||||
// work array - whether src processor bb overlaps the tgt cell
|
||||
// bounds
|
||||
boolList procBbOverlaps(Pstream::nProcs());
|
||||
forAll(cells, celli)
|
||||
{
|
||||
const cell& c = cells[celli];
|
||||
|
||||
// determine bounding box of tgt cell
|
||||
boundBox cellBb(boundBox::invertedBox);
|
||||
forAll(c, facei)
|
||||
{
|
||||
const face& f = faces[c[facei]];
|
||||
forAll(f, fp)
|
||||
{
|
||||
cellBb.add(points, f);
|
||||
}
|
||||
}
|
||||
for (label celli = 0; celli < tgt.nCells(); ++celli)
|
||||
{
|
||||
// Bounding box of tgt cell
|
||||
boundBox cellBb(tgt.cellBb(celli));
|
||||
|
||||
// find the overlapping tgt cells on each src processor
|
||||
(void)calcOverlappingProcs(procBb, cellBb, procBbOverlaps);
|
||||
@ -226,23 +213,22 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
|
||||
}
|
||||
|
||||
// convert dynamicList to labelList
|
||||
sendMap.setSize(Pstream::nProcs());
|
||||
forAll(sendMap, proci)
|
||||
{
|
||||
sendMap[proci].transfer(dynSendMap[proci]);
|
||||
}
|
||||
}
|
||||
|
||||
// debug printing
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Of my " << cells.size()
|
||||
<< " target cells I need to send to:" << nl
|
||||
<< "\tproc\tcells" << endl;
|
||||
forAll(sendMap, proci)
|
||||
// debug printing
|
||||
if (debug)
|
||||
{
|
||||
Pout<< '\t' << proci << '\t' << sendMap[proci].size()
|
||||
<< endl;
|
||||
Pout<< "Of my " << tgt.nCells()
|
||||
<< " target cells I need to send to:" << nl
|
||||
<< "\tproc\tcells" << endl;
|
||||
forAll(sendMap, proci)
|
||||
{
|
||||
Pout<< '\t' << proci << '\t'
|
||||
<< sendMap[proci].size() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +236,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
|
||||
// send over how many tgt cells I need to receive from each
|
||||
// processor
|
||||
labelListList sendSizes(Pstream::nProcs());
|
||||
sendSizes[Pstream::myProcNo()].setSize(Pstream::nProcs());
|
||||
sendSizes[Pstream::myProcNo()].resize(Pstream::nProcs());
|
||||
forAll(sendMap, proci)
|
||||
{
|
||||
sendSizes[Pstream::myProcNo()][proci] = sendMap[proci].size();
|
||||
|
||||
Reference in New Issue
Block a user