1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "mapDistributePolyMesh.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 void Foam::mapDistributePolyMesh::calcPatchSizes()
35 oldPatchSizes_.setSize(oldPatchStarts_.size());
37 // Calculate old patch sizes
38 for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
40 oldPatchSizes_[patchI] =
41 oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
44 // Set the last one by hand
45 const label lastPatchID = oldPatchStarts_.size() - 1;
47 oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
49 if (min(oldPatchSizes_) < 0)
51 FatalErrorIn("mapDistributePolyMesh::calcPatchSizes()")
52 << "Calculated negative old patch size:" << oldPatchSizes_ << nl
53 << "Error in mapping data" << abort(FatalError);
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 //- Construct from components
61 Foam::mapDistributePolyMesh::mapDistributePolyMesh
65 // mesh before changes
66 const label nOldPoints,
67 const label nOldFaces,
68 const label nOldCells,
69 const labelList& oldPatchStarts,
70 const labelList& oldPatchNMeshPoints,
72 // how to subset pieces of mesh to send across
73 const labelListList& subPointMap,
74 const labelListList& subFaceMap,
75 const labelListList& subCellMap,
76 const labelListList& subPatchMap,
78 // how to reconstruct received mesh
79 const labelListList& constructPointMap,
80 const labelListList& constructFaceMap,
81 const labelListList& constructCellMap,
82 const labelListList& constructPatchMap
86 nOldPoints_(nOldPoints),
87 nOldFaces_(nOldFaces),
88 nOldCells_(nOldCells),
89 oldPatchSizes_(oldPatchStarts.size()),
90 oldPatchStarts_(oldPatchStarts),
91 oldPatchNMeshPoints_(oldPatchNMeshPoints),
92 pointMap_(mesh.nPoints(), subPointMap, constructPointMap),
93 faceMap_(mesh.nFaces(), subFaceMap, constructFaceMap),
94 cellMap_(mesh.nCells(), subCellMap, constructCellMap),
95 patchMap_(mesh.boundaryMesh().size(), subPatchMap, constructPatchMap)
101 //- (optionally destructively) construct from components
102 Foam::mapDistributePolyMesh::mapDistributePolyMesh
104 const polyMesh& mesh,
105 const label nOldPoints,
106 const label nOldFaces,
107 const label nOldCells,
108 labelList& oldPatchStarts,
109 labelList& oldPatchNMeshPoints,
111 labelListList& subPointMap,
112 labelListList& subFaceMap,
113 labelListList& subCellMap,
114 labelListList& subPatchMap,
115 labelListList& constructPointMap,
116 labelListList& constructFaceMap,
117 labelListList& constructCellMap,
118 labelListList& constructPatchMap,
119 const bool reUse // clone or reuse
123 nOldPoints_(nOldPoints),
124 nOldFaces_(nOldFaces),
125 nOldCells_(nOldCells),
126 oldPatchSizes_(oldPatchStarts.size()),
127 oldPatchStarts_(oldPatchStarts, reUse),
128 oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse),
130 pointMap_(mesh.nPoints(), subPointMap, constructPointMap, reUse),
131 faceMap_(mesh.nFaces(), subFaceMap, constructFaceMap, reUse),
132 cellMap_(mesh.nCells(), subCellMap, constructCellMap, reUse),
133 patchMap_(mesh.boundaryMesh().size(), subPatchMap, constructPatchMap, reUse)
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst) const
143 // Construct boolList from selected elements
146 createWithValues<boolList>
156 distributePointData(isSelected);
158 // Collect selected elements
159 lst = findIndices(isSelected, true);
163 void Foam::mapDistributePolyMesh::distributeFaceIndices(labelList& lst) const
165 // Construct boolList from selected elements
168 createWithValues<boolList>
178 distributeFaceData(isSelected);
180 // Collect selected elements
181 lst = findIndices(isSelected, true);
185 void Foam::mapDistributePolyMesh::distributeCellIndices(labelList& lst) const
187 // Construct boolList from selected elements
190 createWithValues<boolList>
200 distributeCellData(isSelected);
202 // Collect selected elements
203 lst = findIndices(isSelected, true);
207 void Foam::mapDistributePolyMesh::distributePatchIndices(labelList& lst) const
209 // Construct boolList from selected elements
212 createWithValues<boolList>
214 oldPatchStarts().size(), // nOldPatches
222 distributePatchData(isSelected);
224 // Collect selected elements
225 lst = findIndices(isSelected, true);
229 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
232 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
235 // ************************************************************************* //