FreeFOAM The Cross-Platform CFD Toolkit
directInteractionList.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) 2008-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 "directInteractionList.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 void Foam::directInteractionList::buildDirectInteractionList
32 (
33  bool pointPointListBuild
34 )
35 {
36  Info<< nl << "Building list of direct interaction neighbours" << endl;
37 
38  const polyMesh& mesh(il_.mesh());
39 
40  List<DynamicList<label> > directInteractionList(mesh.nCells());
41 
42  if (pointPointListBuild)
43  {
44  Info<< tab << "Point-Point direct interaction list build." << endl;
45 
46  label pointJIndex;
47 
48  forAll (mesh.points(), pointIIndex)
49  {
50  for
51  (
52  pointJIndex = pointIIndex;
53  pointJIndex != mesh.points().size();
54  ++pointJIndex
55  )
56  {
57  if (il_.testPointPointDistance(pointIIndex, pointJIndex))
58  {
59  const labelList& ptICells
60  (
61  mesh.pointCells()[pointIIndex]
62  );
63 
64  const labelList& ptJCells
65  (
66  mesh.pointCells()[pointJIndex]
67  );
68 
69  forAll(ptICells, pIC)
70  {
71  const label cellI(ptICells[pIC]);
72 
73  forAll(ptJCells, pJC)
74  {
75  const label cellJ(ptJCells[pJC]);
76 
77  if (cellJ > cellI)
78  {
79  if
80  (
81  findIndex
82  (
83  directInteractionList[cellI],
84  cellJ
85  )
86  == -1
87  )
88  {
89  directInteractionList[cellI].append(cellJ);
90  }
91  }
92 
93  if (cellI > cellJ)
94  {
95  if
96  (
97  findIndex
98  (
99  directInteractionList[cellJ],
100  cellI
101  )
102  ==
103  -1
104  )
105  {
106  directInteractionList[cellJ].append(cellI);
107  }
108  }
109  }
110  }
111  }
112  }
113  }
114  }
115  else
116  {
117  Info<< tab << "Point-Face, Edge-Edge direct interaction list build."
118  << endl;
119 
120  forAll(mesh.points(), p)
121  {
122  forAll(mesh.faces(), f)
123  {
124  if (il_.testPointFaceDistance(p, f))
125  {
126  const labelList& pCells(mesh.pointCells()[p]);
127 
128  const label cellO(mesh.faceOwner()[f]);
129 
130  forAll(pCells, pC)
131  {
132  const label cellI(pCells[pC]);
133 
134  // cells are not added to their own DIL
135 
136  if (cellO > cellI)
137  {
138  if
139  (
140  findIndex
141  (
142  directInteractionList[cellI],
143  cellO
144  )
145  ==
146  -1
147  )
148  {
149  directInteractionList[cellI].append(cellO);
150  }
151  }
152 
153  if (cellI > cellO)
154  {
155  if
156  (
157  findIndex
158  (
159  directInteractionList[cellO],
160  cellI
161  )
162  ==
163  -1
164  )
165  {
166  directInteractionList[cellO].append(cellI);
167  }
168  }
169 
170  if (mesh.isInternalFace(f))
171  {
172  // boundary faces will not have neighbour
173  // information
174 
175  const label cellN(mesh.faceNeighbour()[f]);
176 
177  if (cellN > cellI)
178  {
179  if
180  (
181  findIndex
182  (
183  directInteractionList[cellI],
184  cellN
185  )
186  ==
187  -1
188  )
189  {
190  directInteractionList[cellI].append(cellN);
191  }
192  }
193 
194  if (cellI > cellN)
195  {
196  if
197  (
198  findIndex
199  (
200  directInteractionList[cellN],
201  cellI
202  )
203  ==
204  -1
205  )
206  {
207  directInteractionList[cellN].append(cellI);
208  }
209  }
210  }
211  }
212  }
213  }
214  }
215 
216  label edgeJIndex;
217 
218  forAll(mesh.edges(), edgeIIndex)
219  {
220  const edge& eI(mesh.edges()[edgeIIndex]);
221 
222  for
223  (
224  edgeJIndex = edgeIIndex + 1;
225  edgeJIndex != mesh.edges().size();
226  ++edgeJIndex
227  )
228  {
229  const edge& eJ(mesh.edges()[edgeJIndex]);
230 
231  if (il_.testEdgeEdgeDistance(eI, eJ))
232  {
233  const labelList& eICells(mesh.edgeCells()[edgeIIndex]);
234 
235  const labelList& eJCells(mesh.edgeCells()[edgeJIndex]);
236 
237  forAll(eICells, eIC)
238  {
239  const label cellI(eICells[eIC]);
240 
241  forAll(eJCells, eJC)
242  {
243  const label cellJ(eJCells[eJC]);
244 
245  if (cellJ > cellI)
246  {
247  if
248  (
249  findIndex
250  (
251  directInteractionList[cellI],
252  cellJ
253  )
254  ==
255  -1
256  )
257  {
258  directInteractionList[cellI].append(cellJ);
259  }
260  }
261 
262  if (cellI > cellJ)
263  {
264  if
265  (
266  findIndex
267  (
268  directInteractionList[cellJ],
269  cellI
270  )
271  ==
272  -1
273  )
274  {
275  directInteractionList[cellJ].append(cellI);
276  }
277  }
278  }
279  }
280  }
281  }
282  }
283  }
284 
285  forAll(directInteractionList, transDIL)
286  {
287  (*this)[transDIL].transfer
288  (
289  directInteractionList[transDIL].shrink()
290  );
291  }
292 
293  // sorting DILs
294 
295  forAll((*this), dIL)
296  {
297  sort((*this)[dIL]);
298  }
299 }
300 
301 
302 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
303 
304 Foam::directInteractionList::directInteractionList
305 (
306  const interactionLists& il,
307  bool pointPointListBuild
308 )
309 :
310  labelListList(il.mesh().nCells()),
311  il_(il)
312 {
313  if ((*this).size() > 1)
314  {
315  buildDirectInteractionList(pointPointListBuild);
316  }
317  else if ((*this).size() == 1)
318  {
319  Info<< nl
320  << "Single cell mesh, no direct interaction lists required."
321  << endl;
322 
323  (*this)[0].setSize(0);
324  }
325 }
326 
327 
328 Foam::directInteractionList::directInteractionList
329 (
330  const interactionLists& il
331 )
332 :
333  labelListList(il.mesh().nCells()),
334  il_(il)
335 {
336  Info<< "Read directInteractionList from disk not implemented" << endl;
337 }
338 
339 
340 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
341 
343 {}
344 
345 
346 // ************************ vim: set sw=4 sts=4 et: ************************ //