FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 eighbour
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 <OpenFOAM/labelList.H>
100 #include <OpenFOAM/lduSchedule.H>
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 namespace Foam
105 {
106 
107 /*---------------------------------------------------------------------------*\
108  Class lduAddressing Declaration
109 \*---------------------------------------------------------------------------*/
110 
112 {
113  // Private data
114 
115  //- Number of equations
116  label size_;
117 
118 
119  //- Demand-driven data
120 
121  //- Losort addressing
122  mutable labelList* losortPtr_;
123 
124  //- Owner start addressing
125  mutable labelList* ownerStartPtr_;
126 
127  //- Losort start addressing
128  mutable labelList* losortStartPtr_;
129 
130 
131  // Private Member Functions
132 
133  //- Disallow default bitwise copy construct
135 
136  //- Disallow default bitwise assignment
137  void operator=(const lduAddressing&);
138 
139  //- Calculate losort
140  void calcLosort() const;
141 
142  //- Calculate owner start
143  void calcOwnerStart() const;
144 
145  //- Calculate losort start
146  void calcLosortStart() const;
147 
148 
149 public:
150 
151  // Constructor
152  lduAddressing(const label nEqns)
153  :
154  size_(nEqns),
155  losortPtr_(NULL),
156  ownerStartPtr_(NULL),
157  losortStartPtr_(NULL)
158  {}
159 
160 
161  // Destructor
162 
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 unallocLabelList& lowerAddr() const = 0;
176 
177  //- Return upper addressing
178  virtual const unallocLabelList& upperAddr() const = 0;
179 
180  //- Return patch to internal addressing given patch number
181  virtual const unallocLabelList& 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 unallocLabelList& losortAddr() const;
191 
192  //- Return owner start addressing
193  const unallocLabelList& ownerStartAddr() const;
194 
195  //- Return losort start addressing
196  const unallocLabelList& 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 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************ vim: set sw=4 sts=4 et: ************************ //