1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "extrude2DMesh.H"
28 #include "directTopoChange.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(extrude2DMesh, 0);
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 // Construct from mesh
45 Foam::extrude2DMesh::extrude2DMesh(const polyMesh& mesh)
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 void Foam::extrude2DMesh::setRefinement
55 const direction extrudeDir,
56 const scalar thickness,
57 const label frontPatchI,
58 directTopoChange& meshMod
61 for (label cellI = 0; cellI < mesh_.nCells(); cellI++)
68 cellI, //masterCellID,
69 mesh_.cellZones().whichZone(cellI) //zoneID
77 forAll(mesh_.points(), pointI)
81 mesh_.points()[pointI],
88 //Info<< "Adding offsetted points." << nl << endl;
89 forAll(mesh_.points(), pointI)
91 point newPoint(mesh_.points()[pointI]);
92 newPoint[extrudeDir] = thickness;
107 const faceList& faces = mesh_.faces();
108 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
110 for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
112 label zoneID = mesh_.faceZones().whichZone(faceI);
113 bool zoneFlip = false;
116 const faceZone& fZone = mesh_.faceZones()[zoneID];
117 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
121 const face& f = faces[faceI];
124 newFace[2] = f[1]+mesh_.nPoints();
125 newFace[3] = f[0]+mesh_.nPoints();
130 mesh_.faceOwner()[faceI], // own
131 mesh_.faceNeighbour()[faceI], // nei
134 faceI, // masterFaceID
135 false, // flipFaceFlux
142 forAll(patches, patchI)
144 label startFaceI = patches[patchI].start();
145 label endFaceI = startFaceI + patches[patchI].size();
147 for (label faceI = startFaceI; faceI < endFaceI; faceI++)
149 label zoneID = mesh_.faceZones().whichZone(faceI);
150 bool zoneFlip = false;
153 const faceZone& fZone = mesh_.faceZones()[zoneID];
154 zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)];
158 const face& f = faces[faceI];
161 newFace[2] = f[1]+mesh_.nPoints();
162 newFace[3] = f[0]+mesh_.nPoints();
167 mesh_.faceOwner()[faceI], // own
171 faceI, // masterFaceID
172 false, // flipFaceFlux
181 // Generate front and back faces
182 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184 forAll(mesh_.cells(), cellI)
186 const cell& cFaces = mesh_.cells()[cellI];
188 // Make a loop out of faces.
189 const face& f = faces[cFaces[0]];
191 face frontFace(cFaces.size());
194 label nextPointI = f[1];
195 label nextFaceI = cFaces[0];
197 for (label i = 1; i < frontFace.size(); i++)
199 frontFace[i] = nextPointI;
201 // Find face containing pointI
202 forAll(cFaces, cFaceI)
204 label faceI = cFaces[cFaceI];
205 if (faceI != nextFaceI)
207 const face& f = faces[faceI];
209 if (f[0] == nextPointI)
215 else if (f[1] == nextPointI)
229 frontFace.reverseFace(),
234 cFaces[0], // masterFaceID
235 false, // flipFaceFlux
236 frontPatchI, // patchID
241 // Offset to create front face.
242 forAll(frontFace, fp)
244 frontFace[fp] += mesh_.nPoints();
253 cFaces[0], // masterFaceID
254 false, // flipFaceFlux
255 frontPatchI, // patchID
263 // ************************************************************************* //