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
26 Foam::addPatchCellLayer
29 Adds layers of cells to outside of polyPatch.
31 Call setRefinement with offset vector for every patch point and number
32 of layers per patch face and number of layers per patch point.
33 - offset vector should be zero for any non-manifold point and synchronised
34 on coupled points before calling this.
35 - offset vector of zero will not add any points.
36 - gets supplied the number of extruded layers both per face and per
37 point. Usually the point nlayers is the max of surrounding face nlayers.
40 - 0 : no extrusion. Any surrounding face being extruded becomes 'prism'
41 - >0 : should be max of surrounding face nlayers.
43 - differing face nlayers: 'termination' : (e.g. from 2 to 4 layers) match
44 at original patch face side.
46 E.g. 2 boundary faces on patches a,b. 2 layers for a, 3 for b.
51 a b <- patch of boundary face
53 | | | <- original cells
58 a b <- patch of boundary face
63 | | | <- original cells
68 - added faces get same patchID as face they are extruded from
69 - 'side' faces (i.e. on the edge of pp) get the patchID of the
70 other patch they are connected to.
73 E.g. 3 boundary faces on patches a,b. b gets extruded, a doesn't.
76 a b b <- patch of boundary face
77 +------+------+------+
79 +------+------+------+
82 ^ ^ <- wanted extrusion vector (none at far right)
83 a | b | b <- patch of boundary face
84 +------+------+------+
86 +------+------+------+
89 +------+\ b 1. prism cell added onto second b face since
90 a a| | ----\ only one side gets extruded.
91 +------+------+------+ 2. side-face gets patch a, not b.
93 +------+------+------+
100 \*---------------------------------------------------------------------------*/
102 #ifndef addPatchCellLayer_H
103 #define addPatchCellLayer_H
105 #include "labelList.H"
106 #include "typeInfo.H"
107 #include "labelPair.H"
108 #include "indirectPrimitivePatch.H"
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 // Forward declaration of classes
117 class polyTopoChange;
122 /*---------------------------------------------------------------------------*\
123 Class addPatchCellLayer Declaration
124 \*---------------------------------------------------------------------------*/
126 class addPatchCellLayer
130 // To combineReduce a labelList. Filters out duplicates.
136 void operator()(labelList& x, const labelList& y) const
149 if (findIndex(x, y[yi]) == -1)
164 //- Reference to mesh
165 const polyMesh& mesh_;
167 //- For all patchpoints: list of added points (size 0 or nLayers)
168 // First point in list is one nearest to original point in patch,
169 // last one is the new point on the surface.
170 labelListList addedPoints_;
172 //- For all patchfaces: list of layer faces.
173 // - empty if no face extruded
174 // - first face is original boundary face
175 // - last one is new boundary face.
176 labelListList layerFaces_;
179 // Private Member Functions
181 //- Per patch edge the pp faces (in global indices) using it. Uses
182 // uniqueEqOp() to remove duplicates.
183 labelListList calcGlobalEdgeFaces
185 const polyMesh& mesh,
186 const globalIndex& globalFaces,
187 const indirectPrimitivePatch& pp,
188 const labelList& meshEdges
191 //- Get the face on the other side of the edge.
194 const labelListList& edgeFaces,
199 //- Add vertex to face if unique.
200 static void addVertex(const label, face&, label& fp);
202 bool sameEdgeNeighbour
204 const indirectPrimitivePatch& pp,
205 const labelListList& globalEdgeFaces,
206 const boolList& doneEdge,
207 const label thisGlobalFaceI,
208 const label nbrGlobalFaceI,
212 labelPair getEdgeString
214 const indirectPrimitivePatch& pp,
215 const labelListList& globalEdgeFaces,
216 const boolList& doneEdge,
217 const label patchFaceI,
218 const label globalFaceI
222 //- Add face between layer-1 and layer.
225 const indirectPrimitivePatch&,
226 const labelList& patchID,
227 const labelListList& addedCells,
229 const label ownFaceI,
230 const label nbrFaceI,
231 const label patchEdgeI,
232 const label meshEdgeI,
234 const label numEdgeFaces,
239 //- Disallow default bitwise copy construct
240 addPatchCellLayer(const addPatchCellLayer&);
242 //- Disallow default bitwise assignment
243 void operator=(const addPatchCellLayer&);
248 //- Runtime type information
249 ClassName("addPatchCellLayer");
254 //- Construct from mesh.
255 addPatchCellLayer(const polyMesh& mesh);
263 //- Added points per patch point.
264 const labelListList& addedPoints() const
269 //- Layer faces per patch face. See above.
270 const labelListList& layerFaces() const
275 //- Helper: get added cells per patch face.
276 // addedCells[patchFace] is list of cells added. Last element is
277 // the top cells (i.e. the boundary cell)
278 static labelListList addedCells
281 const labelListList& layerFaces
284 //- added cells given current mesh & layerfaces.
285 labelListList addedCells() const;
290 //- Play commands into polyTopoChange to create layers on top
291 // of indirectPrimitivePatch (have to be outside faces).
292 // Gets displacement per patch point.
293 // - nPointLayers : number of layers per (patch)point
294 // - nFaceLayers : number of layers per (patch) face
295 // - firstDisplacement : displacement per point for first
296 // layer of points. If zero do not add point.
297 // Layer thicknesses are calculated to constant geometric
298 // expansion. Use expansionRatio for constant size.
299 // Sets addedPoints_ which is per pp point a list of points
301 // Note: firstDisplacement has to be parallel synchronised before
302 // calling this routine. Only if all procs sharing a point
303 // get a cell should firstDisplacement be <> 0
304 // Note: cells get added from owner cells of patch faces
305 // (instead of e.g. from patch faces)
308 const scalarField& expansionRatio,
309 const indirectPrimitivePatch& pp,
310 const labelList& nFaceLayers,
311 const labelList& nPointLayers,
312 const vectorField& firstLayerDisp,
313 polyTopoChange& meshMod
317 //- Add with constant expansion ratio and same nLayers everywhere
321 const indirectPrimitivePatch& pp,
322 const vectorField& overallDisplacement,
323 polyTopoChange& meshMod
328 scalarField(pp.nPoints(), 1.0), // expansion ration
330 labelList(pp.size(), nLayers),
331 labelList(pp.nPoints(), nLayers),
332 overallDisplacement / nLayers,
338 //- Update any locally stored mesh information. Gets additional
339 // map from new to old patch (since patch needs to be
340 // recreated since has to be on outside).
344 const labelList& faceMap, // new to old patch faces
345 const labelList& pointMap // new to old patch points
350 //- Per patch edge the corresponding mesh edge
351 static labelList calcMeshEdges
353 const primitiveMesh& mesh,
354 const indirectPrimitivePatch&
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 } // End namespace Foam
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 // ************************************************************************* //