initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / polyMesh / mapPolyMesh / mapDistribute / mapDistributePolyMesh.C
blob0da43e68b7373e4c063c05a4cc30fd46cc2782af
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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 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
19     for more details.
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"
28 #include "polyMesh.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++)
39     {
40         oldPatchSizes_[patchI] =
41             oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
42     }
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)
50     {
51         FatalErrorIn("mapDistributePolyMesh::calcPatchSizes()")
52             << "Calculated negative old patch size:" << oldPatchSizes_ << nl
53             << "Error in mapping data" << abort(FatalError);
54     }
58 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
60 //- Construct from components
61 Foam::mapDistributePolyMesh::mapDistributePolyMesh
63     const polyMesh& mesh,
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
85     mesh_(mesh),
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)
97     calcPatchSizes();
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
122     mesh_(mesh),
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)
135     calcPatchSizes();
139 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
141 void Foam::mapDistributePolyMesh::distributePointIndices(labelList& lst) const
143     // Construct boolList from selected elements
144     boolList isSelected
145     (
146         createWithValues<boolList>
147         (
148             nOldPoints(),
149             false,
150             lst,
151             true
152         )
153     );
155     // Distribute
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
166     boolList isSelected
167     (
168         createWithValues<boolList>
169         (
170             nOldFaces(),
171             false,
172             lst,
173             true
174         )
175     );
177     // Distribute
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
188     boolList isSelected
189     (
190         createWithValues<boolList>
191         (
192             nOldCells(),
193             false,
194             lst,
195             true
196         )
197     );
199     // Distribute
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
210     boolList isSelected
211     (
212         createWithValues<boolList>
213         (
214             oldPatchStarts().size(),    // nOldPatches
215             false,
216             lst,
217             true
218         )
219     );
221     // Distribute
222     distributePatchData(isSelected);
224     // Collect selected elements
225     lst = findIndices(isSelected, true);
229 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
232 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
235 // ************************************************************************* //