1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "attachDetach.H"
28 #include "primitiveMesh.H"
29 #include "primitiveFacePatch.H"
30 #include "polyTopoChanger.H"
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 const Foam::Map<Foam::label>&
35 Foam::attachDetach::pointMatchMap() const
37 if (!pointMatchMapPtr_)
42 return *pointMatchMapPtr_;
46 void Foam::attachDetach::calcPointMatchMap() const
50 Pout<< "void attachDetach::calcPointMatchMap() const "
51 << " for object " << name() << " : "
52 << "Calculating point matching" << endl;
55 if (pointMatchMapPtr_)
59 "void attachDetach::calcPointMatchMap() const"
60 ) << "Point match map already calculated for object " << name()
64 const polyMesh& mesh = topoChanger().mesh();
65 const faceList& faces = mesh.faces();
67 const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchID_.index()];
68 const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchID_.index()];
70 // Create the reverse patch out of the slave patch
71 primitiveFacePatch reverseSlavePatch
73 faceList(slavePatch.size()),
77 const label slavePatchStart = slavePatch.start();
79 forAll(reverseSlavePatch, faceI)
81 reverseSlavePatch[faceI] =
82 faces[slavePatchStart + faceI].reverseFace();
85 // Create point merge list and remove merged points
86 const labelList& masterMeshPoints = masterPatch.meshPoints();
87 const labelList& slaveMeshPoints = reverseSlavePatch.meshPoints();
89 const faceList& masterLocalFaces = masterPatch.localFaces();
90 const faceList& slaveLocalFaces = reverseSlavePatch.localFaces();
92 pointMatchMapPtr_ = new Map<label>(2*slaveMeshPoints.size());
93 Map<label>& removedPointMap = *pointMatchMapPtr_;
95 forAll(masterLocalFaces, faceI)
97 const face& curMasterPoints = masterLocalFaces[faceI];
98 const face& curSlavePoints = slaveLocalFaces[faceI];
100 forAll(curMasterPoints, pointI)
102 // If the master and slave point labels are the same, the
103 // point remains. Otherwise, the slave point is removed and
104 // replaced by the master
107 masterMeshPoints[curMasterPoints[pointI]]
108 != slaveMeshPoints[curSlavePoints[pointI]]
111 // Pout<< "Matching slave point "
112 // << slaveMeshPoints[curSlavePoints[pointI]]
114 // << masterMeshPoints[curMasterPoints[pointI]]
117 // Grab the addressing
118 removedPointMap.insert
120 slaveMeshPoints[curSlavePoints[pointI]],
121 masterMeshPoints[curMasterPoints[pointI]]
129 Pout<< "void attachDetach::calcPointMatchMap() const "
130 << " for object " << name() << " : "
131 << "Finished calculating point matching" << endl;
136 // ************************************************************************* //