1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "attachDetach.H"
29 #include "primitiveMesh.H"
30 #include "primitiveFacePatch.H"
31 #include "polyTopoChanger.H"
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 const Foam::Map<Foam::label>&
36 Foam::attachDetach::pointMatchMap() const
38 if (!pointMatchMapPtr_)
43 return *pointMatchMapPtr_;
47 void Foam::attachDetach::calcPointMatchMap() const
51 Pout<< "void attachDetach::calcPointMatchMap() const "
52 << " for object " << name() << " : "
53 << "Calculating point matching" << endl;
56 if (pointMatchMapPtr_)
60 "void attachDetach::calcPointMatchMap() const"
61 ) << "Point match map already calculated for object " << name()
65 const polyMesh& mesh = topoChanger().mesh();
66 const faceList& faces = mesh.faces();
68 const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchID_.index()];
69 const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchID_.index()];
71 // Create the reverse patch out of the slave patch
72 primitiveFacePatch reverseSlavePatch
74 faceList(slavePatch.size()),
78 const label slavePatchStart = slavePatch.start();
80 forAll (reverseSlavePatch, faceI)
82 reverseSlavePatch[faceI] =
83 faces[slavePatchStart + faceI].reverseFace();
86 // Create point merge list and remove merged points
87 const labelList& masterMeshPoints = masterPatch.meshPoints();
88 const labelList& slaveMeshPoints = reverseSlavePatch.meshPoints();
90 const faceList& masterLocalFaces = masterPatch.localFaces();
91 const faceList& slaveLocalFaces = reverseSlavePatch.localFaces();
93 pointMatchMapPtr_ = new Map<label>(2*slaveMeshPoints.size());
94 Map<label>& removedPointMap = *pointMatchMapPtr_;
96 forAll (masterLocalFaces, faceI)
98 const face& curMasterPoints = masterLocalFaces[faceI];
99 const face& curSlavePoints = slaveLocalFaces[faceI];
101 forAll (curMasterPoints, pointI)
103 // If the master and slave point labels are the same, the
104 // point remains. Otherwise, the slave point is removed and
105 // replaced by the master
108 masterMeshPoints[curMasterPoints[pointI]]
109 != slaveMeshPoints[curSlavePoints[pointI]]
112 // Pout << "Matching slave point " << slaveMeshPoints[curSlavePoints[pointI]] << " with " << masterMeshPoints[curMasterPoints[pointI]] << endl;
114 // Grab the addressing
115 removedPointMap.insert
117 slaveMeshPoints[curSlavePoints[pointI]],
118 masterMeshPoints[curMasterPoints[pointI]]
126 Pout<< "void attachDetach::calcPointMatchMap() const "
127 << " for object " << name() << " : "
128 << "Finished calculating point matching" << endl;
133 // ************************************************************************* //