mergedSurf.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "mergedSurf.H"
29#include "PatchTools.H"
30#include "globalIndex.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
35(
36 const meshedSurf& unmergedSurface,
37 const scalar mergeDim
38)
39:
41{
42 merge(unmergedSurface, mergeDim);
43}
44
45
47(
48 const pointField& unmergedPoints,
49 const faceList& unmergedFaces,
50 const scalar mergeDim
51)
52:
54{
55 merge(unmergedPoints, unmergedFaces, mergeDim);
56}
57
58
60(
61 const pointField& unmergedPoints,
62 const faceList& unmergedFaces,
63 const labelList& origZoneIds,
64 const labelList& origFaceIds,
65 const scalar mergeDim
66)
67:
69{
70 merge
71 (
72 unmergedPoints,
73 unmergedFaces,
74 origZoneIds,
75 origFaceIds,
76 mergeDim
77 );
78}
79
80
81// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82
84{
85 return Pstream::parRun();
86}
87
88
90{
91 points_.clear();
92 faces_.clear();
93 pointsMap_.clear();
94
95 zoneIds_.clear();
96 faceIds_.clear();
97}
98
99
101(
102 const meshedSurf& unmergedSurface,
103 const scalar mergeDim
104)
105{
106 return
107 merge
108 (
109 unmergedSurface.points(),
110 unmergedSurface.faces(),
111 unmergedSurface.zoneIds(),
112 unmergedSurface.faceIds(),
113 mergeDim
114 );
115}
116
117
119(
120 const pointField& unmergedPoints,
121 const faceList& unmergedFaces,
122 const scalar mergeDim
123)
124{
125 return
126 merge
127 (
128 unmergedPoints,
129 unmergedFaces,
130 labelList(),
131 labelList(),
132 mergeDim
133 );
134}
135
136
138(
139 const pointField& unmergedPoints,
140 const faceList& unmergedFaces,
141 const labelList& origZoneIds,
142 const labelList& origFaceIds,
143 const scalar mergeDim
144)
145{
146 if (!use())
147 {
148 clear(); // Extra safety?
149 return false;
150 }
151
153 (
154 mergeDim,
155 primitivePatch(SubList<face>(unmergedFaces), unmergedPoints),
156 points_,
157 faces_,
158 pointsMap_
159 );
160
161
162 // Now handle per-face information
163
164 globalIndex::gatherOp(origZoneIds, zoneIds_);
165 globalIndex::gatherOp(origFaceIds, faceIds_);
166
167 return true;
168}
169
170
171// ************************************************************************* //
static void gatherAndMerge(const scalar mergeDist, const PrimitivePatch< FaceList, PointField > &pp, Field< typename PrimitivePatch< FaceList, PointField >::point_type > &mergedPoints, List< typename PrimitivePatch< FaceList, PointField >::face_type > &mergedFaces, labelList &pointMergeMap, const bool useLocal=false)
Gather points and faces onto master and merge into single patch.
A List obtained as a section of another List.
Definition: SubList.H:70
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
virtual bool merge() const
static void gatherOp(const UList< Type > &sendData, List< Type > &allData, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm)
Collect data in processor order on master (in serial: performs a simple copy).
Simple class to manage surface merging information.
Definition: mergedSurf.H:55
bool merge(const meshedSurf &unmergedSurface, const scalar mergeDim)
Merge meshed surfaces (in parallel only).
Definition: mergedSurf.C:101
static bool use()
Can use (parallel only)
Definition: mergedSurf.C:83
void clear()
Clear all storage.
Definition: mergedSurf.C:89
mergedSurf()=default
Default construct.
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:50
virtual const faceList & faces() const =0
The faces used for the surface.
virtual const labelList & faceIds() const
Per-face identifier (eg, element Id)
Definition: meshedSurf.H:83
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: meshedSurf.H:77
virtual const pointField & points() const =0
The points used for the surface.
patchWriters clear()
List< label > labelList
A List of labels.
Definition: List.H:66
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.