1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
29 The class contains the addressing required by the lduMatrix: upper, lower
32 The addressing can be created in two ways: either with references to
33 upper and lower in which case it stores references or from labelLists,
34 in which case it stores the addressing itself. Additionally, the losort
35 addressing belongs to the class is as on lazy evaluation.
37 The ordering of owner addresses is such that the labels are in
38 increasing order, with groups of identical labels for edges "owned" by
39 the same point. The neighbour labels are also ordered in ascending
40 order but only for groups of edges belonging to each point. An example
66 There exists an alternative way of addressing the owner
67 list: instead of repeating the same label in the owner list, it is
68 possible to address the start of each point neighbours in the
69 neighbour list. This reduces the size of owner addressing from a list
70 over all edges to a list over all points + 1:
73 Owner start list: 0 2 4 6 8 10 12 14 16 18
76 We shall use the second form of the addressing for fast lookup
77 of edge label from the known owner and neighbour, using the following
79 -# take the owner label and position the start of lookup
80 using the owner start list
81 -# loop through all neighbours of this owner (ending at the start of
82 lookup of owner + 1) until the match with current neighbour is found.
83 The index used on the neighbour list for the match is the edge index.
85 While owner start addressing allows us to find the edge owned by the
86 points, it is also necessary to find the edges for which the point is
87 a neighbour. Losort addressing lists the edges neighboured by the
88 point and we shall use the same trick as above to address into this
89 list. Thus, for every point the losort start gives the address of the
90 first face to neighbour this point.
95 \*---------------------------------------------------------------------------*/
97 #ifndef lduAddressing_H
98 #define lduAddressing_H
100 #include "labelList.H"
101 #include "lduSchedule.H"
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 /*---------------------------------------------------------------------------*\
109 Class lduAddressing Declaration
110 \*---------------------------------------------------------------------------*/
116 //- Number of equations
120 //- Demand-driven data
122 //- Losort addressing
123 mutable labelList* losortPtr_;
125 //- Owner start addressing
126 mutable labelList* ownerStartPtr_;
128 //- Losort start addressing
129 mutable labelList* losortStartPtr_;
132 // Private Member Functions
134 //- Disallow default bitwise copy construct
135 lduAddressing(const lduAddressing&);
137 //- Disallow default bitwise assignment
138 void operator=(const lduAddressing&);
141 void calcLosort() const;
143 //- Calculate owner start
144 void calcOwnerStart() const;
146 //- Calculate losort start
147 void calcLosortStart() const;
153 lduAddressing(const label nEqns)
157 ownerStartPtr_(NULL),
158 losortStartPtr_(NULL)
164 virtual ~lduAddressing();
169 //- Return number of equations
175 //- Return number of interfaces
176 virtual label nPatches() const = 0;
178 //- Return lower addressing
179 virtual const unallocLabelList& lowerAddr() const = 0;
181 //- Return upper addressing
182 virtual const unallocLabelList& upperAddr() const = 0;
184 //- Return patch to internal addressing given patch number
185 virtual const unallocLabelList& patchAddr
190 // Return patch field evaluation schedule
191 virtual const lduSchedule& patchSchedule() const = 0;
193 //- Return losort addressing
194 const unallocLabelList& losortAddr() const;
196 //- Return owner start addressing
197 const unallocLabelList& ownerStartAddr() const;
199 //- Return losort start addressing
200 const unallocLabelList& losortStartAddr() const;
202 //- Return off-diagonal index given owner and neighbour label
203 label triIndex(const label a, const label b) const;
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 } // End namespace Foam
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 // ************************************************************************* //