mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: renumberMesh: changed api of renumber library.
Changed API. Made bandCompression proper CutHillMcKey. Better stats.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anispulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -105,6 +105,44 @@ label getBand(const labelList& owner, const labelList& neighbour)
|
||||
}
|
||||
|
||||
|
||||
// Calculate band of matrix
|
||||
void getBand
|
||||
(
|
||||
const label nCells,
|
||||
const labelList& owner,
|
||||
const labelList& neighbour,
|
||||
label& bandwidth,
|
||||
scalar& profile, // scalar to avoid overflow
|
||||
scalar& sumSqrIntersect // scalar to avoid overflow
|
||||
)
|
||||
{
|
||||
labelList cellBandwidth(nCells, 0);
|
||||
scalarField nIntersect(nCells, 0.0);
|
||||
|
||||
forAll(neighbour, faceI)
|
||||
{
|
||||
label own = owner[faceI];
|
||||
label nei = neighbour[faceI];
|
||||
|
||||
// Note: mag not necessary for correct (upper-triangular) ordering.
|
||||
label diff = nei-own;
|
||||
cellBandwidth[nei] = max(cellBandwidth[nei], diff);
|
||||
}
|
||||
|
||||
forAll(nIntersect, cellI)
|
||||
{
|
||||
for (label rowI = cellI-cellBandwidth[cellI]; rowI < cellI; rowI++)
|
||||
{
|
||||
nIntersect[rowI]++;
|
||||
}
|
||||
}
|
||||
|
||||
bandwidth = max(cellBandwidth);
|
||||
profile = sum(cellBandwidth);
|
||||
sumSqrIntersect = sum(Foam::sqr(nIntersect));
|
||||
}
|
||||
|
||||
|
||||
// Determine upper-triangular face order
|
||||
labelList getFaceOrder
|
||||
(
|
||||
@ -488,21 +526,12 @@ labelList regionRenumber
|
||||
|
||||
const fvMesh& subMesh = subsetter.subMesh();
|
||||
|
||||
labelList subReverseCellOrder = method.renumber
|
||||
labelList subCellOrder = method.renumber
|
||||
(
|
||||
subMesh,
|
||||
subMesh.cellCentres()
|
||||
);
|
||||
|
||||
labelList subCellOrder
|
||||
(
|
||||
invert
|
||||
(
|
||||
subMesh.nCells(),
|
||||
subReverseCellOrder
|
||||
)
|
||||
);
|
||||
|
||||
// Restore state
|
||||
UPstream::parRun() = oldParRun;
|
||||
|
||||
@ -556,13 +585,46 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
|
||||
label band = getBand(mesh.faceOwner(), mesh.faceNeighbour());
|
||||
label band;
|
||||
scalar profile;
|
||||
scalar sumSqrIntersect;
|
||||
getBand
|
||||
(
|
||||
mesh.nCells(),
|
||||
mesh.faceOwner(),
|
||||
mesh.faceNeighbour(),
|
||||
band,
|
||||
profile,
|
||||
sumSqrIntersect
|
||||
);
|
||||
|
||||
Info<< "Mesh size: " << returnReduce(mesh.nCells(), sumOp<label>()) << nl
|
||||
<< "Band before renumbering: "
|
||||
<< returnReduce(band, maxOp<label>()) << nl << endl;
|
||||
if (band != getBand(mesh.faceOwner(), mesh.faceNeighbour()))
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "band:" << band
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
reduce(band, maxOp<label>());
|
||||
reduce(profile, sumOp<scalar>());
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
returnReduce
|
||||
(
|
||||
sumSqrIntersect,
|
||||
sumOp<scalar>()
|
||||
)
|
||||
/ mesh.globalData().nTotalCells()
|
||||
);
|
||||
|
||||
Info<< "Mesh size: " << mesh.globalData().nTotalCells() << nl
|
||||
<< "Before renumbering :" << nl
|
||||
<< " band : " << band << nl
|
||||
<< " profile : " << profile << nl
|
||||
<< " rms frontwidth : " << rmsFrontwidth << nl
|
||||
<< endl;
|
||||
|
||||
bool sortCoupledFaceCells = false;
|
||||
bool writeMaps = false;
|
||||
bool orderPoints = false;
|
||||
@ -803,14 +865,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
// Detemines old to new cell ordering
|
||||
labelList reverseCellOrder = renumberPtr().renumber
|
||||
// Detemines sorted back to original cell ordering
|
||||
cellOrder = renumberPtr().renumber
|
||||
(
|
||||
mesh,
|
||||
mesh.cellCentres()
|
||||
);
|
||||
|
||||
cellOrder = invert(mesh.nCells(), reverseCellOrder);
|
||||
labelList reverseCellOrder = invert(mesh.nCells(), cellOrder);
|
||||
|
||||
|
||||
if (sortCoupledFaceCells)
|
||||
@ -969,11 +1030,36 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
band = getBand(mesh.faceOwner(), mesh.faceNeighbour());
|
||||
|
||||
Info<< "Band after renumbering: "
|
||||
<< returnReduce(band, maxOp<label>()) << nl << endl;
|
||||
|
||||
{
|
||||
label band;
|
||||
scalar profile;
|
||||
scalar sumSqrIntersect;
|
||||
getBand
|
||||
(
|
||||
mesh.nCells(),
|
||||
mesh.faceOwner(),
|
||||
mesh.faceNeighbour(),
|
||||
band,
|
||||
profile,
|
||||
sumSqrIntersect
|
||||
);
|
||||
reduce(band, maxOp<label>());
|
||||
reduce(profile, sumOp<scalar>());
|
||||
scalar rmsFrontwidth = Foam::sqrt
|
||||
(
|
||||
returnReduce
|
||||
(
|
||||
sumSqrIntersect,
|
||||
sumOp<scalar>()
|
||||
)
|
||||
/ mesh.globalData().nTotalCells()
|
||||
);
|
||||
Info<< "After renumbering :" << nl
|
||||
<< " band : " << band << nl
|
||||
<< " profile : " << profile << nl
|
||||
<< " rms frontwidth : " << rmsFrontwidth << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (orderPoints)
|
||||
{
|
||||
|
||||
@ -50,7 +50,7 @@ method CuthillMcKee;
|
||||
|
||||
manualCoeffs
|
||||
{
|
||||
// In system directory: old to new labelIOList
|
||||
// In system directory: new-to-original (i.e. order) labelIOList
|
||||
dataFile "cellMap";
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,6 +32,10 @@ Description
|
||||
|
||||
#include "bandCompression.H"
|
||||
#include "SLList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "DynamicList.H"
|
||||
#include "ListOps.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,58 +47,97 @@ Foam::labelList Foam::bandCompression(const labelListList& cellCellAddressing)
|
||||
// the business bit of the renumbering
|
||||
SLList<label> nextCell;
|
||||
|
||||
labelList visited(cellCellAddressing.size());
|
||||
PackedBoolList visited(cellCellAddressing.size());
|
||||
|
||||
label currentCell;
|
||||
label cellInOrder = 0;
|
||||
|
||||
// reset the visited cells list
|
||||
forAll(visited, cellI)
|
||||
{
|
||||
visited[cellI] = 0;
|
||||
}
|
||||
|
||||
// loop over the cells
|
||||
forAll(visited, cellI)
|
||||
// Work arrays. Kept outside of loop to minimise allocations.
|
||||
// - neighbour cells
|
||||
DynamicList<label> nbrs;
|
||||
// - corresponding weights
|
||||
DynamicList<label> weights;
|
||||
|
||||
// - ordering
|
||||
labelList order;
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
// find the first cell that has not been visited yet
|
||||
if (visited[cellI] == 0)
|
||||
// For a disconnected region find the lowest connected cell.
|
||||
|
||||
label currentCell = -1;
|
||||
label minWeight = labelMax;
|
||||
|
||||
forAll(visited, cellI)
|
||||
{
|
||||
currentCell = cellI;
|
||||
|
||||
// use this cell as a start
|
||||
nextCell.append(currentCell);
|
||||
|
||||
// loop through the nextCell list. Add the first cell into the
|
||||
// cell order if it has not already been visited and ask for its
|
||||
// neighbours. If the neighbour in question has not been visited,
|
||||
// add it to the end of the nextCell list
|
||||
|
||||
while (nextCell.size())
|
||||
// find the lowest connected cell that has not been visited yet
|
||||
if (!visited[cellI])
|
||||
{
|
||||
currentCell = nextCell.removeHead();
|
||||
|
||||
if (visited[currentCell] == 0)
|
||||
if (cellCellAddressing[cellI].size() < minWeight)
|
||||
{
|
||||
visited[currentCell] = 1;
|
||||
minWeight = cellCellAddressing[cellI].size();
|
||||
currentCell = cellI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add into cellOrder
|
||||
newOrder[cellInOrder] = currentCell;
|
||||
cellInOrder++;
|
||||
|
||||
// find if the neighbours have been visited
|
||||
const labelList& neighbours =
|
||||
cellCellAddressing[currentCell];
|
||||
if (currentCell == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
forAll(neighbours, nI)
|
||||
|
||||
// Starting from currentCell walk breadth-first
|
||||
|
||||
|
||||
// use this cell as a start
|
||||
nextCell.append(currentCell);
|
||||
|
||||
// loop through the nextCell list. Add the first cell into the
|
||||
// cell order if it has not already been visited and ask for its
|
||||
// neighbours. If the neighbour in question has not been visited,
|
||||
// add it to the end of the nextCell list
|
||||
|
||||
while (nextCell.size())
|
||||
{
|
||||
currentCell = nextCell.removeHead();
|
||||
|
||||
if (!visited[currentCell])
|
||||
{
|
||||
visited[currentCell] = 1;
|
||||
|
||||
// add into cellOrder
|
||||
newOrder[cellInOrder] = currentCell;
|
||||
cellInOrder++;
|
||||
|
||||
// find if the neighbours have been visited
|
||||
const labelList& neighbours = cellCellAddressing[currentCell];
|
||||
|
||||
// Add in increasing order of connectivity
|
||||
|
||||
// 1. Count neighbours of unvisited neighbours
|
||||
nbrs.clear();
|
||||
weights.clear();
|
||||
|
||||
forAll(neighbours, nI)
|
||||
{
|
||||
label nbr = neighbours[nI];
|
||||
if (!visited[nbr])
|
||||
{
|
||||
if (visited[neighbours[nI]] == 0)
|
||||
{
|
||||
// not visited, add to the list
|
||||
nextCell.append(neighbours[nI]);
|
||||
}
|
||||
// not visited, add to the list
|
||||
nbrs.append(nbr);
|
||||
weights.append(cellCellAddressing[nbr].size());
|
||||
}
|
||||
}
|
||||
// 2. Sort
|
||||
sortedOrder(weights, order);
|
||||
// 3. Add in sorted order
|
||||
forAll(order, i)
|
||||
{
|
||||
nextCell.append(nbrs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,7 +27,8 @@ InNamespace
|
||||
Description
|
||||
The bandCompression function renumbers the addressing such that the
|
||||
band of the matrix is reduced. The algorithm uses a simple search
|
||||
through the neighbour list
|
||||
through the neighbour list in order of connectivity.
|
||||
(CutHill-McKee algorithm)
|
||||
|
||||
SourceFiles
|
||||
bandCompression.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -604,52 +604,96 @@ Foam::label Foam::polyTopoChange::getCellOrder
|
||||
label cellInOrder = 0;
|
||||
|
||||
|
||||
// loop over the cells
|
||||
forAll(visited, cellI)
|
||||
// Work arrays. Kept outside of loop to minimise allocations.
|
||||
// - neighbour cells
|
||||
DynamicList<label> nbrs;
|
||||
// - corresponding weights
|
||||
DynamicList<label> weights;
|
||||
|
||||
// - ordering
|
||||
labelList order;
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
// find the first non-removed cell that has not been visited yet
|
||||
if (!cellRemoved(cellI) && visited[cellI] == 0)
|
||||
// For a disconnected region find the lowest connected cell.
|
||||
|
||||
label currentCell = -1;
|
||||
label minWeight = labelMax;
|
||||
|
||||
forAll(visited, cellI)
|
||||
{
|
||||
// use this cell as a start
|
||||
nextCell.append(cellI);
|
||||
|
||||
// loop through the nextCell list. Add the first cell into the
|
||||
// cell order if it has not already been visited and ask for its
|
||||
// neighbours. If the neighbour in question has not been visited,
|
||||
// add it to the end of the nextCell list
|
||||
|
||||
do
|
||||
// find the lowest connected cell that has not been visited yet
|
||||
if (!cellRemoved(cellI) && !visited[cellI])
|
||||
{
|
||||
label currentCell = nextCell.removeHead();
|
||||
|
||||
if (visited[currentCell] == 0)
|
||||
if (cellCellAddressing[cellI].size() < minWeight)
|
||||
{
|
||||
visited[currentCell] = 1;
|
||||
|
||||
// add into cellOrder
|
||||
newOrder[cellInOrder] = currentCell;
|
||||
cellInOrder++;
|
||||
|
||||
// find if the neighbours have been visited
|
||||
const UList<label> cCells = cellCellAddressing[currentCell];
|
||||
|
||||
forAll(cCells, i)
|
||||
{
|
||||
label nbr = cCells[i];
|
||||
|
||||
if (!cellRemoved(nbr) && visited[nbr] == 0)
|
||||
{
|
||||
// not visited, add to the list
|
||||
nextCell.append(nbr);
|
||||
}
|
||||
}
|
||||
minWeight = cellCellAddressing[cellI].size();
|
||||
currentCell = cellI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (currentCell == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Starting from currentCell walk breadth-first
|
||||
|
||||
|
||||
// use this cell as a start
|
||||
nextCell.append(currentCell);
|
||||
|
||||
// loop through the nextCell list. Add the first cell into the
|
||||
// cell order if it has not already been visited and ask for its
|
||||
// neighbours. If the neighbour in question has not been visited,
|
||||
// add it to the end of the nextCell list
|
||||
|
||||
while (nextCell.size())
|
||||
{
|
||||
currentCell = nextCell.removeHead();
|
||||
|
||||
if (!visited[currentCell])
|
||||
{
|
||||
visited[currentCell] = 1;
|
||||
|
||||
// add into cellOrder
|
||||
newOrder[cellInOrder] = currentCell;
|
||||
cellInOrder++;
|
||||
|
||||
// find if the neighbours have been visited
|
||||
const labelList& neighbours = cellCellAddressing[currentCell];
|
||||
|
||||
// Add in increasing order of connectivity
|
||||
|
||||
// 1. Count neighbours of unvisited neighbours
|
||||
nbrs.clear();
|
||||
weights.clear();
|
||||
|
||||
forAll(neighbours, nI)
|
||||
{
|
||||
label nbr = neighbours[nI];
|
||||
if (!cellRemoved(nbr) && !visited[nbr])
|
||||
{
|
||||
// not visited, add to the list
|
||||
nbrs.append(nbr);
|
||||
weights.append(cellCellAddressing[nbr].size());
|
||||
}
|
||||
}
|
||||
// 2. Sort
|
||||
sortedOrder(weights, order);
|
||||
// 3. Add in sorted order
|
||||
forAll(order, i)
|
||||
{
|
||||
nextCell.append(nbrs[i]);
|
||||
}
|
||||
}
|
||||
while (nextCell.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now we have new-to-old in newOrder.
|
||||
newOrder.setSize(cellInOrder);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -275,7 +275,7 @@ void Foam::decompositionMethod::calcCellCells
|
||||
{
|
||||
const polyPatch& pp = patches[patchI];
|
||||
|
||||
if (pp.coupled())
|
||||
if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
|
||||
{
|
||||
label faceI = pp.start();
|
||||
label bFaceI = pp.start()-mesh.nInternalFaces();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -82,7 +82,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber
|
||||
reverse(orderedToOld);
|
||||
}
|
||||
|
||||
return invert(orderedToOld.size(), orderedToOld);
|
||||
return orderedToOld;
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber
|
||||
reverse(orderedToOld);
|
||||
}
|
||||
|
||||
return invert(orderedToOld.size(), orderedToOld);
|
||||
return orderedToOld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -80,23 +80,26 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return for every coordinate the wanted processor number.
|
||||
// We need a polyMesh (to be able to load the file)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// This is only defined for geometric renumberMethods.
|
||||
virtual labelList renumber(const pointField&) const
|
||||
{
|
||||
notImplemented("CuthillMcKeeRenumber::renumber(const pointField&)");
|
||||
return labelList(0);
|
||||
}
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Use the
|
||||
// mesh connectivity (if needed)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cc
|
||||
) const;
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// The connectivity is equal to mesh.cellCells() except
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList renumber
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -194,7 +194,7 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
|
||||
// << endl;
|
||||
//}
|
||||
|
||||
return invert(newOrder.size(), newOrder);
|
||||
return newOrder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -80,8 +80,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return for every coordinate the wanted processor number.
|
||||
// We need a polyMesh (to be able to load the file)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// This is only defined for geometric renumberMethods.
|
||||
virtual labelList renumber(const pointField&) const
|
||||
{
|
||||
notImplemented
|
||||
@ -91,15 +92,17 @@ public:
|
||||
return labelList(0);
|
||||
}
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Use the
|
||||
// mesh connectivity (if needed)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cc
|
||||
) const;
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// The connectivity is equal to mesh.cellCells() except
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList renumber
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -63,7 +63,7 @@ Foam::labelList Foam::manualRenumber::renumber
|
||||
const pointField& points
|
||||
) const
|
||||
{
|
||||
labelIOList oldToNew
|
||||
labelIOList newToOld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -78,14 +78,14 @@ Foam::labelList Foam::manualRenumber::renumber
|
||||
|
||||
// check if the final renumbering is OK
|
||||
|
||||
if (oldToNew.size() != points.size())
|
||||
if (newToOld.size() != points.size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"manualRenumber::renumber(const pointField&, const scalarField&)"
|
||||
) << "Size of renumber list does not correspond "
|
||||
<< "to the number of points. Size: "
|
||||
<< oldToNew.size() << " Number of points: "
|
||||
<< newToOld.size() << " Number of points: "
|
||||
<< points.size()
|
||||
<< ".\n" << "Manual renumbering data read from file "
|
||||
<< dataFile_ << "." << endl
|
||||
@ -93,27 +93,27 @@ Foam::labelList Foam::manualRenumber::renumber
|
||||
}
|
||||
|
||||
// Invert to see if one to one
|
||||
labelList newToOld(points.size(), -1);
|
||||
forAll(oldToNew, i)
|
||||
labelList oldToNew(points.size(), -1);
|
||||
forAll(newToOld, i)
|
||||
{
|
||||
label newI = oldToNew[i];
|
||||
label origCellI = newToOld[i];
|
||||
|
||||
if (newI < 0 || newI >= oldToNew.size())
|
||||
if (origCellI < 0 || origCellI >= points.size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"manualRenumber::renumber(const pointField&"
|
||||
", const scalarField&)"
|
||||
) << "Renumbering is not one-to-one. Index "
|
||||
<< i << " maps onto " << newI
|
||||
<< i << " maps onto original cell " << origCellI
|
||||
<< ".\n" << "Manual renumbering data read from file "
|
||||
<< dataFile_ << "." << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (newToOld[newI] == -1)
|
||||
if (oldToNew[origCellI] == -1)
|
||||
{
|
||||
newToOld[newI] = i;
|
||||
oldToNew[origCellI] = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,15 +122,15 @@ Foam::labelList Foam::manualRenumber::renumber
|
||||
"manualRenumber::renumber(const pointField&"
|
||||
", const scalarField&)"
|
||||
) << "Renumbering is not one-to-one. Both index "
|
||||
<< newToOld[newI]
|
||||
<< " and " << i << " map onto " << newI
|
||||
<< oldToNew[origCellI]
|
||||
<< " and " << i << " map onto " << origCellI
|
||||
<< ".\n" << "Manual renumbering data read from file "
|
||||
<< dataFile_ << "." << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return oldToNew;
|
||||
return newToOld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::manualRenumber
|
||||
|
||||
Description
|
||||
Renumber given a cell-to-new cell association in a file
|
||||
Renumber given a ordered-to-original cell association in a file
|
||||
|
||||
SourceFiles
|
||||
manualRenumber.C
|
||||
@ -79,23 +79,26 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return for every coordinate the wanted processor number.
|
||||
// We need a polyMesh (to be able to load the file)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// This is only defined for geometric renumberMethods.
|
||||
virtual labelList renumber(const pointField&) const
|
||||
{
|
||||
notImplemented("manualRenumber::renumber(const pointField&)");
|
||||
return labelList(0);
|
||||
}
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Use the
|
||||
// mesh connectivity (if needed)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cc
|
||||
) const;
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// The connectivity is equal to mesh.cellCells() except
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList renumber
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,17 +59,17 @@ Foam::labelList Foam::randomRenumber::renumber
|
||||
{
|
||||
Random rndGen(0);
|
||||
|
||||
labelList oldToNew(identity(points.size()));
|
||||
labelList newToOld(identity(points.size()));
|
||||
|
||||
for (label iter = 0; iter < 10; iter++)
|
||||
{
|
||||
forAll(oldToNew, i)
|
||||
forAll(newToOld, i)
|
||||
{
|
||||
label j = rndGen.integer(0, oldToNew.size()-1);
|
||||
Swap(oldToNew[i], oldToNew[j]);
|
||||
label j = rndGen.integer(0, newToOld.size()-1);
|
||||
Swap(newToOld[i], newToOld[j]);
|
||||
}
|
||||
}
|
||||
return oldToNew;
|
||||
return newToOld;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -74,19 +74,22 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return for every coordinate the wanted processor number.
|
||||
// We need a polyMesh (to be able to load the file)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber(const pointField&) const;
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Use the
|
||||
// mesh connectivity (if needed)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cc
|
||||
) const;
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// The connectivity is equal to mesh.cellCells() except
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList renumber
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -109,7 +109,8 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// This is only defined for geometric renumberMethods.
|
||||
virtual labelList renumber(const pointField&) const
|
||||
{
|
||||
@ -120,12 +121,14 @@ public:
|
||||
return labelList(0);
|
||||
}
|
||||
|
||||
//- Return for every cell the new cell label. Use the
|
||||
// mesh connectivity (if needed)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber(const polyMesh&, const pointField&) const;
|
||||
|
||||
//- Return for every cell the new cell label. Gets
|
||||
// passed agglomeration map (from fine to coarse cells) and coarse
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Gets passed agglomeration map (from fine to coarse cells) and coarse
|
||||
// cell
|
||||
// location. Can be overridden by renumberMethods that provide this
|
||||
// functionality natively. Coarse cells are local to the processor
|
||||
@ -138,7 +141,8 @@ public:
|
||||
const pointField& regionPoints
|
||||
) const;
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// The connectivity is equal to mesh.cellCells() except
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList renumber
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -165,7 +165,7 @@ Foam::labelList Foam::springRenumber::renumber
|
||||
// Reorder oldToNew
|
||||
inplaceReorder(shuffle, oldToNew);
|
||||
|
||||
return oldToNew;
|
||||
return invert(oldToNew.size(), oldToNew);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -95,22 +95,26 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return for every coordinate the wanted processor number.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// This is only defined for geometric renumberMethods.
|
||||
virtual labelList renumber(const pointField&) const
|
||||
{
|
||||
notImplemented("springRenumber::renumber(const pointField&)");
|
||||
return labelList(0);
|
||||
}
|
||||
|
||||
//- Return for every coordinate the wanted processor number. Use the
|
||||
// mesh connectivity (if needed)
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// Use the mesh connectivity (if needed)
|
||||
virtual labelList renumber
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& cc
|
||||
) const;
|
||||
|
||||
//- Return for every cell the new cell label.
|
||||
//- Return the order in which cells need to be visited, i.e.
|
||||
// from ordered back to original cell label.
|
||||
// The connectivity is equal to mesh.cellCells() except
|
||||
// - the connections are across coupled patches
|
||||
virtual labelList renumber
|
||||
|
||||
Reference in New Issue
Block a user