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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "pointFieldDecomposer.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const pointPatch& completeMeshPatch,
35  const pointPatch& procMeshPatch,
36  const labelList& directAddr
37 )
38 :
39  pointPatchFieldMapperPatchRef
40  (
41  completeMeshPatch,
42  procMeshPatch
43  ),
44  directAddressing_(procMeshPatch.size(), -1),
45  hasUnmapped_(false)
46 {
47  // Create the inverse-addressing of the patch point labels.
48  labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
49 
50  const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
51 
52  forAll(completeMeshPatchPoints, pointi)
53  {
54  pointMap[completeMeshPatchPoints[pointi]] = pointi;
55  }
56 
57  // Use the inverse point addressing to create the addressing table for this
58  // patch
59  const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
60 
61  forAll(procMeshPatchPoints, pointi)
62  {
63  directAddressing_[pointi] =
64  pointMap[directAddr[procMeshPatchPoints[pointi]]];
65  }
66 
67  // Check that all the patch point addresses are set
68  if (directAddressing_.size() && min(directAddressing_) < 0)
69  {
70  hasUnmapped_ = true;
71 
73  << "Incomplete patch point addressing"
74  << abort(FatalError);
75  }
76 }
77 
78 
79 Foam::pointFieldDecomposer::pointFieldDecomposer
80 (
81  const pointMesh& completeMesh,
82  const pointMesh& procMesh,
83  const labelList& pointAddressing,
84  const labelList& boundaryAddressing
85 )
86 :
87  completeMesh_(completeMesh),
88  procMesh_(procMesh),
89  pointAddressing_(pointAddressing),
90  boundaryAddressing_(boundaryAddressing),
91  patchFieldDecomposerPtrs_
92  (
93  procMesh_.boundary().size(),
94  static_cast<patchFieldDecomposer*>(nullptr)
95  )
96 {
97  forAll(boundaryAddressing_, patchi)
98  {
99  if (boundaryAddressing_[patchi] >= 0)
100  {
101  patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
102  (
103  completeMesh_.boundary()[boundaryAddressing_[patchi]],
104  procMesh_.boundary()[patchi],
105  pointAddressing_
106  );
107  }
108  }
109 }
110 
111 
112 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
113 
115 {
116  forAll(patchFieldDecomposerPtrs_, patchi)
117  {
118  if (patchFieldDecomposerPtrs_[patchi])
119  {
120  delete patchFieldDecomposerPtrs_[patchi];
121  }
122  }
123 }
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
patchFieldDecomposer(const pointPatch &completeMeshPatch, const pointPatch &procMeshPatch, const labelList &directAddr)
Construct given addressing.
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
pointFieldDecomposer.H
boundary
faceListList boundary
Definition: createBlockMesh.H:4
Foam::pointFieldDecomposer::~pointFieldDecomposer
~pointFieldDecomposer()
Destructor.