lduPrimitiveMesh.H 8.93 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
OpenFOAM bot's avatar
OpenFOAM bot committed
6 7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9
    Copyright (C) 2016-2019 OpenCFD Ltd.
10 11 12 13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14 15 16 17
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
18 19 20 21 22 23 24

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    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 28 29 30

Class
    Foam::lduPrimitiveMesh

Description
31
    Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
32

33 34 35
SourceFiles
    lduPrimitiveMesh.C

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
\*---------------------------------------------------------------------------*/

#ifndef lduPrimitiveMesh_H
#define lduPrimitiveMesh_H

#include "lduMesh.H"
#include "labelList.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
                       Class lduPrimitiveMesh Declaration
\*---------------------------------------------------------------------------*/

class lduPrimitiveMesh
:
    public lduMesh,
    public lduAddressing
{
    // Private data

        //- Lower addressing
        labelList lowerAddr_;

        //- Upper addressing
        labelList upperAddr_;

        //- List of pointers for each patch
        //  with only those pointing to interfaces being set
68
        lduInterfacePtrsList interfaces_;
69

70
        //- Concrete interfaces
71
        PtrList<const lduInterface> primitiveInterfaces_;
72

73
        //- Patch field evaluation schedule
74
        lduSchedule patchSchedule_;
75

76 77
        //- Communicator to use for any parallel communication
        const label comm_;
78

79

80 81
    // Private Member Functions

82
        //- Get size of all meshes
83
        static label totalSize(const PtrList<lduPrimitiveMesh>&);
84

85 86
        //- No copy construct
        lduPrimitiveMesh(const lduPrimitiveMesh&) = delete;
87

88 89
        //- No copy assignment
        void operator=(const lduPrimitiveMesh&) = delete;
90 91 92 93


public:

94 95 96 97 98
    // Static data

        // Declare name of the class and its debug switch
        ClassName("lduPrimitiveMesh");

99

100 101
    // Constructors

102 103
        //- Construct from components but without interfaces. Add interfaces
        //  separately using addInterfaces
104 105 106 107 108
        lduPrimitiveMesh
        (
            const label nCells,
            labelList& l,
            labelList& u,
109
            const label comm,
110
            bool reuse
111 112
        );

113 114 115 116 117 118 119
        //- Add interfaces to a mesh constructed without
        void addInterfaces
        (
            lduInterfacePtrsList& interfaces,
            const lduSchedule& ps
        );

120 121 122 123 124 125
        //- Construct from components and re-use storage.
        lduPrimitiveMesh
        (
            const label nCells,
            labelList& l,
            labelList& u,
126
            PtrList<const lduInterface>& primitiveInterfaces,
127 128 129 130
            const lduSchedule& ps,
            const label comm
        );

131
        //- Construct by combining multiple meshes. The meshes come from
132 133 134 135 136 137 138 139 140
        //  processors procIDs:
        //  procIDs[0] : local processor (myMesh)
        //  procIDs[i] : processor where otherMeshes[i-1] comes from
        //  procAgglomMap : for every processor which processor it agglomerates
        //                  onto. The new processor numbers are in compact
        //                  numbering (so ranks in communicator comm), i.e.
        //                  similar to cell-restrict-addressing.
        //                  We need this information to be able to map
        //                  inter-processor interfaces
141 142 143 144 145 146 147 148 149 150 151
        // cellOffsets : for every processor the offset it gets in the mesh
        // faceMap     : for every processor, for every face, the destination
        //               face. Negative for flipped faces.
        // boundaryMap : for every processor, for every patch, -1 or the new
        //               patch index in the mesh.
        // boundaryFaceMap : for every processor, for every patch, for every
        //                   patch face:
        //                   - the new internal face (if boundaryMap=-1)
        //                   - the new patch face (if boundaryMap>=0)
        //                   Faces becoming internal are negative for flipped
        //                   faces.
152 153 154
        lduPrimitiveMesh
        (
            const label comm,
155 156
            const labelList& procAgglomMap,

157
            const labelList& procIDs,
158
            const lduMesh& myMesh,
159
            const PtrList<lduPrimitiveMesh>& otherMeshes,
160 161

            labelList& cellOffsets,
162
            labelList& faceOffsets,
163 164 165 166
            labelListList& faceMap,
            labelListList& boundaryMap,
            labelListListList& boundaryFaceMap
        );
167 168


169
    //- Destructor
170
    virtual ~lduPrimitiveMesh() = default;
171 172 173 174 175 176


    // Member Functions

        // Access

177 178 179 180 181 182
            //- Return true if thisDb() is a valid DB
            virtual bool hasDb() const
            {
                return false;
            }

183 184 185 186 187 188 189 190 191 192 193 194 195
            //- Return ldu addressing
            virtual const lduAddressing& lduAddr() const
            {
                return *this;
            }

            //- Return a list of pointers for each patch
            //  with only those pointing to interfaces being set
            virtual lduInterfacePtrsList interfaces() const
            {
                return interfaces_;
            }

196 197 198 199 200 201 202 203
            //- Return a list of pointers for each patch
            //  with only those pointing to interfaces being set
            //  (reference to cached interfaces)
            const lduInterfacePtrsList& rawInterfaces() const
            {
                return interfaces_;
            }

204 205 206 207 208 209
            //- Return communicator used for parallel communication
            virtual label comm() const
            {
                return comm_;
            }

210
            //- Return Lower addressing
211
            virtual const labelUList& lowerAddr() const
212 213 214 215 216
            {
                return lowerAddr_;
            }

            //- Return Upper addressing
217
            virtual const labelUList& upperAddr() const
218 219 220 221 222
            {
                return upperAddr_;
            }

            //- Return patch addressing
223
            virtual const labelUList& patchAddr(const label i) const
224
            {
225
                return interfaces_[i].faceCells();
226 227 228 229 230 231 232
            }

            //- Return patch evaluation schedule
            virtual const lduSchedule& patchSchedule() const
            {
                return patchSchedule_;
            }
233 234 235 236


        // Helper

237 238 239 240
            //- Select either mesh0 (meshI is 0) or otherMeshes[meshI-1]
            static const lduMesh& mesh
            (
                const lduMesh& mesh0,
241
                const PtrList<lduPrimitiveMesh>& otherMeshes,
242 243 244 245
                const label meshI
            );

            //- Gather meshes from other processors onto procIDs[0].
246
            //  Received meshes get GAMGInterface and communicator comm
247 248
            static void gather
            (
249
                const label comm,
250 251
                const lduMesh& mesh,
                const labelList& procIDs,
252
                PtrList<lduPrimitiveMesh>& otherMeshes
253
            );
mattijs's avatar
mattijs committed
254 255 256 257 258

            //- Get non-scheduled send/receive schedule
            template<class ProcPatch>
            static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList&);

259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
            //- Calculate upper-triangular order
            static labelList upperTriOrder
            (
                const label nCells,
                const labelUList& lower,
                const labelUList& upper
            );

            //- Check if in upper-triangular ordering
            static void checkUpperTriangular
            (
                const label size,
                const labelUList& l,
                const labelUList& u
            );
274 275 276 277 278 279 280 281 282
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

283
#ifdef NoRepository
284
    #include "lduPrimitiveMeshTemplates.C"
285 286 287 288
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

289 290 291
#endif

// ************************************************************************* //