FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

lduAddressing.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::lduAddressing
00026 
00027 Description
00028     The class contains the addressing required by the lduMatrix: upper, lower
00029     and losort.
00030 
00031     The addressing can be created in two ways: either with references to
00032     upper and lower in which case it stores references or from labelLists,
00033     in which case it stores the addressing itself. Additionally, the losort
00034     addressing belongs to the class is as on lazy evaluation.
00035 
00036     The ordering of owner addresses is such that the labels are in
00037     increasing order, with groups of identical labels for edges "owned" by
00038     the same point. The neighbour labels are also ordered in ascending
00039     order but only for groups of edges belonging to each point. An example
00040     is given below:
00041     @verbatim
00042         owner     eighbour
00043         0         1
00044         0         20
00045         1         2
00046         1         21
00047         2         3
00048         2         22
00049         3         4
00050         3         23
00051         4         5
00052         4         24
00053         5         6
00054         5         25
00055         6         7
00056         6         26
00057         7         8
00058         7         27
00059         8         9
00060         8         28
00061         9         10
00062         9         29
00063     @endverbatim
00064 
00065     There exists an alternative way of addressing the owner
00066     list: instead of repeating the same label in the owner list, it is
00067     possible to address the start of each point neighbours in the
00068     neighbour list. This reduces the size of owner addressing from a list
00069     over all edges to a list over all points + 1:
00070 
00071     @verbatim
00072         Owner start list: 0 2 4 6 8 10 12 14 16 18
00073     @endverbatim
00074 
00075     We shall use the second form of the addressing for fast lookup
00076     of edge label from the known owner and neighbour, using the following
00077     algorithm:
00078     -# take the owner label and position the start of lookup
00079        using the owner start list
00080     -# loop through all neighbours of this owner (ending at the start of
00081       lookup of owner + 1) until the match with current neighbour is found.
00082       The index used on the neighbour list for the match is the edge index.
00083 
00084     While owner start addressing allows us to find the edge owned by the
00085     points, it is also necessary to find the edges for which the point is
00086     a neighbour. Losort addressing lists the edges neighboured by the
00087     point and we shall use the same trick as above to address into this
00088     list. Thus, for every point the losort start gives the address of the
00089     first face to neighbour this point.
00090 
00091 SourceFiles
00092     lduAddressing.C
00093 
00094 \*---------------------------------------------------------------------------*/
00095 
00096 #ifndef lduAddressing_H
00097 #define lduAddressing_H
00098 
00099 #include <OpenFOAM/labelList.H>
00100 #include <OpenFOAM/lduSchedule.H>
00101 
00102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00103 
00104 namespace Foam
00105 {
00106 
00107 /*---------------------------------------------------------------------------*\
00108                            Class lduAddressing Declaration
00109 \*---------------------------------------------------------------------------*/
00110 
00111 class lduAddressing
00112 {
00113     // Private data
00114 
00115         //- Number of equations
00116         label size_;
00117 
00118 
00119     //- Demand-driven data
00120 
00121         //- Losort addressing
00122         mutable labelList* losortPtr_;
00123 
00124         //- Owner start addressing
00125         mutable labelList* ownerStartPtr_;
00126 
00127         //- Losort start addressing
00128         mutable labelList* losortStartPtr_;
00129 
00130 
00131     // Private Member Functions
00132 
00133         //- Disallow default bitwise copy construct
00134         lduAddressing(const lduAddressing&);
00135 
00136         //- Disallow default bitwise assignment
00137         void operator=(const lduAddressing&);
00138 
00139         //- Calculate losort
00140         void calcLosort() const;
00141 
00142         //- Calculate owner start
00143         void calcOwnerStart() const;
00144 
00145         //- Calculate losort start
00146         void calcLosortStart() const;
00147 
00148 
00149 public:
00150 
00151     // Constructor
00152     lduAddressing(const label nEqns)
00153     :
00154         size_(nEqns),
00155         losortPtr_(NULL),
00156         ownerStartPtr_(NULL),
00157         losortStartPtr_(NULL)
00158     {}
00159 
00160 
00161     // Destructor
00162 
00163         virtual ~lduAddressing();
00164 
00165 
00166     // Member Functions
00167 
00168         //- Return number of equations
00169         label size() const
00170         {
00171             return size_;
00172         }
00173 
00174         //- Return lower addressing
00175         virtual const unallocLabelList& lowerAddr() const = 0;
00176 
00177         //- Return upper addressing
00178         virtual const unallocLabelList& upperAddr() const = 0;
00179 
00180         //- Return patch to internal addressing given patch number
00181         virtual const unallocLabelList& patchAddr
00182         (
00183             const label patchNo
00184         ) const = 0;
00185 
00186         // Return patch field evaluation schedule
00187         virtual const lduSchedule& patchSchedule() const = 0;
00188 
00189         //- Return losort addressing
00190         const unallocLabelList& losortAddr() const;
00191 
00192         //- Return owner start addressing
00193         const unallocLabelList& ownerStartAddr() const;
00194 
00195         //- Return losort start addressing
00196         const unallocLabelList& losortStartAddr() const;
00197 
00198         //- Return off-diagonal index given owner and neighbour label
00199         label triIndex(const label a, const label b) const;
00200 };
00201 
00202 
00203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00204 
00205 } // End namespace Foam
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 #endif
00210 
00211 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines