processorPolyPatch.H 10.4 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
6
     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
7
8
9
10
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

11
12
13
14
    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.
15
16
17
18
19
20
21

    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
22
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
23
24
25
26
27
28
29

Class
    Foam::processorPolyPatch

Description
    Neighbour processor patch.

30
31
    Note: morph patch face ordering tries to do a geometric ordering.
    (assumes faces coincident) Hence will have problems when cyclics
32
    are present.
33
34
35
36
37
38
39
40
41
42

SourceFiles
    processorPolyPatch.C

\*---------------------------------------------------------------------------*/

#ifndef processorPolyPatch_H
#define processorPolyPatch_H

#include "coupledPolyPatch.H"
mattijs's avatar
mattijs committed
43
44
#include "polyBoundaryMesh.H"
#include "faceListFwd.H"
45
#include "polyMesh.H"
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

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

namespace Foam
{

/*---------------------------------------------------------------------------*\
                           Class processorPolyPatch Declaration
\*---------------------------------------------------------------------------*/

class processorPolyPatch
:
    public coupledPolyPatch
{
    // Private data

        int myProcNo_;
        int neighbProcNo_;

65
        //- Processor-neighbour patch face centres
66
67
        vectorField neighbFaceCentres_;

68
        //- Processor-neighbour patch face areas
69
70
        vectorField neighbFaceAreas_;

71
        //- Processor-neighbour patch neighbour cell centres
72
73
        vectorField neighbFaceCellCentres_;

mattijs's avatar
mattijs committed
74
75
76
        //- Corresponding neighbouring local point label for every local point
        //  (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
        mutable autoPtr<labelList> neighbPointsPtr_;
77

mattijs's avatar
mattijs committed
78
79
80
        //- Corresponding neighbouring local edge label for every local edge
        //  (so edges()[i] == neighb.edges()[neighbEdges_[i]])
        mutable autoPtr<labelList> neighbEdgesPtr_;
81
82
83
84
85
86

protected:

    // Protected Member functions

        //- Initialise the calculation of the patch geometry
87
        void initGeometry(PstreamBuffers&);
88
89

        //- Calculate the patch geometry
90
        void calcGeometry(PstreamBuffers&);
91

mattijs's avatar
mattijs committed
92
93
94
95
96
        //- Calculate the patch geometry with externally
        //  provided geometry
        virtual void calcGeometry
        (
            const primitivePatch& referPatch,
97
98
99
100
101
102
            const pointField& thisCtrs,
            const vectorField& thisAreas,
            const pointField& thisCc,
            const pointField& nbrCtrs,
            const vectorField& nbrAreas,
            const pointField& nbrCc
mattijs's avatar
mattijs committed
103
104
105
106
107
        )
        {
            notImplemented("processorPolyPatch::calcGeometry(..)");
        }

108
        //- Initialise the patches for moving points
109
        void initMovePoints(PstreamBuffers&, const pointField&);
110
111

        //- Correct patches after moving points
112
        void movePoints(PstreamBuffers&, const pointField&);
113
114

        //- Initialise the update of the patch topology
115
        virtual void initUpdateMesh(PstreamBuffers&);
116
117

        //- Update of the patch topology
118
        virtual void updateMesh(PstreamBuffers&);
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137


public:

    //- Runtime type information
    TypeName("processor");


    // Constructors

        //- Construct from components
        processorPolyPatch
        (
            const word& name,
            const label size,
            const label start,
            const label index,
            const polyBoundaryMesh& bm,
            const int myProcNo,
laurence's avatar
laurence committed
138
            const int neighbProcNo,
139
140
            const transformType transform = UNKNOWN,  // transformation type
            const word& patchType = typeName
141
142
143
144
145
146
147
148
        );

        //- Construct from dictionary
        processorPolyPatch
        (
            const word& name,
            const dictionary& dict,
            const label index,
149
150
            const polyBoundaryMesh&,
            const word& patchType
151
152
153
        );

        //- Construct as copy, resetting the boundary mesh
mattijs's avatar
mattijs committed
154
        processorPolyPatch(const processorPolyPatch&, const polyBoundaryMesh&);
155
156
157
158
159
160
161
162
163

        //- Construct as given the original patch and resetting the
        //  face list and boundary mesh information
        processorPolyPatch
        (
            const processorPolyPatch& pp,
            const polyBoundaryMesh& bm,
            const label index,
            const label newSize,
mattijs's avatar
mattijs committed
164
            const label newStart
165
166
        );

mattijs's avatar
mattijs committed
167
168
169
170
171
172
        //- Construct given the original patch and a map
        processorPolyPatch
        (
            const processorPolyPatch& pp,
            const polyBoundaryMesh& bm,
            const label index,
173
            const labelUList& mapAddressing,
mattijs's avatar
mattijs committed
174
175
176
            const label newStart
        );

177
178
179
180
181
182
183
184
185
186
187
188
189
        //- Construct and return a clone, resetting the boundary mesh
        virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
        {
            return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
        }

        //- Construct and return a clone, resetting the face list
        //  and boundary mesh
        virtual autoPtr<polyPatch> clone
        (
            const polyBoundaryMesh& bm,
            const label index,
            const label newSize,
mattijs's avatar
mattijs committed
190
            const label newStart
191
192
193
194
195
196
        ) const
        {
            return autoPtr<polyPatch>
            (
                new processorPolyPatch
                (
mattijs's avatar
mattijs committed
197
                    *this,
198
199
200
                    bm,
                    index,
                    newSize,
mattijs's avatar
mattijs committed
201
                    newStart
202
203
204
205
                )
            );
        }

mattijs's avatar
mattijs committed
206
207
208
209
210
211
        //- Construct and return a clone, resetting the face list
        //  and boundary mesh
        virtual autoPtr<polyPatch> clone
        (
            const polyBoundaryMesh& bm,
            const label index,
212
            const labelUList& mapAddressing,
mattijs's avatar
mattijs committed
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
            const label newStart
        ) const
        {
            return autoPtr<polyPatch>
            (
                new processorPolyPatch
                (
                    *this,
                    bm,
                    index,
                    mapAddressing,
                    newStart
                )
            );
        }

229

230
231
    //- Destructor
    virtual ~processorPolyPatch();
232
233
234
235


    // Member functions

236
237
238
239
240
241
242
243
244
245
246
247
248
        //- Return true only if this is a parallel run
        virtual bool coupled() const
        {
            if (Pstream::parRun())
            {
                return true;
            }
            else
            {
                return false;
            }
        }

249
250
251
252
253
254
255
256
257
258
259
260
261
        //- Return processor number
        int myProcNo() const
        {
            return myProcNo_;
        }

        //- Return neigbour processor number
        int neighbProcNo() const
        {
            return neighbProcNo_;
        }

        //- Does the processor own the patch ?
262
        virtual bool owner() const
263
264
265
266
267
268
269
270
271
272
        {
            return (myProcNo_ < neighbProcNo_);
        }

        //- Is the processor the patch neighbour ?
        bool neighbour() const
        {
            return !owner();
        }

273
        //- Return processor-neighbour patch face centres
274
275
276
277
278
        const vectorField& neighbFaceCentres() const
        {
            return neighbFaceCentres_;
        }

279
        //- Return processor-neighbour patch face areas
280
281
282
283
284
        const vectorField& neighbFaceAreas() const
        {
            return neighbFaceAreas_;
        }

285
        //- Return processor-neighbour patch neighbour cell centres
286
287
288
289
290
        const vectorField& neighbFaceCellCentres() const
        {
            return neighbFaceCellCentres_;
        }

mattijs's avatar
mattijs committed
291
292
        //- Return neighbour point labels. WIP.
        const labelList& neighbPoints() const;
mattijs's avatar
mattijs committed
293

mattijs's avatar
mattijs committed
294
295
296
        //- Return neighbour edge labels. WIP.
        const labelList& neighbEdges() const;

297
298
299
300
301
302
        //- Return message tag to use for communication
        virtual int tag() const
        {
            return Pstream::msgType();
        }

303
304
305
306
307
308
        //- Return communicator used for communication
        virtual label comm() const
        {
            return boundaryMesh().mesh().comm();
        }

mattijs's avatar
mattijs committed
309
310
311
        //- Transform a patch-based position from other side to this side
        virtual void transformPosition(pointField& l) const
        {}
mattijs's avatar
mattijs committed
312

313
314
315
316
        //- Transform a patch-based position from other side to this side
        virtual void transformPosition(point&, const label facei) const
        {}

317
318
        //- Initialize ordering for primitivePatch. Does not
        //  refer to *this (except for name() and type() etc.)
319
        virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
320

laurence's avatar
laurence committed
321
322
323
324
325
326
327
328
329
330
331
        static label matchFace
        (
            const face& localFace,
            const pointField& localPts,
            const face& masterFace,
            const pointField& masterPts,
            const bool sameOrientation,
            const scalar absTolSqr,
            scalar& matchDistSqr
        );

332
333
334
335
336
337
338
        //- Return new ordering for primitivePatch.
        //  Ordering is -faceMap: for every face
        //  index of the new face -rotation:for every new face the clockwise
        //  shift of the original face. Return false if nothing changes
        //  (faceMap is identity, rotation is 0), true otherwise.
        virtual bool order
        (
339
            PstreamBuffers&,
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
            const primitivePatch&,
            labelList& faceMap,
            labelList& rotation
        ) const;


        //- Write the polyPatch data as a dictionary
        virtual void write(Ostream&) const;
};


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

} // End namespace Foam

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

#endif

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