1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "mapDistributePolyMesh.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 void Foam::mapDistributePolyMesh::calcPatchSizes()
34 oldPatchSizes_.setSize(oldPatchStarts_.size());
36 // Calculate old patch sizes
37 for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
39 oldPatchSizes_[patchI] =
40 oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
43 // Set the last one by hand
44 const label lastPatchID = oldPatchStarts_.size() - 1;
46 oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
48 if (min(oldPatchSizes_) < 0)
50 FatalErrorIn("mapDistributePolyMesh::calcPatchSizes()")
51 << "Calculated negative old patch size:" << oldPatchSizes_ << nl
52 << "Error in mapping data" << abort(FatalError);
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 //- Construct from components
60 Foam::mapDistributePolyMesh::mapDistributePolyMesh
64 // mesh before changes
65 const label nOldPoints,
66 const label nOldFaces,
67 const label nOldCells,
68 const Xfer<labelList>& oldPatchStarts,
69 const Xfer<labelList>& oldPatchNMeshPoints,
71 // how to subset pieces of mesh to send across
72 const Xfer<labelListList>& subPointMap,
73 const Xfer<labelListList>& subFaceMap,
74 const Xfer<labelListList>& subCellMap,
75 const Xfer<labelListList>& subPatchMap,
77 // how to reconstruct received mesh
78 const Xfer<labelListList>& constructPointMap,
79 const Xfer<labelListList>& constructFaceMap,
80 const Xfer<labelListList>& constructCellMap,
81 const Xfer<labelListList>& constructPatchMap
85 nOldPoints_(nOldPoints),
86 nOldFaces_(nOldFaces),
87 nOldCells_(nOldCells),
88 oldPatchSizes_(oldPatchStarts().size()),
89 oldPatchStarts_(oldPatchStarts),
90 oldPatchNMeshPoints_(oldPatchNMeshPoints),
91 pointMap_(mesh.nPoints(), subPointMap, constructPointMap),
92 faceMap_(mesh.nFaces(), subFaceMap, constructFaceMap),
93 cellMap_(mesh.nCells(), subCellMap, constructCellMap),
94 patchMap_(mesh.boundaryMesh().size(), subPatchMap, constructPatchMap)
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst) const
104 // Construct boolList from selected elements
107 createWithValues<boolList>
117 distributePointData(isSelected);
119 // Collect selected elements
120 lst = findIndices(isSelected, true);
124 void Foam::mapDistributePolyMesh::distributeFaceIndices(labelList& lst) const
126 // Construct boolList from selected elements
129 createWithValues<boolList>
139 distributeFaceData(isSelected);
141 // Collect selected elements
142 lst = findIndices(isSelected, true);
146 void Foam::mapDistributePolyMesh::distributeCellIndices(labelList& lst) const
148 // Construct boolList from selected elements
151 createWithValues<boolList>
161 distributeCellData(isSelected);
163 // Collect selected elements
164 lst = findIndices(isSelected, true);
168 void Foam::mapDistributePolyMesh::distributePatchIndices(labelList& lst) const
170 // Construct boolList from selected elements
173 createWithValues<boolList>
175 oldPatchStarts().size(), // nOldPatches
183 distributePatchData(isSelected);
185 // Collect selected elements
186 lst = findIndices(isSelected, true);
190 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
193 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
196 // ************************************************************************* //