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-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 :
40  mergedSurf()
41 {
42  merge(unmergedSurface, mergeDim);
43 }
44 
45 
47 (
48  const pointField& unmergedPoints,
49  const faceList& unmergedFaces,
50  const scalar mergeDim
51 )
52 :
53  mergedSurf()
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 :
68  mergedSurf()
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,
156  (
157  SubList<face>(unmergedFaces, unmergedFaces.size()),
158  unmergedPoints
159  ),
160  points_,
161  faces_,
162  pointsMap_
163  );
164 
165 
166  // Now handle per-face information
167 
168  globalIndex::gatherOp(origZoneIds, zoneIds_);
169  globalIndex::gatherOp(origFaceIds, faceIds_);
170 
171  return true;
172 }
173 
174 
175 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
PatchTools.H
Foam::PatchTools::gatherAndMerge
static void gatherAndMerge(const scalar mergeDist, const PrimitivePatch< FaceList, PointField > &p, Field< typename PrimitivePatch< FaceList, PointField >::point_type > &mergedPoints, List< typename PrimitivePatch< FaceList, PointField >::face_type > &mergedFaces, labelList &pointMergeMap)
Gather points and faces onto master and merge into single patch.
Definition: PatchToolsGatherAndMerge.C:38
Foam::mergedSurf::clear
void clear()
Clear all storage.
Definition: mergedSurf.C:89
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
globalIndex.H
Foam::meshedSurf::faces
virtual const faceList & faces() const =0
The faces used for the surface.
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
mergedSurf.H
Foam::Field< vector >
Foam::mergedSurf
Simple class to manage surface merging information.
Definition: mergedSurf.H:52
Foam::mergedSurf::merge
bool merge(const meshedSurf &unmergedSurface, const scalar mergeDim)
Merge meshed surfaces (in parallel only).
Definition: mergedSurf.C:101
Foam::meshedSurf::points
virtual const pointField & points() const =0
The points used for the surface.
Foam::globalIndex::gatherOp
static void gatherOp(const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes=Pstream::commsTypes::nonBlocking)
Collect data in processor order on master.
Definition: globalIndexTemplates.C:472
Foam::mergedSurf::mergedSurf
mergedSurf()=default
Default construct.
Foam::meshedSurf::faceIds
virtual const labelList & faceIds() const
Per-face identifier (eg, element Id)
Definition: meshedSurf.H:83
clear
patchWriters clear()
Foam::mergedSurf::use
static bool use()
Can use (parallel only)
Definition: mergedSurf.C:83
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< face >
Foam::meshedSurf::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: meshedSurf.H:77
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79