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

attachDetachPointMatchMap.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 "attachDetach.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <OpenFOAM/primitiveMesh.H>
00029 #include <OpenFOAM/primitiveFacePatch.H>
00030 #include <dynamicMesh/polyTopoChanger.H>
00031 
00032 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00033 
00034 const Foam::Map<Foam::label>&
00035 Foam::attachDetach::pointMatchMap() const
00036 {
00037     if (!pointMatchMapPtr_)
00038     {
00039         calcPointMatchMap();
00040     }
00041 
00042     return *pointMatchMapPtr_;
00043 }
00044 
00045 
00046 void Foam::attachDetach::calcPointMatchMap() const
00047 {
00048     if (debug)
00049     {
00050         Pout<< "void attachDetach::calcPointMatchMap() const "
00051             << " for object " << name() << " : "
00052             << "Calculating point matching" << endl;
00053     }
00054 
00055     if (pointMatchMapPtr_)
00056     {
00057         FatalErrorIn
00058         (
00059             "void attachDetach::calcPointMatchMap() const"
00060         )   << "Point match map already calculated for object " << name()
00061             << abort(FatalError);
00062     }
00063 
00064     const polyMesh& mesh = topoChanger().mesh();
00065     const faceList& faces = mesh.faces();
00066 
00067     const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchID_.index()];
00068     const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchID_.index()];
00069 
00070     // Create the reverse patch out of the slave patch
00071     primitiveFacePatch reverseSlavePatch
00072     (
00073         faceList(slavePatch.size()),
00074         mesh.points()
00075     );
00076 
00077     const label slavePatchStart = slavePatch.start();
00078 
00079     forAll (reverseSlavePatch, faceI)
00080     {
00081         reverseSlavePatch[faceI] =
00082             faces[slavePatchStart + faceI].reverseFace();
00083     }
00084 
00085     // Create point merge list and remove merged points
00086     const labelList& masterMeshPoints = masterPatch.meshPoints();
00087     const labelList& slaveMeshPoints = reverseSlavePatch.meshPoints();
00088 
00089     const faceList& masterLocalFaces = masterPatch.localFaces();
00090     const faceList& slaveLocalFaces = reverseSlavePatch.localFaces();
00091 
00092     pointMatchMapPtr_ = new Map<label>(2*slaveMeshPoints.size());
00093     Map<label>& removedPointMap = *pointMatchMapPtr_;
00094 
00095     forAll (masterLocalFaces, faceI)
00096     {
00097         const face& curMasterPoints = masterLocalFaces[faceI];
00098         const face& curSlavePoints = slaveLocalFaces[faceI];
00099 
00100         forAll (curMasterPoints, pointI)
00101         {
00102             // If the master and slave point labels are the same, the
00103             // point remains.  Otherwise, the slave point is removed and
00104             // replaced by the master
00105             if
00106             (
00107                 masterMeshPoints[curMasterPoints[pointI]]
00108              != slaveMeshPoints[curSlavePoints[pointI]]
00109             )
00110             {
00111 // Pout << "Matching slave point " << slaveMeshPoints[curSlavePoints[pointI]] << " with " << masterMeshPoints[curMasterPoints[pointI]] << endl;
00112 
00113                 // Grab the addressing
00114                 removedPointMap.insert
00115                 (
00116                     slaveMeshPoints[curSlavePoints[pointI]],
00117                     masterMeshPoints[curMasterPoints[pointI]]
00118                 );
00119             }
00120         }
00121     }
00122 
00123     if (debug)
00124     {
00125         Pout<< "void attachDetach::calcPointMatchMap() const "
00126             << " for object " << name() << " : "
00127             << "Finished calculating point matching" << endl;
00128     }
00129 }
00130 
00131 
00132 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines