Loading...
Searching...
No Matches
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
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34(
35 const meshedSurf& unmergedSurface,
36 const scalar mergeDim
37)
38{
39 merge(unmergedSurface, mergeDim);
40}
41
42
44(
45 const pointField& unmergedPoints,
46 const faceList& unmergedFaces,
47 const scalar mergeDim
48)
49{
50 merge(unmergedPoints, unmergedFaces, mergeDim);
51}
52
53
55(
56 const pointField& unmergedPoints,
57 const faceList& unmergedFaces,
58 const labelList& origZoneIds,
59 const labelList& origFaceIds,
60 const scalar mergeDim
61)
62{
63 merge
64 (
65 unmergedPoints,
66 unmergedFaces,
67 origZoneIds,
68 origFaceIds,
69 mergeDim
70 );
71}
72
73
74// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75
77{
78 points_.clear();
79 faces_.clear();
80 pointsMap_.clear();
81
82 zoneIds_.clear();
83 faceIds_.clear();
84
85 pointGlobalIndex_.clear();
86 faceGlobalIndex_.clear();
87}
88
89
91(
92 const meshedSurf& unmergedSurface,
93 const scalar mergeDim
94)
95{
96 return
97 merge
98 (
99 unmergedSurface.points(),
100 unmergedSurface.faces(),
101 unmergedSurface.zoneIds(),
102 unmergedSurface.faceIds(),
103 mergeDim
104 );
105}
106
107
109(
110 const pointField& unmergedPoints,
111 const faceList& unmergedFaces,
112 const scalar mergeDim
113)
114{
115 return
116 merge
117 (
118 unmergedPoints,
119 unmergedFaces,
122 mergeDim
123 );
124}
125
126
128(
129 const pointField& unmergedPoints,
130 const faceList& unmergedFaces,
131 const labelList& origZoneIds,
132 const labelList& origFaceIds,
133 const scalar mergeDim
134)
135{
136 if (!UPstream::parRun())
137 {
138 clear(); // Safety
139 return false;
140 }
141
143 (
144 mergeDim,
145 primitivePatch(SubList<face>(unmergedFaces), unmergedPoints),
146 points_,
147 faces_,
148 pointGlobalIndex_,
149 faceGlobalIndex_,
150 pointsMap_
151 );
152
153
154 // The zone/ids information is either *exactly* the same size as
155 // the number of faces, or zero-sized everywhere.
156 // However, use gatherOp anyhow, which has redundant overhead,
157 // but safer if there are any size mis-matches
158
159 if (notNull(origZoneIds))
160 {
161 globalIndex::gatherOp(origZoneIds, zoneIds_);
162 }
163 if (notNull(origFaceIds))
164 {
165 globalIndex::gatherOp(origFaceIds, faceIds_);
166 }
167
168 return true;
169}
170
171
172// ************************************************************************* //
static const List< label > & null() noexcept
Definition List.H:138
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, globalIndex &pointAddr, globalIndex &faceAddr, labelList &pointMergeMap=const_cast< labelList & >(labelList::null()), const bool useLocal=false)
Gather points and faces onto master and merge into single patch.
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
static void gatherOp(const UList< Type > &sendData, List< Type > &allData, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking, const label comm=UPstream::worldComm)
Collect data in processor order on master (in serial: performs a simple copy).
bool merge(const meshedSurf &unmergedSurface, const scalar mergeDim)
Merge meshed surfaces (in parallel only).
Definition mergedSurf.C:84
mergedSurf() noexcept=default
Default construct.
void clear()
Clear all storage.
Definition mergedSurf.C:69
Abstract definition of a meshed surface defined by faces and points.
Definition meshedSurf.H:44
virtual const faceList & faces() const =0
The faces used for the surface.
constexpr meshedSurf() noexcept=default
Default construct.
virtual const labelList & faceIds() const
Per-face identifier (eg, element Id).
Definition meshedSurf.H:90
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition meshedSurf.H:82
virtual const pointField & points() const =0
The points used for the surface.
surface1 clear()
List< label > labelList
A List of labels.
Definition List.H:62
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
Definition nullObject.H:267
vectorField pointField
pointField is a vectorField.