1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011-2011 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 "PatchTools.H"
28 #include "indirectPrimitivePatch.H"
29 #include "globalMeshData.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 const vectorTensorTransform& vt,
45 List<List<point> >& fld
57 List<point>& elems = fld[i];
60 elems[elemI] = transform(T, elems[elemI]);
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 template<class> class FaceList,
78 Foam::tmp<Foam::pointField>
79 Foam::PatchTools::pointNormals
82 const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
83 const labelList& meshFaces
86 // Assume patch is smaller than the globalData().coupledPatch() (?) so
87 // loop over patch meshPoints.
89 const globalMeshData& globalData = mesh.globalData();
90 const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
91 const Map<label>& coupledPatchMP = coupledPatch.meshPointMap();
92 const mapDistribute& map = globalData.globalPointSlavesMap();
93 const globalIndexAndTransform& transforms =
94 globalData.globalTransforms();
97 // 1. Start off with local normals (note:without calculating pointNormals
98 // to avoid them being stored)
100 tmp<pointField> textrudeN(new pointField(p.nPoints(), vector::zero));
101 pointField& extrudeN = textrudeN();
103 const faceList& localFaces = p.localFaces();
104 const vectorField& faceNormals = p.faceNormals();
106 forAll(localFaces, faceI)
108 const face& f = localFaces[faceI];
109 const vector& n = faceNormals[faceI];
112 extrudeN[f[fp]] += n;
115 extrudeN /= mag(extrudeN)+VSMALL;
119 // Collect local pointFaces
120 List<List<point> > pointFaceNormals(map.constructSize());
121 forAll(p.meshPoints(), patchPointI)
123 label meshPointI = p.meshPoints()[patchPointI];
124 Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
125 if (fnd != coupledPatchMP.end())
127 label coupledPointI = fnd();
129 List<point>& pNormals = pointFaceNormals[coupledPointI];
130 const labelList& pFaces = p.pointFaces()[patchPointI];
131 pNormals.setSize(pFaces.size());
134 pNormals[i] = p.faceNormals()[pFaces[i]];
140 // Pull remote data into local slots
150 const labelListList& slaves = globalData.globalPointSlaves();
151 const labelListList& transformedSlaves =
152 globalData.globalPointTransformedSlaves();
155 pointField coupledPointNormals(map.constructSize(), vector::zero);
157 forAll(p.meshPoints(), patchPointI)
159 label meshPointI = p.meshPoints()[patchPointI];
160 Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
161 if (fnd != coupledPatchMP.end())
163 label coupledPointI = fnd();
164 const labelList& slaveSlots =
165 slaves[coupledPointI];
166 const labelList& transformedSlaveSlots =
167 transformedSlaves[coupledPointI];
169 label nFaces = slaveSlots.size()+transformedSlaveSlots.size();
173 point& n = coupledPointNormals[coupledPointI];
175 n += sum(pointFaceNormals[coupledPointI]);
177 forAll(slaveSlots, i)
179 n += sum(pointFaceNormals[slaveSlots[i]]);
181 forAll(transformedSlaveSlots, i)
183 n += sum(pointFaceNormals[transformedSlaveSlots[i]]);
187 // Put back into slave slots
188 forAll(slaveSlots, i)
190 coupledPointNormals[slaveSlots[i]] = n;
192 forAll(transformedSlaveSlots, i)
194 coupledPointNormals[transformedSlaveSlots[i]] = n;
202 map.reverseDistribute
205 coupledPointNormals.size(),
207 mapDistribute::transform()
211 // Override patch normals
212 forAll(p.meshPoints(), patchPointI)
214 label meshPointI = p.meshPoints()[patchPointI];
215 Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
216 if (fnd != coupledPatchMP.end())
218 label coupledPointI = fnd();
219 extrudeN[patchPointI] = coupledPointNormals[coupledPointI];
227 // ************************************************************************* //