lduAddressing.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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  //- Calculate losort
135  void calcLosort() const;
136 
137  //- Calculate owner start
138  void calcOwnerStart() const;
139 
140  //- Calculate losort start
141  void calcLosortStart() const;
142 
143 
144 public:
145 
146  // Constructors
148  lduAddressing(const label nEqns)
149  :
150  size_(nEqns),
151  losortPtr_(nullptr),
152  ownerStartPtr_(nullptr),
153  losortStartPtr_(nullptr)
154  {}
155 
156  //- Disallow default bitwise copy construction
157  lduAddressing(const lduAddressing&) = delete;
158 
159 
160  //- Destructor
161  virtual ~lduAddressing();
162 
163 
164  // Member Functions
165 
166  //- Return number of equations
167  label size() const
168  {
169  return size_;
170  }
171 
172  //- Return lower addressing
173  virtual const labelUList& lowerAddr() const = 0;
174 
175  //- Return upper addressing
176  virtual const labelUList& upperAddr() const = 0;
177 
178  //- Return patch to internal addressing given patch number
179  virtual const labelUList& patchAddr
180  (
181  const label patchNo
182  ) const = 0;
183 
184  // Return patch field evaluation schedule
185  virtual const lduSchedule& patchSchedule() const = 0;
186 
187  //- Return losort addressing
188  const labelUList& losortAddr() const;
189 
190  //- Return owner start addressing
191  const labelUList& ownerStartAddr() const;
192 
193  //- Return losort start addressing
194  const labelUList& losortStartAddr() const;
195 
196  //- Return off-diagonal index given owner and neighbour label
197  label triIndex(const label a, const label b) const;
198 
199  //- Calculate bandwidth and profile of addressing
200  Tuple2<label, scalar> band() const;
201 
202 
203  // Member Operators
204 
205  //- Disallow default bitwise assignment
206  void operator=(const lduAddressing&) = delete;
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
void operator=(const lduAddressing &)=delete
Disallow default bitwise assignment.
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
label triIndex(const label a, const label b) const
Return off-diagonal index given owner and neighbour label.
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
const labelUList & losortStartAddr() const
Return losort start addressing.
lduAddressing(const label nEqns)
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
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
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
virtual ~lduAddressing()
Destructor.
const labelUList & losortAddr() const
Return losort addressing.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const labelUList & ownerStartAddr() const
Return owner start addressing.
Namespace for OpenFOAM.
label size() const
Return number of equations.
virtual const lduSchedule & patchSchedule() const =0