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-2018 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& mesh,
33  const PtrList<pointMesh>& procMeshes,
34  const PtrList<labelIOList>& pointProcAddressing,
35  const PtrList<labelIOList>& boundaryProcAddressing
36 )
37 :
38  mesh_(mesh),
39  procMeshes_(procMeshes),
40  pointProcAddressing_(pointProcAddressing),
41  boundaryProcAddressing_(boundaryProcAddressing),
42  patchPointAddressing_(procMeshes.size()),
43  nReconstructed_(0)
44 {
45  // Inverse-addressing of the patch point labels.
46  labelList pointMap(mesh_.size(), -1);
47 
48  // Create the pointPatch addressing
49  forAll(procMeshes_, proci)
50  {
51  const pointMesh& procMesh = procMeshes_[proci];
52 
53  patchPointAddressing_[proci].setSize(procMesh.boundary().size());
54 
55  forAll(procMesh.boundary(), patchi)
56  {
57  if (boundaryProcAddressing_[proci][patchi] >= 0)
58  {
59  labelList& procPatchAddr = patchPointAddressing_[proci][patchi];
60  procPatchAddr.setSize(procMesh.boundary()[patchi].size(), -1);
61 
62  const labelList& patchPointLabels =
63  mesh_.boundary()[boundaryProcAddressing_[proci][patchi]]
64  .meshPoints();
65 
66  // Create the inverse-addressing of the patch point labels.
67  forAll(patchPointLabels, pointi)
68  {
69  pointMap[patchPointLabels[pointi]] = pointi;
70  }
71 
72  const labelList& procPatchPoints =
73  procMesh.boundary()[patchi].meshPoints();
74 
75  forAll(procPatchPoints, pointi)
76  {
77  procPatchAddr[pointi] =
78  pointMap
79  [
80  pointProcAddressing_[proci][procPatchPoints[pointi]]
81  ];
82  }
83 
84  if (procPatchAddr.size() && min(procPatchAddr) < 0)
85  {
87  << "Incomplete patch point addressing"
88  << abort(FatalError);
89  }
90  }
91  }
92  }
93 }
94 
95 
96 // ************************************************************************* //
#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:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:48
pointFieldReconstructor(const pointMesh &mesh, const PtrList< pointMesh > &procMeshes, const PtrList< labelIOList > &pointProcAddressing, const PtrList< labelIOList > &boundaryProcAddressing)
Construct from components.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
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
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: pointMesh.H:103