BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / constraint / processorCyclic / processorCyclicPolyPatch.C
blob1f194578e05ccb24a4a7bdd9df67c043de3a80ab
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 "processorCyclicPolyPatch.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "SubField.H"
29 #include "cyclicPolyPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(processorCyclicPolyPatch, 0);
36     addToRunTimeSelectionTable(polyPatch, processorCyclicPolyPatch, dictionary);
40 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
47     const word& name,
48     const label size,
49     const label start,
50     const label index,
51     const polyBoundaryMesh& bm,
52     const int myProcNo,
53     const int neighbProcNo,
54     const word& referPatchName
57     processorPolyPatch(name, size, start, index, bm, myProcNo, neighbProcNo),
58     tag_
59     (
60         Pstream::nProcs()*max(myProcNo, neighbProcNo)
61       + min(myProcNo, neighbProcNo)
62     ),
63     referPatchName_(referPatchName),
64     referPatchID_(-1)
66     if (debug)
67     {
68         Pout<< "processorCyclicPolyPatch " << name << " uses tag " << tag_
69             << endl;
70     }
74 Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
76     const word& name,
77     const dictionary& dict,
78     const label index,
79     const polyBoundaryMesh& bm
82     processorPolyPatch(name, dict, index, bm),
83     tag_
84     (
85         Pstream::nProcs()*max(myProcNo(), neighbProcNo())
86       + min(myProcNo(), neighbProcNo())
87     ),
88     referPatchName_(dict.lookup("referPatch")),
89     referPatchID_(-1)
91     if (debug)
92     {
93         Pout<< "processorCyclicPolyPatch " << name << " uses tag " << tag_
94             << endl;
95     }
99 Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
101     const processorCyclicPolyPatch& pp,
102     const polyBoundaryMesh& bm
105     processorPolyPatch(pp, bm),
106     tag_(pp.tag_),
107     referPatchName_(pp.referPatchName()),
108     referPatchID_(-1)
112 Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
114     const processorCyclicPolyPatch& pp,
115     const polyBoundaryMesh& bm,
116     const label index,
117     const label newSize,
118     const label newStart,
119     const word& referPatchName
122     processorPolyPatch(pp, bm, index, newSize, newStart),
123     tag_(pp.tag_),
124     referPatchName_(referPatchName),
125     referPatchID_(-1)
129 Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
131     const processorCyclicPolyPatch& pp,
132     const polyBoundaryMesh& bm,
133     const label index,
134     const labelUList& mapAddressing,
135     const label newStart
138     processorPolyPatch(pp, bm, index, mapAddressing, newStart),
139     tag_(pp.tag_),
140     referPatchName_(pp.referPatchName()),
141     referPatchID_(-1)
145 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
147 Foam::processorCyclicPolyPatch::~processorCyclicPolyPatch()
151 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
154 void Foam::processorCyclicPolyPatch::initGeometry(PstreamBuffers& pBufs)
156     // Send over processorPolyPatch data
157     processorPolyPatch::initGeometry(pBufs);
161 void Foam::processorCyclicPolyPatch::calcGeometry(PstreamBuffers& pBufs)
163     // Receive and initialise processorPolyPatch data
164     processorPolyPatch::calcGeometry(pBufs);
166     if (Pstream::parRun())
167     {
169         // Where do we store the calculated transformation?
170         // - on the processor patch?
171         // - on the underlying cyclic patch?
172         // - or do we not auto-calculate the transformation but
173         //   have option of reading it.
175         // Update underlying cyclic halves. Need to do both since only one
176         // half might be present as a processorCyclic.
177         coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch());
178         pp.calcGeometry
179         (
180             *this,
181             faceCentres(),
182             faceAreas(),
183             faceCellCentres(),
184             neighbFaceCentres(),
185             neighbFaceAreas(),
186             neighbFaceCellCentres()
187         );
189         if (isA<cyclicPolyPatch>(pp))
190         {
191             const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
192             const_cast<cyclicPolyPatch&>(cpp.neighbPatch()).calcGeometry
193             (
194                 *this,
195                 neighbFaceCentres(),
196                 neighbFaceAreas(),
197                 neighbFaceCellCentres(),
198                 faceCentres(),
199                 faceAreas(),
200                 faceCellCentres()
201             );
202         }
203     }
207 void Foam::processorCyclicPolyPatch::initMovePoints
209     PstreamBuffers& pBufs,
210     const pointField& p
213     // Recalculate geometry
214     initGeometry(pBufs);
218 void Foam::processorCyclicPolyPatch::movePoints
220     PstreamBuffers& pBufs,
221     const pointField&
224     calcGeometry(pBufs);
228 void Foam::processorCyclicPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
230     processorPolyPatch::initUpdateMesh(pBufs);
234 void Foam::processorCyclicPolyPatch::updateMesh(PstreamBuffers& pBufs)
236      referPatchID_ = -1;
237      processorPolyPatch::updateMesh(pBufs);
241 void Foam::processorCyclicPolyPatch::initOrder
243     PstreamBuffers& pBufs,
244     const primitivePatch& pp
245 ) const
247     // For now use the same algorithm as processorPolyPatch
248     processorPolyPatch::initOrder(pBufs, pp);
252 // Return new ordering. Ordering is -faceMap: for every face index
253 // the new face -rotation:for every new face the clockwise shift
254 // of the original face. Return false if nothing changes (faceMap
255 // is identity, rotation is 0)
256 bool Foam::processorCyclicPolyPatch::order
258     PstreamBuffers& pBufs,
259     const primitivePatch& pp,
260     labelList& faceMap,
261     labelList& rotation
262 ) const
264     // For now use the same algorithm as processorPolyPatch
265     return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
269 void Foam::processorCyclicPolyPatch::write(Ostream& os) const
271     processorPolyPatch::write(os);
272     os.writeKeyword("referPatch") << referPatchName_
273         << token::END_STATEMENT << nl;
277 // ************************************************************************* //