2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
2016-06-20 15:00:40 +00:00
|
|
|
\\ / O peration | Version: 4.0
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
License
|
2013-12-11 16:09:41 +00:00
|
|
|
This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
option) any later version.
|
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "extrudedMesh.H"
|
|
|
|
#include "wallPolyPatch.H"
|
|
|
|
#include "meshTools.H"
|
|
|
|
#include "ListOps.H"
|
|
|
|
#include "OFstream.H"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
|
|
|
|
|
|
bool Foam::extrudedMesh::sameOrder(const face& f, const edge& e)
|
|
|
|
{
|
|
|
|
label i = findIndex(f, e[0]);
|
|
|
|
|
|
|
|
label nextI = (i == f.size()-1 ? 0 : i+1);
|
|
|
|
|
|
|
|
return f[nextI] == e[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template
|
|
|
|
<
|
|
|
|
class Face,
|
|
|
|
template<class> class FaceList,
|
|
|
|
class PointField
|
|
|
|
>
|
2010-08-25 21:42:57 +00:00
|
|
|
Foam::Xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
|
2010-05-12 13:27:55 +00:00
|
|
|
(
|
|
|
|
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
|
|
|
|
const extrudeModel& model
|
|
|
|
)
|
|
|
|
{
|
|
|
|
const pointField& surfacePoints = extrudePatch.localPoints();
|
|
|
|
const vectorField& surfaceNormals = extrudePatch.pointNormals();
|
|
|
|
|
|
|
|
const label nLayers = model.nLayers();
|
|
|
|
|
|
|
|
pointField ePoints((nLayers + 1)*surfacePoints.size());
|
|
|
|
|
|
|
|
for (label layer=0; layer<=nLayers; layer++)
|
|
|
|
{
|
|
|
|
label offset = layer*surfacePoints.size();
|
|
|
|
|
|
|
|
forAll(surfacePoints, i)
|
|
|
|
{
|
|
|
|
ePoints[offset + i] = model
|
|
|
|
(
|
|
|
|
surfacePoints[i],
|
|
|
|
surfaceNormals[i],
|
|
|
|
layer
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
// return points for transferring
|
|
|
|
return xferMove(ePoints);
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Face, template<class> class FaceList, class PointField>
|
2010-08-25 21:42:57 +00:00
|
|
|
Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
|
2010-05-12 13:27:55 +00:00
|
|
|
(
|
|
|
|
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
|
|
|
|
const extrudeModel& model
|
|
|
|
)
|
|
|
|
{
|
|
|
|
const pointField& surfacePoints = extrudePatch.localPoints();
|
|
|
|
const List<face>& surfaceFaces = extrudePatch.localFaces();
|
|
|
|
const edgeList& surfaceEdges = extrudePatch.edges();
|
|
|
|
const label nInternalEdges = extrudePatch.nInternalEdges();
|
|
|
|
|
|
|
|
const label nLayers = model.nLayers();
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
label nFaces =
|
2010-05-12 13:27:55 +00:00
|
|
|
(nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size();
|
|
|
|
|
|
|
|
faceList eFaces(nFaces);
|
|
|
|
|
|
|
|
labelList quad(4);
|
|
|
|
label facei = 0;
|
|
|
|
|
|
|
|
// Internal faces
|
|
|
|
for (label layer=0; layer<nLayers; layer++)
|
|
|
|
{
|
|
|
|
label currentLayerOffset = layer*surfacePoints.size();
|
|
|
|
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
|
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
// Vertical faces from layer to layer+1
|
|
|
|
for (label edgeI=0; edgeI<nInternalEdges; edgeI++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-08-25 21:42:57 +00:00
|
|
|
const edge& e = surfaceEdges[edgeI];
|
|
|
|
const labelList& edgeFaces = extrudePatch.edgeFaces()[edgeI];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
face& f = eFaces[facei++];
|
|
|
|
f.setSize(4);
|
|
|
|
|
|
|
|
if
|
|
|
|
(
|
|
|
|
(edgeFaces[0] < edgeFaces[1])
|
|
|
|
== sameOrder(surfaceFaces[edgeFaces[0]], e)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
f[0] = e[0] + currentLayerOffset;
|
|
|
|
f[1] = e[1] + currentLayerOffset;
|
|
|
|
f[2] = e[1] + nextLayerOffset;
|
|
|
|
f[3] = e[0] + nextLayerOffset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
f[0] = e[1] + currentLayerOffset;
|
|
|
|
f[1] = e[0] + currentLayerOffset;
|
|
|
|
f[2] = e[0] + nextLayerOffset;
|
|
|
|
f[3] = e[1] + nextLayerOffset;
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Faces between layer and layer+1
|
|
|
|
if (layer < nLayers-1)
|
|
|
|
{
|
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
|
|
|
eFaces[facei++] =
|
|
|
|
face
|
|
|
|
(
|
2010-08-25 21:42:57 +00:00
|
|
|
surfaceFaces[i] //.reverseFace()
|
2010-05-12 13:27:55 +00:00
|
|
|
+ nextLayerOffset
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// External side faces
|
|
|
|
for (label layer=0; layer<nLayers; layer++)
|
|
|
|
{
|
|
|
|
label currentLayerOffset = layer*surfacePoints.size();
|
|
|
|
label nextLayerOffset = currentLayerOffset + surfacePoints.size();
|
|
|
|
|
|
|
|
// Side faces across layer
|
2010-08-25 21:42:57 +00:00
|
|
|
for (label edgeI=nInternalEdges; edgeI<surfaceEdges.size(); edgeI++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-08-25 21:42:57 +00:00
|
|
|
const edge& e = surfaceEdges[edgeI];
|
|
|
|
const labelList& edgeFaces = extrudePatch.edgeFaces()[edgeI];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
face& f = eFaces[facei++];
|
|
|
|
f.setSize(4);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
if (sameOrder(surfaceFaces[edgeFaces[0]], e))
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-08-25 21:42:57 +00:00
|
|
|
f[0] = e[0] + currentLayerOffset;
|
|
|
|
f[1] = e[1] + currentLayerOffset;
|
|
|
|
f[2] = e[1] + nextLayerOffset;
|
|
|
|
f[3] = e[0] + nextLayerOffset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
f[0] = e[1] + currentLayerOffset;
|
|
|
|
f[1] = e[0] + currentLayerOffset;
|
|
|
|
f[2] = e[0] + nextLayerOffset;
|
|
|
|
f[3] = e[1] + nextLayerOffset;
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
// Bottom faces
|
2010-05-12 13:27:55 +00:00
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
2010-08-25 21:42:57 +00:00
|
|
|
eFaces[facei++] = face(surfaceFaces[i]).reverseFace();
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
// Top faces
|
2010-05-12 13:27:55 +00:00
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
|
|
|
eFaces[facei++] =
|
|
|
|
face
|
|
|
|
(
|
2010-08-25 21:42:57 +00:00
|
|
|
surfaceFaces[i]
|
2010-05-12 13:27:55 +00:00
|
|
|
+ nLayers*surfacePoints.size()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
// return points for transferring
|
|
|
|
return xferMove(eFaces);
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class Face, template<class> class FaceList, class PointField>
|
2010-08-25 21:42:57 +00:00
|
|
|
Foam::Xfer<Foam::cellList> Foam::extrudedMesh::extrudedCells
|
2010-05-12 13:27:55 +00:00
|
|
|
(
|
|
|
|
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
|
|
|
|
const extrudeModel& model
|
|
|
|
)
|
|
|
|
{
|
|
|
|
const List<face>& surfaceFaces = extrudePatch.localFaces();
|
|
|
|
const edgeList& surfaceEdges = extrudePatch.edges();
|
|
|
|
const label nInternalEdges = extrudePatch.nInternalEdges();
|
|
|
|
|
|
|
|
const label nLayers = model.nLayers();
|
|
|
|
|
|
|
|
cellList eCells(nLayers*surfaceFaces.size());
|
|
|
|
|
|
|
|
// Size the cells
|
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
|
|
|
const face& f = surfaceFaces[i];
|
|
|
|
|
|
|
|
for (label layer=0; layer<nLayers; layer++)
|
|
|
|
{
|
|
|
|
eCells[i + layer*surfaceFaces.size()].setSize(f.size() + 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Current face count per cell.
|
|
|
|
labelList nCellFaces(eCells.size(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
label facei = 0;
|
|
|
|
|
|
|
|
for (label layer=0; layer<nLayers; layer++)
|
|
|
|
{
|
|
|
|
// Side faces from layer to layer+1
|
|
|
|
for (label i=0; i<nInternalEdges; i++)
|
|
|
|
{
|
|
|
|
// Get patch faces using edge
|
|
|
|
const labelList& edgeFaces = extrudePatch.edgeFaces()[i];
|
|
|
|
|
|
|
|
// Get cells on this layer
|
|
|
|
label cell0 = layer*surfaceFaces.size() + edgeFaces[0];
|
|
|
|
label cell1 = layer*surfaceFaces.size() + edgeFaces[1];
|
|
|
|
|
|
|
|
eCells[cell0][nCellFaces[cell0]++] = facei;
|
|
|
|
eCells[cell1][nCellFaces[cell1]++] = facei;
|
|
|
|
|
|
|
|
facei++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Faces between layer and layer+1
|
|
|
|
if (layer < nLayers-1)
|
|
|
|
{
|
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
|
|
|
label cell0 = layer*surfaceFaces.size() + i;
|
|
|
|
label cell1 = (layer+1)*surfaceFaces.size() + i;
|
|
|
|
|
|
|
|
eCells[cell0][nCellFaces[cell0]++] = facei;
|
|
|
|
eCells[cell1][nCellFaces[cell1]++] = facei;
|
|
|
|
|
|
|
|
facei++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// External side faces
|
|
|
|
for (label layer=0; layer<nLayers; layer++)
|
|
|
|
{
|
|
|
|
// Side faces across layer
|
|
|
|
for (label i=nInternalEdges; i<surfaceEdges.size(); i++)
|
|
|
|
{
|
|
|
|
// Get patch faces using edge
|
|
|
|
const labelList& edgeFaces = extrudePatch.edgeFaces()[i];
|
|
|
|
|
|
|
|
// Get cells on this layer
|
|
|
|
label cell0 = layer*surfaceFaces.size() + edgeFaces[0];
|
|
|
|
|
|
|
|
eCells[cell0][nCellFaces[cell0]++] = facei;
|
|
|
|
|
|
|
|
facei++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top faces
|
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
|
|
|
eCells[i][nCellFaces[i]++] = facei;
|
|
|
|
|
|
|
|
facei++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bottom faces
|
|
|
|
forAll(surfaceFaces, i)
|
|
|
|
{
|
|
|
|
label cell0 = (nLayers-1)*surfaceFaces.size() + i;
|
|
|
|
|
|
|
|
eCells[cell0][nCellFaces[cell0]++] = facei;
|
|
|
|
|
|
|
|
facei++;
|
|
|
|
}
|
|
|
|
|
2010-08-25 21:42:57 +00:00
|
|
|
// return points for transferring
|
|
|
|
return xferMove(eCells);
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
template
|
|
|
|
<
|
|
|
|
class Face,
|
|
|
|
template<class> class FaceList,
|
|
|
|
class PointField
|
|
|
|
>
|
|
|
|
Foam::extrudedMesh::extrudedMesh
|
|
|
|
(
|
|
|
|
const IOobject& io,
|
|
|
|
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
|
|
|
|
const extrudeModel& model
|
|
|
|
)
|
|
|
|
:
|
|
|
|
polyMesh
|
|
|
|
(
|
|
|
|
io,
|
|
|
|
extrudedPoints(extrudePatch, model),
|
|
|
|
extrudedFaces(extrudePatch, model),
|
|
|
|
extrudedCells(extrudePatch, model)
|
|
|
|
),
|
|
|
|
model_(model)
|
|
|
|
{
|
|
|
|
List<polyPatch*> patches(3);
|
|
|
|
|
|
|
|
label facei = nInternalFaces();
|
|
|
|
|
|
|
|
label sz =
|
|
|
|
model_.nLayers()
|
|
|
|
*(extrudePatch.nEdges() - extrudePatch.nInternalEdges());
|
|
|
|
|
|
|
|
patches[0] = new wallPolyPatch
|
|
|
|
(
|
|
|
|
"sides",
|
|
|
|
sz,
|
|
|
|
facei,
|
|
|
|
0,
|
|
|
|
boundaryMesh()
|
|
|
|
);
|
|
|
|
|
|
|
|
facei += sz;
|
|
|
|
|
|
|
|
patches[1] = new polyPatch
|
|
|
|
(
|
|
|
|
"originalPatch",
|
|
|
|
extrudePatch.size(),
|
|
|
|
facei,
|
|
|
|
1,
|
|
|
|
boundaryMesh()
|
|
|
|
);
|
|
|
|
|
|
|
|
facei += extrudePatch.size();
|
|
|
|
|
|
|
|
patches[2] = new polyPatch
|
|
|
|
(
|
|
|
|
"otherSide",
|
|
|
|
extrudePatch.size(),
|
|
|
|
facei,
|
|
|
|
2,
|
|
|
|
boundaryMesh()
|
|
|
|
);
|
|
|
|
|
|
|
|
addPatches(patches);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|
|
|
|
|