ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / polyMesh / mapPolyMesh / mapDistribute / mapDistributePolyMesh.C
blob0dc63bdb577a8bf4385ecf7d416c97f090d2bd1d
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.
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
19     for more details.
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"
27 #include "polyMesh.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++)
38     {
39         oldPatchSizes_[patchI] =
40             oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
41     }
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)
49     {
50         FatalErrorIn("mapDistributePolyMesh::calcPatchSizes()")
51             << "Calculated negative old patch size:" << oldPatchSizes_ << nl
52             << "Error in mapping data" << abort(FatalError);
53     }
57 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
59 //- Construct from components
60 Foam::mapDistributePolyMesh::mapDistributePolyMesh
62     const polyMesh& mesh,
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
84     mesh_(mesh),
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)
96     calcPatchSizes();
100 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
102 void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst) const
104     // Construct boolList from selected elements
105     boolList isSelected
106     (
107         createWithValues<boolList>
108         (
109             nOldPoints(),
110             false,
111             lst,
112             true
113         )
114     );
116     // Distribute
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
127     boolList isSelected
128     (
129         createWithValues<boolList>
130         (
131             nOldFaces(),
132             false,
133             lst,
134             true
135         )
136     );
138     // Distribute
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
149     boolList isSelected
150     (
151         createWithValues<boolList>
152         (
153             nOldCells(),
154             false,
155             lst,
156             true
157         )
158     );
160     // Distribute
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
171     boolList isSelected
172     (
173         createWithValues<boolList>
174         (
175             oldPatchStarts().size(),    // nOldPatches
176             false,
177             lst,
178             true
179         )
180     );
182     // Distribute
183     distributePatchData(isSelected);
185     // Collect selected elements
186     lst = findIndices(isSelected, true);
190 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
193 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
196 // ************************************************************************* //