OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

enrichedPatchMasterPoints.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) 1991-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "enrichedPatch.H"
00030 #include "primitiveMesh.H"
00031 #include "demandDrivenData.H"
00032 #include "DynamicList.H"
00033 
00034 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00035 
00036 const Foam::label Foam::enrichedPatch::nFaceHits_ = 4;
00037 
00038 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00039 
00040 void Foam::enrichedPatch::calcMasterPointFaces() const
00041 {
00042     if (masterPointFacesPtr_)
00043     {
00044         FatalErrorIn("void enrichedPatch::calcMasterPointFaces() const")
00045             << "Master point face addressing already calculated."
00046             << abort(FatalError);
00047     }
00048 
00049     // Note:
00050     // Master point face addressing lists the master faces for all points
00051     // in the enriched patch support (if there are no master faces, which is
00052     // normal, the list will be empty).  The index represents the index of
00053     // the master face rather than the index from the enriched patch
00054     // Master face points lists the points of the enriched master face plus
00055     // points projected into the master face
00056 
00057     Map<DynamicList<label> > mpf(meshPoints().size());
00058 
00059     const faceList& ef = enrichedFaces();
00060 
00061     // Add the original face points
00062     forAll (masterPatch_, faceI)
00063     {
00064         const face& curFace = ef[faceI + slavePatch_.size()];
00065 //         Pout << "Cur face in pfAddr: " << curFace << endl;
00066         forAll (curFace, pointI)
00067         {
00068             Map<DynamicList<label> >::iterator mpfIter =
00069                 mpf.find(curFace[pointI]);
00070 
00071             if (mpfIter == mpf.end())
00072             {
00073                 // Not found, add new dynamic list
00074                 mpf.insert
00075                 (
00076                     curFace[pointI],
00077                     DynamicList<label>(primitiveMesh::facesPerPoint_)
00078                 );
00079 
00080                 // Iterator is invalidated - have to find again
00081                 mpf.find(curFace[pointI])().append(faceI);
00082             }
00083             else
00084             {
00085                 mpfIter().append(faceI);
00086             }
00087         }
00088     }
00089 
00090     // Add the projected points which hit the face
00091     const labelList& slaveMeshPoints = slavePatch_.meshPoints();
00092 
00093     forAll (slavePointFaceHits_, pointI)
00094     {
00095         if
00096         (
00097             slavePointPointHits_[pointI] < 0
00098          && slavePointEdgeHits_[pointI] < 0
00099          && slavePointFaceHits_[pointI].hit()
00100         )
00101         {
00102             // Get the index of projected point corresponding to this slave
00103             // point
00104             const label mergedSmp =
00105                 pointMergeMap().find(slaveMeshPoints[pointI])();
00106 
00107             Map<DynamicList<label> >::iterator mpfIter =
00108                 mpf.find(mergedSmp);
00109 
00110             if (mpfIter == mpf.end())
00111             {
00112                 // Not found, add new dynamic list
00113                 mpf.insert
00114                 (
00115                     mergedSmp,
00116                     DynamicList<label>(primitiveMesh::facesPerPoint_)
00117                 );
00118 
00119                 // Iterator is invalidated - have to find again
00120                 mpf.find(mergedSmp)().append
00121                 (
00122                     slavePointFaceHits_[pointI].hitObject()
00123                 );
00124             }
00125             else
00126             {
00127                 mpfIter().append(slavePointFaceHits_[pointI].hitObject());
00128             }
00129         }
00130     }
00131 
00132     // Re-pack dynamic lists into normal lists
00133     const labelList mpfToc = mpf.toc();
00134 
00135     masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size());
00136     Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_;
00137 
00138     forAll (mpfToc, mpfTocI)
00139     {
00140         labelList l;
00141         l.transfer(mpf.find(mpfToc[mpfTocI])());
00142 
00143         masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
00144     }
00145     // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl;
00146 }
00147 
00148 
00149 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00150 
00151 const Foam::Map<Foam::labelList>& Foam::enrichedPatch::masterPointFaces() const
00152 {
00153     if (!masterPointFacesPtr_)
00154     {
00155         calcMasterPointFaces();
00156     }
00157 
00158     return *masterPointFacesPtr_;
00159 }
00160 
00161 
00162 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd