FreeFOAM The Cross-Platform CFD Toolkit
cyclicPointPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cyclicPointPatch.H"
29 #include <OpenFOAM/pointMesh.H>
31 #include <OpenFOAM/edgeList.H>
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(cyclicPointPatch, 0);
41 
43 (
44  facePointPatch,
45  cyclicPointPatch,
46  polyPatch
47 );
48 
49 
50 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
51 
52 void Foam::cyclicPointPatch::initGeometry()
53 {
54  transformPairs_.setSize(0);
55 }
56 
57 
58 void Foam::cyclicPointPatch::calcGeometry()
59 {
60  const edgeList& cp = cyclicPolyPatch_.coupledPoints();
61  const labelList& mp = cyclicPolyPatch_.meshPoints();
62 
63  // If there are no global points create a 1->1 map
64  if (!boundaryMesh().mesh().globalData().nGlobalPoints())
65  {
66  nonGlobalPatchPoints_.setSize(mp.size());
67  forAll(nonGlobalPatchPoints_, i)
68  {
69  nonGlobalPatchPoints_[i] = i;
70  }
71 
72  meshPoints_ = cyclicPolyPatch_.meshPoints();
73  transformPairs_ = cp;
74  }
75  else
76  {
77  // Get reference to shared points
78  const labelList& sharedPoints =
79  boundaryMesh().globalPatch().meshPoints();
80 
81  nonGlobalPatchPoints_.setSize(mp.size());
82  meshPoints_.setSize(mp.size());
83 
84  labelList pointMap(mp.size(), -1);
85 
86  label noFiltPoints = 0;
87 
88  forAll (mp, pointI)
89  {
90  label curP = mp[pointI];
91 
92  bool found = false;
93 
94  forAll (sharedPoints, sharedI)
95  {
96  if (sharedPoints[sharedI] == curP)
97  {
98  found = true;
99  break;
100  }
101  }
102 
103  if (!found)
104  {
105  pointMap[pointI] = noFiltPoints;
106  nonGlobalPatchPoints_[noFiltPoints] = pointI;
107  meshPoints_[noFiltPoints] = curP;
108  noFiltPoints++;
109  }
110  }
111 
112  nonGlobalPatchPoints_.setSize(noFiltPoints);
113  meshPoints_.setSize(noFiltPoints);
114 
115 
116  transformPairs_.setSize(cp.size());
117 
118  label noFiltPointPairs = 0;
119 
120  forAll(cp, i)
121  {
122  if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] != -1)
123  {
124  transformPairs_[noFiltPointPairs][0] = pointMap[cp[i][0]];
125  transformPairs_[noFiltPointPairs][1] = pointMap[cp[i][1]];
126  noFiltPointPairs++;
127  }
128  else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1)
129  {
130  FatalErrorIn("cyclicPointPatch::calcGeometry() const")
131  << "Point " << cp[i][0] << "of point-pair " << i
132  << " is a global point but the other point "
133  << cp[i][1] << " is not"
134  << exit(FatalError);
135  }
136  else if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] == -1)
137  {
138  FatalErrorIn("cyclicPointPatch::calcGeometry() const")
139  << "Point " << cp[i][1] << "of point-pair " << i
140  << " is a global point but the other point "
141  << cp[i][0] << " is not"
142  << exit(FatalError);
143  }
144  }
145 
146  transformPairs_.setSize(noFiltPointPairs);
147  }
148 }
149 
150 
151 void cyclicPointPatch::initMovePoints(const pointField&)
152 {}
153 
154 
155 void cyclicPointPatch::movePoints(const pointField&)
156 {}
157 
158 
159 void cyclicPointPatch::initUpdateMesh()
160 {
162  cyclicPointPatch::initGeometry();
163 }
164 
165 
166 void cyclicPointPatch::updateMesh()
167 {
169  cyclicPointPatch::calcGeometry();
170 }
171 
172 
173 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
174 
175 cyclicPointPatch::cyclicPointPatch
176 (
177  const polyPatch& patch,
178  const pointBoundaryMesh& bm
179 )
180 :
181  coupledFacePointPatch(patch, bm),
182  cyclicPolyPatch_(refCast<const cyclicPolyPatch>(patch))
183 {}
184 
185 
186 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
187 
189 {}
190 
191 
192 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
193 
195 {
196  return transformPairs_;
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // ************************ vim: set sw=4 sts=4 et: ************************ //