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

cyclicPointPatch.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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "cyclicPointPatch.H"
00028 #include "pointBoundaryMesh.H"
00029 #include "addToRunTimeSelectionTable.H"
00030 #include "pointMesh.H"
00031 #include "globalPointPatch.H"
00032 #include "edgeList.H"
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 defineTypeNameAndDebug(cyclicPointPatch, 0);
00042 
00043 addToRunTimeSelectionTable
00044 (
00045     facePointPatch,
00046     cyclicPointPatch,
00047     polyPatch
00048 );
00049 
00050 
00051 // * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
00052 
00053 void Foam::cyclicPointPatch::initGeometry()
00054 {
00055     transformPairs_.setSize(0);
00056 }
00057 
00058 
00059 void Foam::cyclicPointPatch::calcGeometry()
00060 {
00061     const edgeList& cp = cyclicPolyPatch_.coupledPoints();
00062     const labelList& mp = cyclicPolyPatch_.meshPoints();
00063 
00064     // If there are no global points create a 1->1 map
00065     if (!boundaryMesh().mesh().globalData().nGlobalPoints())
00066     {
00067         nonGlobalPatchPoints_.setSize(mp.size());
00068         forAll(nonGlobalPatchPoints_, i)
00069         {
00070             nonGlobalPatchPoints_[i] = i;
00071         }
00072 
00073         meshPoints_ = cyclicPolyPatch_.meshPoints();
00074         transformPairs_ = cp;
00075     }
00076     else
00077     {
00078         // Get reference to shared points
00079         const labelList& sharedPoints = 
00080             boundaryMesh().globalPatch().meshPoints();
00081 
00082         nonGlobalPatchPoints_.setSize(mp.size());
00083         meshPoints_.setSize(mp.size());
00084 
00085         labelList pointMap(mp.size(), -1);
00086 
00087         label noFiltPoints = 0;
00088 
00089         forAll (mp, pointI)
00090         {
00091             label curP = mp[pointI];
00092 
00093             bool found = false;
00094 
00095             forAll (sharedPoints, sharedI)
00096             {
00097                 if (sharedPoints[sharedI] == curP)
00098                 {
00099                     found = true;
00100                     break;
00101                 }
00102             }
00103 
00104             if (!found)
00105             {
00106                 pointMap[pointI] = noFiltPoints;
00107                 nonGlobalPatchPoints_[noFiltPoints] = pointI;
00108                 meshPoints_[noFiltPoints] = curP;
00109                 noFiltPoints++;
00110             }
00111         }
00112 
00113         nonGlobalPatchPoints_.setSize(noFiltPoints);
00114         meshPoints_.setSize(noFiltPoints);
00115 
00116 
00117         transformPairs_.setSize(cp.size());
00118 
00119         label noFiltPointPairs = 0;
00120 
00121         forAll(cp, i)
00122         {
00123             if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] != -1)
00124             {
00125                 transformPairs_[noFiltPointPairs][0] = pointMap[cp[i][0]];
00126                 transformPairs_[noFiltPointPairs][1] = pointMap[cp[i][1]];
00127                 noFiltPointPairs++;
00128             }
00129             else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1)
00130             {
00131                 FatalErrorIn("cyclicPointPatch::calcGeometry() const")
00132                     << "Point " << cp[i][0] << "of point-pair " << i
00133                     << " is a global point but the other point "
00134                     << cp[i][1] << " is not"
00135                     << exit(FatalError);
00136             }
00137             else if (pointMap[cp[i][0]] != -1 && pointMap[cp[i][1]] == -1)
00138             {
00139                 FatalErrorIn("cyclicPointPatch::calcGeometry() const")
00140                     << "Point " << cp[i][1] << "of point-pair " << i
00141                     << " is a global point but the other point "
00142                     << cp[i][0] << " is not"
00143                     << exit(FatalError);
00144             }
00145         }
00146 
00147         transformPairs_.setSize(noFiltPointPairs);
00148     }
00149 }
00150 
00151 
00152 void cyclicPointPatch::initMovePoints(const pointField&)
00153 {}
00154 
00155 
00156 void cyclicPointPatch::movePoints(const pointField&)
00157 {}
00158 
00159 
00160 void cyclicPointPatch::initUpdateMesh()
00161 {
00162     facePointPatch::initUpdateMesh();
00163     cyclicPointPatch::initGeometry();
00164 }
00165 
00166 
00167 void cyclicPointPatch::updateMesh()
00168 {
00169     facePointPatch::updateMesh();
00170     cyclicPointPatch::calcGeometry();
00171 }
00172 
00173 
00174 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00175 
00176 cyclicPointPatch::cyclicPointPatch
00177 (
00178     const polyPatch& patch,
00179     const pointBoundaryMesh& bm
00180 )
00181 :
00182     coupledFacePointPatch(patch, bm),
00183     cyclicPolyPatch_(refCast<const cyclicPolyPatch>(patch))
00184 {}
00185 
00186 
00187 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00188 
00189 cyclicPointPatch::~cyclicPointPatch()
00190 {}
00191 
00192 
00193 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00194 
00195 const edgeList& cyclicPointPatch::transformPairs() const
00196 {
00197     return transformPairs_;
00198 }
00199 
00200 
00201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00202 
00203 } // End namespace Foam
00204 
00205 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd