1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::hierarchGeomDecomp
29 Does hierarchical decomposition of points. Works by first sorting the
30 points in x direction into equal sized bins, then in y direction and
31 finally in z direction.
33 Uses single array to hold decomposition which is indexed as if it is a
36 finalDecomp[i,j,k] is indexed as
38 i*n[0]*n[1] + j*n[1] + k
40 E.g. if we're sorting 'xyz': the first sort (over the x-component)
41 determines in which x-domain the point goes. Then for each of the x-domains
42 the points are sorted in y direction and each individual x-domain gets
43 split into three y-domains. And similar for the z-direction.
45 Since the domains are of equal size the maximum difference in size is
46 n[0]*n[1] (or n[1]*n[2]?) (small anyway)
52 \*---------------------------------------------------------------------------*/
54 #ifndef hierarchGeomDecomp_H
55 #define hierarchGeomDecomp_H
57 #include "geomDecomp.H"
58 #include "FixedList.H"
59 #include "direction.H"
64 /*---------------------------------------------------------------------------*\
65 Class hierarchGeomDecomp Declaration
66 \*---------------------------------------------------------------------------*/
68 class hierarchGeomDecomp
74 //- Decomposition order in terms of components.
75 FixedList<direction, 3> decompOrder_;
78 // Private Member Functions
80 //- Convert ordering string ("xyz") into list of components.
81 void setDecompOrder();
83 //- Find index of t in list inbetween indices left and right
84 static label findLower
92 //- Find midValue (at local index mid) such that the number of
93 // elements between mid and leftIndex are (globally summed) the
94 // wantedSize. Binary search.
95 static void findBinary
97 const label sizeTol, // size difference considered acceptible
99 const label leftIndex, // index of previous value
100 const scalar leftValue, // value at leftIndex
101 const scalar maxValue, // global max of values
102 const scalar wantedSize, // wanted size
103 label& mid, // index where size of bin is wantedSize
104 scalar& midValue // value at mid
107 //- Recursively sort in x,y,z (or rather acc. to decompOrder_)
112 const labelList& slice, // slice of points to decompose
113 const direction componentIndex, // index in decompOrder_
114 const label prevMult, // multiplication factor
115 labelList& finalDecomp // overall decomposition
119 //- Disallow default bitwise copy construct and assignment
120 void operator=(const hierarchGeomDecomp&);
121 hierarchGeomDecomp(const hierarchGeomDecomp&);
126 //- Runtime type information
127 TypeName("hierarchical");
132 //- Construct given the decomposition dictionary
133 hierarchGeomDecomp(const dictionary& decompositionDict);
135 //- Construct given the decomposition dictionary and mesh
138 const dictionary& decompositionDict,
145 virtual ~hierarchGeomDecomp()
151 //- hierarchgeom is aware of processor boundaries
152 virtual bool parallelAware() const
157 //- Return for every coordinate the wanted processor number. Use the
158 // mesh connectivity (if needed)
159 virtual labelList decompose(const pointField&);
161 //- Return for every coordinate the wanted processor number. Explicitly
162 // provided connectivity - does not use mesh_.
163 // The connectivity is equal to mesh.cellCells() except for
164 // - in parallel the cell numbers are global cell numbers (starting
165 // from 0 at processor0 and then incrementing all through the
167 // - the connections are across coupled patches
168 virtual labelList decompose
170 const labelListList& globalCellCells,
174 return decompose(cc);
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 // ************************************************************************* //