FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

directInteractionList.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "directInteractionList.H"
00027 #include <molecule/interactionLists.H>
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 void Foam::directInteractionList::buildDirectInteractionList
00032 (
00033     bool pointPointListBuild
00034 )
00035 {
00036     Info<< nl << "Building list of direct interaction neighbours" << endl;
00037 
00038     const polyMesh& mesh(il_.mesh());
00039 
00040     List<DynamicList<label> > directInteractionList(mesh.nCells());
00041 
00042     if (pointPointListBuild)
00043     {
00044         Info<< tab << "Point-Point direct interaction list build." << endl;
00045 
00046         label pointJIndex;
00047 
00048         forAll (mesh.points(), pointIIndex)
00049         {
00050             for
00051             (
00052                 pointJIndex = pointIIndex;
00053                 pointJIndex != mesh.points().size();
00054                 ++pointJIndex
00055             )
00056             {
00057                 if (il_.testPointPointDistance(pointIIndex, pointJIndex))
00058                 {
00059                     const labelList& ptICells
00060                     (
00061                         mesh.pointCells()[pointIIndex]
00062                     );
00063 
00064                     const labelList& ptJCells
00065                     (
00066                         mesh.pointCells()[pointJIndex]
00067                     );
00068 
00069                     forAll(ptICells, pIC)
00070                     {
00071                         const label cellI(ptICells[pIC]);
00072 
00073                         forAll(ptJCells, pJC)
00074                         {
00075                             const label cellJ(ptJCells[pJC]);
00076 
00077                             if (cellJ > cellI)
00078                             {
00079                                 if
00080                                 (
00081                                     findIndex
00082                                     (
00083                                         directInteractionList[cellI],
00084                                         cellJ
00085                                     )
00086                                  == -1
00087                                 )
00088                                 {
00089                                     directInteractionList[cellI].append(cellJ);
00090                                 }
00091                             }
00092 
00093                             if (cellI > cellJ)
00094                             {
00095                                 if
00096                                 (
00097                                     findIndex
00098                                     (
00099                                         directInteractionList[cellJ],
00100                                         cellI
00101                                     )
00102                                  ==
00103                                     -1
00104                                 )
00105                                 {
00106                                     directInteractionList[cellJ].append(cellI);
00107                                 }
00108                             }
00109                         }
00110                     }
00111                 }
00112             }
00113         }
00114     }
00115     else
00116     {
00117         Info<< tab << "Point-Face, Edge-Edge direct interaction list build."
00118             << endl;
00119 
00120         forAll(mesh.points(), p)
00121         {
00122             forAll(mesh.faces(), f)
00123             {
00124                 if (il_.testPointFaceDistance(p, f))
00125                 {
00126                     const labelList& pCells(mesh.pointCells()[p]);
00127 
00128                     const label cellO(mesh.faceOwner()[f]);
00129 
00130                     forAll(pCells, pC)
00131                     {
00132                         const label cellI(pCells[pC]);
00133 
00134                         // cells are not added to their own DIL
00135 
00136                         if (cellO > cellI)
00137                         {
00138                             if
00139                             (
00140                                 findIndex
00141                                 (
00142                                     directInteractionList[cellI],
00143                                     cellO
00144                                 )
00145                              ==
00146                                 -1
00147                             )
00148                             {
00149                                 directInteractionList[cellI].append(cellO);
00150                             }
00151                         }
00152 
00153                         if (cellI > cellO)
00154                         {
00155                             if
00156                             (
00157                                 findIndex
00158                                 (
00159                                     directInteractionList[cellO],
00160                                     cellI
00161                                 )
00162                              ==
00163                                 -1
00164                             )
00165                             {
00166                                 directInteractionList[cellO].append(cellI);
00167                             }
00168                         }
00169 
00170                         if (mesh.isInternalFace(f))
00171                         {
00172                             // boundary faces will not have neighbour
00173                             // information
00174 
00175                             const label cellN(mesh.faceNeighbour()[f]);
00176 
00177                             if (cellN > cellI)
00178                             {
00179                                 if
00180                                 (
00181                                     findIndex
00182                                     (
00183                                         directInteractionList[cellI],
00184                                         cellN
00185                                     )
00186                                  ==
00187                                     -1
00188                                 )
00189                                 {
00190                                     directInteractionList[cellI].append(cellN);
00191                                 }
00192                             }
00193 
00194                             if (cellI > cellN)
00195                             {
00196                                 if
00197                                 (
00198                                     findIndex
00199                                     (
00200                                         directInteractionList[cellN],
00201                                         cellI
00202                                     )
00203                                  ==
00204                                     -1
00205                                 )
00206                                 {
00207                                     directInteractionList[cellN].append(cellI);
00208                                 }
00209                             }
00210                         }
00211                     }
00212                 }
00213             }
00214         }
00215 
00216         label edgeJIndex;
00217 
00218         forAll(mesh.edges(), edgeIIndex)
00219         {
00220             const edge& eI(mesh.edges()[edgeIIndex]);
00221 
00222             for
00223             (
00224                 edgeJIndex = edgeIIndex + 1;
00225                 edgeJIndex != mesh.edges().size();
00226                 ++edgeJIndex
00227             )
00228             {
00229                 const edge& eJ(mesh.edges()[edgeJIndex]);
00230 
00231                 if (il_.testEdgeEdgeDistance(eI, eJ))
00232                 {
00233                     const labelList& eICells(mesh.edgeCells()[edgeIIndex]);
00234 
00235                     const labelList& eJCells(mesh.edgeCells()[edgeJIndex]);
00236 
00237                     forAll(eICells, eIC)
00238                     {
00239                         const label cellI(eICells[eIC]);
00240 
00241                         forAll(eJCells, eJC)
00242                         {
00243                             const label cellJ(eJCells[eJC]);
00244 
00245                             if (cellJ > cellI)
00246                             {
00247                                 if
00248                                 (
00249                                     findIndex
00250                                     (
00251                                         directInteractionList[cellI],
00252                                         cellJ
00253                                     )
00254                                  ==
00255                                     -1
00256                                 )
00257                                 {
00258                                     directInteractionList[cellI].append(cellJ);
00259                                 }
00260                             }
00261 
00262                             if (cellI > cellJ)
00263                             {
00264                                 if
00265                                 (
00266                                     findIndex
00267                                     (
00268                                         directInteractionList[cellJ],
00269                                         cellI
00270                                     )
00271                                  ==
00272                                     -1
00273                                 )
00274                                 {
00275                                     directInteractionList[cellJ].append(cellI);
00276                                 }
00277                             }
00278                         }
00279                     }
00280                 }
00281             }
00282         }
00283     }
00284 
00285     forAll(directInteractionList, transDIL)
00286     {
00287         (*this)[transDIL].transfer
00288         (
00289             directInteractionList[transDIL].shrink()
00290         );
00291     }
00292 
00293     // sorting DILs
00294 
00295     forAll((*this), dIL)
00296     {
00297         sort((*this)[dIL]);
00298     }
00299 }
00300 
00301 
00302 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00303 
00304 Foam::directInteractionList::directInteractionList
00305 (
00306     const interactionLists& il,
00307     bool pointPointListBuild
00308 )
00309 :
00310     labelListList(il.mesh().nCells()),
00311     il_(il)
00312 {
00313     if ((*this).size() > 1)
00314     {
00315         buildDirectInteractionList(pointPointListBuild);
00316     }
00317     else if ((*this).size() == 1)
00318     {
00319         Info<< nl
00320             << "Single cell mesh, no direct interaction lists required."
00321             << endl;
00322 
00323         (*this)[0].setSize(0);
00324     }
00325 }
00326 
00327 
00328 Foam::directInteractionList::directInteractionList
00329 (
00330     const interactionLists& il
00331 )
00332 :
00333     labelListList(il.mesh().nCells()),
00334     il_(il)
00335 {
00336     Info<< "Read directInteractionList from disk not implemented" << endl;
00337 }
00338 
00339 
00340 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00341 
00342 Foam::directInteractionList::~directInteractionList()
00343 {}
00344 
00345 
00346 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines