mergedSurf.C 3.75 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
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
8
    Copyright (C) 2016-2020 OpenCFD Ltd.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
-------------------------------------------------------------------------------
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/>.

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

#include "mergedSurf.H"
#include "PatchTools.H"
30
#include "globalIndex.H"
31 32 33

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

34 35 36 37 38
Foam::mergedSurf::mergedSurf
(
    const meshedSurf& unmergedSurface,
    const scalar mergeDim
)
39
:
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    mergedSurf()
{
    merge(unmergedSurface, mergeDim);
}


Foam::mergedSurf::mergedSurf
(
    const pointField& unmergedPoints,
    const faceList& unmergedFaces,
    const scalar mergeDim
)
:
    mergedSurf()
{
    merge(unmergedPoints, unmergedFaces, mergeDim);
}
57 58 59 60


Foam::mergedSurf::mergedSurf
(
61 62
    const pointField& unmergedPoints,
    const faceList& unmergedFaces,
63
    const labelList& origZoneIds,
64
    const labelList& origFaceIds,
65 66 67 68 69
    const scalar mergeDim
)
:
    mergedSurf()
{
70 71 72 73 74
    merge
    (
        unmergedPoints,
        unmergedFaces,
        origZoneIds,
75
        origFaceIds,
76 77
        mergeDim
    );
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

bool Foam::mergedSurf::use()
{
    return Pstream::parRun();
}


void Foam::mergedSurf::clear()
{
    points_.clear();
    faces_.clear();
    pointsMap_.clear();
94 95

    zoneIds_.clear();
96
    faceIds_.clear();
97 98 99 100 101
}


bool Foam::mergedSurf::merge
(
102
    const meshedSurf& unmergedSurface,
103 104 105
    const scalar mergeDim
)
{
106 107 108 109 110 111
    return
        merge
        (
            unmergedSurface.points(),
            unmergedSurface.faces(),
            unmergedSurface.zoneIds(),
112
            unmergedSurface.faceIds(),
113 114 115
            mergeDim
        );
}
116

117 118 119 120 121 122 123 124

bool Foam::mergedSurf::merge
(
    const pointField& unmergedPoints,
    const faceList& unmergedFaces,
    const scalar mergeDim
)
{
125 126 127 128 129 130
    return
        merge
        (
            unmergedPoints,
            unmergedFaces,
            labelList(),
131
            labelList(),
132 133
            mergeDim
        );
134 135 136 137 138 139 140
}


bool Foam::mergedSurf::merge
(
    const pointField& unmergedPoints,
    const faceList& unmergedFaces,
141
    const labelList& origZoneIds,
142
    const labelList& origFaceIds,
143 144 145
    const scalar mergeDim
)
{
146 147
    if (!use())
    {
148
        clear();   // Extra safety?
149 150 151 152 153 154 155 156
        return false;
    }

    PatchTools::gatherAndMerge
    (
        mergeDim,
        primitivePatch
        (
157 158
            SubList<face>(unmergedFaces, unmergedFaces.size()),
            unmergedPoints
159 160 161 162 163 164
        ),
        points_,
        faces_,
        pointsMap_
    );

165

166
    // Now handle per-face information
167

168
    globalIndex::gatherOp(origZoneIds, zoneIds_);
169
    globalIndex::gatherOp(origFaceIds, faceIds_);
170 171 172 173 174 175

    return true;
}


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