1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 The class contains the addressing required by the lduMatrix: upper, lower
31 The addressing can be created in two ways: either with references to
32 upper and lower in which case it stores references or from labelLists,
33 in which case it stores the addressing itself. Additionally, the losort
34 addressing belongs to the class is as on lazy evaluation.
36 The ordering of owner addresses is such that the labels are in
37 increasing order, with groups of identical labels for edges "owned" by
38 the same point. The neighbour labels are also ordered in ascending
39 order but only for groups of edges belonging to each point. An example
65 There exists an alternative way of addressing the owner
66 list: instead of repeating the same label in the owner list, it is
67 possible to address the start of each point neighbours in the
68 neighbour list. This reduces the size of owner addressing from a list
69 over all edges to a list over all points + 1:
72 Owner start list: 0 2 4 6 8 10 12 14 16 18
75 We shall use the second form of the addressing for fast lookup
76 of edge label from the known owner and neighbour, using the following
78 -# take the owner label and position the start of lookup
79 using the owner start list
80 -# loop through all neighbours of this owner (ending at the start of
81 lookup of owner + 1) until the match with current neighbour is found.
82 The index used on the neighbour list for the match is the edge index.
84 While owner start addressing allows us to find the edge owned by the
85 points, it is also necessary to find the edges for which the point is
86 a neighbour. Losort addressing lists the edges neighboured by the
87 point and we shall use the same trick as above to address into this
88 list. Thus, for every point the losort start gives the address of the
89 first face to neighbour this point.
94 \*---------------------------------------------------------------------------*/
96 #ifndef lduAddressing_H
97 #define lduAddressing_H
99 #include "labelList.H"
100 #include "lduSchedule.H"
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 /*---------------------------------------------------------------------------*\
108 Class lduAddressing Declaration
109 \*---------------------------------------------------------------------------*/
115 //- Number of equations
119 //- Demand-driven data
121 //- Losort addressing
122 mutable labelList* losortPtr_;
124 //- Owner start addressing
125 mutable labelList* ownerStartPtr_;
127 //- Losort start addressing
128 mutable labelList* losortStartPtr_;
131 // Private Member Functions
133 //- Disallow default bitwise copy construct
134 lduAddressing(const lduAddressing&);
136 //- Disallow default bitwise assignment
137 void operator=(const lduAddressing&);
140 void calcLosort() const;
142 //- Calculate owner start
143 void calcOwnerStart() const;
145 //- Calculate losort start
146 void calcLosortStart() const;
152 lduAddressing(const label nEqns)
156 ownerStartPtr_(NULL),
157 losortStartPtr_(NULL)
163 virtual ~lduAddressing();
168 //- Return number of equations
174 //- Return number of interfaces
175 virtual label nPatches() const = 0;
177 //- Return lower addressing
178 virtual const unallocLabelList& lowerAddr() const = 0;
180 //- Return upper addressing
181 virtual const unallocLabelList& upperAddr() const = 0;
183 //- Return patch to internal addressing given patch number
184 virtual const unallocLabelList& patchAddr
189 // Return patch field evaluation schedule
190 virtual const lduSchedule& patchSchedule() const = 0;
192 //- Return losort addressing
193 const unallocLabelList& losortAddr() const;
195 //- Return owner start addressing
196 const unallocLabelList& ownerStartAddr() const;
198 //- Return losort start addressing
199 const unallocLabelList& losortStartAddr() const;
201 //- Return off-diagonal index given owner and neighbour label
202 label triIndex(const label a, const label b) const;
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 } // End namespace Foam
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 // ************************************************************************* //