FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const pointPatch& completeMeshPatch,
38  const pointPatch& procMeshPatch,
39  const labelList& directAddr
40 )
41 :
42  pointPatchFieldMapperPatchRef
43  (
44  completeMeshPatch,
45  procMeshPatch
46  ),
47  directAddressing_(procMeshPatch.size(), -1)
48 {
49  // Create the inverse-addressing of the patch point labels.
50  labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
51 
52  const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
53 
54  forAll (completeMeshPatchPoints, pointi)
55  {
56  pointMap[completeMeshPatchPoints[pointi]] = pointi;
57  }
58 
59  // Use the inverse point addressing to create the addressing table for this
60  // patch
61  const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
62 
63  forAll (procMeshPatchPoints, pointi)
64  {
65  directAddressing_[pointi] =
66  pointMap[directAddr[procMeshPatchPoints[pointi]]];
67  }
68 
69  // Check that all the patch point addresses are set
70  if (directAddressing_.size() && min(directAddressing_) < 0)
71  {
73  (
74  "pointFieldDecomposer::patchFieldDecomposer()"
75  ) << "Incomplete patch point addressing"
76  << abort(FatalError);
77  }
78 }
79 
80 
81 pointFieldDecomposer::pointFieldDecomposer
82 (
83  const pointMesh& completeMesh,
84  const pointMesh& procMesh,
85  const labelList& pointAddressing,
86  const labelList& boundaryAddressing
87 )
88 :
89  completeMesh_(completeMesh),
90  procMesh_(procMesh),
91  pointAddressing_(pointAddressing),
92  boundaryAddressing_(boundaryAddressing),
93  patchFieldDecomposerPtrs_
94  (
95  procMesh_.boundary().size(),
96  static_cast<patchFieldDecomposer*>(NULL)
97  )
98 {
99  forAll (boundaryAddressing_, patchi)
100  {
101  if (boundaryAddressing_[patchi] >= 0)
102  {
103  patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
104  (
105  completeMesh_.boundary()[boundaryAddressing_[patchi]],
106  procMesh_.boundary()[patchi],
107  pointAddressing_
108  );
109  }
110  }
111 }
112 
113 
114 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
115 
117 {
118  forAll (patchFieldDecomposerPtrs_, patchi)
119  {
120  if (patchFieldDecomposerPtrs_[patchi])
121  {
122  delete patchFieldDecomposerPtrs_[patchi];
123  }
124  }
125 }
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // ************************ vim: set sw=4 sts=4 et: ************************ //