Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
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
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
00103
00104
00105 if
00106 (
00107 masterMeshPoints[curMasterPoints[pointI]]
00108 != slaveMeshPoints[curSlavePoints[pointI]]
00109 )
00110 {
00111
00112
00113
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