pointFieldDecomposer.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "pointFieldDecomposer.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 (
32  const pointPatch& completeMeshPatch,
33  const pointPatch& procMeshPatch,
34  const labelList& directAddr
35 )
36 :
37  pointPatchFieldMapperPatchRef
38  (
39  completeMeshPatch,
40  procMeshPatch
41  ),
42  directAddressing_(procMeshPatch.size(), -1),
43  hasUnmapped_(false)
44 {
45  // Create the inverse-addressing of the patch point labels.
46  labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
47 
48  const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
49 
50  forAll(completeMeshPatchPoints, pointi)
51  {
52  pointMap[completeMeshPatchPoints[pointi]] = pointi;
53  }
54 
55  // Use the inverse point addressing to create the addressing table for this
56  // patch
57  const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
58 
59  forAll(procMeshPatchPoints, pointi)
60  {
61  directAddressing_[pointi] =
62  pointMap[directAddr[procMeshPatchPoints[pointi]]];
63  }
64 
65  // Check that all the patch point addresses are set
66  if (directAddressing_.size() && min(directAddressing_) < 0)
67  {
68  hasUnmapped_ = true;
69 
71  << "Incomplete patch point addressing"
72  << abort(FatalError);
73  }
74 }
75 
76 
78 (
79  const pointMesh& completeMesh,
80  const pointMesh& procMesh,
81  const labelList& pointAddressing
82 )
83 :
84  completeMesh_(completeMesh),
85  procMesh_(procMesh),
86  pointAddressing_(pointAddressing),
87  patchFieldDecomposers_(procMesh_.boundary().size())
88 {
89  forAll(procMesh_.boundary(), patchi)
90  {
91  if (patchi < completeMesh_.boundary().size())
92  {
93  patchFieldDecomposers_.set
94  (
95  patchi,
96  new patchFieldDecomposer
97  (
98  completeMesh_.boundary()[patchi],
99  procMesh_.boundary()[patchi],
100  pointAddressing_
101  )
102  );
103  }
104  }
105 }
106 
107 
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 
111 {}
112 
113 
114 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
patchFieldDecomposer(const pointPatch &completeMeshPatch, const pointPatch &procMeshPatch, const labelList &directAddr)
Construct given addressing.
pointFieldDecomposer(const pointMesh &completeMesh, const pointMesh &procMesh, const labelList &pointAddressing)
Construct from components.
~pointFieldDecomposer()
Destructor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
label patchi
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
error FatalError
faceListList boundary(nPatches)