1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh 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 3 of the License, or (at your
14 option) any later version.
16 cfMesh 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
21 You should have received a copy of the GNU General Public License
22 along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
27 \*---------------------------------------------------------------------------*/
29 #include "meshOptimizer.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 template<class labelListType>
39 inline void meshOptimizer::lockCells(const labelListType& l)
41 boolList lockedFace(mesh_.faces().size(), false);
42 const cellListPMG& cells = mesh_.cells();
45 const cell& c = cells[l[lcI]];
48 lockedFace[c[fI]] = true;
51 if( Pstream::parRun() )
53 const PtrList<processorBoundaryPatch>& procBoundaries =
54 mesh_.procBoundaries();
56 forAll(procBoundaries, patchI)
58 labelLongList dataToSend;
60 const label start = procBoundaries[patchI].patchStart();
61 const label end = start+procBoundaries[patchI].patchSize();
63 for(label faceI=start;faceI<end;++faceI)
64 if( lockedFace[faceI] )
65 dataToSend.append(faceI-start);
70 procBoundaries[patchI].neiProcNo(),
74 toOtherProc << dataToSend;
77 forAll(procBoundaries, patchI)
79 const label start = procBoundaries[patchI].patchStart();
81 IPstream fromOtherProc
84 procBoundaries[patchI].neiProcNo()
87 labelList receivedData;
88 fromOtherProc >> receivedData;
90 forAll(receivedData, i)
91 lockedFace[start+receivedData[i]];
95 //- Finally, mark locked points and faces
96 const faceListPMG& faces = mesh_.faces();
97 forAll(lockedFace, faceI)
99 if( lockedFace[faceI] )
101 lockedFaces_.append(faceI);
103 const face& f = faces[faceI];
106 vertexLocation_[f[pI]] |= LOCKED;
110 # ifdef DEBUGSmoothing
111 const label lockedFacesI = mesh_.addFaceSubset("lockedFaces");
112 forAll(lockedFaces_, lfI)
113 mesh_.addFaceToSubset(lockedFacesI, lockedFaces_[lfI]);
115 const label lockPointsI = mesh_.addPointSubset("lockedPoints");
116 forAll(vertexLocation_, pointI)
117 if( vertexLocation_[pointI] & LOCKED )
118 mesh_.addPointToSubset(lockPointsI, pointI);
122 template<class labelListType>
123 inline void meshOptimizer::lockFaces(const labelListType& lf)
125 boolList lockedFace(mesh_.faces().size(), false);
128 lockedFace[lf[lfI]] = true;
131 if( Pstream::parRun() )
133 const PtrList<processorBoundaryPatch>& procBoundaries =
134 mesh_.procBoundaries();
136 forAll(procBoundaries, patchI)
138 labelLongList dataToSend;
140 const label start = procBoundaries[patchI].patchStart();
141 const label end = start+procBoundaries[patchI].patchSize();
143 for(label faceI=start;faceI<end;++faceI)
144 if( lockedFace[faceI] )
145 dataToSend.append(faceI-start);
150 procBoundaries[patchI].neiProcNo(),
151 dataToSend.byteSize()
154 toOtherProc << dataToSend;
157 forAll(procBoundaries, patchI)
159 const label start = procBoundaries[patchI].patchStart();
161 IPstream fromOtherProc
164 procBoundaries[patchI].neiProcNo()
167 labelList receivedData;
168 fromOtherProc >> receivedData;
170 forAll(receivedData, i)
171 lockedFace[start+receivedData[i]];
175 //- Finally, mark locked points and faces
176 const faceListPMG& faces = mesh_.faces();
177 forAll(lockedFace, faceI)
179 if( lockedFace[faceI] )
181 lockedFaces_.append(faceI);
183 const face& f = faces[faceI];
186 vertexLocation_[f[pI]] |= LOCKED;
190 # ifdef DEBUGSmoothing
191 const label lockedFacesI = mesh_.addFaceSubset("lockedFaces");
192 forAll(lockedFaces_, lfI)
193 mesh_.addFaceToSubset(lockedFacesI, lockedFaces_[lfI]);
195 const label lockPointsI = mesh_.addPointSubset("lockedPoints");
196 forAll(vertexLocation_, pointI)
197 if( vertexLocation_[pointI] & LOCKED )
198 mesh_.addPointToSubset(lockPointsI, pointI);
202 template<class labelListType>
203 inline void meshOptimizer::lockPoints(const labelListType& lp)
206 vertexLocation_[lp[lpI]] |= LOCKED;
208 if( Pstream::parRun() )
210 const PtrList<processorBoundaryPatch>& procBoundaries =
211 mesh_.procBoundaries();
212 const faceListPMG& faces = mesh_.faces();
214 forAll(procBoundaries, patchI)
216 labelLongList dataToSend;
218 const label start = procBoundaries[patchI].patchStart();
219 const label end = start+procBoundaries[patchI].patchSize();
221 for(label faceI=start;faceI<end;++faceI)
223 const face& f = faces[faceI];
227 if( vertexLocation_[pI] & LOCKED )
229 // send the face lable and the location in the face
230 dataToSend.append(faceI-start);
231 dataToSend.append((f.size()-pI)%f.size());
239 procBoundaries[patchI].neiProcNo(),
240 dataToSend.byteSize()
243 toOtherProc << dataToSend;
246 forAll(procBoundaries, patchI)
248 const label start = procBoundaries[patchI].patchStart();
250 IPstream fromOtherProc
253 procBoundaries[patchI].neiProcNo()
256 labelList receivedData;
257 fromOtherProc >> receivedData;
260 while( counter < receivedData.size() )
262 const face& f = faces[start+receivedData[counter++]];
263 vertexLocation_[f[receivedData[counter++]]] |= LOCKED;
268 # ifdef DEBUGSmoothing
269 const label lockPointsI = mesh_.addPointSubset("lockedPoints");
270 forAll(vertexLocation_, pointI)
271 if( vertexLocation_[pointI] & LOCKED )
272 mesh_.addPointToSubset(lockPointsI, pointI);
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 } // End namespace Foam
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //