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

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