OpenFOAM
4.1
The OpenFOAM Foundation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
renumber
renumberMethods
randomRenumber
randomRenumber.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
11
OpenFOAM is free software: you can redistribute it and/or modify it
12
under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
\*---------------------------------------------------------------------------*/
25
26
#include "
randomRenumber.H
"
27
#include "
addToRunTimeSelectionTable.H
"
28
#include "
Random.H
"
29
30
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31
32
namespace
Foam
33
{
34
defineTypeNameAndDebug
(randomRenumber, 0);
35
36
addToRunTimeSelectionTable
37
(
38
renumberMethod,
39
randomRenumber,
40
dictionary
41
);
42
}
43
44
45
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46
47
Foam::randomRenumber::randomRenumber(
const
dictionary
& renumberDict)
48
:
49
renumberMethod
(renumberDict)
50
{}
51
52
53
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54
55
Foam::labelList
Foam::randomRenumber::renumber
56
(
57
const
pointField
& points
58
)
const
59
{
60
Random
rndGen
(0);
61
62
labelList
newToOld(
identity
(points.
size
()));
63
64
for
(
label
iter = 0; iter < 10; iter++)
65
{
66
forAll
(newToOld, i)
67
{
68
label
j = rndGen.
integer
(0, newToOld.
size
()-1);
69
Swap
(newToOld[i], newToOld[j]);
70
}
71
}
72
return
newToOld;
73
}
74
75
76
Foam::labelList
Foam::randomRenumber::renumber
77
(
78
const
polyMesh
& mesh,
79
const
pointField
& points
80
)
const
81
{
82
return
renumber
(points);
83
}
84
85
86
Foam::labelList
Foam::randomRenumber::renumber
87
(
88
const
labelListList
& cellCells,
89
const
pointField
& points
90
)
const
91
{
92
return
renumber
(points);
93
}
94
95
96
// ************************************************************************* //
rndGen
cachedRandom rndGen(label(0),-1)
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition:
UList.H:428
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition:
label.H:59
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition:
dictionary.H:137
Foam::List< label >
Foam::Random::integer
label integer(const label lower, const label upper)
Label [lower..upper].
Definition:
Random.C:118
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Definition:
ListI.H:76
randomRenumber.H
Foam::identity
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition:
ListOps.C:104
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::renumberMethod
Abstract base class for renumbering.
Definition:
renumberMethod.H:48
Foam::Swap
void Swap(T &a, T &b)
Definition:
Swap.H:43
Foam::Field< vector >
Foam::randomRenumber::renumber
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
Definition:
randomRenumber.C:56
Random.H
Foam::Random
Simple random number generator.
Definition:
Random.H:49
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition:
polyMesh.H:74
Foam
Namespace for OpenFOAM.
Definition:
combustionModel.C:30
Generated by
1.8.11