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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::lduAddressing
29 
30 Description
31  The class contains the addressing required by the lduMatrix: upper, lower
32  and losort.
33 
34  The addressing can be created in two ways: either with references to
35  upper and lower in which case it stores references or from labelLists,
36  in which case it stores the addressing itself. Additionally, the losort
37  addressing belongs to the class is as on lazy evaluation.
38 
39  The ordering of owner addresses is such that the labels are in
40  increasing order, with groups of identical labels for edges "owned" by
41  the same point. The neighbour labels are also ordered in ascending
42  order but only for groups of edges belonging to each point. An example
43  is given below:
44  \verbatim
45  owner neighbour
46  0 1
47  0 20
48  1 2
49  1 21
50  2 3
51  2 22
52  3 4
53  3 23
54  4 5
55  4 24
56  5 6
57  5 25
58  6 7
59  6 26
60  7 8
61  7 27
62  8 9
63  8 28
64  9 10
65  9 29
66  \endverbatim
67 
68  There exists an alternative way of addressing the owner
69  list: instead of repeating the same label in the owner list, it is
70  possible to address the start of each point neighbours in the
71  neighbour list. This reduces the size of owner addressing from a list
72  over all edges to a list over all points + 1:
73 
74  \verbatim
75  Owner start list: 0 2 4 6 8 10 12 14 16 18
76  \endverbatim
77 
78  We shall use the second form of the addressing for fast lookup
79  of edge label from the known owner and neighbour, using the following
80  algorithm:
81  -# take the owner label and position the start of lookup
82  using the owner start list
83  -# loop through all neighbours of this owner (ending at the start of
84  lookup of owner + 1) until the match with current neighbour is found.
85  The index used on the neighbour list for the match is the edge index.
86 
87  While owner start addressing allows us to find the edge owned by the
88  points, it is also necessary to find the edges for which the point is
89  a neighbour. Losort addressing lists the edges neighboured by the
90  point and we shall use the same trick as above to address into this
91  list. Thus, for every point the losort start gives the address of the
92  first face to neighbour this point.
93 
94 SourceFiles
95  lduAddressing.C
96 
97 \*---------------------------------------------------------------------------*/
98 
99 #ifndef lduAddressing_H
100 #define lduAddressing_H
101 
102 #include "labelList.H"
103 #include "lduSchedule.H"
104 #include "Tuple2.H"
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 namespace Foam
109 {
110 
111 /*---------------------------------------------------------------------------*\
112  Class lduAddressing Declaration
113 \*---------------------------------------------------------------------------*/
114 
115 class lduAddressing
116 {
117  // Private Data
118 
119  //- Number of equations
120  label size_;
121 
122 
123  //- Demand-driven data
124 
125  //- Losort addressing
126  mutable labelList* losortPtr_;
127 
128  //- Owner start addressing
129  mutable labelList* ownerStartPtr_;
130 
131  //- Losort start addressing
132  mutable labelList* losortStartPtr_;
133 
134 
135  // Private Member Functions
136 
137  //- No copy construct
138  lduAddressing(const lduAddressing&) = delete;
139 
140  //- No copy assignment
141  void operator=(const lduAddressing&) = delete;
142 
143  //- Calculate losort
144  void calcLosort() const;
145 
146  //- Calculate owner start
147  void calcOwnerStart() const;
148 
149  //- Calculate losort start
150  void calcLosortStart() const;
151 
152 
153 public:
154 
155  //- Construct with size (number of equations)
156  explicit lduAddressing(const label nEqns)
157  :
158  size_(nEqns),
159  losortPtr_(nullptr),
160  ownerStartPtr_(nullptr),
161  losortStartPtr_(nullptr)
162  {}
163 
164 
165  //- Destructor
166  virtual ~lduAddressing();
167 
168 
169  // Member Functions
170 
171  //- Return number of equations
172  label size() const
173  {
174  return size_;
175  }
176 
177  //- Return lower addressing
178  virtual const labelUList& lowerAddr() const = 0;
179 
180  //- Return upper addressing
181  virtual const labelUList& upperAddr() const = 0;
182 
183  //- Return patch to internal addressing given patch number
184  virtual const labelUList& patchAddr
185  (
186  const label patchNo
187  ) const = 0;
188 
189  //- Return patch field evaluation schedule
190  virtual const lduSchedule& patchSchedule() const = 0;
191 
192  //- Clear additional addressing
193  void clearOut();
194 
195  //- Return losort addressing
196  const labelUList& losortAddr() const;
197 
198  //- Return owner start addressing
199  const labelUList& ownerStartAddr() const;
200 
201  //- Return losort start addressing
202  const labelUList& losortStartAddr() const;
203 
204  //- Return off-diagonal index given owner and neighbour label
205  label triIndex(const label a, const label b) const;
206 
207  //- Calculate bandwidth and profile of addressing
208  Tuple2<label, scalar> band() const;
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Tuple2.H
Foam::lduAddressing::losortStartAddr
const labelUList & losortStartAddr() const
Return losort start addressing.
Definition: lduAddressing.C:210
Foam::lduAddressing::ownerStartAddr
const labelUList & ownerStartAddr() const
Return owner start addressing.
Definition: lduAddressing.C:199
Foam::lduAddressing::lduAddressing
lduAddressing(const label nEqns)
Construct with size (number of equations)
Definition: lduAddressing.H:155
Foam::lduAddressing::size
label size() const
Return number of equations.
Definition: lduAddressing.H:171
Foam::lduAddressing::upperAddr
virtual const labelUList & upperAddr() const =0
Return upper addressing.
Foam::lduAddressing::losortAddr
const labelUList & losortAddr() const
Return losort addressing.
Definition: lduAddressing.C:188
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
labelList.H
Foam::lduAddressing::patchSchedule
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.
lduSchedule.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::lduAddressing::clearOut
void clearOut()
Clear additional addressing.
Definition: lduAddressing.C:221
Foam::lduAddressing::lowerAddr
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Foam::List< label >
Foam::UList< label >
Foam::lduAddressing::patchAddr
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
Foam::lduAddressing::triIndex
label triIndex(const label a, const label b) const
Return off-diagonal index given owner and neighbour label.
Definition: lduAddressing.C:229
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:60
Foam::lduAddressing::~lduAddressing
virtual ~lduAddressing()
Destructor.
Definition: lduAddressing.C:178
Foam::lduAddressing::band
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
Definition: lduAddressing.C:260