1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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,
235 const labelList& meshFaces,
240 //- Disallow default bitwise copy construct
241 addPatchCellLayer(const addPatchCellLayer&);
243 //- Disallow default bitwise assignment
244 void operator=(const addPatchCellLayer&);
249 //- Runtime type information
250 ClassName("addPatchCellLayer");
255 //- Construct from mesh.
256 addPatchCellLayer(const polyMesh& mesh);
264 //- Added points per patch point.
265 const labelListList& addedPoints() const
270 //- Layer faces per patch face. See above.
271 const labelListList& layerFaces() const
276 //- Helper: get added cells per patch face.
277 // addedCells[patchFace] is list of cells added. Last element is
278 // the top cells (i.e. the boundary cell)
279 static labelListList addedCells
282 const labelListList& layerFaces
285 //- added cells given current mesh & layerfaces.
286 labelListList addedCells() const;
291 //- Play commands into polyTopoChange to create layers on top
292 // of indirectPrimitivePatch (have to be outside faces).
293 // Gets displacement per patch point.
294 // - nPointLayers : number of layers per (patch)point
295 // - nFaceLayers : number of layers per (patch) face
296 // - firstDisplacement : displacement per point for first
297 // layer of points (i.e. nearest to original mesh). If zero
299 // Layer thicknesses are calculated to constant geometric
300 // expansion. Use expansionRatio 1 for constant size.
301 // Sets addedPoints_ which is per pp point a list of points
303 // Note: firstDisplacement has to be parallel synchronised before
304 // calling this routine. Only if all procs sharing a point
305 // get a cell should firstDisplacement be <> 0
306 // Note: cells get added from owner cells of patch faces
307 // (instead of e.g. from patch faces)
310 const scalarField& expansionRatio,
311 const indirectPrimitivePatch& pp,
312 const labelList& nFaceLayers,
313 const labelList& nPointLayers,
314 const vectorField& firstLayerDisp,
315 polyTopoChange& meshMod
319 //- Add with constant expansion ratio and same nLayers everywhere
323 const indirectPrimitivePatch& pp,
324 const vectorField& overallDisplacement,
325 polyTopoChange& meshMod
330 scalarField(pp.nPoints(), 1.0), // expansion ration
332 labelList(pp.size(), nLayers),
333 labelList(pp.nPoints(), nLayers),
334 overallDisplacement / nLayers,
340 //- Update any locally stored mesh information. Gets additional
341 // map from new to old patch (since patch needs to be
342 // recreated since has to be on outside).
346 const labelList& faceMap, // new to old patch faces
347 const labelList& pointMap // new to old patch points
352 //- Per patch edge the corresponding mesh edge
353 static labelList calcMeshEdges
355 const primitiveMesh& mesh,
356 const indirectPrimitivePatch&
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363 } // End namespace Foam
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
369 // ************************************************************************* //