This file is indexed.

/usr/include/freefoam/dynamicMesh/faceCoupleInfo.H is in libfreefoam-dev 0.1.0+dfsg-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 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
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    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.

    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
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::faceCoupleInfo

Description
    Container for information needed to couple to meshes. When constructed
    from two meshes and a geometric tolerance finds the corresponding
    boundary faces.

    The information it keeps is the set of faces&points (cutFaces,
    cutPoints) that should replace a set of faces on the master
    (masterPatch) and a set of faces on the slave (slavePatch)


    Uses same tolerance to match faces and points on matched faces since
    they both originate from the same points and the tolerance usually
    comes from writing these points with limited precision (6 by default)

    -# Perfect match:
       - one-to-one match for faces and points.
       - the cut is always the 'most connected' of the master and slave so
         multiple master or slave points might point to the same cut point.

    @verbatim
    e.g. master:
    
        +--+
        |  |
        |  |
        +--+
            +--+
            |  |
            |  |
            +--+
    slave:
            +--+
            |  |
            |  |
            +--+
        +--+
        |  |
        |  |
        +--+
    @endverbatim
    adding both together creates a singly connected 2x2 cavity so suddenly
    the duplicate master points and the duplicate slave points all become
    a single cut point.


    -# Subdivision match:
       - Can be constructed from slave being subdivision of master with the
         polyPatch constructor.
       - Does not include above shared-point detection!

    Notes on multiple slave faces per master:

    As long as
    - all master edges are present in slave
    - slave can have extra edges/points/faces BUT all subfaces have to have
      at least one point on a maste face.

    @verbatim
    So master:
    +-------+
    |       |
    |       |
    |       |
    |       |
    |       |
    |       |
    |       |
    +-------+

    slave:
    +---+---+
    |\  |  /|
    | \ | / |
    |  \|/  |
    +---+---+
    |  /|\  |
    | / | \ |
    |/  |  \|
    +---+---+
    is ok.
    @endverbatim

    For this kind of matching the order is:
    - match cutpoint to masterpoint
    - find those cutEdges that align with a master edge. This gives two sets
      of cut edges: those that have a master equivalent ('border edges') and
      those that don't ('internal edges'). The border edges now divide the
      cutFaces into regions with the same masterFace correspondence.
    - find cutFaces that are fully determined by the border edges they use.
    - all cutFaces that are connected through an internal edge have the same
      master face.


    Note: matching refined faces onto master is a bit dodgy and will probably
    only work for unwarped faces. Also it will fail if e.g. face is split
    into 3x3 since then middle face has no point/edge in common with master.
    (problem is in face matching (findSlavesCoveringMaster), probably
     point/edge matching might just work)


SourceFiles
    faceCoupleInfo.C


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

#ifndef faceCoupleInfo_H
#define faceCoupleInfo_H

#include <OpenFOAM/pointField.H>
#include <OpenFOAM/indirectPrimitivePatch.H>
#include <OpenFOAM/primitiveFacePatch.H>

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

namespace Foam
{

typedef HashTable<labelList, edge, Hash<edge> > edgeLookup;


// Forward declaration of classes
class face;
class primitiveMesh;
class polyPatch;
class polyMesh;

/*---------------------------------------------------------------------------*\
                           Class faceCoupleInfo Declaration
\*---------------------------------------------------------------------------*/

class faceCoupleInfo
{
    // Private data

        //- Angle matching tolerance.
        static const scalar angleTol_;

        //- Master patch
        autoPtr<indirectPrimitivePatch> masterPatchPtr_;

        //- Slave patch
        autoPtr<indirectPrimitivePatch> slavePatchPtr_;


        //- Description of cut.
        //  - Cut is the matching area between the slave
        //  and the master.
        //  - cut is the finest of master and slave. It can never be
        //  coarser than either one of them. (so face addressing we keep is
        //  cut-to-master and cut-to-slave)
        //  - multiple master or slave points can end up becoming one cut point
        //  (so point addressing we keep is master-to-cut and slave-to-cut)

        //  Cut consists of faces and points (note: could be expressed as some
        //  kind of PrimitivePatch which holds points instead of reference to
        //  them)
        //  Orientation of cutFaces should be same as masterFaces!
        pointField cutPoints_;
        autoPtr<primitiveFacePatch> cutFacesPtr_;

        //- Additional point coupling information. Is between points on
        //  boundary of both meshes.

        // Addressing to/from cut

            //- master
            labelList cutToMasterFaces_;
            labelList masterToCutPoints_;

            //- slave
            labelList cutToSlaveFaces_;
            labelList slaveToCutPoints_;

            //- For edges originating from splitting of edges:
            //  given the two endpoints of the unsplit edge give the list
            //  of inbetween vertices
            edgeLookup cutEdgeToPoints_;


    // Private Member Functions

        // Debugging

            //- Calculate face centres from (subset of) faces.
            template<template<class> class FaceList>
            static pointField calcFaceCentres
            (
                const FaceList<face>&,
                const pointField&,
                const label start,
                const label size
            );

            //- Write edges
            static void writeOBJ
            (
                const fileName& fName,
                const edgeList& edges,
                const pointField& points,
                const bool compact = true
            );

            //- Write edges
            static void writeOBJ
            (
                const fileName& fName,
                const pointField& points0,
                const pointField& points1
            );

            //- Write connections between corresponding points and faces
            //  as .obj files.
            void writePointsFaces() const;

            //- Write connections between corresponding edges as .obj files.
            void writeEdges(const labelList&, const labelList&) const;


        // Edge handling/matching

            //- Find corresponding edges on patch when having only a map for
            //  the points.
            labelList findMappedEdges
            (
                const edgeList& edges,
                const labelList& pointMap,
                const indirectPrimitivePatch&
            );

            //- Check if edge on slavePatch corresponds to an edge between faces
            //  in two different polyPatches on the mesh.
            bool regionEdge(const polyMesh&, const label slaveEdgeI) const;

            //- Finds edge connected to point most aligned with master edge.
            label mostAlignedCutEdge
            (
                const bool report,
                const polyMesh& slaveMesh,
                const bool patchDivision,
                const labelList& cutToMasterEdges,
                const labelList& cutToSlaveEdges,
                const label pointI,
                const label edgeStart,
                const label edgeEnd
            ) const;

            //- From (many-to-one) map of cut edges to master edges determine
            //  points inbetween. I.e. just string up the edges. Stores this
            //  all on cutEdgeToPoints_
            void setCutEdgeToPoints(const labelList& cutToMasterEdges);

        // Face matching

            //- Matches two faces.Determines rotation for f1 to match up
            // with f0, i.e. the index in f0 of
            // the first point of f1.
            static label matchFaces
            (
                const scalar absTol,
                const pointField& points0,
                const face& f0,
                const pointField& points1,
                const face& f1,
                const bool sameOrientation
            );

            //- Matches points on patch to points on cut.
            static bool matchPointsThroughFaces
            (
                const scalar absTol,
                const pointField& cutPoints,
                const faceList& cutFaces,
                const pointField& patchPoints,
                const faceList& patchFaces,
                const bool sameOrientation,

                labelList& patchToCutPoints,    // patch to (uncompacted) cut points
                labelList& cutToCompact,        // compaction list
                labelList& compactToCut         // compaction list
            );

            //- Returns max distance to masterF of any point on cutF.
            static scalar maxDistance
            (
                const face& cutF,
                const pointField& cutPoints,
                const face& masterF,
                const pointField& masterPoints
            );

            //- Finds matching (boundary)face centres.
            //  Since faces identical uses geometric match on face centres.
            static void findPerfectMatchingFaces
            (
                const primitiveMesh& mesh0,
                const primitiveMesh& mesh1,
                const scalar absTol,

                labelList& mesh0Faces,
                labelList& mesh1Faces
            );

            //- Find matching (boundary)faces. Matching if slave is on top of
            //  master face (slaves is subdivision of master)
            static void findSlavesCoveringMaster
            (
                const primitiveMesh& mesh0,
                const primitiveMesh& mesh1,
                const scalar absTol,

                labelList& mesh0Faces,
                labelList& mesh1Faces
            );

            //- Grow cutToMasterFace across 'internal' edges.
            label growCutFaces(const labelList&, Map<labelList>&);

            void checkMatch(const labelList& cutToMasterEdges) const;

            //- Gets a list of cutFaces (that use a master edge) and the
            // candidate master faces.
            // Checks among these master faces if there is only one remaining
            // unmatched one.
            label matchEdgeFaces(const labelList&, Map<labelList>& candidates);

            //- Gets a list of cutFaces (that use a master edge) and the
            //  candidate master faces.
            //  Finds most aligned master face.
            label geometricMatchEdgeFaces(Map<labelList>& candidates);

        //- Used by perfectPointMatch. Determine match from cut points to
        //  slave points (for perfect matching faces)
        void perfectSlavePointMatch(const scalar absTol);

        //- Find point and edge correspondence for perfect matching faces
        void perfectPointMatch(const scalar absTol, const bool);

        //- Find point and edge correspondence for slaves being subdivision of
        //  master.
        void subDivisionMatch
        (
            const polyMesh& slaveMesh,
            const bool patchDivision,
            const scalar absTol
        );

public:

    //- Runtime type information
    ClassName("faceCoupleInfo");


    // Constructors

        //- Construct from two meshes and absolute tolerance.
        //  Finds out matches geometrically. No checking for nonsense match.
        //  Tolerance is absolute one so use with care.
        //  perfectMatch : each point/edge/face has corresponding point on other
        //                 side
        //                 if this is false then assumes slave is subdivision.
        //                 Matching then will work only for non-warped faces
        //                 since does nearest-to-face comparison with absTol.
        faceCoupleInfo
        (
            const polyMesh& mesh0,
            const polyMesh& mesh1,
            const scalar absTol,
            const bool perfectMatch
        );

        //- Construct from meshes and subset of mesh faces
        //  (i.e. indirectPrimitivePatch addressing)
        //  All faces in patch are considered matched (but don't have to be 
        //  ordered)
        //  perfectMatch : each point/edge/face has corresponding point on other
        //                 side
        //  orderedFaces : faces in patch are ordered (so masterAddressing[i]
        //  matches slaveAddressing[i])
        //  patchDivision: faces in slave mesh that originate from the
        //  same master face have the same patch. Used by some triangulation
        //  methods.
        faceCoupleInfo
        (
            const polyMesh& masterMesh,
            const labelList& masterAddressing,
            const polyMesh& slaveMesh,
            const labelList& slaveAddressing,
            const scalar absTol,
            const bool perfectMatch,
            const bool orderedFaces,
            const bool patchDivision
        );


    // Destructor

        ~faceCoupleInfo();



    // Member Functions

        //- Utility functions

            //- Get patch face labels
            static labelList faceLabels(const polyPatch&);

            //- Create Map from List
            static Map<label> makeMap(const labelList&);
            static Map<labelList> makeMap(const labelListList&);


        // Access

            //- Addressing engine for coupled faces on mesh0
            const indirectPrimitivePatch& masterPatch() const
            {
                return masterPatchPtr_();
            }

            //- Addressing engine for coupled faces on mesh1
            const indirectPrimitivePatch& slavePatch() const
            {
                return slavePatchPtr_();
            }

            //- Addressing engine for combined set of faces.
            const primitiveFacePatch& cutFaces() const
            {
                return cutFacesPtr_();
            }

            //- Points for combined set of faces.
            const pointField& cutPoints() const
            {
                return cutPoints_;
            }


        // Addressing from meshes to cut and vice versa.

            //- Master face for every face on cut. Will always be at least
            //  one but there might be multiple cut faces pointing to the same
            //  master
            const labelList& cutToMasterFaces() const
            {
                return cutToMasterFaces_;
            }
            const labelList& masterToCutPoints() const
            {
                return masterToCutPoints_;
            }

            const labelList& cutToSlaveFaces() const
            {
                return cutToSlaveFaces_;
            }
            const labelList& slaveToCutPoints() const
            {
                return slaveToCutPoints_;
            }

            //- From two cut points (original edge) to list of inserted
            //  points
            const edgeLookup& cutEdgeToPoints() const
            {
                return cutEdgeToPoints_;
            }

 };


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

} // End namespace Foam

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

#ifdef NoRepository
#   include <dynamicMesh/faceCoupleInfoTemplates.C>
#endif

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

#endif

// ************************ vim: set sw=4 sts=4 et: ************************ //