initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / pointMesh / pointPatches / constraint / cyclic / cyclicPointPatch.C
blob81104d726e24b88254ecc9adc4dd9a24d746ef9e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "cyclicPointPatch.H"
28 #include "pointBoundaryMesh.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "pointMesh.H"
31 #include "globalPointPatch.H"
32 #include "edgeList.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(cyclicPointPatch, 0);
43 addToRunTimeSelectionTable
45     facePointPatch,
46     cyclicPointPatch,
47     polyPatch
51 // * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
53 void Foam::cyclicPointPatch::initGeometry()
55     transformPairs_.setSize(0);
59 void Foam::cyclicPointPatch::calcGeometry()
61     const edgeList& cp = cyclicPolyPatch_.coupledPoints();
62     const labelList& mp = cyclicPolyPatch_.meshPoints();
64     // If there are no global points create a 1->1 map
65     if (!boundaryMesh().mesh().globalData().nGlobalPoints())
66     {
67         nonGlobalPatchPoints_.setSize(mp.size());
68         forAll(nonGlobalPatchPoints_, i)
69         {
70             nonGlobalPatchPoints_[i] = i;
71         }
73         meshPoints_ = cyclicPolyPatch_.meshPoints();
74         transformPairs_ = cp;
75     }
76     else
77     {
78         // Get reference to shared points
79         const labelList& sharedPoints = 
80             boundaryMesh().globalPatch().meshPoints();
82         nonGlobalPatchPoints_.setSize(mp.size());
83         meshPoints_.setSize(mp.size());
85         labelList pointMap(mp.size(), -1);
87         label noFiltPoints = 0;
89         forAll (mp, pointI)
90         {
91             label curP = mp[pointI];
93             bool found = false;
95             forAll (sharedPoints, sharedI)
96             {
97                 if (sharedPoints[sharedI] == curP)
98                 {
99                     found = true;
100                     break;
101                 }
102             }
104             if (!found)
105             {
106                 pointMap[pointI] = noFiltPoints;
107                 nonGlobalPatchPoints_[noFiltPoints] = pointI;
108                 meshPoints_[noFiltPoints] = curP;
109                 noFiltPoints++;
110             }
111         }
113         nonGlobalPatchPoints_.setSize(noFiltPoints);
114         meshPoints_.setSize(noFiltPoints);
117         transformPairs_.setSize(cp.size());
119         label noFiltPointPairs = 0;
121         forAll(cp, i)
122         {
123             if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] != -1)
124             {
125                 transformPairs_[noFiltPointPairs][0] = pointMap[cp[i][0]];
126                 transformPairs_[noFiltPointPairs][1] = pointMap[cp[i][1]];
127                 noFiltPointPairs++;
128             }
129             else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1)
130             {
131                 FatalErrorIn("cyclicPointPatch::calcGeometry() const")
132                     << "Point " << cp[i][0] << "of point-pair " << i
133                     << " is a global point but the other point "
134                     << cp[i][1] << " is not"
135                     << exit(FatalError);
136             }
137             else if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] == -1)
138             {
139                 FatalErrorIn("cyclicPointPatch::calcGeometry() const")
140                     << "Point " << cp[i][1] << "of point-pair " << i
141                     << " is a global point but the other point "
142                     << cp[i][0] << " is not"
143                     << exit(FatalError);
144             }
145         }
147         transformPairs_.setSize(noFiltPointPairs);
148     }
152 void cyclicPointPatch::initMovePoints(const pointField&)
156 void cyclicPointPatch::movePoints(const pointField&)
160 void cyclicPointPatch::initUpdateMesh()
162     facePointPatch::initUpdateMesh();
163     cyclicPointPatch::initGeometry();
167 void cyclicPointPatch::updateMesh()
169     facePointPatch::updateMesh();
170     cyclicPointPatch::calcGeometry();
174 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
176 cyclicPointPatch::cyclicPointPatch
178     const polyPatch& patch,
179     const pointBoundaryMesh& bm
182     coupledFacePointPatch(patch, bm),
183     cyclicPolyPatch_(refCast<const cyclicPolyPatch>(patch))
187 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
189 cyclicPointPatch::~cyclicPointPatch()
193 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
195 const edgeList& cyclicPointPatch::transformPairs() const
197     return transformPairs_;
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace Foam
205 // ************************************************************************* //