lduAddressing.H
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-2013 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 Class
25  Foam::lduAddressing
26 
27 Description
28  The class contains the addressing required by the lduMatrix: upper, lower
29  and losort.
30 
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.
35 
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
40  is given below:
41  \verbatim
42  owner neighbour
43  0 1
44  0 20
45  1 2
46  1 21
47  2 3
48  2 22
49  3 4
50  3 23
51  4 5
52  4 24
53  5 6
54  5 25
55  6 7
56  6 26
57  7 8
58  7 27
59  8 9
60  8 28
61  9 10
62  9 29
63  \endverbatim
64 
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:
70 
71  \verbatim
72  Owner start list: 0 2 4 6 8 10 12 14 16 18
73  \endverbatim
74 
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
77  algorithm:
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.
83 
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.
90 
91 SourceFiles
92  lduAddressing.C
93 
94 \*---------------------------------------------------------------------------*/
95 
96 #ifndef lduAddressing_H
97 #define lduAddressing_H
98 
99 #include "labelList.H"
100 #include "lduSchedule.H"
101 #include "Tuple2.H"
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 namespace Foam
106 {
107 
108 /*---------------------------------------------------------------------------*\
109  Class lduAddressing Declaration
110 \*---------------------------------------------------------------------------*/
112 class lduAddressing
113 {
114  // Private data
115 
116  //- Number of equations
117  label size_;
118 
119 
120  //- Demand-driven data
121 
122  //- Losort addressing
123  mutable labelList* losortPtr_;
124 
125  //- Owner start addressing
126  mutable labelList* ownerStartPtr_;
127 
128  //- Losort start addressing
129  mutable labelList* losortStartPtr_;
130 
131 
132  // Private Member Functions
133 
134  //- Disallow default bitwise copy construct
136 
137  //- Disallow default bitwise assignment
138  void operator=(const lduAddressing&);
139 
140  //- Calculate losort
141  void calcLosort() const;
142 
143  //- Calculate owner start
144  void calcOwnerStart() const;
145 
146  //- Calculate losort start
147  void calcLosortStart() const;
148 
149 
150 public:
151 
152  // Constructor
153  lduAddressing(const label nEqns)
154  :
155  size_(nEqns),
156  losortPtr_(NULL),
157  ownerStartPtr_(NULL),
158  losortStartPtr_(NULL)
159  {}
160 
161 
162  //- Destructor
163  virtual ~lduAddressing();
164 
165 
166  // Member Functions
167 
168  //- Return number of equations
169  label size() const
170  {
171  return size_;
172  }
173 
174  //- Return lower addressing
175  virtual const labelUList& lowerAddr() const = 0;
176 
177  //- Return upper addressing
178  virtual const labelUList& upperAddr() const = 0;
179 
180  //- Return patch to internal addressing given patch number
181  virtual const labelUList& patchAddr
182  (
183  const label patchNo
184  ) const = 0;
185 
186  // Return patch field evaluation schedule
187  virtual const lduSchedule& patchSchedule() const = 0;
188 
189  //- Return losort addressing
190  const labelUList& losortAddr() const;
191 
192  //- Return owner start addressing
193  const labelUList& ownerStartAddr() const;
194 
195  //- Return losort start addressing
196  const labelUList& losortStartAddr() const;
197 
198  //- Return off-diagonal index given owner and neighbour label
199  label triIndex(const label a, const label b) const;
200 
201  //- Calculate bandwidth and profile of addressing
202  Tuple2<label, scalar> band() const;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
label triIndex(const label a, const label b) const
Return off-diagonal index given owner and neighbour label.
const labelUList & ownerStartAddr() const
Return owner start addressing.
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
const labelUList & losortAddr() const
Return losort addressing.
Namespace for OpenFOAM.
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
const labelUList & losortStartAddr() const
Return losort start addressing.
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
virtual const lduSchedule & patchSchedule() const =0
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual ~lduAddressing()
Destructor.