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
25 \*---------------------------------------------------------------------------*/
27 #include "extrude2DMesh.H"
29 #include "polyTopoChange.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(extrude2DMesh, 0);
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 // Construct from mesh
46 Foam::extrude2DMesh::extrude2DMesh(const polyMesh& mesh)
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54 void Foam::extrude2DMesh::setRefinement
56 const direction extrudeDir,
57 const scalar thickness,
58 const label frontPatchI,
59 polyTopoChange& meshMod
62 for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
69 cellI, //masterCellID,
70 mesh_.cellZones().whichZone(cellI) //zoneID
78 forAll(mesh_.points(), pointI)
82 mesh_.points()[pointI],
89 //Info<< "Adding offsetted points." << nl << endl;
90 forAll(mesh_.points(), pointI)
92 point newPoint(mesh_.points()[pointI]);
93 newPoint[extrudeDir] = thickness;
108 const faceList& faces = mesh_.faces();
109 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
111 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
113 label zoneID = mesh_.faceZones().whichZone(faceI);
114 bool zoneFlip = false;
117 const faceZone& fZone = mesh_.faceZones()[zoneID];
118 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
122 const face& f = faces[faceI];
125 newFace[2] = f[1]+mesh_.nPoints();
126 newFace[3] = f[0]+mesh_.nPoints();
131 mesh_.faceOwner()[faceI], // own
132 mesh_.faceNeighbour()[faceI], // nei
135 faceI, // masterFaceID
136 false, // flipFaceFlux
143 forAll(patches, patchI)
145 label startFaceI = patches[patchI].start();
146 label endFaceI = startFaceI + patches[patchI].size();
148 for (label faceI = startFaceI; faceI < endFaceI; faceI++)
150 label zoneID = mesh_.faceZones().whichZone(faceI);
151 bool zoneFlip = false;
154 const faceZone& fZone = mesh_.faceZones()[zoneID];
155 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
159 const face& f = faces[faceI];
162 newFace[2] = f[1]+mesh_.nPoints();
163 newFace[3] = f[0]+mesh_.nPoints();
168 mesh_.faceOwner()[faceI], // own
172 faceI, // masterFaceID
173 false, // flipFaceFlux
182 // Generate front and back faces
183 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185 forAll(mesh_.cells(), cellI)
187 const cell& cFaces = mesh_.cells()[cellI];
189 // Make a loop out of faces.
190 const face& f = faces[cFaces[0]];
192 face frontFace(cFaces.size());
195 label nextPointI = f[1];
196 label nextFaceI = cFaces[0];
198 for (label i = 1; i < frontFace.size(); i++)
200 frontFace[i] = nextPointI;
202 // Find face containing pointI
203 forAll(cFaces, cFaceI)
205 label faceI = cFaces[cFaceI];
206 if (faceI != nextFaceI)
208 const face& f = faces[faceI];
210 if (f[0] == nextPointI)
216 else if (f[1] == nextPointI)
230 frontFace.reverseFace(),
235 cFaces[0], // masterFaceID
236 false, // flipFaceFlux
237 frontPatchI, // patchID
242 // Offset to create front face.
243 forAll(frontFace, fp)
245 frontFace[fp] += mesh_.nPoints();
254 cFaces[0], // masterFaceID
255 false, // flipFaceFlux
256 frontPatchI, // patchID
264 // ************************************************************************* //