1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, 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)
162 virtual ~lduAddressing();
167 //- Return number of equations
173 //- Return lower addressing
174 virtual const labelUList& lowerAddr() const = 0;
176 //- Return upper addressing
177 virtual const labelUList& upperAddr() const = 0;
179 //- Return patch to internal addressing given patch number
180 virtual const labelUList& patchAddr
185 // Return patch field evaluation schedule
186 virtual const lduSchedule& patchSchedule() const = 0;
188 //- Return losort addressing
189 const labelUList& losortAddr() const;
191 //- Return owner start addressing
192 const labelUList& ownerStartAddr() const;
194 //- Return losort start addressing
195 const labelUList& losortStartAddr() const;
197 //- Return off-diagonal index given owner and neighbour label
198 label triIndex(const label a, const label b) const;
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 } // End namespace Foam
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 // ************************************************************************* //