From 208cfcfc3163724171728c1dd04dc177385d8e5c Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Fri, 23 Dec 2011 12:13:09 +0000 Subject: [PATCH] GIT: renumberMethods: moved to subdirectory --- .../CuthillMcKeeRenumber.C | 106 --------- .../CuthillMcKeeRenumber.H | 118 ---------- src/renumberMethods/Make/files | 8 - src/renumberMethods/Make/options | 7 - .../boundaryFirstRenumber.C | 201 ------------------ .../boundaryFirstRenumber.H | 129 ----------- .../manualRenumber/manualRenumber.C | 137 ------------ .../manualRenumber/manualRenumber.H | 125 ----------- .../randomRenumber/randomRenumber.C | 96 --------- .../randomRenumber/randomRenumber.H | 108 ---------- .../renumberMethod/renumberMethod.C | 131 ------------ .../renumberMethod/renumberMethod.H | 161 -------------- .../springRenumber/springRenumber.C | 172 --------------- .../springRenumber/springRenumber.H | 132 ------------ 14 files changed, 1631 deletions(-) delete mode 100644 src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C delete mode 100644 src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H delete mode 100644 src/renumberMethods/Make/files delete mode 100644 src/renumberMethods/Make/options delete mode 100644 src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C delete mode 100644 src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H delete mode 100644 src/renumberMethods/manualRenumber/manualRenumber.C delete mode 100644 src/renumberMethods/manualRenumber/manualRenumber.H delete mode 100644 src/renumberMethods/randomRenumber/randomRenumber.C delete mode 100644 src/renumberMethods/randomRenumber/randomRenumber.H delete mode 100644 src/renumberMethods/renumberMethod/renumberMethod.C delete mode 100644 src/renumberMethods/renumberMethod/renumberMethod.H delete mode 100644 src/renumberMethods/springRenumber/springRenumber.C delete mode 100644 src/renumberMethods/springRenumber/springRenumber.H diff --git a/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C b/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C deleted file mode 100644 index 2732484b36d..00000000000 --- a/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C +++ /dev/null @@ -1,106 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "CuthillMcKeeRenumber.H" -#include "addToRunTimeSelectionTable.H" -#include "bandCompression.H" -#include "decompositionMethod.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(CuthillMcKeeRenumber, 0); - - addToRunTimeSelectionTable - ( - renumberMethod, - CuthillMcKeeRenumber, - dictionary - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::CuthillMcKeeRenumber::CuthillMcKeeRenumber(const dictionary& renumberDict) -: - renumberMethod(renumberDict), - reverse_ - ( - renumberDict.found(typeName + "Coeffs") - ? Switch(renumberDict.subDict(typeName + "Coeffs").lookup("reverse")) - : Switch(false) - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::CuthillMcKeeRenumber::renumber -( - const polyMesh& mesh, - const pointField& points -) const -{ - CompactListList<label> cellCells; - decompositionMethod::calcCellCells - ( - mesh, - identity(mesh.nCells()), - mesh.nCells(), - false, // local only - cellCells - ); - - labelList orderedToOld = bandCompression(cellCells()); - - if (reverse_) - { - reverse(orderedToOld); - } - - return invert(orderedToOld.size(), orderedToOld); -} - - -Foam::labelList Foam::CuthillMcKeeRenumber::renumber -( - const labelListList& cellCells, - const pointField& points -) const -{ - labelList orderedToOld = bandCompression(cellCells); - - if (reverse_) - { - reverse(orderedToOld); - } - - return invert(orderedToOld.size(), orderedToOld); -} - - -// ************************************************************************* // diff --git a/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H b/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H deleted file mode 100644 index a4ec011b407..00000000000 --- a/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H +++ /dev/null @@ -1,118 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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::CuthillMcKeeRenumber - -Description - Cuthill-McKee renumbering - -SourceFiles - CuthillMcKeeRenumber.C - -\*---------------------------------------------------------------------------*/ - -#ifndef CuthillMcKeeRenumber_H -#define CuthillMcKeeRenumber_H - -#include "renumberMethod.H" -#include "Switch.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class CuthillMcKeeRenumber Declaration -\*---------------------------------------------------------------------------*/ - -class CuthillMcKeeRenumber -: - public renumberMethod -{ - // Private data - - const Switch reverse_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct and assignment - void operator=(const CuthillMcKeeRenumber&); - CuthillMcKeeRenumber(const CuthillMcKeeRenumber&); - - -public: - - //- Runtime type information - TypeName("CuthillMcKee"); - - - // Constructors - - //- Construct given the renumber dictionary - CuthillMcKeeRenumber(const dictionary& renumberDict); - - - //- Destructor - virtual ~CuthillMcKeeRenumber() - {} - - - // Member Functions - - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) - 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) - virtual labelList renumber - ( - const polyMesh& mesh, - const pointField& cc - ) const; - - //- Return for every cell the new 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 - -// ************************************************************************* // diff --git a/src/renumberMethods/Make/files b/src/renumberMethods/Make/files deleted file mode 100644 index c19f1e6b6d6..00000000000 --- a/src/renumberMethods/Make/files +++ /dev/null @@ -1,8 +0,0 @@ -renumberMethod/renumberMethod.C -manualRenumber/manualRenumber.C -CuthillMcKeeRenumber/CuthillMcKeeRenumber.C -randomRenumber/randomRenumber.C -springRenumber/springRenumber.C -boundaryFirstRenumber/boundaryFirstRenumber.C - -LIB = $(FOAM_LIBBIN)/librenumberMethods diff --git a/src/renumberMethods/Make/options b/src/renumberMethods/Make/options deleted file mode 100644 index 03cb68d9468..00000000000 --- a/src/renumberMethods/Make/options +++ /dev/null @@ -1,7 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -LIB_LIBS = \ - -ldecompositionMethods \ - -lmeshTools diff --git a/src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C b/src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C deleted file mode 100644 index 293e5ba19b9..00000000000 --- a/src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C +++ /dev/null @@ -1,201 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "boundaryFirstRenumber.H" -#include "addToRunTimeSelectionTable.H" -#include "bandCompression.H" -#include "decompositionMethod.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(boundaryFirstRenumber, 0); - - addToRunTimeSelectionTable - ( - renumberMethod, - boundaryFirstRenumber, - dictionary - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::boundaryFirstRenumber::boundaryFirstRenumber -( - const dictionary& renumberDict -) -: - renumberMethod(renumberDict), - reverse_ - ( - renumberDict.found(typeName + "Coeffs") - ? Switch(renumberDict.subDict(typeName + "Coeffs").lookup("reverse")) - : Switch(true) - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::boundaryFirstRenumber::renumber -( - const polyMesh& mesh, - const pointField& points -) const -{ - const labelList& own = mesh.faceOwner(); - const labelList& nei = mesh.faceNeighbour(); - - // Distance to boundary. Minimum of neighbours. - labelList distance(mesh.nCells(), -1); - - // New order - labelList newOrder(mesh.nCells()); - label cellInOrder = 0; - - - // Starting faces for walk. These are the zero distance faces. - DynamicList<label> frontFaces(mesh.nFaces()-mesh.nInternalFaces()); - - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll(patches, patchI) - { - const polyPatch& pp = patches[patchI]; - - //- Note: cannot check for empty since these are introduced by - // fvMeshSubset. Also most loops don't care about patch type. - //if (!isA<emptyPolyPatch>(pp)) - { - forAll(pp, i) - { - frontFaces.append(pp.start()+i); - } - } - } - - // Loop over all frontFaces - label currentDistance = 0; - while (frontFaces.size() > 0) - { - DynamicList<label> frontCells(frontFaces.size()); - - // Set all of frontFaces' neighbours to current distance - - forAll(frontFaces, i) - { - label faceI = frontFaces[i]; - - if (mesh.isInternalFace(faceI)) - { - label ownCellI = own[faceI]; - if (distance[ownCellI] == -1) - { - distance[ownCellI] = currentDistance; - frontCells.append(ownCellI); - } - label neiCellI = nei[faceI]; - if (distance[neiCellI] == -1) - { - distance[neiCellI] = currentDistance; - frontCells.append(neiCellI); - } - } - else - { - label ownCellI = own[faceI]; - if (distance[ownCellI] == -1) - { - distance[ownCellI] = currentDistance; - frontCells.append(ownCellI); - } - } - } - - //Pout<< "For distance:" << currentDistance - // << " from " << frontFaces.size() << " faces to " - // << frontCells.size() << " cells." << endl; - - - // TBD. Determine order within current shell (frontCells). For now - // just add them. - forAll(frontCells, i) - { - newOrder[cellInOrder] = frontCells[i]; - cellInOrder++; - } - - // From cells to faces - frontFaces.clear(); - forAll(frontCells, i) - { - label cellI = frontCells[i]; - const cell& cFaces = mesh.cells()[cellI]; - - forAll(cFaces, i) - { - label faceI = cFaces[i]; - if (mesh.isInternalFace(faceI)) - { - label nbrCellI = - ( - mesh.faceOwner()[faceI] == cellI - ? mesh.faceNeighbour()[faceI] - : mesh.faceOwner()[faceI] - ); - if (distance[nbrCellI] == -1) - { - frontFaces.append(faceI); - } - } - } - } - - currentDistance++; - } - - // Return furthest away cell first - if (reverse_) - { - reverse(newOrder); - } - - //forAll(newOrder, i) - //{ - // label cellI = newOrder[i]; - // - // Pout<< "cell:" << cellI << endl; - // Pout<< " at distance:" << distance[cellI] - // << endl; - //} - - return invert(newOrder.size(), newOrder); -} - - -// ************************************************************************* // diff --git a/src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H b/src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H deleted file mode 100644 index 690af21455a..00000000000 --- a/src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H +++ /dev/null @@ -1,129 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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::boundaryFirstRenumber - -Description - Cuthill-McKee renumbering - -SourceFiles - boundaryFirstRenumber.C - -\*---------------------------------------------------------------------------*/ - -#ifndef boundaryFirstRenumber_H -#define boundaryFirstRenumber_H - -#include "renumberMethod.H" -#include "Switch.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class boundaryFirstRenumber Declaration -\*---------------------------------------------------------------------------*/ - -class boundaryFirstRenumber -: - public renumberMethod -{ - // Private data - - const Switch reverse_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct and assignment - void operator=(const boundaryFirstRenumber&); - boundaryFirstRenumber(const boundaryFirstRenumber&); - - -public: - - //- Runtime type information - TypeName("boundaryFirst"); - - - // Constructors - - //- Construct given the renumber dictionary - boundaryFirstRenumber(const dictionary& renumberDict); - - - //- Destructor - virtual ~boundaryFirstRenumber() - {} - - - // Member Functions - - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) - virtual labelList renumber(const pointField&) const - { - notImplemented - ( - "boundaryFirstRenumber::renumber(const pointField&)" - ); - return labelList(0); - } - - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) - virtual labelList renumber - ( - const polyMesh& mesh, - const pointField& cc - ) const; - - //- Return for every cell the new 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 - { - notImplemented - ( - "boundaryFirstRenumber::renumber" - "(const labelListList&, const pointField&)" - ); - return labelList(0); - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/renumberMethods/manualRenumber/manualRenumber.C b/src/renumberMethods/manualRenumber/manualRenumber.C deleted file mode 100644 index 92b5c8e00cb..00000000000 --- a/src/renumberMethods/manualRenumber/manualRenumber.C +++ /dev/null @@ -1,137 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "manualRenumber.H" -#include "addToRunTimeSelectionTable.H" -#include "IFstream.H" -#include "labelIOList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(manualRenumber, 0); - - addToRunTimeSelectionTable - ( - renumberMethod, - manualRenumber, - dictionary - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::manualRenumber::manualRenumber(const dictionary& renumberDict) -: - renumberMethod(renumberDict), - dataFile_ - ( - renumberDict.subDict(typeName+"Coeffs").lookup("dataFile") - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::manualRenumber::renumber -( - const polyMesh& mesh, - const pointField& points -) const -{ - labelIOList oldToNew - ( - IOobject - ( - dataFile_, - mesh.facesInstance(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE, - false - ) - ); - - // check if the final renumbering is OK - - if (oldToNew.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: " - << points.size() - << ".\n" << "Manual renumbering data read from file " - << dataFile_ << "." << endl - << exit(FatalError); - } - - // Invert to see if one to one - labelList newToOld(points.size(), -1); - forAll(oldToNew, i) - { - label newI = oldToNew[i]; - - if (newI < 0 || newI >= oldToNew.size()) - { - FatalErrorIn - ( - "manualRenumber::renumber(const pointField&" - ", const scalarField&)" - ) << "Renumbering is not one-to-one. Index " - << i << " maps onto " << newI - << ".\n" << "Manual renumbering data read from file " - << dataFile_ << "." << endl - << exit(FatalError); - } - - if (newToOld[newI] == -1) - { - newToOld[newI] = i; - } - else - { - FatalErrorIn - ( - "manualRenumber::renumber(const pointField&" - ", const scalarField&)" - ) << "Renumbering is not one-to-one. Both index " - << newToOld[newI] - << " and " << i << " map onto " << newI - << ".\n" << "Manual renumbering data read from file " - << dataFile_ << "." << endl - << exit(FatalError); - } - } - - return oldToNew; -} - - -// ************************************************************************* // diff --git a/src/renumberMethods/manualRenumber/manualRenumber.H b/src/renumberMethods/manualRenumber/manualRenumber.H deleted file mode 100644 index a4d4b2f46f2..00000000000 --- a/src/renumberMethods/manualRenumber/manualRenumber.H +++ /dev/null @@ -1,125 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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::manualRenumber - -Description - Renumber given a cell-to-new cell association in a file - -SourceFiles - manualRenumber.C - -\*---------------------------------------------------------------------------*/ - -#ifndef manualRenumber_H -#define manualRenumber_H - -#include "renumberMethod.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class manualRenumber Declaration -\*---------------------------------------------------------------------------*/ - -class manualRenumber -: - public renumberMethod -{ - // Private data - - const fileName dataFile_; - - - // Private Member Functions - - //- Disallow default bitwise copy construct and assignment - void operator=(const manualRenumber&); - manualRenumber(const manualRenumber&); - - -public: - - //- Runtime type information - TypeName("manual"); - - - // Constructors - - //- Construct given the renumber dictionary - manualRenumber(const dictionary& renumberDict); - - - //- Destructor - virtual ~manualRenumber() - {} - - - // Member Functions - - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) - 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) - virtual labelList renumber - ( - const polyMesh& mesh, - const pointField& cc - ) const; - - //- Return for every cell the new 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 - { - notImplemented - ( - "manualRenumber::renumber" - "(const labelListList&, const pointField&)" - ); - return labelList(0); - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/renumberMethods/randomRenumber/randomRenumber.C b/src/renumberMethods/randomRenumber/randomRenumber.C deleted file mode 100644 index 2dae28e4381..00000000000 --- a/src/renumberMethods/randomRenumber/randomRenumber.C +++ /dev/null @@ -1,96 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "randomRenumber.H" -#include "addToRunTimeSelectionTable.H" -#include "Random.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(randomRenumber, 0); - - addToRunTimeSelectionTable - ( - renumberMethod, - randomRenumber, - dictionary - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::randomRenumber::randomRenumber(const dictionary& renumberDict) -: - renumberMethod(renumberDict) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::randomRenumber::renumber -( - const pointField& points -) const -{ - Random rndGen(0); - - labelList oldToNew(identity(points.size())); - - for (label iter = 0; iter < 10; iter++) - { - forAll(oldToNew, i) - { - label j = rndGen.integer(0, oldToNew.size()-1); - Swap(oldToNew[i], oldToNew[j]); - } - } - return oldToNew; -} - - -Foam::labelList Foam::randomRenumber::renumber -( - const polyMesh& mesh, - const pointField& points -) const -{ - return renumber(points); -} - - -Foam::labelList Foam::randomRenumber::renumber -( - const labelListList& cellCells, - const pointField& points -) const -{ - return renumber(points); -} - - -// ************************************************************************* // diff --git a/src/renumberMethods/randomRenumber/randomRenumber.H b/src/renumberMethods/randomRenumber/randomRenumber.H deleted file mode 100644 index 0665d5159b3..00000000000 --- a/src/renumberMethods/randomRenumber/randomRenumber.H +++ /dev/null @@ -1,108 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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::randomRenumber - -Description - Random renumber. Just to see effect of renumbering. - -SourceFiles - randomRenumber.C - -\*---------------------------------------------------------------------------*/ - -#ifndef randomRenumber_H -#define randomRenumber_H - -#include "renumberMethod.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class randomRenumber Declaration -\*---------------------------------------------------------------------------*/ - -class randomRenumber -: - public renumberMethod -{ - // Private Member Functions - - //- Disallow default bitwise copy construct and assignment - void operator=(const randomRenumber&); - randomRenumber(const randomRenumber&); - - -public: - - //- Runtime type information - TypeName("random"); - - - // Constructors - - //- Construct given the renumber dictionary - randomRenumber(const dictionary& renumberDict); - - - //- Destructor - virtual ~randomRenumber() - {} - - - // Member Functions - - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) - virtual labelList renumber(const pointField&) const; - - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) - virtual labelList renumber - ( - const polyMesh& mesh, - const pointField& cc - ) const; - - //- Return for every cell the new 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 - -// ************************************************************************* // diff --git a/src/renumberMethods/renumberMethod/renumberMethod.C b/src/renumberMethods/renumberMethod/renumberMethod.C deleted file mode 100644 index 76ba1911e2a..00000000000 --- a/src/renumberMethods/renumberMethod/renumberMethod.C +++ /dev/null @@ -1,131 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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/>. - -InClass - renumberMethod - -\*---------------------------------------------------------------------------*/ - -#include "renumberMethod.H" -#include "decompositionMethod.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(renumberMethod, 0); - defineRunTimeSelectionTable(renumberMethod, dictionary); -} - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::autoPtr<Foam::renumberMethod> Foam::renumberMethod::New -( - const dictionary& renumberDict -) -{ - const word methodType(renumberDict.lookup("method")); - - //Info<< "Selecting renumberMethod " << methodType << endl; - - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(methodType); - - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - FatalErrorIn - ( - "renumberMethod::New" - "(const dictionary& renumberDict)" - ) << "Unknown renumberMethod " - << methodType << nl << nl - << "Valid renumberMethods are : " << endl - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalError); - } - - return autoPtr<renumberMethod>(cstrIter()(renumberDict)); -} - - -Foam::labelList Foam::renumberMethod::renumber -( - const polyMesh& mesh, - const pointField& points -) const -{ - CompactListList<label> cellCells; - decompositionMethod::calcCellCells - ( - mesh, - identity(mesh.nCells()), - mesh.nCells(), - false, // local only - cellCells - ); - - // Renumber based on agglomerated points - return renumber(cellCells(), points); -} - - -Foam::labelList Foam::renumberMethod::renumber -( - const polyMesh& mesh, - const labelList& fineToCoarse, - const pointField& coarsePoints -) const -{ - CompactListList<label> coarseCellCells; - decompositionMethod::calcCellCells - ( - mesh, - fineToCoarse, - coarsePoints.size(), - false, // local only - coarseCellCells - ); - - // Renumber based on agglomerated points - labelList coarseDistribution - ( - renumber - ( - coarseCellCells(), - coarsePoints - ) - ); - - // Rework back into renumbering for original mesh_ - labelList fineDistribution(fineToCoarse.size()); - - forAll(fineDistribution, i) - { - fineDistribution[i] = coarseDistribution[fineToCoarse[i]]; - } - - return fineDistribution; -} - - -// ************************************************************************* // diff --git a/src/renumberMethods/renumberMethod/renumberMethod.H b/src/renumberMethods/renumberMethod/renumberMethod.H deleted file mode 100644 index ead92b1e415..00000000000 --- a/src/renumberMethods/renumberMethod/renumberMethod.H +++ /dev/null @@ -1,161 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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::renumberMethod - -Description - Abstract base class for renumbering - -SourceFiles - renumberMethod.C - -\*---------------------------------------------------------------------------*/ - -#ifndef renumberMethod_H -#define renumberMethod_H - -#include "polyMesh.H" -#include "pointField.H" -#include "CompactListList.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class renumberMethod Declaration -\*---------------------------------------------------------------------------*/ - -class renumberMethod -{ - -protected: - - // Protected data - - const dictionary& renumberDict_; - -private: - - // Private Member Functions - - //- Disallow default bitwise copy construct and assignment - renumberMethod(const renumberMethod&); - void operator=(const renumberMethod&); - - -public: - - //- Runtime type information - TypeName("renumberMethod"); - - - // Declare run-time constructor selection tables - - declareRunTimeSelectionTable - ( - autoPtr, - renumberMethod, - dictionary, - ( - const dictionary& renumberDict - ), - (renumberDict) - ); - - - // Selectors - - //- Return a reference to the selected renumbering method - static autoPtr<renumberMethod> New - ( - const dictionary& renumberDict - ); - - - // Constructors - - //- Construct given the renumber dictionary - renumberMethod(const dictionary& renumberDict) - : - renumberDict_(renumberDict) - {} - - - //- Destructor - virtual ~renumberMethod() - {} - - - // Member Functions - - //- Return for every cell the new cell label. - // This is only defined for geometric renumberMethods. - virtual labelList renumber(const pointField&) const - { - notImplemented - ( - "renumberMethod:renumber(const pointField&)" - ); - return labelList(0); - } - - //- Return for every cell the new 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 - // cell - // location. Can be overridden by renumberMethods that provide this - // functionality natively. Coarse cells are local to the processor - // (if in parallel). If you want to have coarse cells spanning - // processors use the globalCellCells instead. - virtual labelList renumber - ( - const polyMesh& mesh, - const labelList& cellToRegion, - const pointField& regionPoints - ) const; - - //- Return for every cell the new 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 = 0; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/renumberMethods/springRenumber/springRenumber.C b/src/renumberMethods/springRenumber/springRenumber.C deleted file mode 100644 index 64a15145ce4..00000000000 --- a/src/renumberMethods/springRenumber/springRenumber.C +++ /dev/null @@ -1,172 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "springRenumber.H" -#include "addToRunTimeSelectionTable.H" -#include "decompositionMethod.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(springRenumber, 0); - - addToRunTimeSelectionTable - ( - renumberMethod, - springRenumber, - dictionary - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::springRenumber::springRenumber(const dictionary& renumberDict) -: - renumberMethod(renumberDict), - dict_(renumberDict.subDict(typeName+"Coeffs")), - maxCo_(readScalar(dict_.lookup("maxCo"))), - maxIter_(readLabel(dict_.lookup("maxIter"))), - freezeFraction_(readScalar(dict_.lookup("freezeFraction"))) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelList Foam::springRenumber::renumber -( - const polyMesh& mesh, - const pointField& points -) const -{ - CompactListList<label> cellCells; - decompositionMethod::calcCellCells - ( - mesh, - identity(mesh.nCells()), - mesh.nCells(), - false, // local only - cellCells - ); - - return renumber(cellCells(), points); -} - - -Foam::labelList Foam::springRenumber::renumber -( - const labelListList& cellCells, - const pointField& points -) const -{ - // Look at cell index as a 1D position parameter. - // Move cells to the average 'position' of their neighbour. - - scalarField position(cellCells.size()); - forAll(position, cellI) - { - position[cellI] = cellI; - } - - labelList oldToNew(identity(cellCells.size())); - - scalar maxCo = maxCo_ * cellCells.size(); - - for (label iter = 0; iter < maxIter_; iter++) - { - //Pout<< "Iteration : " << iter << nl - // << "------------" - // << endl; - - //Pout<< "Position :" << nl - // << " min : " << min(position) << nl - // << " max : " << max(position) << nl - // << " avg : " << average(position) << nl - // << endl; - - // Sum force per cell. - scalarField sumForce(cellCells.size(), 0.0); - forAll(cellCells, oldCellI) - { - const labelList& cCells = cellCells[oldCellI]; - label cellI = oldToNew[oldCellI]; - - forAll(cCells, i) - { - label nbrCellI = oldToNew[cCells[i]]; - - sumForce[cellI] += (position[nbrCellI]-position[cellI]); - } - } - - //Pout<< "Force :" << nl - // << " min : " << min(sumForce) << nl - // << " max : " << max(sumForce) << nl - // << " avgMag : " << average(mag(sumForce)) << nl - // << "DeltaT : " << deltaT << nl - // << endl; - - // Limit displacement - scalar deltaT = maxCo / max(mag(sumForce)); - - Info<< "Iter:" << iter - << " maxCo:" << maxCo - << " deltaT:" << deltaT - << " average force:" << average(mag(sumForce)) << endl; - - // Determine displacement. - scalarField displacement = deltaT*sumForce; - - //Pout<< "Displacement :" << nl - // << " min : " << min(displacement) << nl - // << " max : " << max(displacement) << nl - // << " avgMag : " << average(mag(displacement)) << nl - // << endl; - - // Calculate new position and scale to be within original range - // (0..nCells-1) for ease of postprocessing. - position += displacement; - position -= min(position); - position *= (position.size()-1)/max(position); - - // Slowly freeze. - maxCo *= freezeFraction_; - } - - //writeOBJ("endPosition.obj", cellCells, position); - - // Move cells to new position - labelList shuffle; - sortedOrder(position, shuffle); - - // Reorder oldToNew - inplaceReorder(shuffle, oldToNew); - - return oldToNew; -} - - -// ************************************************************************* // diff --git a/src/renumberMethods/springRenumber/springRenumber.H b/src/renumberMethods/springRenumber/springRenumber.H deleted file mode 100644 index 30f7a3d8381..00000000000 --- a/src/renumberMethods/springRenumber/springRenumber.H +++ /dev/null @@ -1,132 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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::springRenumber - -Description - Use spring analogy - attract neighbouring cells according to the distance - of their cell indices. - - // Maximum jump of cell indices. Is fraction of number of cells - maxCo 0.1; - - // Limit the amount of movement; the fraction maxCo gets decreased - // with every iteration. - freezeFraction 0.9; - - // Maximum number of iterations - maxIter 1000; - -SourceFiles - springRenumber.C - -\*---------------------------------------------------------------------------*/ - -#ifndef springRenumber_H -#define springRenumber_H - -#include "renumberMethod.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class springRenumber Declaration -\*---------------------------------------------------------------------------*/ - -class springRenumber -: - public renumberMethod -{ - // Private data - - const dictionary& dict_; - - const scalar maxCo_; - - const label maxIter_; - - const scalar freezeFraction_; - - // Private Member Functions - - //- Disallow default bitwise copy construct and assignment - void operator=(const springRenumber&); - springRenumber(const springRenumber&); - - -public: - - //- Runtime type information - TypeName("spring"); - - - // Constructors - - //- Construct given the renumber dictionary - springRenumber(const dictionary& renumberDict); - - - //- Destructor - virtual ~springRenumber() - {} - - - // Member Functions - - //- Return for every coordinate the wanted processor number. - 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) - virtual labelList renumber - ( - const polyMesh& mesh, - const pointField& cc - ) const; - - //- Return for every cell the new 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 - -// ************************************************************************* // -- GitLab