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 \*---------------------------------------------------------------------------*/
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 label boundaryLayers::findNewNodeLabel
43 if( otherVrts_.find(pointI) != otherVrts_.end() )
47 label, std::map<std::pair<label, label>, label>
48 >::const_iterator it = otherVrts_.find(pointI);
49 const std::map<std::pair<label, label>, label>& m = it->second;
51 std::map<std::pair<label, label>, label>::const_iterator mit;
54 for(mit=m.begin();mit!=m.end();++mit)
56 if( mit->first.first != pKey )
62 for(mit=m.begin();mit!=m.end();++mit)
64 if( mit->first.first == pKey )
66 if( mit->first.second == pKey )
68 if( mit->first.first == mit->first.second )
76 return newLabelForVertex_[pointI];
79 inline void boundaryLayers::createNewCellFromEdge
84 FixedList<FixedList<label, 4>, 6>& cellFaces
87 const std::map<std::pair<label, label>, label>& ms =
88 otherVrts_.find(e.start())->second;
89 const std::map<std::pair<label, label>, label>& me =
90 otherVrts_.find(e.end())->second;
93 Info << "Creating cell for edge " << edgeI << " with nodes " << e << endl;
94 Info << "pKeyI " << pKeyI << endl;
95 Info << "pKeyJ " << pKeyJ << endl;
96 std::map<std::pair<label, label>, label>::const_iterator iter;
97 for(iter=ms.begin();iter!=ms.end();++iter)
98 Info << "1. Pair (" << iter->first.first << ", "
99 << iter->first.second << ") has value " << iter->second << endl;
100 for(iter=me.begin();iter!=me.end();++iter)
101 Info << "2. Pair (" << iter->first.first << ", "
102 << iter->first.second << ") has value " << iter->second << endl;
105 label p0s(-1), p1s(-1), ns(-1), p0e(-1), p1e(-1), ne(-1);
109 p0s = ms.find(std::pair<label, label>(pKeyI, pKeyI))->second;
110 p1s = ms.find(std::pair<label, label>(pKeyJ, pKeyJ))->second;
111 ns = newLabelForVertex_[e.start()];
115 std::map<std::pair<label, label>, label>::const_iterator it;
116 for(it=ms.begin();it!=ms.end();++it)
119 (it->first.first != pKeyJ) && (it->first.second != pKeyJ)
120 && (it->first.first != it->first.second)
126 (it->first.first != pKeyI) && (it->first.second != pKeyI)
127 && (it->first.first != it->first.second)
133 (it->first.first == it->first.second) &&
134 (it->first.first != pKeyI) && (it->first.first != pKeyJ)
143 p0e = me.find(std::pair<label, label>(pKeyI, pKeyI))->second;
144 p1e = me.find(std::pair<label, label>(pKeyJ, pKeyJ))->second;
145 ne = newLabelForVertex_[e.end()];
149 std::map<std::pair<label, label>, label>::const_iterator it;
150 for(it=me.begin();it!=me.end();++it)
153 (it->first.first != pKeyJ) && (it->first.second != pKeyJ)
154 && (it->first.first != it->first.second)
160 (it->first.first != pKeyI) && (it->first.second != pKeyI)
161 && (it->first.first != it->first.second)
167 (it->first.first == it->first.second) &&
168 (it->first.first != pKeyI) && (it->first.first != pKeyJ)
177 cellFaces[0][0] = e.end();
178 cellFaces[0][1] = e.start();
179 cellFaces[0][2] = p1s;
180 cellFaces[0][3] = p1e;
183 cellFaces[1][0] = p0e;
184 cellFaces[1][1] = ne;
185 cellFaces[1][2] = ns;
186 cellFaces[1][3] = p0s;
189 cellFaces[2][0] = e.start();
190 cellFaces[2][1] = e.end();
191 cellFaces[2][2] = p0e;
192 cellFaces[2][3] = p0s;
195 cellFaces[3][0] = p1s;
196 cellFaces[3][1] = ns;
197 cellFaces[3][2] = ne;
198 cellFaces[3][3] = p1e;
201 cellFaces[4][0] = e.end();
202 cellFaces[4][1] = p1e;
203 cellFaces[4][2] = ne;
204 cellFaces[4][3] = p0e;
207 cellFaces[5][0] = e.start();
208 cellFaces[5][1] = p0s;
209 cellFaces[5][2] = ns;
210 cellFaces[5][3] = p1s;
213 inline void boundaryLayers::createNewCellFromNode
216 const DynList<label, 3>& pKeys,
217 FixedList<FixedList<label, 4>, 6>& cellFaces
220 const std::map<std::pair<label, label>, label>& m =
221 otherVrts_.find(pointI)->second;
223 //- create labels before creating cells
224 const label n = newLabelForVertex_[pointI];
226 m.find(std::pair<label, label>(pKeys[0], pKeys[0]))->second;
228 m.find(std::pair<label, label>(pKeys[1], pKeys[1]))->second;
230 m.find(std::pair<label, label>(pKeys[2], pKeys[2]))->second;
232 std::pair<label, label> pr;
234 pr.second = pKeys[1];
235 if( m.find(pr) == m.end() )
238 pr.second = pKeys[0];
240 const label p01 = m.find(pr)->second;
243 pr.second = pKeys[2];
244 if( m.find(pr) == m.end() )
247 pr.second = pKeys[0];
249 const label p02 = m.find(pr)->second;
252 pr.second = pKeys[2];
253 if( m.find(pr) == m.end() )
256 pr.second = pKeys[1];
258 const label p12 = m.find(pr)->second;
260 //- create the cell and append it
263 cellFaces[0][0] = pointI;
264 cellFaces[0][1] = p02;
265 cellFaces[0][2] = p00;
266 cellFaces[0][3] = p01;
268 cellFaces[1][0] = p12;
269 cellFaces[1][1] = p11;
271 cellFaces[1][3] = p22;
274 cellFaces[2][0] = pointI;
275 cellFaces[2][1] = p01;
276 cellFaces[2][2] = p11;
277 cellFaces[2][3] = p12;
279 cellFaces[3][0] = p02;
280 cellFaces[3][1] = p22;
282 cellFaces[3][3] = p00;
284 cellFaces[4][0] = pointI;
285 cellFaces[4][1] = p12;
286 cellFaces[4][2] = p22;
287 cellFaces[4][3] = p02;
289 cellFaces[5][0] = p01;
290 cellFaces[5][1] = p00;
292 cellFaces[5][3] = p11;
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 } // End namespace Foam
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //