boundaryLayersI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Description
25 
26 
27 \*---------------------------------------------------------------------------*/
28 
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
38 (
39  const label pointI,
40  const label pKey
41 ) const
42 {
43  const std::map
44  <
45  label, std::map<std::pair<label, label>, label>
46  >::const_iterator it = otherVrts_.find(pointI);
47 
48  if( it != otherVrts_.end() )
49  {
50  const std::map<std::pair<label, label>, label>& m = it->second;
51 
52  std::map<std::pair<label, label>, label>::const_iterator mit;
53  if( m.size() == 2 )
54  {
55  for(mit=m.begin();mit!=m.end();++mit)
56  {
57  if( mit->first.first != pKey )
58  return mit->second;
59  }
60  }
61  else
62  {
63  for(mit=m.begin();mit!=m.end();++mit)
64  {
65  if( mit->first.first == pKey )
66  continue;
67  if( mit->first.second == pKey )
68  continue;
69  if( mit->first.first == mit->first.second )
70  continue;
71 
72  return mit->second;
73  }
74  }
75  }
76 
77  return newLabelForVertex_[pointI];
78 }
79 
81 (
82  const edge& e,
83  const label pKeyI,
84  const label pKeyJ,
85  FixedList<FixedList<label, 4>, 6>& cellFaces
86 ) const
87 {
88  const std::map<std::pair<label, label>, label>& ms =
89  otherVrts_.find(e.start())->second;
90  const std::map<std::pair<label, label>, label>& me =
91  otherVrts_.find(e.end())->second;
92 
93  # ifdef DEBUGLayer
94  Info << "Creating cell for edge with nodes " << e << endl;
95  Info << "pKeyI " << pKeyI << endl;
96  Info << "pKeyJ " << pKeyJ << endl;
97  std::map<std::pair<label, label>, label>::const_iterator iter;
98  for(iter=ms.begin();iter!=ms.end();++iter)
99  Info << "1. Pair (" << iter->first.first << ", "
100  << iter->first.second << ") has value " << iter->second << endl;
101  for(iter=me.begin();iter!=me.end();++iter)
102  Info << "2. Pair (" << iter->first.first << ", "
103  << iter->first.second << ") has value " << iter->second << endl;
104  # endif
105 
106  label p0s(-1), p1s(-1), ns(-1), p0e(-1), p1e(-1), ne(-1);
107 
108  if( ms.size() == 2 )
109  {
110  p0s = ms.find(std::pair<label, label>(pKeyI, pKeyI))->second;
111  p1s = ms.find(std::pair<label, label>(pKeyJ, pKeyJ))->second;
112  ns = newLabelForVertex_[e.start()];
113  }
114  else
115  {
116  std::map<std::pair<label, label>, label>::const_iterator it;
117  for(it=ms.begin();it!=ms.end();++it)
118  {
119  if(
120  (it->first.first != pKeyJ) && (it->first.second != pKeyJ)
121  && (it->first.first != it->first.second)
122  )
123  {
124  p0s = it->second;
125  }
126  else if(
127  (it->first.first != pKeyI) && (it->first.second != pKeyI)
128  && (it->first.first != it->first.second)
129  )
130  {
131  p1s = it->second;
132  }
133  else if(
134  (it->first.first == it->first.second) &&
135  (it->first.first != pKeyI) && (it->first.first != pKeyJ)
136  )
137  {
138  ns = it->second;
139  }
140  }
141  }
142  if( me.size() == 2 )
143  {
144  p0e = me.find(std::pair<label, label>(pKeyI, pKeyI))->second;
145  p1e = me.find(std::pair<label, label>(pKeyJ, pKeyJ))->second;
146  ne = newLabelForVertex_[e.end()];
147  }
148  else
149  {
150  std::map<std::pair<label, label>, label>::const_iterator it;
151  for(it=me.begin();it!=me.end();++it)
152  {
153  if(
154  (it->first.first != pKeyJ) && (it->first.second != pKeyJ)
155  && (it->first.first != it->first.second)
156  )
157  {
158  p0e = it->second;
159  }
160  else if(
161  (it->first.first != pKeyI) && (it->first.second != pKeyI)
162  && (it->first.first != it->first.second)
163  )
164  {
165  p1e = it->second;
166  }
167  else if(
168  (it->first.first == it->first.second) &&
169  (it->first.first != pKeyI) && (it->first.first != pKeyJ)
170  )
171  {
172  ne = it->second;
173  }
174  }
175  }
176 
177  //- F0
178  cellFaces[0][0] = e.end();
179  cellFaces[0][1] = e.start();
180  cellFaces[0][2] = p1s;
181  cellFaces[0][3] = p1e;
182 
183  //- F1
184  cellFaces[1][0] = p0e;
185  cellFaces[1][1] = ne;
186  cellFaces[1][2] = ns;
187  cellFaces[1][3] = p0s;
188 
189  //- F2
190  cellFaces[2][0] = e.start();
191  cellFaces[2][1] = e.end();
192  cellFaces[2][2] = p0e;
193  cellFaces[2][3] = p0s;
194 
195  //- F3
196  cellFaces[3][0] = p1s;
197  cellFaces[3][1] = ns;
198  cellFaces[3][2] = ne;
199  cellFaces[3][3] = p1e;
200 
201  //- F4
202  cellFaces[4][0] = e.end();
203  cellFaces[4][1] = p1e;
204  cellFaces[4][2] = ne;
205  cellFaces[4][3] = p0e;
206 
207  //- F5
208  cellFaces[5][0] = e.start();
209  cellFaces[5][1] = p0s;
210  cellFaces[5][2] = ns;
211  cellFaces[5][3] = p1s;
212 
213  # ifdef DEBUGLayer
214  forAll(cellFaces, fI)
215  {
216  forAll(cellFaces[fI], pI)
217  {
218  if
219  (
220  cellFaces[fI][pI] < 0 ||
221  cellFaces[fI][pI] >= mesh_.points().size()
222  )
223  FatalError << "Invalid point indices found!"
224  << abort(FatalError);
225  }
226  }
227  # endif
228 }
229 
231 (
232  const label pointI,
233  const DynList<label, 3>& pKeys,
234  FixedList<FixedList<label, 4>, 6>& cellFaces
235 ) const
236 {
237  const std::map<std::pair<label, label>, label>& m =
238  otherVrts_.find(pointI)->second;
239 
240  //- create labels before creating cells
241  const label n = newLabelForVertex_[pointI];
242  const label p00 =
243  m.find(std::pair<label, label>(pKeys[0], pKeys[0]))->second;
244  const label p11 =
245  m.find(std::pair<label, label>(pKeys[1], pKeys[1]))->second;
246  const label p22 =
247  m.find(std::pair<label, label>(pKeys[2], pKeys[2]))->second;
248 
249  std::pair<label, label> pr;
250  pr.first = pKeys[0];
251  pr.second = pKeys[1];
252  if( m.find(pr) == m.end() )
253  {
254  pr.first = pKeys[1];
255  pr.second = pKeys[0];
256  }
257  const label p01 = m.find(pr)->second;
258 
259  pr.first = pKeys[0];
260  pr.second = pKeys[2];
261  if( m.find(pr) == m.end() )
262  {
263  pr.first = pKeys[2];
264  pr.second = pKeys[0];
265  }
266  const label p02 = m.find(pr)->second;
267 
268  pr.first = pKeys[1];
269  pr.second = pKeys[2];
270  if( m.find(pr) == m.end() )
271  {
272  pr.first = pKeys[2];
273  pr.second = pKeys[1];
274  }
275  const label p12 = m.find(pr)->second;
276 
277  //- create the cell and append it
278  //- F0
279  cellFaces[0][0] = pointI;
280  cellFaces[0][1] = p02;
281  cellFaces[0][2] = p00;
282  cellFaces[0][3] = p01;
283  //- F1
284  cellFaces[1][0] = p12;
285  cellFaces[1][1] = p11;
286  cellFaces[1][2] = n;
287  cellFaces[1][3] = p22;
288 
289  //- F2
290  cellFaces[2][0] = pointI;
291  cellFaces[2][1] = p01;
292  cellFaces[2][2] = p11;
293  cellFaces[2][3] = p12;
294  //- F3
295  cellFaces[3][0] = p02;
296  cellFaces[3][1] = p22;
297  cellFaces[3][2] = n;
298  cellFaces[3][3] = p00;
299  //- F4
300  cellFaces[4][0] = pointI;
301  cellFaces[4][1] = p12;
302  cellFaces[4][2] = p22;
303  cellFaces[4][3] = p02;
304  //- F5
305  cellFaces[5][0] = p01;
306  cellFaces[5][1] = p00;
307  cellFaces[5][2] = n;
308  cellFaces[5][3] = p11;
309 }
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 } // End namespace Foam
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::boundaryLayers::createNewCellFromNode
void createNewCellFromNode(const label pointI, const DynList< label, 3 > &pKeys, FixedList< FixedList< label, 4 >, 6 > &cellFaces) const
creating hex cells near corners
Definition: boundaryLayersI.H:231
Foam::constant::atomic::me
const dimensionedScalar me
Electron mass.
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Info
messageStream Info
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::DynList
Definition: DynList.H:53
Foam::boundaryLayers::createNewCellFromEdge
void createNewCellFromEdge(const edge &e, const label pKeyI, const label pKeyJ, FixedList< FixedList< label, 4 >, 6 > &cellFaces) const
creating hex cells near feature edges
Definition: boundaryLayersI.H:81
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::boundaryLayers::findNewNodeLabel
label findNewNodeLabel(const label pointI, const label pKey) const
helper function finding a new face label for multiply extruded nodes
Definition: boundaryLayersI.H:38