![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 lduAddressing 00027 00028 Description 00029 The class contains the addressing required by the lduMatrix: upper, lower 00030 and losort. It can be created in two ways: either with references to 00031 upper and lower in which case it stores references or from labelLists, 00032 in which case it stores the addressing itself. Additionally, the losort 00033 addressing belongs to the class is as on lazy evaluation. 00034 00035 The ordering of owner addresses is such that the labels are in 00036 increasing order, with groups of identical labels for edges 00037 "owned" by the same point. The neighbour labels are also ordered 00038 in ascending order but only for groups of edges belonging to each 00039 point. An example is given below: 00040 owner neighbour 00041 0 1 00042 0 20 00043 1 2 00044 1 21 00045 2 3 00046 2 22 00047 3 4 00048 3 23 00049 4 5 00050 4 24 00051 5 6 00052 5 25 00053 6 7 00054 6 26 00055 7 8 00056 7 27 00057 8 9 00058 8 28 00059 9 10 00060 9 29 00061 00062 There exists an alternative way of addressing the owner 00063 list: instead of repeating the same label in the owner list, it is 00064 possible to address the start of each point neighbours in the 00065 neighbour list. This reduces the size of owner addressing from a list 00066 over all edges to a list over all points + 1: 00067 00068 Owner start list: 0 2 4 6 8 10 12 14 16 18 00069 00070 We shall use the second form of the addressing for fast lookup 00071 of edge label from the known owner and neighbour, using the following 00072 algorithm: 1) take the owner label and position the start of lookup 00073 using the owner start list 2) loop through all neighbours of this 00074 owner (ending at the start of lookup of owner + 1) until the match 00075 with current neighbour is found. The index used on the neighbour list 00076 for the match is the edge index. 00077 00078 While owner start addressing allows us to find the edge owned by the 00079 points, it is also necessary to find the edges for which the point is 00080 a neighbour. Losort addressing lists the edges neighboured by the 00081 point and we shall use the same trick as above to address into this 00082 list. Thus, for every point the losort start gives the address of the 00083 first face to neighbour this point. 00084 00085 00086 SourceFiles 00087 lduAddressing.C 00088 00089 \*---------------------------------------------------------------------------*/ 00090 00091 #ifndef lduAddressing_H 00092 #define lduAddressing_H 00093 00094 #include "labelList.H" 00095 00096 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00097 00098 namespace Foam 00099 { 00100 00101 /*---------------------------------------------------------------------------*\ 00102 Class lduAddressing Declaration 00103 \*---------------------------------------------------------------------------*/ 00104 00105 class lduAddressing 00106 { 00107 // Private data 00108 00109 //- Number of equations 00110 label size_; 00111 00112 //- Demand-driven data 00113 00114 //- Losort addressing 00115 mutable labelList* losortPtr_; 00116 00117 //- Owner start addressing 00118 mutable labelList* ownerStartPtr_; 00119 00120 //- Losort start addressing 00121 mutable labelList* losortStartPtr_; 00122 00123 00124 // Private Member Functions 00125 00126 //- Disallow default bitwise copy construct 00127 lduAddressing(const lduAddressing&); 00128 00129 //- Disallow default bitwise assignment 00130 void operator=(const lduAddressing&); 00131 00132 //- Calculate losort 00133 void calcLosort() const; 00134 00135 //- Calculate owner start 00136 void calcOwnerStart() const; 00137 00138 //- Calculate losort start 00139 void calcLosortStart() const; 00140 00141 00142 public: 00143 00144 // Constructor 00145 lduAddressing(const label nEqns) 00146 : 00147 size_(nEqns), 00148 losortPtr_(NULL), 00149 ownerStartPtr_(NULL), 00150 losortStartPtr_(NULL) 00151 {} 00152 00153 00154 // Destructor 00155 00156 virtual ~lduAddressing(); 00157 00158 00159 // Member Functions 00160 00161 //- Return number of equations 00162 label size() const 00163 { 00164 return size_; 00165 } 00166 00167 //- Return lower addressing 00168 virtual const unallocLabelList& lowerAddr() const = 0; 00169 00170 //- Return upper addressing 00171 virtual const unallocLabelList& upperAddr() const = 0; 00172 00173 //- Return patch to internal addressing given patch number 00174 virtual const unallocLabelList& patchAddr 00175 ( 00176 const label patchNo 00177 ) const = 0; 00178 00179 //- Return losort addressing 00180 const unallocLabelList& losortAddr() const; 00181 00182 //- Return owner start addressing 00183 const unallocLabelList& ownerStartAddr() const; 00184 00185 //- Return losort start addressing 00186 const unallocLabelList& losortStartAddr() const; 00187 00188 //- Return off-diagonal index given owner and neighbour label 00189 label triIndex(const label a, const label b) const; 00190 }; 00191 00192 00193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00194 00195 } // End namespace Foam 00196 00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00198 00199 #endif 00200 00201 // ************************************************************************* //