pointFieldReconstructor.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 | Copyright (C) 2011 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 
30 Foam::pointFieldReconstructor::pointFieldReconstructor
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  (
88  "pointFieldReconstructor::pointFieldReconstructor"
89  "(\n"
90  " const pointMesh& mesh,\n"
91  " const PtrList<pointMesh>& procMeshes,\n"
92  " const PtrList<labelIOList>& pointProcAddressing,\n"
93  " const PtrList<labelIOList>& "
94  "boundaryProcAddressing\n"
95  ")"
96  ) << "Incomplete patch point addressing"
97  << abort(FatalError);
98  }
99  }
100  }
101  }
102 }
103 
104 
105 // ************************************************************************* //
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:48
void setSize(const label)
Reset size of List.
Definition: List.C:318
#define forAll(list, i)
Definition: UList.H:421
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: pointMesh.H:106
label patchi
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)