mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: renumberMethods: new library to do renumbering
This commit is contained in:
118
src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H
Normal file
118
src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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&)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
7
src/renumberMethods/Make/files
Normal file
7
src/renumberMethods/Make/files
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
renumberMethod/renumberMethod.C
|
||||||
|
manualRenumber/manualRenumber.C
|
||||||
|
CuthillMcKeeRenumber/CuthillMcKeeRenumber.C
|
||||||
|
randomRenumber/randomRenumber.C
|
||||||
|
springRenumber/springRenumber.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/librenumberMethods
|
||||||
7
src/renumberMethods/Make/options
Normal file
7
src/renumberMethods/Make/options
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-ldecompositionMethods \
|
||||||
|
-lmeshTools
|
||||||
137
src/renumberMethods/manualRenumber/manualRenumber.C
Normal file
137
src/renumberMethods/manualRenumber/manualRenumber.C
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
125
src/renumberMethods/manualRenumber/manualRenumber.H
Normal file
125
src/renumberMethods/manualRenumber/manualRenumber.H
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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&)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"manualRenumber::renumber"
|
||||||
|
"(const labelListList&, const pointField&)"
|
||||||
|
);
|
||||||
|
return labelList(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
96
src/renumberMethods/randomRenumber/randomRenumber.C
Normal file
96
src/renumberMethods/randomRenumber/randomRenumber.C
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return renumber(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::labelList Foam::randomRenumber::renumber
|
||||||
|
(
|
||||||
|
const labelListList& cellCells,
|
||||||
|
const pointField& points
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return renumber(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
107
src/renumberMethods/randomRenumber/randomRenumber.H
Normal file
107
src/renumberMethods/randomRenumber/randomRenumber.H
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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&);
|
||||||
|
|
||||||
|
//- Return for every coordinate the wanted processor number. Use the
|
||||||
|
// mesh connectivity (if needed)
|
||||||
|
virtual labelList renumber
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const pointField& cc
|
||||||
|
);
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/renumberMethods/renumberMethod/renumberMethod.C
Normal file
131
src/renumberMethods/renumberMethod/renumberMethod.C
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
161
src/renumberMethods/renumberMethod/renumberMethod.H
Normal file
161
src/renumberMethods/renumberMethod/renumberMethod.H
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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&)
|
||||||
|
{
|
||||||
|
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&);
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
);
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
172
src/renumberMethods/springRenumber/springRenumber.C
Normal file
172
src/renumberMethods/springRenumber/springRenumber.C
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
132
src/renumberMethods/springRenumber/springRenumber.H
Normal file
132
src/renumberMethods/springRenumber/springRenumber.H
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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&)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user