/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
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.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see .
\*---------------------------------------------------------------------------*/
#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 FaceList,
class PointField
>
Foam::Xfer Foam::extrudedMesh::extrudedPoints
(
const PrimitivePatch& 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
);
}
}
// return points for transferring
return xferMove(ePoints);
}
template class FaceList, class PointField>
Foam::Xfer Foam::extrudedMesh::extrudedFaces
(
const PrimitivePatch& extrudePatch,
const extrudeModel& model
)
{
const pointField& surfacePoints = extrudePatch.localPoints();
const List& surfaceFaces = extrudePatch.localFaces();
const edgeList& surfaceEdges = extrudePatch.edges();
const label nInternalEdges = extrudePatch.nInternalEdges();
const label nLayers = model.nLayers();
label nFaces =
(nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size();
faceList eFaces(nFaces);
labelList quad(4);
label facei = 0;
// Internal faces
for (label layer=0; layer class FaceList, class PointField>
Foam::Xfer Foam::extrudedMesh::extrudedCells
(
const PrimitivePatch& extrudePatch,
const extrudeModel& model
)
{
const List& 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 class FaceList,
class PointField
>
Foam::extrudedMesh::extrudedMesh
(
const IOobject& io,
const PrimitivePatch& extrudePatch,
const extrudeModel& model
)
:
polyMesh
(
io,
extrudedPoints(extrudePatch, model),
extrudedFaces(extrudePatch, model),
extrudedCells(extrudePatch, model)
),
model_(model)
{
List 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);
}
// ************************************************************************* //