fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / lagrangian / molecularDynamics / molecule / interactionLists / directInteractionList / directInteractionList.C
blob364d038d6455a0972df422a1d05cb0a8f7183285
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "directInteractionList.H"
28 #include "interactionLists.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 void Foam::directInteractionList::buildDirectInteractionList
34     bool pointPointListBuild
37     Info<< nl << "Building list of direct interaction neighbours" << endl;
39     const polyMesh& mesh(il_.mesh());
41     List<DynamicList<label> > directInteractionList(mesh.nCells());
43     if (pointPointListBuild)
44     {
45         Info<< tab << "Point-Point direct interaction list build." << endl;
47         label pointJIndex;
49         forAll (mesh.points(), pointIIndex)
50         {
51             for
52             (
53                 pointJIndex = pointIIndex;
54                 pointJIndex != mesh.points().size();
55                 ++pointJIndex
56             )
57             {
58                 if (il_.testPointPointDistance(pointIIndex, pointJIndex))
59                 {
60                     const labelList& ptICells
61                     (
62                         mesh.pointCells()[pointIIndex]
63                     );
65                     const labelList& ptJCells
66                     (
67                         mesh.pointCells()[pointJIndex]
68                     );
70                     forAll(ptICells, pIC)
71                     {
72                         const label cellI(ptICells[pIC]);
74                         forAll(ptJCells, pJC)
75                         {
76                             const label cellJ(ptJCells[pJC]);
78                             if (cellJ > cellI)
79                             {
80                                 if
81                                 (
82                                     findIndex
83                                     (
84                                         directInteractionList[cellI],
85                                         cellJ
86                                     )
87                                  == -1
88                                 )
89                                 {
90                                     directInteractionList[cellI].append(cellJ);
91                                 }
92                             }
94                             if (cellI > cellJ)
95                             {
96                                 if
97                                 (
98                                     findIndex
99                                     (
100                                         directInteractionList[cellJ],
101                                         cellI
102                                     )
103                                  ==
104                                     -1
105                                 )
106                                 {
107                                     directInteractionList[cellJ].append(cellI);
108                                 }
109                             }
110                         }
111                     }
112                 }
113             }
114         }
115     }
116     else
117     {
118         Info<< tab << "Point-Face, Edge-Edge direct interaction list build."
119             << endl;
121         forAll(mesh.points(), p)
122         {
123             forAll(mesh.faces(), f)
124             {
125                 if (il_.testPointFaceDistance(p, f))
126                 {
127                     const labelList& pCells(mesh.pointCells()[p]);
129                     const label cellO(mesh.faceOwner()[f]);
131                     forAll(pCells, pC)
132                     {
133                         const label cellI(pCells[pC]);
135                         // cells are not added to their own DIL
137                         if (cellO > cellI)
138                         {
139                             if
140                             (
141                                 findIndex
142                                 (
143                                     directInteractionList[cellI],
144                                     cellO
145                                 )
146                              ==
147                                 -1
148                             )
149                             {
150                                 directInteractionList[cellI].append(cellO);
151                             }
152                         }
154                         if (cellI > cellO)
155                         {
156                             if
157                             (
158                                 findIndex
159                                 (
160                                     directInteractionList[cellO],
161                                     cellI
162                                 )
163                              ==
164                                 -1
165                             )
166                             {
167                                 directInteractionList[cellO].append(cellI);
168                             }
169                         }
171                         if (mesh.isInternalFace(f))
172                         {
173                             // boundary faces will not have neighbour
174                             // information
176                             const label cellN(mesh.faceNeighbour()[f]);
178                             if (cellN > cellI)
179                             {
180                                 if
181                                 (
182                                     findIndex
183                                     (
184                                         directInteractionList[cellI],
185                                         cellN
186                                     )
187                                  ==
188                                     -1
189                                 )
190                                 {
191                                     directInteractionList[cellI].append(cellN);
192                                 }
193                             }
195                             if (cellI > cellN)
196                             {
197                                 if
198                                 (
199                                     findIndex
200                                     (
201                                         directInteractionList[cellN],
202                                         cellI
203                                     )
204                                  ==
205                                     -1
206                                 )
207                                 {
208                                     directInteractionList[cellN].append(cellI);
209                                 }
210                             }
211                         }
212                     }
213                 }
214             }
215         }
217         label edgeJIndex;
219         forAll(mesh.edges(), edgeIIndex)
220         {
221             const edge& eI(mesh.edges()[edgeIIndex]);
223             for
224             (
225                 edgeJIndex = edgeIIndex + 1;
226                 edgeJIndex != mesh.edges().size();
227                 ++edgeJIndex
228             )
229             {
230                 const edge& eJ(mesh.edges()[edgeJIndex]);
232                 if (il_.testEdgeEdgeDistance(eI, eJ))
233                 {
234                     const labelList& eICells(mesh.edgeCells()[edgeIIndex]);
236                     const labelList& eJCells(mesh.edgeCells()[edgeJIndex]);
238                     forAll(eICells, eIC)
239                     {
240                         const label cellI(eICells[eIC]);
242                         forAll(eJCells, eJC)
243                         {
244                             const label cellJ(eJCells[eJC]);
246                             if (cellJ > cellI)
247                             {
248                                 if
249                                 (
250                                     findIndex
251                                     (
252                                         directInteractionList[cellI],
253                                         cellJ
254                                     )
255                                  ==
256                                     -1
257                                 )
258                                 {
259                                     directInteractionList[cellI].append(cellJ);
260                                 }
261                             }
263                             if (cellI > cellJ)
264                             {
265                                 if
266                                 (
267                                     findIndex
268                                     (
269                                         directInteractionList[cellJ],
270                                         cellI
271                                     )
272                                  ==
273                                     -1
274                                 )
275                                 {
276                                     directInteractionList[cellJ].append(cellI);
277                                 }
278                             }
279                         }
280                     }
281                 }
282             }
283         }
284     }
286     forAll(directInteractionList, transDIL)
287     {
288         (*this)[transDIL].transfer
289         (
290             directInteractionList[transDIL].shrink()
291         );
292     }
294     // sorting DILs
296     forAll((*this), dIL)
297     {
298         sort((*this)[dIL]);
299     }
303 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
305 Foam::directInteractionList::directInteractionList
307     const interactionLists& il,
308     bool pointPointListBuild
311     labelListList(il.mesh().nCells()),
312     il_(il)
314     if ((*this).size() > 1)
315     {
316         buildDirectInteractionList(pointPointListBuild);
317     }
318     else if ((*this).size() == 1)
319     {
320         Info<< nl
321             << "Single cell mesh, no direct interaction lists required."
322             << endl;
324         (*this)[0].setSize(0);
325     }
329 Foam::directInteractionList::directInteractionList
331     const interactionLists& il
334     labelListList(il.mesh().nCells()),
335     il_(il)
337     Info<< "Read directInteractionList from disk not implemented" << endl;
341 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
343 Foam::directInteractionList::~directInteractionList()
347 // ************************************************************************* //