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-2024 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 {
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 std::unique_ptr<labelList> losortPtr_;
127 
128  //- Owner start addressing
129  mutable std::unique_ptr<labelList> ownerStartPtr_;
130 
131  //- Losort start addressing
132  mutable std::unique_ptr<labelList> losortStartPtr_;
133 
134 
135  // Private Member Functions
136 
137  //- Calculate losort
138  void calcLosort() const;
139 
140  //- Calculate owner start
141  void calcOwnerStart() const;
142 
143  //- Calculate losort start
144  void calcLosortStart() const;
145 
146 
147 public:
148 
149  // Generated Methods
150 
151  //- No copy construct
152  lduAddressing(const lduAddressing&) = delete;
153 
154  //- No copy assignment
155  void operator=(const lduAddressing&) = delete;
156 
157 
158  // Constructors
159 
160  //- Construct with size (number of equations)
161  explicit lduAddressing(const label nEqns) noexcept
162  :
163  size_(nEqns)
164  {}
165 
166 
167  //- Destructor
168  virtual ~lduAddressing() = default;
169 
170 
171  // Member Functions
172 
173  //- Return number of equations
174  label size() const noexcept
175  {
176  return size_;
177  }
179  //- Return lower addressing
180  virtual const labelUList& lowerAddr() const = 0;
181 
182  //- Return upper addressing
183  virtual const labelUList& upperAddr() const = 0;
184 
185  //- Return patch to internal addressing given patch number
186  virtual const labelUList& patchAddr
187  (
188  const label patchNo
189  ) const = 0;
190 
191  //- Return patch field evaluation schedule
192  virtual const lduSchedule& patchSchedule() const = 0;
193 
194  //- Clear additional addressing
195  void clearOut();
196 
197  //- Return losort addressing
198  const labelUList& losortAddr() const;
199 
200  //- Return owner start addressing
201  const labelUList& ownerStartAddr() const;
202 
203  //- Return losort start addressing
204  const labelUList& losortStartAddr() const;
205 
206  //- Return off-diagonal index given owner and neighbour label
207  label triIndex(const label a, const label b) const;
208 
209  //- Calculate bandwidth and profile of addressing
210  Tuple2<label, scalar> band() const;
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
void operator=(const lduAddressing &)=delete
No copy assignment.
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 dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
virtual ~lduAddressing()=default
Destructor.
const labelUList & losortStartAddr() const
Return losort start addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
label size() const noexcept
Return number of equations.
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.
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
const direction noexcept
Definition: Scalar.H:258
lduAddressing(const lduAddressing &)=delete
No copy construct.
const labelUList & losortAddr() const
Return losort addressing.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
void clearOut()
Clear additional addressing.
const labelUList & ownerStartAddr() const
Return owner start addressing.
Namespace for OpenFOAM.
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.