pointFieldDecomposer.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34(
35 const pointPatch& completeMeshPatch,
36 const pointPatch& procMeshPatch,
37 const labelList& directAddr
38)
39:
41 (
42 completeMeshPatch,
43 procMeshPatch
44 ),
45 directAddressing_(procMeshPatch.size(), -1),
46 hasUnmapped_(false)
47{
48 // Create the inverse-addressing of the patch point labels.
49 labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
50
51 const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
52
53 forAll(completeMeshPatchPoints, pointi)
54 {
55 pointMap[completeMeshPatchPoints[pointi]] = pointi;
56 }
57
58 // Use the inverse point addressing to create the addressing table for this
59 // patch
60 const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
61
62 forAll(procMeshPatchPoints, pointi)
63 {
64 directAddressing_[pointi] =
65 pointMap[directAddr[procMeshPatchPoints[pointi]]];
66 }
67
68 // Check that all the patch point addresses are set
69 if (directAddressing_.size() && min(directAddressing_) < 0)
70 {
71 hasUnmapped_ = true;
72
74 << "Incomplete patch point addressing"
75 << abort(FatalError);
76 }
77}
78
79
81(
82 const Foam::zero,
83 const pointMesh& procMesh,
84 const labelList& pointAddressing,
85 const labelList& boundaryAddressing
86)
87:
88 procMesh_(procMesh),
89 pointAddressing_(pointAddressing),
90 boundaryAddressing_(boundaryAddressing),
91 // Mappers
92 patchFieldDecomposerPtrs_()
93{}
94
95
97(
98 const pointMesh& completeMesh,
99 const pointMesh& procMesh,
100 const labelList& pointAddressing,
101 const labelList& boundaryAddressing
102)
103:
105 (
106 zero{},
107 procMesh,
108 pointAddressing,
109 boundaryAddressing
110 )
111{
112 reset(completeMesh);
113}
114
115
116// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117
119{
120 return patchFieldDecomposerPtrs_.empty();
121}
122
123
125{
126 patchFieldDecomposerPtrs_.clear();
127}
128
129
131(
132 const pointMesh& completeMesh
133)
134{
135 clear();
136 const label nMappers = procMesh_.boundary().size();
137 patchFieldDecomposerPtrs_.resize(nMappers);
138
139 forAll(boundaryAddressing_, patchi)
140 {
141 const label oldPatchi = boundaryAddressing_[patchi];
142
143 if (oldPatchi >= 0)
144 {
145 patchFieldDecomposerPtrs_.set
146 (
147 patchi,
149 (
150 completeMesh.boundary()[oldPatchi],
151 procMesh_.boundary()[patchi],
152 pointAddressing_
153 )
154 );
155 }
156 }
157}
158
159
160// ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
void reset()
Reset to defaults.
const pointMesh & mesh() const noexcept
Return the mesh reference.
Point field decomposer.
bool empty() const
True if no mappers have been allocated.
void reset(const pointMesh &completeMesh)
Reset mappers using information from the complete mesh.
void clear()
Remove all mappers.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
static label size(const Mesh &mesh)
Return size. Number of points.
Definition: pointMesh.H:102
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: pointMesh.H:114
Foam::pointPatchFieldMapperPatchRef.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
virtual const labelList & meshPoints() const =0
Return mesh points.
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: pointPatch.H:141
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
patchWriters clear()
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333