pointFieldReconstructor.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 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 (
32  const pointMesh& completeMesh,
33  const PtrList<pointMesh>& procMeshes,
34  const labelListList& pointProcAddressing
35 )
36 :
37  completeMesh_(completeMesh),
38  procMeshes_(procMeshes),
39  pointProcAddressing_(pointProcAddressing),
40  patchPointAddressing_(procMeshes.size()),
41  nReconstructed_(0)
42 {
43  // Inverse-addressing of the patch point labels.
44  labelList pointMap(completeMesh_.size(), -1);
45 
46  // Create the pointPatch addressing
47  forAll(procMeshes_, proci)
48  {
49  const pointMesh& procMesh = procMeshes_[proci];
50 
51  patchPointAddressing_[proci].setSize(procMesh.boundary().size());
52 
53  forAll(procMesh.boundary(), patchi)
54  {
55  if (patchi < completeMesh_.boundary().size())
56  {
57  labelList& procPatchAddr = patchPointAddressing_[proci][patchi];
58  procPatchAddr.setSize(procMesh.boundary()[patchi].size(), -1);
59 
60  const labelList& patchPointLabels =
61  completeMesh_.boundary()[patchi].meshPoints();
62 
63  // Create the inverse-addressing of the patch point labels.
64  forAll(patchPointLabels, pointi)
65  {
66  pointMap[patchPointLabels[pointi]] = pointi;
67  }
68 
69  const labelList& procPatchPoints =
70  procMesh.boundary()[patchi].meshPoints();
71 
72  forAll(procPatchPoints, pointi)
73  {
74  procPatchAddr[pointi] =
75  pointMap
76  [
77  pointProcAddressing_[proci][procPatchPoints[pointi]]
78  ];
79  }
80 
81  if (procPatchAddr.size() && min(procPatchAddr) < 0)
82  {
84  << "Incomplete patch point addressing"
85  << abort(FatalError);
86  }
87  }
88  }
89  }
90 }
91 
92 
93 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
pointFieldReconstructor(const pointMesh &mesh, const PtrList< pointMesh > &procMeshes, const labelListList &pointProcAddressing)
Construct from components.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
void setSize(const label)
Reset size of List.
Definition: List.C:281
label patchi
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:800