mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -96,6 +96,20 @@ T returnReduce
|
||||
}
|
||||
|
||||
|
||||
// Non-blocking version of reduce. Sets request.
|
||||
template <class T, class BinaryOp>
|
||||
void reduce
|
||||
(
|
||||
T& Value,
|
||||
const BinaryOp& bop,
|
||||
const int tag,
|
||||
label& request
|
||||
)
|
||||
{
|
||||
notImplemented("reduce(T&, const BinaryOp&, const int, label&");
|
||||
}
|
||||
|
||||
|
||||
// Insist there is a specialisation for the sum reduction of scalar(s)
|
||||
void reduce
|
||||
(
|
||||
@ -111,6 +125,14 @@ void reduce
|
||||
const int tag = Pstream::msgType()
|
||||
);
|
||||
|
||||
void reduce
|
||||
(
|
||||
scalar& Value,
|
||||
const sumOp<scalar>& bop,
|
||||
const int tag,
|
||||
label& request
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -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 in ascending order
|
||||
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
|
||||
@ -360,8 +360,14 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs)
|
||||
labelList nbrEdgeIndex;
|
||||
|
||||
{
|
||||
// Note cannot predict exact size since opposite nPoints might
|
||||
// be different from one over here.
|
||||
// !Note: there is one situation where the opposite points and
|
||||
// do not exactly match and that is while we are distributing
|
||||
// meshes and multiple parts come together from different
|
||||
// processors. This can temporarily create the situation that
|
||||
// we have points which will be merged out later but we still
|
||||
// need the face connectivity to be correct.
|
||||
// So: cannot check here on same points and edges.
|
||||
|
||||
UIPstream fromNeighbProc(neighbProcNo(), pBufs);
|
||||
|
||||
fromNeighbProc
|
||||
@ -369,24 +375,6 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs)
|
||||
>> nbrPointIndex
|
||||
>> nbrEdgeFace
|
||||
>> nbrEdgeIndex;
|
||||
|
||||
if
|
||||
(
|
||||
nbrPointIndex.size() != nPoints()
|
||||
|| nbrEdgeIndex.size() != nEdges()
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"processorPolyPatch::updateMesh(PstreamBuffers&)"
|
||||
) << "Size of data from processor " << neighbProcNo()
|
||||
<< " does not match size of data on processor "
|
||||
<< Pstream::myProcNo() << "." << nl
|
||||
<< " Neighbour has " << nbrPointFace.size()
|
||||
<< " points and " << nbrEdgeFace.size() << " edges." << nl
|
||||
<< " This proc has " << nPoints() << " points and "
|
||||
<< nEdges() << " edges." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert neighbour faces and indices into face back into
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -63,6 +63,10 @@ void Foam::reduce(vector2D&, const sumOp<vector2D>&, const int)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::reduce(scalar&, const sumOp<scalar>&, const int, label&)
|
||||
{}
|
||||
|
||||
|
||||
Foam::label Foam::UPstream::nRequests()
|
||||
{
|
||||
return 0;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -455,6 +455,41 @@ void Foam::reduce(vector2D& Value, const sumOp<vector2D>& bop, const int tag)
|
||||
}
|
||||
|
||||
|
||||
void Foam::reduce
|
||||
(
|
||||
scalar& Value,
|
||||
const sumOp<scalar>& bop,
|
||||
const int tag,
|
||||
label& requestID
|
||||
)
|
||||
{
|
||||
#ifdef MPIX_COMM_TYPE_SHARED
|
||||
// Assume mpich2 with non-blocking collectives extensions. Once mpi3
|
||||
// is available this will change.
|
||||
MPI_Request request;
|
||||
scalar v = Value;
|
||||
MPIX_Ireduce
|
||||
(
|
||||
&v,
|
||||
&Value,
|
||||
1,
|
||||
MPI_SCALAR,
|
||||
MPI_SUM,
|
||||
0, //root
|
||||
MPI_COMM_WORLD,
|
||||
&request
|
||||
);
|
||||
|
||||
requestID = PstreamGlobals::outstandingRequests_.size();
|
||||
PstreamGlobals::outstandingRequests_.append(request);
|
||||
#else
|
||||
// Non-blocking not yet implemented in mpi
|
||||
reduce(Value, bop, tag);
|
||||
requestID = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::UPstream::nRequests()
|
||||
{
|
||||
return PstreamGlobals::outstandingRequests_.size();
|
||||
|
||||
@ -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
|
||||
@ -553,6 +553,12 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::repatch
|
||||
saveBoundaryFields<tensor, surfaceMesh>(tFlds);
|
||||
|
||||
// Change the mesh (no inflation). Note: parallel comms allowed.
|
||||
//
|
||||
// NOTE: there is one very particular problem with this ordering.
|
||||
// We first create the processor patches and use these to merge out
|
||||
// shared points (see mergeSharedPoints below). So temporarily points
|
||||
// and edges do not match!
|
||||
|
||||
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
|
||||
|
||||
// Update fields. No inflation, parallel sync.
|
||||
@ -2429,10 +2435,14 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
||||
|
||||
// Change patches. Since this might change ordering of coupled faces
|
||||
// we also need to adapt our constructMaps.
|
||||
// NOTE: there is one very particular problem with this structure.
|
||||
// We first create the processor patches and use these to merge out
|
||||
// shared points (see mergeSharedPoints below). So temporarily points
|
||||
// and edges do not match!
|
||||
repatch(newPatchID, constructFaceMap);
|
||||
|
||||
// See if any geometrically shared points need to be merged. Note: does
|
||||
// parallel comms.
|
||||
// parallel comms. After this points and edges should again be consistent.
|
||||
mergeSharedPoints(constructPointMap);
|
||||
|
||||
// Bit of hack: processorFvPatchField does not get reset since created
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -54,7 +54,16 @@ surfaceNormalFixedValueFvPatchVectorField
|
||||
fixedValueFvPatchVectorField(p, iF),
|
||||
refValue_(ptf.refValue_, mapper)
|
||||
{
|
||||
fvPatchVectorField::operator=(refValue_*patch().nf());
|
||||
// Note: calculate product only on ptf to avoid multiplication on
|
||||
// unset values in reconstructPar.
|
||||
fixedValueFvPatchVectorField::operator=
|
||||
(
|
||||
vectorField
|
||||
(
|
||||
ptf.refValue_*ptf.patch().nf(),
|
||||
mapper
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
@ -72,19 +72,13 @@ void Foam::inversePointDistanceDiffusivity::correct()
|
||||
const polyMesh& mesh = mSolver().mesh();
|
||||
const polyBoundaryMesh& bdry = mesh.boundaryMesh();
|
||||
|
||||
labelHashSet patchSet(bdry.size());
|
||||
labelHashSet patchSet(bdry.patchSet(patchNames_));
|
||||
|
||||
label nPatchEdges = 0;
|
||||
|
||||
forAll(patchNames_, i)
|
||||
forAllConstIter(labelHashSet, patchSet, iter)
|
||||
{
|
||||
const label pID = bdry.findPatchID(patchNames_[i]);
|
||||
|
||||
if (pID > -1)
|
||||
{
|
||||
patchSet.insert(pID);
|
||||
nPatchEdges += bdry[pID].nEdges();
|
||||
}
|
||||
nPatchEdges += bdry[iter.key()].nEdges();
|
||||
}
|
||||
|
||||
// Distance to wall on points and edges.
|
||||
|
||||
@ -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
|
||||
@ -53,7 +53,7 @@ class inversePointDistanceDiffusivity
|
||||
// Private data
|
||||
|
||||
//- Patches selected to base the distance on
|
||||
wordList patchNames_;
|
||||
wordReList patchNames_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -18,6 +18,16 @@ set -x
|
||||
|
||||
wmake $makeType renumberMethods
|
||||
|
||||
if [ -n "$BOOST_ARCH_PATH" ]
|
||||
then
|
||||
wmake $makeType SloanRenumber
|
||||
else
|
||||
echo
|
||||
echo "Skipping SloanRenumber"
|
||||
echo
|
||||
fi
|
||||
|
||||
|
||||
#if [ -n "$ZOLTAN_ARCH_PATH" ]
|
||||
#then
|
||||
# wmake $makeType zoltanRenumber
|
||||
|
||||
3
src/renumber/SloanRenumber/Make/files
Normal file
3
src/renumber/SloanRenumber/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
SloanRenumber.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libSloanRenumber
|
||||
12
src/renumber/SloanRenumber/Make/options
Normal file
12
src/renumber/SloanRenumber/Make/options
Normal file
@ -0,0 +1,12 @@
|
||||
EXE_INC = \
|
||||
/* -DFULLDEBUG -g -O0 */ \
|
||||
-I$BOOST_ARCH_PATH/include \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||
-I$(LIB_SRC)/renumber/renumberMethods/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-L$(BOOST_ARCH_PATH)/lib -lboost_thread \
|
||||
-lmeshTools \
|
||||
-ldecompositionMethods \
|
||||
-lrenumberMethods
|
||||
263
src/renumber/SloanRenumber/SloanRenumber.C
Normal file
263
src/renumber/SloanRenumber/SloanRenumber.C
Normal file
@ -0,0 +1,263 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Adapted from Boost graph/example/sloan_ordering.cpp
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SloanRenumber.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "decompositionMethod.H"
|
||||
#include "processorPolyPatch.H"
|
||||
#include "syncTools.H"
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/sloan_ordering.hpp>
|
||||
#include <boost/graph/properties.hpp>
|
||||
#include <boost/graph/bandwidth.hpp>
|
||||
#include <boost/graph/profile.hpp>
|
||||
#include <boost/graph/wavefront.hpp>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
//Defining the graph type
|
||||
typedef adjacency_list
|
||||
<
|
||||
setS,
|
||||
vecS,
|
||||
undirectedS,
|
||||
property
|
||||
<
|
||||
vertex_color_t,
|
||||
default_color_type,
|
||||
property
|
||||
<
|
||||
vertex_degree_t,
|
||||
Foam::label,
|
||||
property
|
||||
<
|
||||
vertex_priority_t,
|
||||
Foam::scalar
|
||||
>
|
||||
>
|
||||
>
|
||||
> Graph;
|
||||
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::vertices_size_type size_type;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(SloanRenumber, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
renumberMethod,
|
||||
SloanRenumber,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::SloanRenumber::SloanRenumber(const dictionary& renumberDict)
|
||||
:
|
||||
renumberMethod(renumberDict),
|
||||
reverse_
|
||||
(
|
||||
renumberDict.found(typeName + "Coeffs")
|
||||
? Switch(renumberDict.subDict(typeName + "Coeffs").lookup("reverse"))
|
||||
: Switch(false)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelList Foam::SloanRenumber::renumber
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const pointField& points
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
|
||||
// Construct graph : faceOwner + connections across cyclics.
|
||||
|
||||
// Determine neighbour cell
|
||||
labelList nbr(mesh.nFaces()-mesh.nInternalFaces(), -1);
|
||||
forAll(pbm, patchI)
|
||||
{
|
||||
if (pbm[patchI].coupled() && !isA<processorPolyPatch>(pbm[patchI]))
|
||||
{
|
||||
SubList<label>
|
||||
(
|
||||
nbr,
|
||||
pbm[patchI].size(),
|
||||
pbm[patchI].start()-mesh.nInternalFaces()
|
||||
).assign(pbm[patchI].faceCells());
|
||||
}
|
||||
}
|
||||
syncTools::swapBoundaryFaceList(mesh, nbr);
|
||||
|
||||
|
||||
Graph G(mesh.nCells());
|
||||
|
||||
// Add internal faces
|
||||
forAll(mesh.faceNeighbour(), faceI)
|
||||
{
|
||||
add_edge(mesh.faceOwner()[faceI], mesh.faceNeighbour()[faceI], G);
|
||||
}
|
||||
// Add cyclics
|
||||
forAll(pbm, patchI)
|
||||
{
|
||||
if
|
||||
(
|
||||
pbm[patchI].coupled()
|
||||
&& !isA<processorPolyPatch>(pbm[patchI])
|
||||
&& refCast<const coupledPolyPatch>(pbm[patchI]).owner()
|
||||
)
|
||||
{
|
||||
const labelUList& faceCells = pbm[patchI].faceCells();
|
||||
forAll(faceCells, i)
|
||||
{
|
||||
label bFaceI = pbm[patchI].start()+i-mesh.nInternalFaces();
|
||||
label nbrCellI = nbr[bFaceI];
|
||||
|
||||
if (faceCells[i] < nbrCellI)
|
||||
{
|
||||
add_edge(faceCells[i], nbrCellI, G);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_edge(nbrCellI, faceCells[i], G);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Creating two iterators over the vertices
|
||||
graph_traits<Graph>::vertex_iterator ui, ui_end;
|
||||
|
||||
//Creating a property_map with the degrees of the degrees of each vertex
|
||||
property_map<Graph,vertex_degree_t>::type deg = get(vertex_degree, G);
|
||||
for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
|
||||
deg[*ui] = degree(*ui, G);
|
||||
|
||||
//Creating a property_map for the indices of a vertex
|
||||
property_map<Graph, vertex_index_t>::type index_map = get(vertex_index, G);
|
||||
|
||||
//Creating a vector of vertices
|
||||
std::vector<Vertex> sloan_order(num_vertices(G));
|
||||
|
||||
sloan_ordering
|
||||
(
|
||||
G,
|
||||
sloan_order.begin(),
|
||||
get(vertex_color, G),
|
||||
make_degree_map(G),
|
||||
get(vertex_priority, G)
|
||||
);
|
||||
|
||||
labelList orderedToOld(sloan_order.size());
|
||||
forAll(orderedToOld, c)
|
||||
{
|
||||
orderedToOld[c] = index_map[sloan_order[c]];
|
||||
}
|
||||
|
||||
if (reverse_)
|
||||
{
|
||||
reverse(orderedToOld);
|
||||
}
|
||||
|
||||
return orderedToOld;
|
||||
}
|
||||
|
||||
|
||||
Foam::labelList Foam::SloanRenumber::renumber
|
||||
(
|
||||
const labelListList& cellCells,
|
||||
const pointField& points
|
||||
) const
|
||||
{
|
||||
Graph G(cellCells.size());
|
||||
|
||||
forAll(cellCells, cellI)
|
||||
{
|
||||
const labelList& nbrs = cellCells[cellI];
|
||||
forAll(nbrs, i)
|
||||
{
|
||||
if (nbrs[i] > cellI)
|
||||
{
|
||||
add_edge(cellI, nbrs[i], G);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Creating two iterators over the vertices
|
||||
graph_traits<Graph>::vertex_iterator ui, ui_end;
|
||||
|
||||
//Creating a property_map with the degrees of the degrees of each vertex
|
||||
property_map<Graph,vertex_degree_t>::type deg = get(vertex_degree, G);
|
||||
for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui)
|
||||
deg[*ui] = degree(*ui, G);
|
||||
|
||||
//Creating a property_map for the indices of a vertex
|
||||
property_map<Graph, vertex_index_t>::type index_map = get(vertex_index, G);
|
||||
|
||||
//Creating a vector of vertices
|
||||
std::vector<Vertex> sloan_order(num_vertices(G));
|
||||
|
||||
sloan_ordering
|
||||
(
|
||||
G,
|
||||
sloan_order.begin(),
|
||||
get(vertex_color, G),
|
||||
make_degree_map(G),
|
||||
get(vertex_priority, G)
|
||||
);
|
||||
|
||||
labelList orderedToOld(sloan_order.size());
|
||||
forAll(orderedToOld, c)
|
||||
{
|
||||
orderedToOld[c] = index_map[sloan_order[c]];
|
||||
}
|
||||
|
||||
if (reverse_)
|
||||
{
|
||||
reverse(orderedToOld);
|
||||
}
|
||||
|
||||
return orderedToOld;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
123
src/renumber/SloanRenumber/SloanRenumber.H
Normal file
123
src/renumber/SloanRenumber/SloanRenumber.H
Normal file
@ -0,0 +1,123 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::SloanRenumber
|
||||
|
||||
Description
|
||||
Sloan renumbering algorithm
|
||||
|
||||
E.g. http://www.apav.it/sito_ratio/file_pdf/ratio_4/capitolo_1.pdf
|
||||
|
||||
SourceFiles
|
||||
SloanRenumber.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SloanRenumber_H
|
||||
#define SloanRenumber_H
|
||||
|
||||
#include "renumberMethod.H"
|
||||
#include "Switch.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SloanRenumber Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class SloanRenumber
|
||||
:
|
||||
public renumberMethod
|
||||
{
|
||||
// Private data
|
||||
|
||||
const Switch reverse_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
void operator=(const SloanRenumber&);
|
||||
SloanRenumber(const SloanRenumber&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Sloan");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given the renumber dictionary
|
||||
SloanRenumber(const dictionary& renumberDict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~SloanRenumber()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- 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("SloanRenumber::renumber(const pointField&)");
|
||||
return labelList(0);
|
||||
}
|
||||
|
||||
//- 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 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
|
||||
(
|
||||
const labelListList& cellCells,
|
||||
const pointField& cc
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
@ -43,6 +43,30 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::boundaryFirstRenumber::countInternalFaces
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const label cellI
|
||||
) const
|
||||
{
|
||||
const cell& cFaces = mesh.cells()[cellI];
|
||||
|
||||
label nInt = 0;
|
||||
|
||||
forAll(cFaces, i)
|
||||
{
|
||||
label faceI = cFaces[i];
|
||||
if (mesh.isInternalFace(faceI))
|
||||
{
|
||||
nInt++;
|
||||
}
|
||||
}
|
||||
return nInt;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::boundaryFirstRenumber::boundaryFirstRenumber
|
||||
@ -99,11 +123,19 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DynamicList<label> frontCells(frontFaces.size());
|
||||
DynamicList<label> frontCellWeights(frontFaces.size());
|
||||
|
||||
// - ordering
|
||||
labelList order;
|
||||
|
||||
// Loop over all frontFaces
|
||||
label currentDistance = 0;
|
||||
while (frontFaces.size() > 0)
|
||||
{
|
||||
DynamicList<label> frontCells(frontFaces.size());
|
||||
frontCells.clear();
|
||||
frontCellWeights.clear();
|
||||
|
||||
// Set all of frontFaces' neighbours to current distance
|
||||
|
||||
@ -118,12 +150,28 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
|
||||
{
|
||||
distance[ownCellI] = currentDistance;
|
||||
frontCells.append(ownCellI);
|
||||
frontCellWeights.append
|
||||
(
|
||||
countInternalFaces
|
||||
(
|
||||
mesh,
|
||||
ownCellI
|
||||
)
|
||||
);
|
||||
}
|
||||
label neiCellI = nei[faceI];
|
||||
if (distance[neiCellI] == -1)
|
||||
{
|
||||
distance[neiCellI] = currentDistance;
|
||||
frontCells.append(neiCellI);
|
||||
frontCellWeights.append
|
||||
(
|
||||
countInternalFaces
|
||||
(
|
||||
mesh,
|
||||
neiCellI
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -133,6 +181,14 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
|
||||
{
|
||||
distance[ownCellI] = currentDistance;
|
||||
frontCells.append(ownCellI);
|
||||
frontCellWeights.append
|
||||
(
|
||||
countInternalFaces
|
||||
(
|
||||
mesh,
|
||||
ownCellI
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,11 +198,12 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
|
||||
// << frontCells.size() << " cells." << endl;
|
||||
|
||||
|
||||
// TBD. Determine order within current shell (frontCells). For now
|
||||
// just add them.
|
||||
forAll(frontCells, i)
|
||||
// Determine order within current shell (frontCells) and add them
|
||||
sortedOrder(frontCellWeights, order);
|
||||
// 3. Add in sorted order
|
||||
forAll(order, i)
|
||||
{
|
||||
newOrder[cellInOrder] = frontCells[i];
|
||||
newOrder[cellInOrder] = frontCells[order[i]];
|
||||
cellInOrder++;
|
||||
}
|
||||
|
||||
@ -194,7 +251,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
|
||||
@ -56,6 +56,10 @@ class boundaryFirstRenumber
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Count the number of internal faces of a cell
|
||||
label countInternalFaces(const primitiveMesh&, const label) const;
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
void operator=(const boundaryFirstRenumber&);
|
||||
boundaryFirstRenumber(const boundaryFirstRenumber&);
|
||||
@ -80,8 +84,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 +96,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